Definition:
function wp_reschedule_event( $timestamp, $recurrence, $hook, $args = array() {}
Reschedule a recurring event.
Parameters
- int $timestamp: Timestamp for when to run the event.
- string $recurrence: How often the event should recur.
- string $hook: Action hook to execute when cron is run.
- array $args: Optional. Arguments to pass to the hook’s callback function.
Return values
returns:False on failure. Null when event is rescheduled.
Source code
function wp_reschedule_event( $timestamp, $recurrence, $hook, $args = array()) { $crons = _get_cron_array(); $schedules = wp_get_schedules(); $key = md5(serialize($args)); $interval = 0; // First we try to get it from the schedule if ( 0 == $interval ) $interval = $schedules[$recurrence]['interval']; // Now we try to get it from the saved interval in case the schedule disappears if ( 0 == $interval ) $interval = $crons[$timestamp][$hook][$key]['interval']; // Now we assume something is wrong and fail to schedule if ( 0 == $interval ) return false; $now = time(); if ( $timestamp >= $now ) $timestamp = $now + $interval; else $timestamp = $now + ($interval - (($now - $timestamp) % $interval)); wp_schedule_event( $timestamp, $recurrence, $hook, $args ); }
4053
No comments yet... Be the first to leave a reply!