forked from topspin/topspin-wordpress
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtopspin_cron.php
More file actions
36 lines (31 loc) · 798 Bytes
/
topspin_cron.php
File metadata and controls
36 lines (31 loc) · 798 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
### Hooks
add_filter('cron_schedules','topspin_cron_schedules');
add_action('init','topspin_cron_init');
add_action('topspin_cron_fetch_items','topspin_cron_rebuild');
### Cron Schedules
function topspin_cron_schedules($schedules) {
// add a 'weekly' schedule to the existing set
$schedules['every_5_min'] = array(
'interval' => 300,
'display' => __('Every 5 Minutes')
);
$schedules['every_30_seconds'] = array(
'interval' => 30,
'display' => __('Every 30 Seconds')
);
return $schedules;
}
### Cron Init
function topspin_cron_init() {
if(!wp_next_scheduled('topspin_cron_fetch_items')) {
wp_schedule_event(time(),'every_5_min','topspin_cron_fetch_items');
}
}
### Cron Functions
function topspin_cron_rebuild() {
global $store;
### Rebuild
$store->rebuildAll();
}
?>