Introduce schedule_event filter. fixes #15146

git-svn-id: https://develop.svn.wordpress.org/trunk@15837 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2010-10-18 20:50:35 +00:00
parent 122a2981c4
commit d5bd0ffd71
1 changed files with 22 additions and 4 deletions

View File

@ -26,8 +26,16 @@ function wp_schedule_single_event( $timestamp, $hook, $args = array()) {
return;
$crons = _get_cron_array();
$key = md5(serialize($args));
$crons[$timestamp][$hook][$key] = array( 'schedule' => false, 'args' => $args );
$event = (object) array( 'hook' => $hook, 'timestamp' => $timestamp, 'schedule' => false, 'args' => $args );
$event = apply_filters('schedule_event', $event);
// A plugin disallowed this event
if ( ! $event )
return false;
$key = md5(serialize($event->args));
$crons[$event->timestamp][$event->hook][$key] = array( 'schedule' => $event->schedule, 'args' => $event->args );
uksort( $crons, "strnatcasecmp" );
_set_cron_array( $crons );
}
@ -53,10 +61,20 @@ function wp_schedule_single_event( $timestamp, $hook, $args = array()) {
function wp_schedule_event( $timestamp, $recurrence, $hook, $args = array()) {
$crons = _get_cron_array();
$schedules = wp_get_schedules();
$key = md5(serialize($args));
if ( !isset( $schedules[$recurrence] ) )
return false;
$crons[$timestamp][$hook][$key] = array( 'schedule' => $recurrence, 'args' => $args, 'interval' => $schedules[$recurrence]['interval'] );
$event = (object) array( 'hook' => $hook, 'timestamp' => $timestamp, 'schedule' => $recurrence, 'args' => $args, 'interval' => $schedules[$recurrence]['interval'] );
$event = apply_filters('schedule_event', $event);
// A plugin disallowed this event
if ( ! $event )
return false;
$key = md5(serialize($event->args));
$crons[$event->timestamp][$event->hook][$key] = array( 'schedule' => $event->schedule, 'args' => $event->args, 'interval' => $event->interval );
uksort( $crons, "strnatcasecmp" );
_set_cron_array( $crons );
}