-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscheduler.php
More file actions
29 lines (26 loc) · 878 Bytes
/
scheduler.php
File metadata and controls
29 lines (26 loc) · 878 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
<?php
if (!defined('ABSPATH')) {
exit;
}
require_once __DIR__ . '/git.php';
function gitau_schedule_cron()
{
// 检查主题是否支持更新
if (!gitau_check_theme_support(wp_get_theme())) {
return;
}
$options = get_option('gitau_settings');
if (isset($options['gitau_cron_interval']) && !wp_next_scheduled('gitau_update_theme')) {
$schedules = wp_get_schedules();
$interval = $options['gitau_cron_interval'];
$error = wp_schedule_event(time() + $schedules[$interval]['interval'], $interval, 'gitau_update_theme', array(), true);
if ($error instanceof WP_Error) {
error_log(GITAU_MSG_PREFIX . "schedule failed: " . join(';', $error->get_error_messages()));
return $error;
}
}
}
function gitau_cancel_schedule_cron()
{
wp_clear_scheduled_hook('gitau_update_theme');
}