Skip to content

Commit eeb34fc

Browse files
ensure event schedule exists
1 parent 270d51d commit eeb34fc

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
- Ensure pageview counts are always added to the correct day, even if WP Cron stalls for more than 24 hours.
77
- Improved correctness of the realtime visitor count in case of WP Cron stalls.
88
- Move the temporary buffer file to its own directory inside the uploads directory.
9-
- Bump HTTP request timeout for Jetpack importer up from 5 seconds to 90 seconds.
10-
- Fix division by zero if importing a single day of data with Jetpack Importer.
119
- Fix syntax error on PHP 7.4 introduced in version 1.6.2
10+
- Jetpack Importer: Fix division by zero if importing a single day of data
11+
- Jetpack Importer: Bump HTTP request timeout for Jetpack importer up from 5 seconds to 90 seconds.
12+
- Jetpack Importer: Allow choosing a custom chunk size, which can be useful for sites with a large amount of posts or pages.
1213
- Do not delete database tables on plugin uninstall by default.
1314

1415

migrations/1.6.2-schedule-aggregate-event.php

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
defined('ABSPATH') or exit;
4+
5+
if (! wp_next_scheduled('koko_analytics_aggregate_stats')) {
6+
// ensure schedule exists
7+
add_filter('cron_schedules', function ($schedules) {
8+
$schedules['koko_analytics_stats_aggregate_interval'] = [
9+
'interval' => 60, // 60 seconds
10+
'display' => esc_html__('Every minute', 'koko-analytics'),
11+
];
12+
return $schedules;
13+
}, 10, 1);
14+
15+
// schedule event
16+
wp_schedule_event(time() + 60, 'koko_analytics_stats_aggregate_interval', 'koko_analytics_aggregate_stats');
17+
}

0 commit comments

Comments
 (0)