【发布时间】:2017-09-25 23:16:27
【问题描述】:
我在 wordpress 中创建了一个新插件,它在激活时安排一个 cron。调度部分如下所示:
$crons = _get_cron_array();
//Use wp_next_scheduled to check if the event is already scheduled
$timestamp = wp_next_scheduled('customers-hourly');
if($timestamp == false) {
//Schedule the event for right now, then to repeat daily using the hook 'wi_create_daily_backup'
wp_schedule_event(time(), 'hourly', 'customers-hourly');
}
$crons = _get_cron_array();
add_action('customers-hourly', [$this, 'hourlyCron']);
使用调试器单步执行代码时,激活代码后,_get_cron_array 包含以下内容:
$cron = [ // 12 elements
[.. snip other crons ..]
1493335692 => [
'customers-hourly' => [
'schedule' => 'hourly',
'args' => [],
'interval' => 3600,
],
],
'version' => 2,
];
所以我的 cron 肯定在那里。 当我直接加载 cron.php 并调用 _get_cron_array() 时,它显示了 19 个元素,其中没有一个是客户每小时的。
知道是什么原因造成的吗?
【问题讨论】: