-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautomatic_schedule.php
More file actions
38 lines (25 loc) · 867 Bytes
/
automatic_schedule.php
File metadata and controls
38 lines (25 loc) · 867 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
37
38
<?php
add_filter ( 'cron_schedules', 'wp_automatic_once_a_minute' );
function wp_automatic_once_a_minute($schedules) {
// Adds once weekly to the existing schedules.
$schedules ['once_a_minute'] = array (
'interval' => 60,
'display' => __ ( 'once a minute' )
);
return $schedules;
}
if (! wp_next_scheduled ( 'wp_automatic_hook' )) {
wp_schedule_event ( time (), 'once_a_minute', 'wp_automatic_hook' );
}
add_action ( 'wp_automatic_hook', 'wp_automatic_function' );
function wp_automatic_function() {
$opt = get_option ( 'wp_automatic_options', array ('OPT_CRON') );
if (in_array ( 'OPT_CRON', $opt )) {
// Camapign processor
require_once dirname(__FILE__) . '/campaignsProcessor.php';
$CampaignProcessor = new CampaignProcessor() ;
// Trigger Processing
$CampaignProcessor->process_campaigns(false);
} else {
}
}