Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/cron.php

    r14414 r16938  
    2727
    2828        $crons = _get_cron_array();
    29         $key = md5(serialize($args));
    30         $crons[$timestamp][$hook][$key] = array( 'schedule' => false, 'args' => $args );
     29        $event = (object) array( 'hook' => $hook, 'timestamp' => $timestamp, 'schedule' => false, 'args' => $args );
     30        $event = apply_filters('schedule_event', $event);
     31
     32        // A plugin disallowed this event
     33        if ( ! $event )
     34                return false;
     35
     36        $key = md5(serialize($event->args));
     37
     38        $crons[$event->timestamp][$event->hook][$key] = array( 'schedule' => $event->schedule, 'args' => $event->args );
    3139        uksort( $crons, "strnatcasecmp" );
    3240        _set_cron_array( $crons );
     
    4250 * Valid values for the recurrence are hourly, daily and twicedaily.  These can
    4351 * be extended using the cron_schedules filter in wp_get_schedules().
     52 *
     53 * Use wp_next_scheduled() to prevent duplicates
    4454 *
    4555 * @since 2.1.0
     
    5464        $crons = _get_cron_array();
    5565        $schedules = wp_get_schedules();
    56         $key = md5(serialize($args));
     66
    5767        if ( !isset( $schedules[$recurrence] ) )
    5868                return false;
    59         $crons[$timestamp][$hook][$key] = array( 'schedule' => $recurrence, 'args' => $args, 'interval' => $schedules[$recurrence]['interval'] );
     69
     70        $event = (object) array( 'hook' => $hook, 'timestamp' => $timestamp, 'schedule' => $recurrence, 'args' => $args, 'interval' => $schedules[$recurrence]['interval'] );
     71        $event = apply_filters('schedule_event', $event);
     72
     73        // A plugin disallowed this event
     74        if ( ! $event )
     75                return false;
     76
     77        $key = md5(serialize($event->args));
     78
     79        $crons[$event->timestamp][$event->hook][$key] = array( 'schedule' => $event->schedule, 'args' => $event->args, 'interval' => $event->interval );
    6080        uksort( $crons, "strnatcasecmp" );
    6181        _set_cron_array( $crons );
     
    91111        $now = time();
    92112
    93     if ( $timestamp >= $now )
    94         $timestamp = $now + $interval;
    95     else
    96         $timestamp = $now + ($interval - (($now - $timestamp) % $interval));
     113        if ( $timestamp >= $now )
     114                $timestamp = $now + $interval;
     115        else
     116                $timestamp = $now + ($interval - (($now - $timestamp) % $interval));
    97117
    98118        wp_schedule_event( $timestamp, $recurrence, $hook, $args );
     
    137157        // Previously this function took the arguments as discrete vars rather than an array like the rest of the API
    138158        if ( !is_array($args) ) {
    139                 _deprecated_argument( __FUNCTION__, '3.0.0', __('This argument has changed to an array to match the behavior of the other cron functions.') );
     159                _deprecated_argument( __FUNCTION__, '3.0', __('This argument has changed to an array to match the behavior of the other cron functions.') );
    140160                $args = array_slice( func_get_args(), 1 );
    141161        }
     
    179199
    180200        if ( defined('DOING_CRON') || isset($_GET['doing_wp_cron']) )
    181                 return;
    182 
    183         /*
    184          * do not even start the cron if local server timer has drifted
    185          * such as due to power failure, or misconfiguration
    186          */
    187         $timer_accurate = check_server_timer( $local_time );
    188         if ( !$timer_accurate )
    189201                return;
    190202
     
    394406        return $new_cron;
    395407}
    396 
    397 // stub for checking server timer accuracy, using outside standard time sources
    398 function check_server_timer( $local_time ) {
    399         return true;
    400 }
Note: See TracChangeset for help on using the changeset viewer.