2006-03-07 22:43:59 +01:00
|
|
|
<?php
|
2008-09-04 21:12:40 +02:00
|
|
|
/**
|
2016-08-26 11:22:30 +02:00
|
|
|
* WordPress Cron API
|
2008-09-04 21:12:40 +02:00
|
|
|
*
|
|
|
|
* @package WordPress
|
|
|
|
*/
|
2006-04-06 07:25:50 +02:00
|
|
|
|
2008-09-04 21:12:40 +02:00
|
|
|
/**
|
2016-08-26 11:22:30 +02:00
|
|
|
* Schedules an event to run only once.
|
2008-09-04 21:12:40 +02:00
|
|
|
*
|
2017-11-22 16:16:47 +01:00
|
|
|
* Schedules a hook which will be triggered by WordPress at the specified time.
|
|
|
|
* The action will trigger when someone visits your WordPress site if the scheduled
|
|
|
|
* time has passed.
|
2008-09-04 21:12:40 +02:00
|
|
|
*
|
2016-07-25 14:23:30 +02:00
|
|
|
* Note that scheduling an event to occur within 10 minutes of an existing event
|
2016-08-26 11:22:30 +02:00
|
|
|
* with the same action hook will be ignored unless you pass unique `$args` values
|
2016-07-25 14:23:30 +02:00
|
|
|
* for each scheduled event.
|
|
|
|
*
|
2017-11-22 16:16:47 +01:00
|
|
|
* Use wp_next_scheduled() to prevent duplicate events.
|
|
|
|
*
|
|
|
|
* Use wp_schedule_event() to schedule a recurring event.
|
|
|
|
*
|
2008-09-04 21:12:40 +02:00
|
|
|
* @since 2.1.0
|
2018-12-19 04:41:49 +01:00
|
|
|
* @since 5.1.0 Return value modified to boolean indicating success or failure,
|
2018-12-30 05:51:51 +01:00
|
|
|
* {@see 'pre_schedule_event'} filter added to short-circuit the function.
|
Cron API: Return meaningful values from cron functions.
Return values added to Cron API functions to indicate outcome:
* `wp_schedule_single_event()`, `wp_schedule_event()`, `wp_reschedule_event()` and `wp_unschedule_event()`: boolean indicating success or failure,
* `wp_clear_scheduled_hook()`: integer indicating number of jobs cleared (zero or more), `false` if one or more jobs fail to clear,
* `wp_unschedule_hook()`: integer indicating number of jobs cleared (zero or more), `false` if the jobs fail to clear,
* `spawn_cron()`: boolean indicating whether job spawned,
* `wp_cron()`: integer indicating number of jobs spawned (zero or more), `false` if one or more jobs fail to spawned,
* `_set_cron_array()`: boolean outcome of `update_option()`.
Props evansolomon, jrf, peterwilsoncc, pento for code review.
Fixes #21072.
Built from https://develop.svn.wordpress.org/trunk@43050
git-svn-id: http://core.svn.wordpress.org/trunk@42879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-01 04:05:23 +02:00
|
|
|
*
|
2015-04-12 23:29:32 +02:00
|
|
|
* @link https://codex.wordpress.org/Function_Reference/wp_schedule_single_event
|
2008-09-04 21:12:40 +02:00
|
|
|
*
|
2017-11-22 16:16:47 +01:00
|
|
|
* @param int $timestamp Unix timestamp (UTC) for when to next run the event.
|
|
|
|
* @param string $hook Action hook to execute when the event is run.
|
|
|
|
* @param array $args Optional. Array containing each separate argument to pass to the hook's callback function.
|
Cron API: Return meaningful values from cron functions.
Return values added to Cron API functions to indicate outcome:
* `wp_schedule_single_event()`, `wp_schedule_event()`, `wp_reschedule_event()` and `wp_unschedule_event()`: boolean indicating success or failure,
* `wp_clear_scheduled_hook()`: integer indicating number of jobs cleared (zero or more), `false` if one or more jobs fail to clear,
* `wp_unschedule_hook()`: integer indicating number of jobs cleared (zero or more), `false` if the jobs fail to clear,
* `spawn_cron()`: boolean indicating whether job spawned,
* `wp_cron()`: integer indicating number of jobs spawned (zero or more), `false` if one or more jobs fail to spawned,
* `_set_cron_array()`: boolean outcome of `update_option()`.
Props evansolomon, jrf, peterwilsoncc, pento for code review.
Fixes #21072.
Built from https://develop.svn.wordpress.org/trunk@43050
git-svn-id: http://core.svn.wordpress.org/trunk@42879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-01 04:05:23 +02:00
|
|
|
* @return bool True if event successfully scheduled. False for failure.
|
2008-09-04 21:12:40 +02:00
|
|
|
*/
|
2017-12-01 00:11:00 +01:00
|
|
|
function wp_schedule_single_event( $timestamp, $hook, $args = array() ) {
|
2015-09-07 04:39:23 +02:00
|
|
|
// Make sure timestamp is a positive integer
|
|
|
|
if ( ! is_numeric( $timestamp ) || $timestamp <= 0 ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
$event = (object) array(
|
|
|
|
'hook' => $hook,
|
|
|
|
'timestamp' => $timestamp,
|
|
|
|
'schedule' => false,
|
|
|
|
'args' => $args,
|
|
|
|
);
|
2017-11-22 16:16:47 +01:00
|
|
|
|
Cron: Add hooks and a function to allow hijacking cron implementation.
This allows sites with a large cron option or a custom cron implementation to hijack the cron option to store cron data using custom functionality.
`wp_get_scheduled_event()` is new function to retrieve the event object for a given event based on the hook name, arguments and timestamp. If no timestamp is specified the next occurence is returned.
Preflight filters are added to all functions that read from or modify the cron option: `pre_schedule_event`, `pre_reschedule_event`, `pre_unschedule_event`, `pre_clear_scheduled_hook`, `pre_unschedule_hook`, `pre_get_scheduled_event` and `pre_next_scheduled`.
Additionally, the post scheduling hooks `next_scheduled` and `get_schedule` to allow plugins to modify an event after retrieving it from WordPress.
Props rmccue, DavidAnderson, ethitter, peterwilsoncc.
Fixes #32656.
Built from https://develop.svn.wordpress.org/trunk@43540
git-svn-id: http://core.svn.wordpress.org/trunk@43369 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-07-27 04:23:25 +02:00
|
|
|
/**
|
|
|
|
* Filter to preflight or hijack scheduling an event.
|
|
|
|
*
|
|
|
|
* Returning a non-null value will short-circuit adding the event to the
|
|
|
|
* cron array, causing the function to return the filtered value instead.
|
|
|
|
*
|
|
|
|
* Both single events and recurring events are passed through this filter;
|
|
|
|
* single events have `$event->schedule` as false, whereas recurring events
|
2018-12-30 05:51:51 +01:00
|
|
|
* have this set to a recurrence from wp_get_schedules(). Recurring
|
Cron: Add hooks and a function to allow hijacking cron implementation.
This allows sites with a large cron option or a custom cron implementation to hijack the cron option to store cron data using custom functionality.
`wp_get_scheduled_event()` is new function to retrieve the event object for a given event based on the hook name, arguments and timestamp. If no timestamp is specified the next occurence is returned.
Preflight filters are added to all functions that read from or modify the cron option: `pre_schedule_event`, `pre_reschedule_event`, `pre_unschedule_event`, `pre_clear_scheduled_hook`, `pre_unschedule_hook`, `pre_get_scheduled_event` and `pre_next_scheduled`.
Additionally, the post scheduling hooks `next_scheduled` and `get_schedule` to allow plugins to modify an event after retrieving it from WordPress.
Props rmccue, DavidAnderson, ethitter, peterwilsoncc.
Fixes #32656.
Built from https://develop.svn.wordpress.org/trunk@43540
git-svn-id: http://core.svn.wordpress.org/trunk@43369 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-07-27 04:23:25 +02:00
|
|
|
* events also have the integer recurrence interval set as `$event->interval`.
|
|
|
|
*
|
|
|
|
* For plugins replacing wp-cron, it is recommended you check for an
|
2018-12-30 05:51:51 +01:00
|
|
|
* identical event within ten minutes and apply the {@see 'schedule_event'}
|
Cron: Add hooks and a function to allow hijacking cron implementation.
This allows sites with a large cron option or a custom cron implementation to hijack the cron option to store cron data using custom functionality.
`wp_get_scheduled_event()` is new function to retrieve the event object for a given event based on the hook name, arguments and timestamp. If no timestamp is specified the next occurence is returned.
Preflight filters are added to all functions that read from or modify the cron option: `pre_schedule_event`, `pre_reschedule_event`, `pre_unschedule_event`, `pre_clear_scheduled_hook`, `pre_unschedule_hook`, `pre_get_scheduled_event` and `pre_next_scheduled`.
Additionally, the post scheduling hooks `next_scheduled` and `get_schedule` to allow plugins to modify an event after retrieving it from WordPress.
Props rmccue, DavidAnderson, ethitter, peterwilsoncc.
Fixes #32656.
Built from https://develop.svn.wordpress.org/trunk@43540
git-svn-id: http://core.svn.wordpress.org/trunk@43369 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-07-27 04:23:25 +02:00
|
|
|
* filter to check if another plugin has disallowed the event before scheduling.
|
|
|
|
*
|
|
|
|
* Return true if the event was scheduled, false if not.
|
|
|
|
*
|
|
|
|
* @since 5.0.0
|
|
|
|
*
|
|
|
|
* @param null|bool $pre Value to return instead. Default null to continue adding the event.
|
|
|
|
* @param stdClass $event {
|
|
|
|
* An object containing an event's data.
|
|
|
|
*
|
|
|
|
* @type string $hook Action hook to execute when the event is run.
|
|
|
|
* @type int $timestamp Unix timestamp (UTC) for when to next run the event.
|
|
|
|
* @type string|false $schedule How often the event should subsequently recur.
|
|
|
|
* @type array $args Array containing each separate argument to pass to the hook's callback function.
|
|
|
|
* @type int $interval The interval time in seconds for the schedule. Only present for recurring events.
|
|
|
|
* }
|
|
|
|
*/
|
|
|
|
$pre = apply_filters( 'pre_schedule_event', null, $event );
|
|
|
|
if ( null !== $pre ) {
|
|
|
|
return $pre;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Don't schedule a duplicate if there's already an identical event due within 10 minutes of it
|
|
|
|
$next = wp_next_scheduled( $hook, $args );
|
|
|
|
if ( $next && abs( $next - $timestamp ) <= 10 * MINUTE_IN_SECONDS ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-11-19 06:01:11 +01:00
|
|
|
/**
|
2016-05-22 20:50:28 +02:00
|
|
|
* Filters a single event before it is scheduled.
|
2013-11-19 06:01:11 +01:00
|
|
|
*
|
|
|
|
* @since 3.1.0
|
|
|
|
*
|
2016-08-26 11:22:30 +02:00
|
|
|
* @param stdClass $event {
|
|
|
|
* An object containing an event's data.
|
|
|
|
*
|
2017-11-22 16:16:47 +01:00
|
|
|
* @type string $hook Action hook to execute when the event is run.
|
|
|
|
* @type int $timestamp Unix timestamp (UTC) for when to next run the event.
|
|
|
|
* @type string|false $schedule How often the event should subsequently recur.
|
|
|
|
* @type array $args Array containing each separate argument to pass to the hook's callback function.
|
|
|
|
* @type int $interval The interval time in seconds for the schedule. Only present for recurring events.
|
2016-08-26 11:22:30 +02:00
|
|
|
* }
|
2013-11-19 06:01:11 +01:00
|
|
|
*/
|
|
|
|
$event = apply_filters( 'schedule_event', $event );
|
2010-10-18 22:50:35 +02:00
|
|
|
|
|
|
|
// A plugin disallowed this event
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( ! $event ) {
|
2010-10-18 22:50:35 +02:00
|
|
|
return false;
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2010-10-18 22:50:35 +02:00
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
$key = md5( serialize( $event->args ) );
|
2010-10-18 22:50:35 +02:00
|
|
|
|
Cron: Add hooks and a function to allow hijacking cron implementation.
This allows sites with a large cron option or a custom cron implementation to hijack the cron option to store cron data using custom functionality.
`wp_get_scheduled_event()` is new function to retrieve the event object for a given event based on the hook name, arguments and timestamp. If no timestamp is specified the next occurence is returned.
Preflight filters are added to all functions that read from or modify the cron option: `pre_schedule_event`, `pre_reschedule_event`, `pre_unschedule_event`, `pre_clear_scheduled_hook`, `pre_unschedule_hook`, `pre_get_scheduled_event` and `pre_next_scheduled`.
Additionally, the post scheduling hooks `next_scheduled` and `get_schedule` to allow plugins to modify an event after retrieving it from WordPress.
Props rmccue, DavidAnderson, ethitter, peterwilsoncc.
Fixes #32656.
Built from https://develop.svn.wordpress.org/trunk@43540
git-svn-id: http://core.svn.wordpress.org/trunk@43369 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-07-27 04:23:25 +02:00
|
|
|
$crons = _get_cron_array();
|
2017-12-01 00:11:00 +01:00
|
|
|
$crons[ $event->timestamp ][ $event->hook ][ $key ] = array(
|
|
|
|
'schedule' => $event->schedule,
|
|
|
|
'args' => $event->args,
|
|
|
|
);
|
|
|
|
uksort( $crons, 'strnatcasecmp' );
|
Cron API: Return meaningful values from cron functions.
Return values added to Cron API functions to indicate outcome:
* `wp_schedule_single_event()`, `wp_schedule_event()`, `wp_reschedule_event()` and `wp_unschedule_event()`: boolean indicating success or failure,
* `wp_clear_scheduled_hook()`: integer indicating number of jobs cleared (zero or more), `false` if one or more jobs fail to clear,
* `wp_unschedule_hook()`: integer indicating number of jobs cleared (zero or more), `false` if the jobs fail to clear,
* `spawn_cron()`: boolean indicating whether job spawned,
* `wp_cron()`: integer indicating number of jobs spawned (zero or more), `false` if one or more jobs fail to spawned,
* `_set_cron_array()`: boolean outcome of `update_option()`.
Props evansolomon, jrf, peterwilsoncc, pento for code review.
Fixes #21072.
Built from https://develop.svn.wordpress.org/trunk@43050
git-svn-id: http://core.svn.wordpress.org/trunk@42879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-01 04:05:23 +02:00
|
|
|
return _set_cron_array( $crons );
|
2006-03-07 22:43:59 +01:00
|
|
|
}
|
2006-04-06 07:25:50 +02:00
|
|
|
|
2008-09-04 21:12:40 +02:00
|
|
|
/**
|
2017-11-22 16:16:47 +01:00
|
|
|
* Schedules a recurring event.
|
2008-09-04 21:12:40 +02:00
|
|
|
*
|
2017-11-22 16:16:47 +01:00
|
|
|
* Schedules a hook which will be triggered by WordPress at the specified interval.
|
|
|
|
* The action will trigger when someone visits your WordPress site if the scheduled
|
|
|
|
* time has passed.
|
2008-09-04 21:12:40 +02:00
|
|
|
*
|
2017-11-22 16:16:47 +01:00
|
|
|
* Valid values for the recurrence are 'hourly', 'daily', and 'twicedaily'. These can
|
2016-05-23 20:59:27 +02:00
|
|
|
* be extended using the {@see 'cron_schedules'} filter in wp_get_schedules().
|
2009-04-08 22:16:59 +02:00
|
|
|
*
|
2017-11-22 16:16:47 +01:00
|
|
|
* Note that scheduling an event to occur within 10 minutes of an existing event
|
|
|
|
* with the same action hook will be ignored unless you pass unique `$args` values
|
|
|
|
* for each scheduled event.
|
|
|
|
*
|
|
|
|
* Use wp_next_scheduled() to prevent duplicate events.
|
|
|
|
*
|
|
|
|
* Use wp_schedule_single_event() to schedule a non-recurring event.
|
2010-12-02 17:27:16 +01:00
|
|
|
*
|
2008-09-04 21:12:40 +02:00
|
|
|
* @since 2.1.0
|
2018-12-19 04:41:49 +01:00
|
|
|
* @since 5.1.0 Return value modified to boolean indicating success or failure,
|
2018-12-30 05:51:51 +01:00
|
|
|
* {@see 'pre_schedule_event'} filter added to short-circuit the function.
|
Cron API: Return meaningful values from cron functions.
Return values added to Cron API functions to indicate outcome:
* `wp_schedule_single_event()`, `wp_schedule_event()`, `wp_reschedule_event()` and `wp_unschedule_event()`: boolean indicating success or failure,
* `wp_clear_scheduled_hook()`: integer indicating number of jobs cleared (zero or more), `false` if one or more jobs fail to clear,
* `wp_unschedule_hook()`: integer indicating number of jobs cleared (zero or more), `false` if the jobs fail to clear,
* `spawn_cron()`: boolean indicating whether job spawned,
* `wp_cron()`: integer indicating number of jobs spawned (zero or more), `false` if one or more jobs fail to spawned,
* `_set_cron_array()`: boolean outcome of `update_option()`.
Props evansolomon, jrf, peterwilsoncc, pento for code review.
Fixes #21072.
Built from https://develop.svn.wordpress.org/trunk@43050
git-svn-id: http://core.svn.wordpress.org/trunk@42879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-01 04:05:23 +02:00
|
|
|
*
|
2017-11-22 16:16:47 +01:00
|
|
|
* @link https://codex.wordpress.org/Function_Reference/wp_schedule_event
|
2008-09-04 21:12:40 +02:00
|
|
|
*
|
2017-11-22 16:16:47 +01:00
|
|
|
* @param int $timestamp Unix timestamp (UTC) for when to next run the event.
|
|
|
|
* @param string $recurrence How often the event should subsequently recur. See wp_get_schedules() for accepted values.
|
|
|
|
* @param string $hook Action hook to execute when the event is run.
|
|
|
|
* @param array $args Optional. Array containing each separate argument to pass to the hook's callback function.
|
Cron API: Return meaningful values from cron functions.
Return values added to Cron API functions to indicate outcome:
* `wp_schedule_single_event()`, `wp_schedule_event()`, `wp_reschedule_event()` and `wp_unschedule_event()`: boolean indicating success or failure,
* `wp_clear_scheduled_hook()`: integer indicating number of jobs cleared (zero or more), `false` if one or more jobs fail to clear,
* `wp_unschedule_hook()`: integer indicating number of jobs cleared (zero or more), `false` if the jobs fail to clear,
* `spawn_cron()`: boolean indicating whether job spawned,
* `wp_cron()`: integer indicating number of jobs spawned (zero or more), `false` if one or more jobs fail to spawned,
* `_set_cron_array()`: boolean outcome of `update_option()`.
Props evansolomon, jrf, peterwilsoncc, pento for code review.
Fixes #21072.
Built from https://develop.svn.wordpress.org/trunk@43050
git-svn-id: http://core.svn.wordpress.org/trunk@42879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-01 04:05:23 +02:00
|
|
|
* @return bool True if event successfully scheduled. False for failure.
|
2008-09-04 21:12:40 +02:00
|
|
|
*/
|
2017-12-01 00:11:00 +01:00
|
|
|
function wp_schedule_event( $timestamp, $recurrence, $hook, $args = array() ) {
|
2015-09-07 04:39:23 +02:00
|
|
|
// Make sure timestamp is a positive integer
|
|
|
|
if ( ! is_numeric( $timestamp ) || $timestamp <= 0 ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-03-07 22:43:59 +01:00
|
|
|
$schedules = wp_get_schedules();
|
2010-10-18 22:50:35 +02:00
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( ! isset( $schedules[ $recurrence ] ) ) {
|
2006-03-07 22:43:59 +01:00
|
|
|
return false;
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2010-10-18 22:50:35 +02:00
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
$event = (object) array(
|
|
|
|
'hook' => $hook,
|
|
|
|
'timestamp' => $timestamp,
|
|
|
|
'schedule' => $recurrence,
|
|
|
|
'args' => $args,
|
|
|
|
'interval' => $schedules[ $recurrence ]['interval'],
|
|
|
|
);
|
Cron: Add hooks and a function to allow hijacking cron implementation.
This allows sites with a large cron option or a custom cron implementation to hijack the cron option to store cron data using custom functionality.
`wp_get_scheduled_event()` is new function to retrieve the event object for a given event based on the hook name, arguments and timestamp. If no timestamp is specified the next occurence is returned.
Preflight filters are added to all functions that read from or modify the cron option: `pre_schedule_event`, `pre_reschedule_event`, `pre_unschedule_event`, `pre_clear_scheduled_hook`, `pre_unschedule_hook`, `pre_get_scheduled_event` and `pre_next_scheduled`.
Additionally, the post scheduling hooks `next_scheduled` and `get_schedule` to allow plugins to modify an event after retrieving it from WordPress.
Props rmccue, DavidAnderson, ethitter, peterwilsoncc.
Fixes #32656.
Built from https://develop.svn.wordpress.org/trunk@43540
git-svn-id: http://core.svn.wordpress.org/trunk@43369 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-07-27 04:23:25 +02:00
|
|
|
|
|
|
|
/** This filter is documented in wp-includes/cron.php */
|
|
|
|
$pre = apply_filters( 'pre_schedule_event', null, $event );
|
|
|
|
if ( null !== $pre ) {
|
|
|
|
return $pre;
|
|
|
|
}
|
|
|
|
|
2013-11-19 06:01:11 +01:00
|
|
|
/** This filter is documented in wp-includes/cron.php */
|
|
|
|
$event = apply_filters( 'schedule_event', $event );
|
2010-10-18 22:50:35 +02:00
|
|
|
|
|
|
|
// A plugin disallowed this event
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( ! $event ) {
|
2010-10-18 22:50:35 +02:00
|
|
|
return false;
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2010-10-18 22:50:35 +02:00
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
$key = md5( serialize( $event->args ) );
|
2010-10-18 22:50:35 +02:00
|
|
|
|
Cron: Add hooks and a function to allow hijacking cron implementation.
This allows sites with a large cron option or a custom cron implementation to hijack the cron option to store cron data using custom functionality.
`wp_get_scheduled_event()` is new function to retrieve the event object for a given event based on the hook name, arguments and timestamp. If no timestamp is specified the next occurence is returned.
Preflight filters are added to all functions that read from or modify the cron option: `pre_schedule_event`, `pre_reschedule_event`, `pre_unschedule_event`, `pre_clear_scheduled_hook`, `pre_unschedule_hook`, `pre_get_scheduled_event` and `pre_next_scheduled`.
Additionally, the post scheduling hooks `next_scheduled` and `get_schedule` to allow plugins to modify an event after retrieving it from WordPress.
Props rmccue, DavidAnderson, ethitter, peterwilsoncc.
Fixes #32656.
Built from https://develop.svn.wordpress.org/trunk@43540
git-svn-id: http://core.svn.wordpress.org/trunk@43369 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-07-27 04:23:25 +02:00
|
|
|
$crons = _get_cron_array();
|
2017-12-01 00:11:00 +01:00
|
|
|
$crons[ $event->timestamp ][ $event->hook ][ $key ] = array(
|
|
|
|
'schedule' => $event->schedule,
|
|
|
|
'args' => $event->args,
|
|
|
|
'interval' => $event->interval,
|
|
|
|
);
|
|
|
|
uksort( $crons, 'strnatcasecmp' );
|
Cron API: Return meaningful values from cron functions.
Return values added to Cron API functions to indicate outcome:
* `wp_schedule_single_event()`, `wp_schedule_event()`, `wp_reschedule_event()` and `wp_unschedule_event()`: boolean indicating success or failure,
* `wp_clear_scheduled_hook()`: integer indicating number of jobs cleared (zero or more), `false` if one or more jobs fail to clear,
* `wp_unschedule_hook()`: integer indicating number of jobs cleared (zero or more), `false` if the jobs fail to clear,
* `spawn_cron()`: boolean indicating whether job spawned,
* `wp_cron()`: integer indicating number of jobs spawned (zero or more), `false` if one or more jobs fail to spawned,
* `_set_cron_array()`: boolean outcome of `update_option()`.
Props evansolomon, jrf, peterwilsoncc, pento for code review.
Fixes #21072.
Built from https://develop.svn.wordpress.org/trunk@43050
git-svn-id: http://core.svn.wordpress.org/trunk@42879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-01 04:05:23 +02:00
|
|
|
return _set_cron_array( $crons );
|
2006-03-07 22:43:59 +01:00
|
|
|
}
|
|
|
|
|
2008-09-04 21:12:40 +02:00
|
|
|
/**
|
2017-11-22 16:16:47 +01:00
|
|
|
* Reschedules a recurring event.
|
2008-09-04 21:12:40 +02:00
|
|
|
*
|
2018-09-03 06:04:25 +02:00
|
|
|
* Mainly for internal use, this takes the time stamp of a previously run
|
|
|
|
* recurring event and reschedules it for its next run.
|
|
|
|
*
|
2018-12-30 05:51:51 +01:00
|
|
|
* To change upcoming scheduled events, use wp_schedule_event() to
|
2018-09-03 06:04:25 +02:00
|
|
|
* change the recurrence frequency.
|
|
|
|
*
|
2008-09-04 21:12:40 +02:00
|
|
|
* @since 2.1.0
|
2018-12-19 04:41:49 +01:00
|
|
|
* @since 5.1.0 Return value modified to boolean indicating success or failure,
|
2018-12-30 05:51:51 +01:00
|
|
|
* {@see 'pre_reschedule_event'} filter added to short-circuit the function.
|
2008-09-04 21:12:40 +02:00
|
|
|
*
|
2018-09-03 06:04:25 +02:00
|
|
|
* @param int $timestamp Unix timestamp (UTC) for when the event was scheduled.
|
2017-11-22 16:16:47 +01:00
|
|
|
* @param string $recurrence How often the event should subsequently recur. See wp_get_schedules() for accepted values.
|
|
|
|
* @param string $hook Action hook to execute when the event is run.
|
|
|
|
* @param array $args Optional. Array containing each separate argument to pass to the hook's callback function.
|
Cron API: Return meaningful values from cron functions.
Return values added to Cron API functions to indicate outcome:
* `wp_schedule_single_event()`, `wp_schedule_event()`, `wp_reschedule_event()` and `wp_unschedule_event()`: boolean indicating success or failure,
* `wp_clear_scheduled_hook()`: integer indicating number of jobs cleared (zero or more), `false` if one or more jobs fail to clear,
* `wp_unschedule_hook()`: integer indicating number of jobs cleared (zero or more), `false` if the jobs fail to clear,
* `spawn_cron()`: boolean indicating whether job spawned,
* `wp_cron()`: integer indicating number of jobs spawned (zero or more), `false` if one or more jobs fail to spawned,
* `_set_cron_array()`: boolean outcome of `update_option()`.
Props evansolomon, jrf, peterwilsoncc, pento for code review.
Fixes #21072.
Built from https://develop.svn.wordpress.org/trunk@43050
git-svn-id: http://core.svn.wordpress.org/trunk@42879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-01 04:05:23 +02:00
|
|
|
* @return bool True if event successfully rescheduled. False for failure.
|
2008-09-04 21:12:40 +02:00
|
|
|
*/
|
2014-08-01 22:57:16 +02:00
|
|
|
function wp_reschedule_event( $timestamp, $recurrence, $hook, $args = array() ) {
|
2015-09-07 04:39:23 +02:00
|
|
|
// Make sure timestamp is a positive integer
|
|
|
|
if ( ! is_numeric( $timestamp ) || $timestamp <= 0 ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-03-07 22:43:59 +01:00
|
|
|
$schedules = wp_get_schedules();
|
2017-12-01 00:11:00 +01:00
|
|
|
$interval = 0;
|
2006-04-06 07:25:50 +02:00
|
|
|
|
Cron: Add hooks and a function to allow hijacking cron implementation.
This allows sites with a large cron option or a custom cron implementation to hijack the cron option to store cron data using custom functionality.
`wp_get_scheduled_event()` is new function to retrieve the event object for a given event based on the hook name, arguments and timestamp. If no timestamp is specified the next occurence is returned.
Preflight filters are added to all functions that read from or modify the cron option: `pre_schedule_event`, `pre_reschedule_event`, `pre_unschedule_event`, `pre_clear_scheduled_hook`, `pre_unschedule_hook`, `pre_get_scheduled_event` and `pre_next_scheduled`.
Additionally, the post scheduling hooks `next_scheduled` and `get_schedule` to allow plugins to modify an event after retrieving it from WordPress.
Props rmccue, DavidAnderson, ethitter, peterwilsoncc.
Fixes #32656.
Built from https://develop.svn.wordpress.org/trunk@43540
git-svn-id: http://core.svn.wordpress.org/trunk@43369 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-07-27 04:23:25 +02:00
|
|
|
// First we try to get the interval from the schedule.
|
2014-08-01 22:57:16 +02:00
|
|
|
if ( isset( $schedules[ $recurrence ] ) ) {
|
|
|
|
$interval = $schedules[ $recurrence ]['interval'];
|
|
|
|
}
|
Cron: Add hooks and a function to allow hijacking cron implementation.
This allows sites with a large cron option or a custom cron implementation to hijack the cron option to store cron data using custom functionality.
`wp_get_scheduled_event()` is new function to retrieve the event object for a given event based on the hook name, arguments and timestamp. If no timestamp is specified the next occurence is returned.
Preflight filters are added to all functions that read from or modify the cron option: `pre_schedule_event`, `pre_reschedule_event`, `pre_unschedule_event`, `pre_clear_scheduled_hook`, `pre_unschedule_hook`, `pre_get_scheduled_event` and `pre_next_scheduled`.
Additionally, the post scheduling hooks `next_scheduled` and `get_schedule` to allow plugins to modify an event after retrieving it from WordPress.
Props rmccue, DavidAnderson, ethitter, peterwilsoncc.
Fixes #32656.
Built from https://develop.svn.wordpress.org/trunk@43540
git-svn-id: http://core.svn.wordpress.org/trunk@43369 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-07-27 04:23:25 +02:00
|
|
|
|
|
|
|
// Now we try to get it from the saved interval in case the schedule disappears.
|
|
|
|
if ( 0 === $interval ) {
|
|
|
|
$scheduled_event = wp_get_scheduled_event( $hook, $args, $timestamp );
|
|
|
|
if ( $scheduled_event && isset( $scheduled_event->interval ) ) {
|
|
|
|
$interval = $scheduled_event->interval;
|
|
|
|
}
|
2014-08-01 22:57:16 +02:00
|
|
|
}
|
Cron: Add hooks and a function to allow hijacking cron implementation.
This allows sites with a large cron option or a custom cron implementation to hijack the cron option to store cron data using custom functionality.
`wp_get_scheduled_event()` is new function to retrieve the event object for a given event based on the hook name, arguments and timestamp. If no timestamp is specified the next occurence is returned.
Preflight filters are added to all functions that read from or modify the cron option: `pre_schedule_event`, `pre_reschedule_event`, `pre_unschedule_event`, `pre_clear_scheduled_hook`, `pre_unschedule_hook`, `pre_get_scheduled_event` and `pre_next_scheduled`.
Additionally, the post scheduling hooks `next_scheduled` and `get_schedule` to allow plugins to modify an event after retrieving it from WordPress.
Props rmccue, DavidAnderson, ethitter, peterwilsoncc.
Fixes #32656.
Built from https://develop.svn.wordpress.org/trunk@43540
git-svn-id: http://core.svn.wordpress.org/trunk@43369 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-07-27 04:23:25 +02:00
|
|
|
|
|
|
|
$event = (object) array(
|
|
|
|
'hook' => $hook,
|
|
|
|
'timestamp' => $timestamp,
|
|
|
|
'schedule' => $recurrence,
|
|
|
|
'args' => $args,
|
|
|
|
'interval' => $interval,
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Filter to preflight or hijack rescheduling of events.
|
|
|
|
*
|
|
|
|
* Returning a non-null value will short-circuit the normal rescheduling
|
|
|
|
* process, causing the function to return the filtered value instead.
|
|
|
|
*
|
|
|
|
* For plugins replacing wp-cron, return true if the event was successfully
|
|
|
|
* rescheduled, false if not.
|
|
|
|
*
|
|
|
|
* @since 5.0.0
|
|
|
|
*
|
|
|
|
* @param null|bool $pre Value to return instead. Default null to continue adding the event.
|
|
|
|
* @param stdClass $event {
|
|
|
|
* An object containing an event's data.
|
|
|
|
*
|
|
|
|
* @type string $hook Action hook to execute when the event is run.
|
|
|
|
* @type int $timestamp Unix timestamp (UTC) for when to next run the event.
|
|
|
|
* @type string|false $schedule How often the event should subsequently recur.
|
|
|
|
* @type array $args Array containing each separate argument to pass to the hook's callback function.
|
|
|
|
* @type int $interval The interval time in seconds for the schedule. Only present for recurring events.
|
|
|
|
* }
|
|
|
|
*/
|
|
|
|
$pre = apply_filters( 'pre_reschedule_event', null, $event );
|
|
|
|
if ( null !== $pre ) {
|
|
|
|
return $pre;
|
|
|
|
}
|
|
|
|
|
2006-03-07 22:43:59 +01:00
|
|
|
// Now we assume something is wrong and fail to schedule
|
2014-08-01 22:57:16 +02:00
|
|
|
if ( 0 == $interval ) {
|
2006-03-07 22:43:59 +01:00
|
|
|
return false;
|
2014-08-01 22:57:16 +02:00
|
|
|
}
|
2006-03-07 22:43:59 +01:00
|
|
|
|
2009-04-17 02:23:48 +02:00
|
|
|
$now = time();
|
|
|
|
|
2014-08-01 22:57:16 +02:00
|
|
|
if ( $timestamp >= $now ) {
|
2010-06-30 02:05:18 +02:00
|
|
|
$timestamp = $now + $interval;
|
2014-08-01 22:57:16 +02:00
|
|
|
} else {
|
|
|
|
$timestamp = $now + ( $interval - ( ( $now - $timestamp ) % $interval ) );
|
|
|
|
}
|
2006-04-06 07:25:50 +02:00
|
|
|
|
Cron API: Return meaningful values from cron functions.
Return values added to Cron API functions to indicate outcome:
* `wp_schedule_single_event()`, `wp_schedule_event()`, `wp_reschedule_event()` and `wp_unschedule_event()`: boolean indicating success or failure,
* `wp_clear_scheduled_hook()`: integer indicating number of jobs cleared (zero or more), `false` if one or more jobs fail to clear,
* `wp_unschedule_hook()`: integer indicating number of jobs cleared (zero or more), `false` if the jobs fail to clear,
* `spawn_cron()`: boolean indicating whether job spawned,
* `wp_cron()`: integer indicating number of jobs spawned (zero or more), `false` if one or more jobs fail to spawned,
* `_set_cron_array()`: boolean outcome of `update_option()`.
Props evansolomon, jrf, peterwilsoncc, pento for code review.
Fixes #21072.
Built from https://develop.svn.wordpress.org/trunk@43050
git-svn-id: http://core.svn.wordpress.org/trunk@42879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-01 04:05:23 +02:00
|
|
|
return wp_schedule_event( $timestamp, $recurrence, $hook, $args );
|
2006-03-07 22:43:59 +01:00
|
|
|
}
|
|
|
|
|
2008-09-04 21:12:40 +02:00
|
|
|
/**
|
2016-08-26 11:22:30 +02:00
|
|
|
* Unschedule a previously scheduled event.
|
2008-09-04 21:12:40 +02:00
|
|
|
*
|
2016-08-26 11:22:30 +02:00
|
|
|
* The $timestamp and $hook parameters are required so that the event can be
|
2008-09-04 21:12:40 +02:00
|
|
|
* identified.
|
|
|
|
*
|
|
|
|
* @since 2.1.0
|
2018-12-19 04:41:49 +01:00
|
|
|
* @since 5.1.0 Return value modified to boolean indicating success or failure,
|
2018-12-30 05:51:51 +01:00
|
|
|
* {@see 'pre_unschedule_event'} filter added to short-circuit the function.
|
2008-09-04 21:12:40 +02:00
|
|
|
*
|
2017-11-22 16:16:47 +01:00
|
|
|
* @param int $timestamp Unix timestamp (UTC) of the event.
|
|
|
|
* @param string $hook Action hook of the event.
|
|
|
|
* @param array $args Optional. Array containing each separate argument to pass to the hook's callback function.
|
|
|
|
* Although not passed to a callback, these arguments are used to uniquely identify the
|
|
|
|
* event, so they should be the same as those used when originally scheduling the event.
|
Cron API: Return meaningful values from cron functions.
Return values added to Cron API functions to indicate outcome:
* `wp_schedule_single_event()`, `wp_schedule_event()`, `wp_reschedule_event()` and `wp_unschedule_event()`: boolean indicating success or failure,
* `wp_clear_scheduled_hook()`: integer indicating number of jobs cleared (zero or more), `false` if one or more jobs fail to clear,
* `wp_unschedule_hook()`: integer indicating number of jobs cleared (zero or more), `false` if the jobs fail to clear,
* `spawn_cron()`: boolean indicating whether job spawned,
* `wp_cron()`: integer indicating number of jobs spawned (zero or more), `false` if one or more jobs fail to spawned,
* `_set_cron_array()`: boolean outcome of `update_option()`.
Props evansolomon, jrf, peterwilsoncc, pento for code review.
Fixes #21072.
Built from https://develop.svn.wordpress.org/trunk@43050
git-svn-id: http://core.svn.wordpress.org/trunk@42879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-01 04:05:23 +02:00
|
|
|
* @return bool True if event successfully unscheduled. False for failure.
|
2008-09-04 21:12:40 +02:00
|
|
|
*/
|
2006-09-14 01:54:15 +02:00
|
|
|
function wp_unschedule_event( $timestamp, $hook, $args = array() ) {
|
2015-09-07 04:39:23 +02:00
|
|
|
// Make sure timestamp is a positive integer
|
|
|
|
if ( ! is_numeric( $timestamp ) || $timestamp <= 0 ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
Cron: Add hooks and a function to allow hijacking cron implementation.
This allows sites with a large cron option or a custom cron implementation to hijack the cron option to store cron data using custom functionality.
`wp_get_scheduled_event()` is new function to retrieve the event object for a given event based on the hook name, arguments and timestamp. If no timestamp is specified the next occurence is returned.
Preflight filters are added to all functions that read from or modify the cron option: `pre_schedule_event`, `pre_reschedule_event`, `pre_unschedule_event`, `pre_clear_scheduled_hook`, `pre_unschedule_hook`, `pre_get_scheduled_event` and `pre_next_scheduled`.
Additionally, the post scheduling hooks `next_scheduled` and `get_schedule` to allow plugins to modify an event after retrieving it from WordPress.
Props rmccue, DavidAnderson, ethitter, peterwilsoncc.
Fixes #32656.
Built from https://develop.svn.wordpress.org/trunk@43540
git-svn-id: http://core.svn.wordpress.org/trunk@43369 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-07-27 04:23:25 +02:00
|
|
|
/**
|
|
|
|
* Filter to preflight or hijack unscheduling of events.
|
|
|
|
*
|
|
|
|
* Returning a non-null value will short-circuit the normal unscheduling
|
|
|
|
* process, causing the function to return the filtered value instead.
|
|
|
|
*
|
|
|
|
* For plugins replacing wp-cron, return true if the event was successfully
|
|
|
|
* unscheduled, false if not.
|
|
|
|
*
|
|
|
|
* @since 5.0.0
|
|
|
|
*
|
|
|
|
* @param null|bool $pre Value to return instead. Default null to continue unscheduling the event.
|
|
|
|
* @param int $timestamp Timestamp for when to run the event.
|
|
|
|
* @param string $hook Action hook, the execution of which will be unscheduled.
|
|
|
|
* @param array $args Arguments to pass to the hook's callback function.
|
|
|
|
*/
|
|
|
|
$pre = apply_filters( 'pre_unschedule_event', null, $timestamp, $hook, $args );
|
|
|
|
if ( null !== $pre ) {
|
|
|
|
return $pre;
|
|
|
|
}
|
|
|
|
|
2006-09-14 01:54:15 +02:00
|
|
|
$crons = _get_cron_array();
|
2017-12-01 00:11:00 +01:00
|
|
|
$key = md5( serialize( $args ) );
|
|
|
|
unset( $crons[ $timestamp ][ $hook ][ $key ] );
|
|
|
|
if ( empty( $crons[ $timestamp ][ $hook ] ) ) {
|
|
|
|
unset( $crons[ $timestamp ][ $hook ] );
|
|
|
|
}
|
|
|
|
if ( empty( $crons[ $timestamp ] ) ) {
|
|
|
|
unset( $crons[ $timestamp ] );
|
|
|
|
}
|
Cron API: Return meaningful values from cron functions.
Return values added to Cron API functions to indicate outcome:
* `wp_schedule_single_event()`, `wp_schedule_event()`, `wp_reschedule_event()` and `wp_unschedule_event()`: boolean indicating success or failure,
* `wp_clear_scheduled_hook()`: integer indicating number of jobs cleared (zero or more), `false` if one or more jobs fail to clear,
* `wp_unschedule_hook()`: integer indicating number of jobs cleared (zero or more), `false` if the jobs fail to clear,
* `spawn_cron()`: boolean indicating whether job spawned,
* `wp_cron()`: integer indicating number of jobs spawned (zero or more), `false` if one or more jobs fail to spawned,
* `_set_cron_array()`: boolean outcome of `update_option()`.
Props evansolomon, jrf, peterwilsoncc, pento for code review.
Fixes #21072.
Built from https://develop.svn.wordpress.org/trunk@43050
git-svn-id: http://core.svn.wordpress.org/trunk@42879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-01 04:05:23 +02:00
|
|
|
return _set_cron_array( $crons );
|
2006-03-07 22:43:59 +01:00
|
|
|
}
|
|
|
|
|
2008-09-04 21:12:40 +02:00
|
|
|
/**
|
2017-06-30 06:54:41 +02:00
|
|
|
* Unschedules all events attached to the hook with the specified arguments.
|
2008-09-04 21:12:40 +02:00
|
|
|
*
|
Cron API: Return meaningful values from cron functions.
Return values added to Cron API functions to indicate outcome:
* `wp_schedule_single_event()`, `wp_schedule_event()`, `wp_reschedule_event()` and `wp_unschedule_event()`: boolean indicating success or failure,
* `wp_clear_scheduled_hook()`: integer indicating number of jobs cleared (zero or more), `false` if one or more jobs fail to clear,
* `wp_unschedule_hook()`: integer indicating number of jobs cleared (zero or more), `false` if the jobs fail to clear,
* `spawn_cron()`: boolean indicating whether job spawned,
* `wp_cron()`: integer indicating number of jobs spawned (zero or more), `false` if one or more jobs fail to spawned,
* `_set_cron_array()`: boolean outcome of `update_option()`.
Props evansolomon, jrf, peterwilsoncc, pento for code review.
Fixes #21072.
Built from https://develop.svn.wordpress.org/trunk@43050
git-svn-id: http://core.svn.wordpress.org/trunk@42879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-01 04:05:23 +02:00
|
|
|
* Warning: This function may return Boolean FALSE, but may also return a non-Boolean
|
|
|
|
* value which evaluates to FALSE. For information about casting to booleans see the
|
|
|
|
* {@link https://php.net/manual/en/language.types.boolean.php PHP documentation}. Use
|
|
|
|
* the `===` operator for testing the return value of this function.
|
|
|
|
*
|
2008-09-04 21:12:40 +02:00
|
|
|
* @since 2.1.0
|
2018-12-19 04:41:49 +01:00
|
|
|
* @since 5.1.0 Return value modified to indicate success or failure,
|
2018-12-30 05:51:51 +01:00
|
|
|
* {@see 'pre_clear_scheduled_hook'} filter added to short-circuit the function.
|
2008-09-04 21:12:40 +02:00
|
|
|
*
|
2008-12-19 21:47:20 +01:00
|
|
|
* @param string $hook Action hook, the execution of which will be unscheduled.
|
2016-08-26 11:22:30 +02:00
|
|
|
* @param array $args Optional. Arguments that were to be passed to the hook's callback function.
|
Cron API: Return meaningful values from cron functions.
Return values added to Cron API functions to indicate outcome:
* `wp_schedule_single_event()`, `wp_schedule_event()`, `wp_reschedule_event()` and `wp_unschedule_event()`: boolean indicating success or failure,
* `wp_clear_scheduled_hook()`: integer indicating number of jobs cleared (zero or more), `false` if one or more jobs fail to clear,
* `wp_unschedule_hook()`: integer indicating number of jobs cleared (zero or more), `false` if the jobs fail to clear,
* `spawn_cron()`: boolean indicating whether job spawned,
* `wp_cron()`: integer indicating number of jobs spawned (zero or more), `false` if one or more jobs fail to spawned,
* `_set_cron_array()`: boolean outcome of `update_option()`.
Props evansolomon, jrf, peterwilsoncc, pento for code review.
Fixes #21072.
Built from https://develop.svn.wordpress.org/trunk@43050
git-svn-id: http://core.svn.wordpress.org/trunk@42879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-01 04:05:23 +02:00
|
|
|
* @return bool|int On success an integer indicating number of events unscheduled (0 indicates no
|
|
|
|
* events were registered with the hook and arguments combination), false if
|
|
|
|
* unscheduling one or more events fail.
|
2008-09-04 21:12:40 +02:00
|
|
|
*/
|
2009-12-19 12:47:16 +01:00
|
|
|
function wp_clear_scheduled_hook( $hook, $args = array() ) {
|
|
|
|
// Backward compatibility
|
|
|
|
// Previously this function took the arguments as discrete vars rather than an array like the rest of the API
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( ! is_array( $args ) ) {
|
|
|
|
_deprecated_argument( __FUNCTION__, '3.0.0', __( 'This argument has changed to an array to match the behavior of the other cron functions.' ) );
|
2009-12-19 12:47:16 +01:00
|
|
|
$args = array_slice( func_get_args(), 1 );
|
2009-12-24 12:12:04 +01:00
|
|
|
}
|
2007-02-27 16:24:54 +01:00
|
|
|
|
Cron: Add hooks and a function to allow hijacking cron implementation.
This allows sites with a large cron option or a custom cron implementation to hijack the cron option to store cron data using custom functionality.
`wp_get_scheduled_event()` is new function to retrieve the event object for a given event based on the hook name, arguments and timestamp. If no timestamp is specified the next occurence is returned.
Preflight filters are added to all functions that read from or modify the cron option: `pre_schedule_event`, `pre_reschedule_event`, `pre_unschedule_event`, `pre_clear_scheduled_hook`, `pre_unschedule_hook`, `pre_get_scheduled_event` and `pre_next_scheduled`.
Additionally, the post scheduling hooks `next_scheduled` and `get_schedule` to allow plugins to modify an event after retrieving it from WordPress.
Props rmccue, DavidAnderson, ethitter, peterwilsoncc.
Fixes #32656.
Built from https://develop.svn.wordpress.org/trunk@43540
git-svn-id: http://core.svn.wordpress.org/trunk@43369 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-07-27 04:23:25 +02:00
|
|
|
/**
|
|
|
|
* Filter to preflight or hijack clearing a scheduled hook.
|
|
|
|
*
|
|
|
|
* Returning a non-null value will short-circuit the normal unscheduling
|
|
|
|
* process, causing the function to return the filtered value instead.
|
|
|
|
*
|
|
|
|
* For plugins replacing wp-cron, return the number of events successfully
|
|
|
|
* unscheduled (zero if no events were registered with the hook) or false
|
|
|
|
* if unscheduling one or more events fails.
|
|
|
|
*
|
|
|
|
* @since 5.0.0
|
|
|
|
*
|
|
|
|
* @param null|array $pre Value to return instead. Default null to continue unscheduling the event.
|
|
|
|
* @param string $hook Action hook, the execution of which will be unscheduled.
|
|
|
|
* @param array $args Arguments to pass to the hook's callback function.
|
|
|
|
*/
|
|
|
|
$pre = apply_filters( 'pre_clear_scheduled_hook', null, $hook, $args );
|
|
|
|
if ( null !== $pre ) {
|
|
|
|
return $pre;
|
|
|
|
}
|
|
|
|
|
2013-12-07 10:13:11 +01:00
|
|
|
// This logic duplicates wp_next_scheduled()
|
|
|
|
// It's required due to a scenario where wp_unschedule_event() fails due to update_option() failing,
|
|
|
|
// and, wp_next_scheduled() returns the same schedule in an infinite loop.
|
|
|
|
$crons = _get_cron_array();
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( empty( $crons ) ) {
|
Cron API: Return meaningful values from cron functions.
Return values added to Cron API functions to indicate outcome:
* `wp_schedule_single_event()`, `wp_schedule_event()`, `wp_reschedule_event()` and `wp_unschedule_event()`: boolean indicating success or failure,
* `wp_clear_scheduled_hook()`: integer indicating number of jobs cleared (zero or more), `false` if one or more jobs fail to clear,
* `wp_unschedule_hook()`: integer indicating number of jobs cleared (zero or more), `false` if the jobs fail to clear,
* `spawn_cron()`: boolean indicating whether job spawned,
* `wp_cron()`: integer indicating number of jobs spawned (zero or more), `false` if one or more jobs fail to spawned,
* `_set_cron_array()`: boolean outcome of `update_option()`.
Props evansolomon, jrf, peterwilsoncc, pento for code review.
Fixes #21072.
Built from https://develop.svn.wordpress.org/trunk@43050
git-svn-id: http://core.svn.wordpress.org/trunk@42879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-01 04:05:23 +02:00
|
|
|
return 0;
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2013-12-07 10:13:11 +01:00
|
|
|
|
Cron API: Return meaningful values from cron functions.
Return values added to Cron API functions to indicate outcome:
* `wp_schedule_single_event()`, `wp_schedule_event()`, `wp_reschedule_event()` and `wp_unschedule_event()`: boolean indicating success or failure,
* `wp_clear_scheduled_hook()`: integer indicating number of jobs cleared (zero or more), `false` if one or more jobs fail to clear,
* `wp_unschedule_hook()`: integer indicating number of jobs cleared (zero or more), `false` if the jobs fail to clear,
* `spawn_cron()`: boolean indicating whether job spawned,
* `wp_cron()`: integer indicating number of jobs spawned (zero or more), `false` if one or more jobs fail to spawned,
* `_set_cron_array()`: boolean outcome of `update_option()`.
Props evansolomon, jrf, peterwilsoncc, pento for code review.
Fixes #21072.
Built from https://develop.svn.wordpress.org/trunk@43050
git-svn-id: http://core.svn.wordpress.org/trunk@42879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-01 04:05:23 +02:00
|
|
|
$results = array();
|
|
|
|
$key = md5( serialize( $args ) );
|
2013-12-07 10:13:11 +01:00
|
|
|
foreach ( $crons as $timestamp => $cron ) {
|
|
|
|
if ( isset( $cron[ $hook ][ $key ] ) ) {
|
Cron API: Return meaningful values from cron functions.
Return values added to Cron API functions to indicate outcome:
* `wp_schedule_single_event()`, `wp_schedule_event()`, `wp_reschedule_event()` and `wp_unschedule_event()`: boolean indicating success or failure,
* `wp_clear_scheduled_hook()`: integer indicating number of jobs cleared (zero or more), `false` if one or more jobs fail to clear,
* `wp_unschedule_hook()`: integer indicating number of jobs cleared (zero or more), `false` if the jobs fail to clear,
* `spawn_cron()`: boolean indicating whether job spawned,
* `wp_cron()`: integer indicating number of jobs spawned (zero or more), `false` if one or more jobs fail to spawned,
* `_set_cron_array()`: boolean outcome of `update_option()`.
Props evansolomon, jrf, peterwilsoncc, pento for code review.
Fixes #21072.
Built from https://develop.svn.wordpress.org/trunk@43050
git-svn-id: http://core.svn.wordpress.org/trunk@42879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-01 04:05:23 +02:00
|
|
|
$results[] = wp_unschedule_event( $timestamp, $hook, $args );
|
2013-12-07 10:13:11 +01:00
|
|
|
}
|
|
|
|
}
|
Cron API: Return meaningful values from cron functions.
Return values added to Cron API functions to indicate outcome:
* `wp_schedule_single_event()`, `wp_schedule_event()`, `wp_reschedule_event()` and `wp_unschedule_event()`: boolean indicating success or failure,
* `wp_clear_scheduled_hook()`: integer indicating number of jobs cleared (zero or more), `false` if one or more jobs fail to clear,
* `wp_unschedule_hook()`: integer indicating number of jobs cleared (zero or more), `false` if the jobs fail to clear,
* `spawn_cron()`: boolean indicating whether job spawned,
* `wp_cron()`: integer indicating number of jobs spawned (zero or more), `false` if one or more jobs fail to spawned,
* `_set_cron_array()`: boolean outcome of `update_option()`.
Props evansolomon, jrf, peterwilsoncc, pento for code review.
Fixes #21072.
Built from https://develop.svn.wordpress.org/trunk@43050
git-svn-id: http://core.svn.wordpress.org/trunk@42879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-01 04:05:23 +02:00
|
|
|
if ( in_array( false, $results, true ) ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return count( $results );
|
2006-03-07 22:43:59 +01:00
|
|
|
}
|
|
|
|
|
2017-06-30 02:22:44 +02:00
|
|
|
/**
|
2017-06-30 06:54:41 +02:00
|
|
|
* Unschedules all events attached to the hook.
|
2017-06-30 02:22:44 +02:00
|
|
|
*
|
|
|
|
* Can be useful for plugins when deactivating to clean up the cron queue.
|
|
|
|
*
|
Cron API: Return meaningful values from cron functions.
Return values added to Cron API functions to indicate outcome:
* `wp_schedule_single_event()`, `wp_schedule_event()`, `wp_reschedule_event()` and `wp_unschedule_event()`: boolean indicating success or failure,
* `wp_clear_scheduled_hook()`: integer indicating number of jobs cleared (zero or more), `false` if one or more jobs fail to clear,
* `wp_unschedule_hook()`: integer indicating number of jobs cleared (zero or more), `false` if the jobs fail to clear,
* `spawn_cron()`: boolean indicating whether job spawned,
* `wp_cron()`: integer indicating number of jobs spawned (zero or more), `false` if one or more jobs fail to spawned,
* `_set_cron_array()`: boolean outcome of `update_option()`.
Props evansolomon, jrf, peterwilsoncc, pento for code review.
Fixes #21072.
Built from https://develop.svn.wordpress.org/trunk@43050
git-svn-id: http://core.svn.wordpress.org/trunk@42879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-01 04:05:23 +02:00
|
|
|
* Warning: This function may return Boolean FALSE, but may also return a non-Boolean
|
|
|
|
* value which evaluates to FALSE. For information about casting to booleans see the
|
|
|
|
* {@link https://php.net/manual/en/language.types.boolean.php PHP documentation}. Use
|
|
|
|
* the `===` operator for testing the return value of this function.
|
|
|
|
*
|
2017-06-30 02:22:44 +02:00
|
|
|
* @since 4.9.0
|
2018-12-19 04:41:49 +01:00
|
|
|
* @since 5.1.0 Return value added to indicate success or failure.
|
2017-06-30 02:22:44 +02:00
|
|
|
*
|
|
|
|
* @param string $hook Action hook, the execution of which will be unscheduled.
|
Cron API: Return meaningful values from cron functions.
Return values added to Cron API functions to indicate outcome:
* `wp_schedule_single_event()`, `wp_schedule_event()`, `wp_reschedule_event()` and `wp_unschedule_event()`: boolean indicating success or failure,
* `wp_clear_scheduled_hook()`: integer indicating number of jobs cleared (zero or more), `false` if one or more jobs fail to clear,
* `wp_unschedule_hook()`: integer indicating number of jobs cleared (zero or more), `false` if the jobs fail to clear,
* `spawn_cron()`: boolean indicating whether job spawned,
* `wp_cron()`: integer indicating number of jobs spawned (zero or more), `false` if one or more jobs fail to spawned,
* `_set_cron_array()`: boolean outcome of `update_option()`.
Props evansolomon, jrf, peterwilsoncc, pento for code review.
Fixes #21072.
Built from https://develop.svn.wordpress.org/trunk@43050
git-svn-id: http://core.svn.wordpress.org/trunk@42879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-01 04:05:23 +02:00
|
|
|
* @return bool|int On success an integer indicating number of events unscheduled (0 indicates no
|
|
|
|
* events were registered on the hook), false if unscheduling fails.
|
2017-06-30 02:22:44 +02:00
|
|
|
*/
|
|
|
|
function wp_unschedule_hook( $hook ) {
|
Cron: Add hooks and a function to allow hijacking cron implementation.
This allows sites with a large cron option or a custom cron implementation to hijack the cron option to store cron data using custom functionality.
`wp_get_scheduled_event()` is new function to retrieve the event object for a given event based on the hook name, arguments and timestamp. If no timestamp is specified the next occurence is returned.
Preflight filters are added to all functions that read from or modify the cron option: `pre_schedule_event`, `pre_reschedule_event`, `pre_unschedule_event`, `pre_clear_scheduled_hook`, `pre_unschedule_hook`, `pre_get_scheduled_event` and `pre_next_scheduled`.
Additionally, the post scheduling hooks `next_scheduled` and `get_schedule` to allow plugins to modify an event after retrieving it from WordPress.
Props rmccue, DavidAnderson, ethitter, peterwilsoncc.
Fixes #32656.
Built from https://develop.svn.wordpress.org/trunk@43540
git-svn-id: http://core.svn.wordpress.org/trunk@43369 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-07-27 04:23:25 +02:00
|
|
|
/**
|
|
|
|
* Filter to preflight or hijack clearing all events attached to the hook.
|
|
|
|
*
|
|
|
|
* Returning a non-null value will short-circuit the normal unscheduling
|
|
|
|
* process, causing the function to return the filtered value instead.
|
|
|
|
*
|
|
|
|
* For plugins replacing wp-cron, return the number of events successfully
|
|
|
|
* unscheduled (zero if no events were registered with the hook) or false
|
|
|
|
* if unscheduling one or more events fails.
|
|
|
|
*
|
|
|
|
* @since 5.0.0
|
|
|
|
*
|
|
|
|
* @param null|array $pre Value to return instead. Default null to continue unscheduling the hook.
|
|
|
|
* @param string $hook Action hook, the execution of which will be unscheduled.
|
|
|
|
*/
|
|
|
|
$pre = apply_filters( 'pre_unschedule_hook', null, $hook );
|
|
|
|
if ( null !== $pre ) {
|
|
|
|
return $pre;
|
|
|
|
}
|
|
|
|
|
2017-06-30 02:22:44 +02:00
|
|
|
$crons = _get_cron_array();
|
Cron API: Return meaningful values from cron functions.
Return values added to Cron API functions to indicate outcome:
* `wp_schedule_single_event()`, `wp_schedule_event()`, `wp_reschedule_event()` and `wp_unschedule_event()`: boolean indicating success or failure,
* `wp_clear_scheduled_hook()`: integer indicating number of jobs cleared (zero or more), `false` if one or more jobs fail to clear,
* `wp_unschedule_hook()`: integer indicating number of jobs cleared (zero or more), `false` if the jobs fail to clear,
* `spawn_cron()`: boolean indicating whether job spawned,
* `wp_cron()`: integer indicating number of jobs spawned (zero or more), `false` if one or more jobs fail to spawned,
* `_set_cron_array()`: boolean outcome of `update_option()`.
Props evansolomon, jrf, peterwilsoncc, pento for code review.
Fixes #21072.
Built from https://develop.svn.wordpress.org/trunk@43050
git-svn-id: http://core.svn.wordpress.org/trunk@42879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-01 04:05:23 +02:00
|
|
|
if ( empty( $crons ) ) {
|
|
|
|
return 0;
|
|
|
|
}
|
2017-06-30 02:22:44 +02:00
|
|
|
|
Cron API: Return meaningful values from cron functions.
Return values added to Cron API functions to indicate outcome:
* `wp_schedule_single_event()`, `wp_schedule_event()`, `wp_reschedule_event()` and `wp_unschedule_event()`: boolean indicating success or failure,
* `wp_clear_scheduled_hook()`: integer indicating number of jobs cleared (zero or more), `false` if one or more jobs fail to clear,
* `wp_unschedule_hook()`: integer indicating number of jobs cleared (zero or more), `false` if the jobs fail to clear,
* `spawn_cron()`: boolean indicating whether job spawned,
* `wp_cron()`: integer indicating number of jobs spawned (zero or more), `false` if one or more jobs fail to spawned,
* `_set_cron_array()`: boolean outcome of `update_option()`.
Props evansolomon, jrf, peterwilsoncc, pento for code review.
Fixes #21072.
Built from https://develop.svn.wordpress.org/trunk@43050
git-svn-id: http://core.svn.wordpress.org/trunk@42879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-01 04:05:23 +02:00
|
|
|
$results = array();
|
2017-12-01 00:11:00 +01:00
|
|
|
foreach ( $crons as $timestamp => $args ) {
|
Cron API: Return meaningful values from cron functions.
Return values added to Cron API functions to indicate outcome:
* `wp_schedule_single_event()`, `wp_schedule_event()`, `wp_reschedule_event()` and `wp_unschedule_event()`: boolean indicating success or failure,
* `wp_clear_scheduled_hook()`: integer indicating number of jobs cleared (zero or more), `false` if one or more jobs fail to clear,
* `wp_unschedule_hook()`: integer indicating number of jobs cleared (zero or more), `false` if the jobs fail to clear,
* `spawn_cron()`: boolean indicating whether job spawned,
* `wp_cron()`: integer indicating number of jobs spawned (zero or more), `false` if one or more jobs fail to spawned,
* `_set_cron_array()`: boolean outcome of `update_option()`.
Props evansolomon, jrf, peterwilsoncc, pento for code review.
Fixes #21072.
Built from https://develop.svn.wordpress.org/trunk@43050
git-svn-id: http://core.svn.wordpress.org/trunk@42879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-01 04:05:23 +02:00
|
|
|
if ( ! empty( $crons[ $timestamp ][ $hook ] ) ) {
|
|
|
|
$results[] = count( $crons[ $timestamp ][ $hook ] );
|
|
|
|
}
|
2017-06-30 02:22:44 +02:00
|
|
|
unset( $crons[ $timestamp ][ $hook ] );
|
|
|
|
|
|
|
|
if ( empty( $crons[ $timestamp ] ) ) {
|
|
|
|
unset( $crons[ $timestamp ] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Cron API: Return meaningful values from cron functions.
Return values added to Cron API functions to indicate outcome:
* `wp_schedule_single_event()`, `wp_schedule_event()`, `wp_reschedule_event()` and `wp_unschedule_event()`: boolean indicating success or failure,
* `wp_clear_scheduled_hook()`: integer indicating number of jobs cleared (zero or more), `false` if one or more jobs fail to clear,
* `wp_unschedule_hook()`: integer indicating number of jobs cleared (zero or more), `false` if the jobs fail to clear,
* `spawn_cron()`: boolean indicating whether job spawned,
* `wp_cron()`: integer indicating number of jobs spawned (zero or more), `false` if one or more jobs fail to spawned,
* `_set_cron_array()`: boolean outcome of `update_option()`.
Props evansolomon, jrf, peterwilsoncc, pento for code review.
Fixes #21072.
Built from https://develop.svn.wordpress.org/trunk@43050
git-svn-id: http://core.svn.wordpress.org/trunk@42879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-01 04:05:23 +02:00
|
|
|
/*
|
|
|
|
* If the results are empty (zero events to unschedule), no attempt
|
|
|
|
* to update the cron array is required.
|
|
|
|
*/
|
|
|
|
if ( empty( $results ) ) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if ( _set_cron_array( $crons ) ) {
|
|
|
|
return array_sum( $results );
|
|
|
|
}
|
|
|
|
return false;
|
2017-06-30 02:22:44 +02:00
|
|
|
}
|
|
|
|
|
Cron: Add hooks and a function to allow hijacking cron implementation.
This allows sites with a large cron option or a custom cron implementation to hijack the cron option to store cron data using custom functionality.
`wp_get_scheduled_event()` is new function to retrieve the event object for a given event based on the hook name, arguments and timestamp. If no timestamp is specified the next occurence is returned.
Preflight filters are added to all functions that read from or modify the cron option: `pre_schedule_event`, `pre_reschedule_event`, `pre_unschedule_event`, `pre_clear_scheduled_hook`, `pre_unschedule_hook`, `pre_get_scheduled_event` and `pre_next_scheduled`.
Additionally, the post scheduling hooks `next_scheduled` and `get_schedule` to allow plugins to modify an event after retrieving it from WordPress.
Props rmccue, DavidAnderson, ethitter, peterwilsoncc.
Fixes #32656.
Built from https://develop.svn.wordpress.org/trunk@43540
git-svn-id: http://core.svn.wordpress.org/trunk@43369 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-07-27 04:23:25 +02:00
|
|
|
/**
|
|
|
|
* Retrieve a scheduled event.
|
|
|
|
*
|
|
|
|
* Retrieve the full event object for a given event.
|
|
|
|
*
|
|
|
|
* @since 5.0.0
|
|
|
|
*
|
|
|
|
* @param string $hook Action hook of the event.
|
|
|
|
* @param array $args Optional. Array containing each separate argument to pass to the hook's callback function.
|
|
|
|
* Although not passed to a callback, these arguments are used to uniquely identify the
|
|
|
|
* event, so they should be the same as those used when originally scheduling the event.
|
|
|
|
* @param int|null $timestamp Optional. Unix timestamp (UTC) of the event. If not specified, the next scheduled event is returned.
|
|
|
|
* @return bool|object The event object. False if the event does not exist.
|
|
|
|
*/
|
|
|
|
function wp_get_scheduled_event( $hook, $args = array(), $timestamp = null ) {
|
|
|
|
if ( ! $timestamp ) {
|
|
|
|
// Get the next scheduled event.
|
|
|
|
$timestamp = wp_next_scheduled( $hook, $args );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Filter to preflight or hijack retrieving a scheduled event.
|
|
|
|
*
|
|
|
|
* Returning a non-null value will short-circuit the normal process,
|
|
|
|
* returning the filtered value instead.
|
|
|
|
*
|
|
|
|
* Return false if the event does not exist, otherwise an event object
|
|
|
|
* should be returned.
|
|
|
|
*
|
|
|
|
* @since 5.0.0
|
|
|
|
*
|
|
|
|
* @param null|bool $pre Value to return instead. Default null to continue retrieving the event.
|
|
|
|
* @param string $hook Action hook of the event.
|
|
|
|
* @param array $args Array containing each separate argument to pass to the hook's callback function.
|
|
|
|
* Although not passed to a callback, these arguments are used to uniquely identify the
|
|
|
|
* event.
|
|
|
|
* @param int $timestamp Unix timestamp (UTC) of the event.
|
|
|
|
*/
|
|
|
|
$pre = apply_filters( 'pre_get_scheduled_event', null, $hook, $args, $timestamp );
|
|
|
|
if ( null !== $pre ) {
|
|
|
|
return $pre;
|
|
|
|
}
|
|
|
|
|
|
|
|
$crons = _get_cron_array();
|
|
|
|
$key = md5( serialize( $args ) );
|
|
|
|
|
|
|
|
if ( ! $timestamp || ! isset( $crons[ $timestamp ] ) ) {
|
|
|
|
// No such event.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ! isset( $crons[ $timestamp ][ $hook ] ) || ! isset( $crons[ $timestamp ][ $hook ][ $key ] ) ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$event = (object) array(
|
|
|
|
'hook' => $hook,
|
|
|
|
'timestamp' => $timestamp,
|
|
|
|
'schedule' => $crons[ $timestamp ][ $hook ][ $key ]['schedule'],
|
|
|
|
'args' => $args,
|
|
|
|
);
|
|
|
|
|
|
|
|
if ( isset( $crons[ $timestamp ][ $hook ][ $key ]['interval'] ) ) {
|
|
|
|
$event->interval = $crons[ $timestamp ][ $hook ][ $key ]['interval'];
|
|
|
|
}
|
|
|
|
|
|
|
|
return $event;
|
|
|
|
}
|
|
|
|
|
2008-09-04 21:12:40 +02:00
|
|
|
/**
|
2016-08-26 11:22:30 +02:00
|
|
|
* Retrieve the next timestamp for an event.
|
2008-09-04 21:12:40 +02:00
|
|
|
*
|
|
|
|
* @since 2.1.0
|
2018-12-30 05:51:51 +01:00
|
|
|
* @since 5.0.0 {@see 'pre_next_scheduled'} and {@see 'next_scheduled'} filters added.
|
2008-09-04 21:12:40 +02:00
|
|
|
*
|
2017-11-22 16:16:47 +01:00
|
|
|
* @param string $hook Action hook of the event.
|
|
|
|
* @param array $args Optional. Array containing each separate argument to pass to the hook's callback function.
|
|
|
|
* Although not passed to a callback, these arguments are used to uniquely identify the
|
|
|
|
* event, so they should be the same as those used when originally scheduling the event.
|
|
|
|
* @return false|int The Unix timestamp of the next time the event will occur. False if the event doesn't exist.
|
2008-09-04 21:12:40 +02:00
|
|
|
*/
|
2006-09-14 01:54:15 +02:00
|
|
|
function wp_next_scheduled( $hook, $args = array() ) {
|
Cron: Add hooks and a function to allow hijacking cron implementation.
This allows sites with a large cron option or a custom cron implementation to hijack the cron option to store cron data using custom functionality.
`wp_get_scheduled_event()` is new function to retrieve the event object for a given event based on the hook name, arguments and timestamp. If no timestamp is specified the next occurence is returned.
Preflight filters are added to all functions that read from or modify the cron option: `pre_schedule_event`, `pre_reschedule_event`, `pre_unschedule_event`, `pre_clear_scheduled_hook`, `pre_unschedule_hook`, `pre_get_scheduled_event` and `pre_next_scheduled`.
Additionally, the post scheduling hooks `next_scheduled` and `get_schedule` to allow plugins to modify an event after retrieving it from WordPress.
Props rmccue, DavidAnderson, ethitter, peterwilsoncc.
Fixes #32656.
Built from https://develop.svn.wordpress.org/trunk@43540
git-svn-id: http://core.svn.wordpress.org/trunk@43369 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-07-27 04:23:25 +02:00
|
|
|
/**
|
|
|
|
* Filter to preflight or hijack retrieving the next scheduled event timestamp.
|
|
|
|
*
|
|
|
|
* Returning a non-null value will short-circuit the normal retrieval
|
|
|
|
* process, causing the function to return the filtered value instead.
|
|
|
|
*
|
|
|
|
* Pass the timestamp of the next event if it exists, false if not.
|
|
|
|
*
|
|
|
|
* @since 5.0.0
|
|
|
|
*
|
|
|
|
* @param null|bool $pre Value to return instead. Default null to continue unscheduling the event.
|
|
|
|
* @param string $hook Action hook of the event.
|
|
|
|
* @param array $args Arguments to pass to the hook's callback function.
|
|
|
|
*/
|
|
|
|
$pre = apply_filters( 'pre_next_scheduled', null, $hook, $args );
|
|
|
|
if ( null !== $pre ) {
|
|
|
|
return $pre;
|
|
|
|
}
|
|
|
|
|
2006-09-14 01:54:15 +02:00
|
|
|
$crons = _get_cron_array();
|
2017-12-01 00:11:00 +01:00
|
|
|
$key = md5( serialize( $args ) );
|
Cron: Add hooks and a function to allow hijacking cron implementation.
This allows sites with a large cron option or a custom cron implementation to hijack the cron option to store cron data using custom functionality.
`wp_get_scheduled_event()` is new function to retrieve the event object for a given event based on the hook name, arguments and timestamp. If no timestamp is specified the next occurence is returned.
Preflight filters are added to all functions that read from or modify the cron option: `pre_schedule_event`, `pre_reschedule_event`, `pre_unschedule_event`, `pre_clear_scheduled_hook`, `pre_unschedule_hook`, `pre_get_scheduled_event` and `pre_next_scheduled`.
Additionally, the post scheduling hooks `next_scheduled` and `get_schedule` to allow plugins to modify an event after retrieving it from WordPress.
Props rmccue, DavidAnderson, ethitter, peterwilsoncc.
Fixes #32656.
Built from https://develop.svn.wordpress.org/trunk@43540
git-svn-id: http://core.svn.wordpress.org/trunk@43369 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-07-27 04:23:25 +02:00
|
|
|
$next = false;
|
|
|
|
|
|
|
|
if ( ! empty( $crons ) ) {
|
|
|
|
foreach ( $crons as $timestamp => $cron ) {
|
|
|
|
if ( isset( $cron[ $hook ][ $key ] ) ) {
|
|
|
|
$next = $timestamp;
|
|
|
|
break;
|
|
|
|
}
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2006-09-14 01:54:15 +02:00
|
|
|
}
|
Cron: Add hooks and a function to allow hijacking cron implementation.
This allows sites with a large cron option or a custom cron implementation to hijack the cron option to store cron data using custom functionality.
`wp_get_scheduled_event()` is new function to retrieve the event object for a given event based on the hook name, arguments and timestamp. If no timestamp is specified the next occurence is returned.
Preflight filters are added to all functions that read from or modify the cron option: `pre_schedule_event`, `pre_reschedule_event`, `pre_unschedule_event`, `pre_clear_scheduled_hook`, `pre_unschedule_hook`, `pre_get_scheduled_event` and `pre_next_scheduled`.
Additionally, the post scheduling hooks `next_scheduled` and `get_schedule` to allow plugins to modify an event after retrieving it from WordPress.
Props rmccue, DavidAnderson, ethitter, peterwilsoncc.
Fixes #32656.
Built from https://develop.svn.wordpress.org/trunk@43540
git-svn-id: http://core.svn.wordpress.org/trunk@43369 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-07-27 04:23:25 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Filter the next scheduled event timestamp.
|
|
|
|
*
|
|
|
|
* @since 5.0.0
|
|
|
|
*
|
|
|
|
* @param int|bool $next The UNIX timestamp when the scheduled event will next occur, or false if not found.
|
|
|
|
* @param string $hook Action hook to execute when cron is run.
|
|
|
|
* @param array $args Arguments to be passed to the callback function. Used for deduplicating events.
|
|
|
|
*/
|
|
|
|
return apply_filters( 'next_scheduled', $next, $hook, $args );
|
2006-03-07 22:43:59 +01:00
|
|
|
}
|
|
|
|
|
2008-08-01 07:00:07 +02:00
|
|
|
/**
|
2015-12-19 09:20:27 +01:00
|
|
|
* Sends a request to run cron through HTTP request that doesn't halt page loading.
|
2008-08-01 07:00:07 +02:00
|
|
|
*
|
|
|
|
* @since 2.1.0
|
2018-12-19 04:41:49 +01:00
|
|
|
* @since 5.1.0 Return values added.
|
2015-12-19 09:20:27 +01:00
|
|
|
*
|
2016-08-26 11:22:30 +02:00
|
|
|
* @param int $gmt_time Optional. Unix timestamp (UTC). Default 0 (current time is used).
|
Cron API: Return meaningful values from cron functions.
Return values added to Cron API functions to indicate outcome:
* `wp_schedule_single_event()`, `wp_schedule_event()`, `wp_reschedule_event()` and `wp_unschedule_event()`: boolean indicating success or failure,
* `wp_clear_scheduled_hook()`: integer indicating number of jobs cleared (zero or more), `false` if one or more jobs fail to clear,
* `wp_unschedule_hook()`: integer indicating number of jobs cleared (zero or more), `false` if the jobs fail to clear,
* `spawn_cron()`: boolean indicating whether job spawned,
* `wp_cron()`: integer indicating number of jobs spawned (zero or more), `false` if one or more jobs fail to spawned,
* `_set_cron_array()`: boolean outcome of `update_option()`.
Props evansolomon, jrf, peterwilsoncc, pento for code review.
Fixes #21072.
Built from https://develop.svn.wordpress.org/trunk@43050
git-svn-id: http://core.svn.wordpress.org/trunk@42879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-01 04:05:23 +02:00
|
|
|
* @return bool True if spawned, false if no events spawned.
|
2008-08-01 07:00:07 +02:00
|
|
|
*/
|
2012-09-23 18:57:21 +02:00
|
|
|
function spawn_cron( $gmt_time = 0 ) {
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( ! $gmt_time ) {
|
2012-09-23 18:57:21 +02:00
|
|
|
$gmt_time = microtime( true );
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2009-02-07 14:32:34 +01:00
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( defined( 'DOING_CRON' ) || isset( $_GET['doing_wp_cron'] ) ) {
|
Cron API: Return meaningful values from cron functions.
Return values added to Cron API functions to indicate outcome:
* `wp_schedule_single_event()`, `wp_schedule_event()`, `wp_reschedule_event()` and `wp_unschedule_event()`: boolean indicating success or failure,
* `wp_clear_scheduled_hook()`: integer indicating number of jobs cleared (zero or more), `false` if one or more jobs fail to clear,
* `wp_unschedule_hook()`: integer indicating number of jobs cleared (zero or more), `false` if the jobs fail to clear,
* `spawn_cron()`: boolean indicating whether job spawned,
* `wp_cron()`: integer indicating number of jobs spawned (zero or more), `false` if one or more jobs fail to spawned,
* `_set_cron_array()`: boolean outcome of `update_option()`.
Props evansolomon, jrf, peterwilsoncc, pento for code review.
Fixes #21072.
Built from https://develop.svn.wordpress.org/trunk@43050
git-svn-id: http://core.svn.wordpress.org/trunk@42879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-01 04:05:23 +02:00
|
|
|
return false;
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2008-09-18 09:09:38 +02:00
|
|
|
|
2009-02-07 14:32:34 +01:00
|
|
|
/*
|
2016-08-26 11:22:30 +02:00
|
|
|
* Get the cron lock, which is a Unix timestamp of when the last cron was spawned
|
2015-05-25 08:25:25 +02:00
|
|
|
* and has not finished running.
|
|
|
|
*
|
|
|
|
* Multiple processes on multiple web servers can run this code concurrently,
|
|
|
|
* this lock attempts to make spawning as atomic as possible.
|
|
|
|
*/
|
2017-12-01 00:11:00 +01:00
|
|
|
$lock = get_transient( 'doing_cron' );
|
2009-02-07 14:32:34 +01:00
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( $lock > $gmt_time + 10 * MINUTE_IN_SECONDS ) {
|
2011-09-09 21:59:44 +02:00
|
|
|
$lock = 0;
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2009-02-07 14:32:34 +01:00
|
|
|
|
|
|
|
// don't run if another process is currently running it or more than once every 60 sec.
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( $lock + WP_CRON_LOCK_TIMEOUT > $gmt_time ) {
|
Cron API: Return meaningful values from cron functions.
Return values added to Cron API functions to indicate outcome:
* `wp_schedule_single_event()`, `wp_schedule_event()`, `wp_reschedule_event()` and `wp_unschedule_event()`: boolean indicating success or failure,
* `wp_clear_scheduled_hook()`: integer indicating number of jobs cleared (zero or more), `false` if one or more jobs fail to clear,
* `wp_unschedule_hook()`: integer indicating number of jobs cleared (zero or more), `false` if the jobs fail to clear,
* `spawn_cron()`: boolean indicating whether job spawned,
* `wp_cron()`: integer indicating number of jobs spawned (zero or more), `false` if one or more jobs fail to spawned,
* `_set_cron_array()`: boolean outcome of `update_option()`.
Props evansolomon, jrf, peterwilsoncc, pento for code review.
Fixes #21072.
Built from https://develop.svn.wordpress.org/trunk@43050
git-svn-id: http://core.svn.wordpress.org/trunk@42879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-01 04:05:23 +02:00
|
|
|
return false;
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2009-02-07 14:32:34 +01:00
|
|
|
|
2008-09-18 09:09:38 +02:00
|
|
|
//sanity check
|
|
|
|
$crons = _get_cron_array();
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( ! is_array( $crons ) ) {
|
Cron API: Return meaningful values from cron functions.
Return values added to Cron API functions to indicate outcome:
* `wp_schedule_single_event()`, `wp_schedule_event()`, `wp_reschedule_event()` and `wp_unschedule_event()`: boolean indicating success or failure,
* `wp_clear_scheduled_hook()`: integer indicating number of jobs cleared (zero or more), `false` if one or more jobs fail to clear,
* `wp_unschedule_hook()`: integer indicating number of jobs cleared (zero or more), `false` if the jobs fail to clear,
* `spawn_cron()`: boolean indicating whether job spawned,
* `wp_cron()`: integer indicating number of jobs spawned (zero or more), `false` if one or more jobs fail to spawned,
* `_set_cron_array()`: boolean outcome of `update_option()`.
Props evansolomon, jrf, peterwilsoncc, pento for code review.
Fixes #21072.
Built from https://develop.svn.wordpress.org/trunk@43050
git-svn-id: http://core.svn.wordpress.org/trunk@42879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-01 04:05:23 +02:00
|
|
|
return false;
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2007-02-27 16:24:54 +01:00
|
|
|
|
2006-06-27 08:04:27 +02:00
|
|
|
$keys = array_keys( $crons );
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( isset( $keys[0] ) && $keys[0] > $gmt_time ) {
|
Cron API: Return meaningful values from cron functions.
Return values added to Cron API functions to indicate outcome:
* `wp_schedule_single_event()`, `wp_schedule_event()`, `wp_reschedule_event()` and `wp_unschedule_event()`: boolean indicating success or failure,
* `wp_clear_scheduled_hook()`: integer indicating number of jobs cleared (zero or more), `false` if one or more jobs fail to clear,
* `wp_unschedule_hook()`: integer indicating number of jobs cleared (zero or more), `false` if the jobs fail to clear,
* `spawn_cron()`: boolean indicating whether job spawned,
* `wp_cron()`: integer indicating number of jobs spawned (zero or more), `false` if one or more jobs fail to spawned,
* `_set_cron_array()`: boolean outcome of `update_option()`.
Props evansolomon, jrf, peterwilsoncc, pento for code review.
Fixes #21072.
Built from https://develop.svn.wordpress.org/trunk@43050
git-svn-id: http://core.svn.wordpress.org/trunk@42879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-01 04:05:23 +02:00
|
|
|
return false;
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2006-04-06 07:25:50 +02:00
|
|
|
|
2014-09-11 16:02:15 +02:00
|
|
|
if ( defined( 'ALTERNATE_WP_CRON' ) && ALTERNATE_WP_CRON ) {
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( 'GET' !== $_SERVER['REQUEST_METHOD'] || defined( 'DOING_AJAX' ) || defined( 'XMLRPC_REQUEST' ) ) {
|
Cron API: Return meaningful values from cron functions.
Return values added to Cron API functions to indicate outcome:
* `wp_schedule_single_event()`, `wp_schedule_event()`, `wp_reschedule_event()` and `wp_unschedule_event()`: boolean indicating success or failure,
* `wp_clear_scheduled_hook()`: integer indicating number of jobs cleared (zero or more), `false` if one or more jobs fail to clear,
* `wp_unschedule_hook()`: integer indicating number of jobs cleared (zero or more), `false` if the jobs fail to clear,
* `spawn_cron()`: boolean indicating whether job spawned,
* `wp_cron()`: integer indicating number of jobs spawned (zero or more), `false` if one or more jobs fail to spawned,
* `_set_cron_array()`: boolean outcome of `update_option()`.
Props evansolomon, jrf, peterwilsoncc, pento for code review.
Fixes #21072.
Built from https://develop.svn.wordpress.org/trunk@43050
git-svn-id: http://core.svn.wordpress.org/trunk@42879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-01 04:05:23 +02:00
|
|
|
return false;
|
2014-09-11 16:02:15 +02:00
|
|
|
}
|
2008-09-18 09:09:38 +02:00
|
|
|
|
2012-09-23 18:57:21 +02:00
|
|
|
$doing_wp_cron = sprintf( '%.22F', $gmt_time );
|
2011-09-09 21:59:44 +02:00
|
|
|
set_transient( 'doing_cron', $doing_wp_cron );
|
2009-02-07 14:32:34 +01:00
|
|
|
|
|
|
|
ob_start();
|
2013-03-03 17:30:38 +01:00
|
|
|
wp_redirect( add_query_arg( 'doing_wp_cron', $doing_wp_cron, wp_unslash( $_SERVER['REQUEST_URI'] ) ) );
|
2009-02-07 14:32:34 +01:00
|
|
|
echo ' ';
|
2008-09-18 09:09:38 +02:00
|
|
|
|
2009-02-07 14:32:34 +01:00
|
|
|
// flush any buffers and send the headers
|
2017-12-01 00:11:00 +01:00
|
|
|
while ( @ob_end_flush() ) {
|
|
|
|
}
|
2009-02-07 14:32:34 +01:00
|
|
|
flush();
|
|
|
|
|
2010-05-03 23:46:19 +02:00
|
|
|
WP_DEBUG ? include_once( ABSPATH . 'wp-cron.php' ) : @include_once( ABSPATH . 'wp-cron.php' );
|
Cron API: Return meaningful values from cron functions.
Return values added to Cron API functions to indicate outcome:
* `wp_schedule_single_event()`, `wp_schedule_event()`, `wp_reschedule_event()` and `wp_unschedule_event()`: boolean indicating success or failure,
* `wp_clear_scheduled_hook()`: integer indicating number of jobs cleared (zero or more), `false` if one or more jobs fail to clear,
* `wp_unschedule_hook()`: integer indicating number of jobs cleared (zero or more), `false` if the jobs fail to clear,
* `spawn_cron()`: boolean indicating whether job spawned,
* `wp_cron()`: integer indicating number of jobs spawned (zero or more), `false` if one or more jobs fail to spawned,
* `_set_cron_array()`: boolean outcome of `update_option()`.
Props evansolomon, jrf, peterwilsoncc, pento for code review.
Fixes #21072.
Built from https://develop.svn.wordpress.org/trunk@43050
git-svn-id: http://core.svn.wordpress.org/trunk@42879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-01 04:05:23 +02:00
|
|
|
return true;
|
2009-02-07 14:32:34 +01:00
|
|
|
}
|
2008-09-18 09:09:38 +02:00
|
|
|
|
2015-05-25 08:25:25 +02:00
|
|
|
// Set the cron lock with the current unix timestamp, when the cron is being spawned.
|
2012-09-23 18:57:21 +02:00
|
|
|
$doing_wp_cron = sprintf( '%.22F', $gmt_time );
|
2011-09-09 21:59:44 +02:00
|
|
|
set_transient( 'doing_cron', $doing_wp_cron );
|
2007-06-14 04:25:30 +02:00
|
|
|
|
2013-11-19 06:01:11 +01:00
|
|
|
/**
|
2016-05-22 20:50:28 +02:00
|
|
|
* Filters the cron request arguments.
|
2013-11-19 06:01:11 +01:00
|
|
|
*
|
|
|
|
* @since 3.5.0
|
2016-01-14 18:30:28 +01:00
|
|
|
* @since 4.5.0 The `$doing_wp_cron` parameter was added.
|
2013-11-19 06:01:11 +01:00
|
|
|
*
|
|
|
|
* @param array $cron_request_array {
|
|
|
|
* An array of cron request URL arguments.
|
|
|
|
*
|
|
|
|
* @type string $url The cron request URL.
|
|
|
|
* @type int $key The 22 digit GMT microtime.
|
|
|
|
* @type array $args {
|
|
|
|
* An array of cron request arguments.
|
|
|
|
*
|
|
|
|
* @type int $timeout The request timeout in seconds. Default .01 seconds.
|
|
|
|
* @type bool $blocking Whether to set blocking for the request. Default false.
|
2014-06-20 00:53:19 +02:00
|
|
|
* @type bool $sslverify Whether SSL should be verified for the request. Default false.
|
2013-11-19 06:01:11 +01:00
|
|
|
* }
|
|
|
|
* }
|
2016-01-09 00:54:26 +01:00
|
|
|
* @param string $doing_wp_cron The unix timestamp of the cron lock.
|
2013-11-19 06:01:11 +01:00
|
|
|
*/
|
2017-12-01 00:11:00 +01:00
|
|
|
$cron_request = apply_filters(
|
2018-08-17 03:51:36 +02:00
|
|
|
'cron_request',
|
|
|
|
array(
|
2017-12-01 00:11:00 +01:00
|
|
|
'url' => add_query_arg( 'doing_wp_cron', $doing_wp_cron, site_url( 'wp-cron.php' ) ),
|
|
|
|
'key' => $doing_wp_cron,
|
|
|
|
'args' => array(
|
|
|
|
'timeout' => 0.01,
|
|
|
|
'blocking' => false,
|
|
|
|
/** This filter is documented in wp-includes/class-wp-http-streams.php */
|
|
|
|
'sslverify' => apply_filters( 'https_local_ssl_verify', false ),
|
|
|
|
),
|
2018-08-17 03:51:36 +02:00
|
|
|
),
|
|
|
|
$doing_wp_cron
|
2017-12-01 00:11:00 +01:00
|
|
|
);
|
2012-07-20 17:15:22 +02:00
|
|
|
|
Cron API: Return meaningful values from cron functions.
Return values added to Cron API functions to indicate outcome:
* `wp_schedule_single_event()`, `wp_schedule_event()`, `wp_reschedule_event()` and `wp_unschedule_event()`: boolean indicating success or failure,
* `wp_clear_scheduled_hook()`: integer indicating number of jobs cleared (zero or more), `false` if one or more jobs fail to clear,
* `wp_unschedule_hook()`: integer indicating number of jobs cleared (zero or more), `false` if the jobs fail to clear,
* `spawn_cron()`: boolean indicating whether job spawned,
* `wp_cron()`: integer indicating number of jobs spawned (zero or more), `false` if one or more jobs fail to spawned,
* `_set_cron_array()`: boolean outcome of `update_option()`.
Props evansolomon, jrf, peterwilsoncc, pento for code review.
Fixes #21072.
Built from https://develop.svn.wordpress.org/trunk@43050
git-svn-id: http://core.svn.wordpress.org/trunk@42879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-01 04:05:23 +02:00
|
|
|
$result = wp_remote_post( $cron_request['url'], $cron_request['args'] );
|
|
|
|
return ! is_wp_error( $result );
|
2006-03-07 22:43:59 +01:00
|
|
|
}
|
|
|
|
|
2008-09-04 21:12:40 +02:00
|
|
|
/**
|
|
|
|
* Run scheduled callbacks or spawn cron for all scheduled events.
|
|
|
|
*
|
Cron API: Return meaningful values from cron functions.
Return values added to Cron API functions to indicate outcome:
* `wp_schedule_single_event()`, `wp_schedule_event()`, `wp_reschedule_event()` and `wp_unschedule_event()`: boolean indicating success or failure,
* `wp_clear_scheduled_hook()`: integer indicating number of jobs cleared (zero or more), `false` if one or more jobs fail to clear,
* `wp_unschedule_hook()`: integer indicating number of jobs cleared (zero or more), `false` if the jobs fail to clear,
* `spawn_cron()`: boolean indicating whether job spawned,
* `wp_cron()`: integer indicating number of jobs spawned (zero or more), `false` if one or more jobs fail to spawned,
* `_set_cron_array()`: boolean outcome of `update_option()`.
Props evansolomon, jrf, peterwilsoncc, pento for code review.
Fixes #21072.
Built from https://develop.svn.wordpress.org/trunk@43050
git-svn-id: http://core.svn.wordpress.org/trunk@42879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-01 04:05:23 +02:00
|
|
|
* Warning: This function may return Boolean FALSE, but may also return a non-Boolean
|
|
|
|
* value which evaluates to FALSE. For information about casting to booleans see the
|
|
|
|
* {@link https://php.net/manual/en/language.types.boolean.php PHP documentation}. Use
|
|
|
|
* the `===` operator for testing the return value of this function.
|
|
|
|
*
|
2008-09-04 21:12:40 +02:00
|
|
|
* @since 2.1.0
|
2018-12-19 04:41:49 +01:00
|
|
|
* @since 5.1.0 Return value added to indicate success or failure.
|
Cron API: Return meaningful values from cron functions.
Return values added to Cron API functions to indicate outcome:
* `wp_schedule_single_event()`, `wp_schedule_event()`, `wp_reschedule_event()` and `wp_unschedule_event()`: boolean indicating success or failure,
* `wp_clear_scheduled_hook()`: integer indicating number of jobs cleared (zero or more), `false` if one or more jobs fail to clear,
* `wp_unschedule_hook()`: integer indicating number of jobs cleared (zero or more), `false` if the jobs fail to clear,
* `spawn_cron()`: boolean indicating whether job spawned,
* `wp_cron()`: integer indicating number of jobs spawned (zero or more), `false` if one or more jobs fail to spawned,
* `_set_cron_array()`: boolean outcome of `update_option()`.
Props evansolomon, jrf, peterwilsoncc, pento for code review.
Fixes #21072.
Built from https://develop.svn.wordpress.org/trunk@43050
git-svn-id: http://core.svn.wordpress.org/trunk@42879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-01 04:05:23 +02:00
|
|
|
*
|
|
|
|
* @return bool|int On success an integer indicating number of events spawned (0 indicates no
|
|
|
|
* events needed to be spawned), false if spawning fails for one or more events.
|
2008-09-04 21:12:40 +02:00
|
|
|
*/
|
2006-03-07 22:43:59 +01:00
|
|
|
function wp_cron() {
|
2007-01-30 14:06:56 +01:00
|
|
|
// Prevent infinite loops caused by lack of wp-cron.php
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( strpos( $_SERVER['REQUEST_URI'], '/wp-cron.php' ) !== false || ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ) ) {
|
Cron API: Return meaningful values from cron functions.
Return values added to Cron API functions to indicate outcome:
* `wp_schedule_single_event()`, `wp_schedule_event()`, `wp_reschedule_event()` and `wp_unschedule_event()`: boolean indicating success or failure,
* `wp_clear_scheduled_hook()`: integer indicating number of jobs cleared (zero or more), `false` if one or more jobs fail to clear,
* `wp_unschedule_hook()`: integer indicating number of jobs cleared (zero or more), `false` if the jobs fail to clear,
* `spawn_cron()`: boolean indicating whether job spawned,
* `wp_cron()`: integer indicating number of jobs spawned (zero or more), `false` if one or more jobs fail to spawned,
* `_set_cron_array()`: boolean outcome of `update_option()`.
Props evansolomon, jrf, peterwilsoncc, pento for code review.
Fixes #21072.
Built from https://develop.svn.wordpress.org/trunk@43050
git-svn-id: http://core.svn.wordpress.org/trunk@42879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-01 04:05:23 +02:00
|
|
|
return 0;
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2007-01-30 14:06:56 +01:00
|
|
|
|
Cron API: Return meaningful values from cron functions.
Return values added to Cron API functions to indicate outcome:
* `wp_schedule_single_event()`, `wp_schedule_event()`, `wp_reschedule_event()` and `wp_unschedule_event()`: boolean indicating success or failure,
* `wp_clear_scheduled_hook()`: integer indicating number of jobs cleared (zero or more), `false` if one or more jobs fail to clear,
* `wp_unschedule_hook()`: integer indicating number of jobs cleared (zero or more), `false` if the jobs fail to clear,
* `spawn_cron()`: boolean indicating whether job spawned,
* `wp_cron()`: integer indicating number of jobs spawned (zero or more), `false` if one or more jobs fail to spawned,
* `_set_cron_array()`: boolean outcome of `update_option()`.
Props evansolomon, jrf, peterwilsoncc, pento for code review.
Fixes #21072.
Built from https://develop.svn.wordpress.org/trunk@43050
git-svn-id: http://core.svn.wordpress.org/trunk@42879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-01 04:05:23 +02:00
|
|
|
$crons = _get_cron_array();
|
|
|
|
if ( false === $crons ) {
|
|
|
|
return 0;
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2006-06-10 22:43:49 +02:00
|
|
|
|
2012-09-23 18:57:21 +02:00
|
|
|
$gmt_time = microtime( true );
|
2017-12-01 00:11:00 +01:00
|
|
|
$keys = array_keys( $crons );
|
|
|
|
if ( isset( $keys[0] ) && $keys[0] > $gmt_time ) {
|
Cron API: Return meaningful values from cron functions.
Return values added to Cron API functions to indicate outcome:
* `wp_schedule_single_event()`, `wp_schedule_event()`, `wp_reschedule_event()` and `wp_unschedule_event()`: boolean indicating success or failure,
* `wp_clear_scheduled_hook()`: integer indicating number of jobs cleared (zero or more), `false` if one or more jobs fail to clear,
* `wp_unschedule_hook()`: integer indicating number of jobs cleared (zero or more), `false` if the jobs fail to clear,
* `spawn_cron()`: boolean indicating whether job spawned,
* `wp_cron()`: integer indicating number of jobs spawned (zero or more), `false` if one or more jobs fail to spawned,
* `_set_cron_array()`: boolean outcome of `update_option()`.
Props evansolomon, jrf, peterwilsoncc, pento for code review.
Fixes #21072.
Built from https://develop.svn.wordpress.org/trunk@43050
git-svn-id: http://core.svn.wordpress.org/trunk@42879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-01 04:05:23 +02:00
|
|
|
return 0;
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2006-03-07 22:43:59 +01:00
|
|
|
|
|
|
|
$schedules = wp_get_schedules();
|
Cron API: Return meaningful values from cron functions.
Return values added to Cron API functions to indicate outcome:
* `wp_schedule_single_event()`, `wp_schedule_event()`, `wp_reschedule_event()` and `wp_unschedule_event()`: boolean indicating success or failure,
* `wp_clear_scheduled_hook()`: integer indicating number of jobs cleared (zero or more), `false` if one or more jobs fail to clear,
* `wp_unschedule_hook()`: integer indicating number of jobs cleared (zero or more), `false` if the jobs fail to clear,
* `spawn_cron()`: boolean indicating whether job spawned,
* `wp_cron()`: integer indicating number of jobs spawned (zero or more), `false` if one or more jobs fail to spawned,
* `_set_cron_array()`: boolean outcome of `update_option()`.
Props evansolomon, jrf, peterwilsoncc, pento for code review.
Fixes #21072.
Built from https://develop.svn.wordpress.org/trunk@43050
git-svn-id: http://core.svn.wordpress.org/trunk@42879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-01 04:05:23 +02:00
|
|
|
$results = array();
|
2006-04-06 07:25:50 +02:00
|
|
|
foreach ( $crons as $timestamp => $cronhooks ) {
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( $timestamp > $gmt_time ) {
|
|
|
|
break;
|
|
|
|
}
|
2008-08-06 22:31:54 +02:00
|
|
|
foreach ( (array) $cronhooks as $hook => $args ) {
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( isset( $schedules[ $hook ]['callback'] ) && ! call_user_func( $schedules[ $hook ]['callback'] ) ) {
|
2006-03-07 22:43:59 +01:00
|
|
|
continue;
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
Cron API: Return meaningful values from cron functions.
Return values added to Cron API functions to indicate outcome:
* `wp_schedule_single_event()`, `wp_schedule_event()`, `wp_reschedule_event()` and `wp_unschedule_event()`: boolean indicating success or failure,
* `wp_clear_scheduled_hook()`: integer indicating number of jobs cleared (zero or more), `false` if one or more jobs fail to clear,
* `wp_unschedule_hook()`: integer indicating number of jobs cleared (zero or more), `false` if the jobs fail to clear,
* `spawn_cron()`: boolean indicating whether job spawned,
* `wp_cron()`: integer indicating number of jobs spawned (zero or more), `false` if one or more jobs fail to spawned,
* `_set_cron_array()`: boolean outcome of `update_option()`.
Props evansolomon, jrf, peterwilsoncc, pento for code review.
Fixes #21072.
Built from https://develop.svn.wordpress.org/trunk@43050
git-svn-id: http://core.svn.wordpress.org/trunk@42879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-01 04:05:23 +02:00
|
|
|
$results[] = spawn_cron( $gmt_time );
|
2006-03-07 22:43:59 +01:00
|
|
|
break 2;
|
|
|
|
}
|
|
|
|
}
|
Cron API: Return meaningful values from cron functions.
Return values added to Cron API functions to indicate outcome:
* `wp_schedule_single_event()`, `wp_schedule_event()`, `wp_reschedule_event()` and `wp_unschedule_event()`: boolean indicating success or failure,
* `wp_clear_scheduled_hook()`: integer indicating number of jobs cleared (zero or more), `false` if one or more jobs fail to clear,
* `wp_unschedule_hook()`: integer indicating number of jobs cleared (zero or more), `false` if the jobs fail to clear,
* `spawn_cron()`: boolean indicating whether job spawned,
* `wp_cron()`: integer indicating number of jobs spawned (zero or more), `false` if one or more jobs fail to spawned,
* `_set_cron_array()`: boolean outcome of `update_option()`.
Props evansolomon, jrf, peterwilsoncc, pento for code review.
Fixes #21072.
Built from https://develop.svn.wordpress.org/trunk@43050
git-svn-id: http://core.svn.wordpress.org/trunk@42879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-01 04:05:23 +02:00
|
|
|
|
|
|
|
if ( in_array( false, $results, true ) ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return count( $results );
|
2006-03-07 22:43:59 +01:00
|
|
|
}
|
|
|
|
|
2008-09-04 21:12:40 +02:00
|
|
|
/**
|
2016-08-26 11:22:30 +02:00
|
|
|
* Retrieve supported event recurrence schedules.
|
2008-09-04 21:12:40 +02:00
|
|
|
*
|
2016-08-26 11:22:30 +02:00
|
|
|
* The default supported recurrences are 'hourly', 'twicedaily', and 'daily'. A plugin may
|
|
|
|
* add more by hooking into the {@see 'cron_schedules'} filter. The filter accepts an array
|
|
|
|
* of arrays. The outer array has a key that is the name of the schedule or for
|
2008-09-04 21:12:40 +02:00
|
|
|
* example 'weekly'. The value is an array with two keys, one is 'interval' and
|
|
|
|
* the other is 'display'.
|
|
|
|
*
|
|
|
|
* The 'interval' is a number in seconds of when the cron job should run. So for
|
|
|
|
* 'hourly', the time is 3600 or 60*60. For weekly, the value would be
|
|
|
|
* 60*60*24*7 or 604800. The value of 'interval' would then be 604800.
|
|
|
|
*
|
|
|
|
* The 'display' is the description. For the 'weekly' key, the 'display' would
|
2014-11-24 05:58:22 +01:00
|
|
|
* be `__( 'Once Weekly' )`.
|
2008-09-04 21:12:40 +02:00
|
|
|
*
|
|
|
|
* For your plugin, you will be passed an array. you can easily add your
|
|
|
|
* schedule by doing the following.
|
2014-11-24 05:58:22 +01:00
|
|
|
*
|
|
|
|
* // Filter parameter variable name is 'array'.
|
|
|
|
* $array['weekly'] = array(
|
|
|
|
* 'interval' => 604800,
|
2017-12-01 00:11:00 +01:00
|
|
|
* 'display' => __( 'Once Weekly' )
|
2014-11-24 05:58:22 +01:00
|
|
|
* );
|
|
|
|
*
|
2008-09-04 21:12:40 +02:00
|
|
|
* @since 2.1.0
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
2006-03-07 22:43:59 +01:00
|
|
|
function wp_get_schedules() {
|
|
|
|
$schedules = array(
|
2017-12-01 00:11:00 +01:00
|
|
|
'hourly' => array(
|
|
|
|
'interval' => HOUR_IN_SECONDS,
|
|
|
|
'display' => __( 'Once Hourly' ),
|
|
|
|
),
|
|
|
|
'twicedaily' => array(
|
|
|
|
'interval' => 12 * HOUR_IN_SECONDS,
|
|
|
|
'display' => __( 'Twice Daily' ),
|
|
|
|
),
|
|
|
|
'daily' => array(
|
|
|
|
'interval' => DAY_IN_SECONDS,
|
|
|
|
'display' => __( 'Once Daily' ),
|
|
|
|
),
|
2006-03-07 22:43:59 +01:00
|
|
|
);
|
2013-11-19 06:01:11 +01:00
|
|
|
/**
|
2016-05-22 20:50:28 +02:00
|
|
|
* Filters the non-default cron schedules.
|
2013-11-19 06:01:11 +01:00
|
|
|
*
|
|
|
|
* @since 2.1.0
|
|
|
|
*
|
|
|
|
* @param array $new_schedules An array of non-default cron schedules. Default empty.
|
|
|
|
*/
|
2006-04-06 07:25:50 +02:00
|
|
|
return array_merge( apply_filters( 'cron_schedules', array() ), $schedules );
|
2006-03-07 22:43:59 +01:00
|
|
|
}
|
2006-04-06 07:25:50 +02:00
|
|
|
|
2008-09-04 21:12:40 +02:00
|
|
|
/**
|
2016-08-26 11:22:30 +02:00
|
|
|
* Retrieve the recurrence schedule for an event.
|
|
|
|
*
|
|
|
|
* @see wp_get_schedules() for available schedules.
|
2008-09-04 21:12:40 +02:00
|
|
|
*
|
|
|
|
* @since 2.1.0
|
2018-12-30 05:51:51 +01:00
|
|
|
* @since 5.0.0 {@see 'get_schedule'} filter added.
|
2008-09-04 21:12:40 +02:00
|
|
|
*
|
2016-08-26 11:22:30 +02:00
|
|
|
* @param string $hook Action hook to identify the event.
|
|
|
|
* @param array $args Optional. Arguments passed to the event's callback function.
|
|
|
|
* @return string|false False, if no schedule. Schedule name on success.
|
2008-09-04 21:12:40 +02:00
|
|
|
*/
|
2017-12-01 00:11:00 +01:00
|
|
|
function wp_get_schedule( $hook, $args = array() ) {
|
Cron: Add hooks and a function to allow hijacking cron implementation.
This allows sites with a large cron option or a custom cron implementation to hijack the cron option to store cron data using custom functionality.
`wp_get_scheduled_event()` is new function to retrieve the event object for a given event based on the hook name, arguments and timestamp. If no timestamp is specified the next occurence is returned.
Preflight filters are added to all functions that read from or modify the cron option: `pre_schedule_event`, `pre_reschedule_event`, `pre_unschedule_event`, `pre_clear_scheduled_hook`, `pre_unschedule_hook`, `pre_get_scheduled_event` and `pre_next_scheduled`.
Additionally, the post scheduling hooks `next_scheduled` and `get_schedule` to allow plugins to modify an event after retrieving it from WordPress.
Props rmccue, DavidAnderson, ethitter, peterwilsoncc.
Fixes #32656.
Built from https://develop.svn.wordpress.org/trunk@43540
git-svn-id: http://core.svn.wordpress.org/trunk@43369 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-07-27 04:23:25 +02:00
|
|
|
$schedule = false;
|
|
|
|
$event = wp_get_scheduled_event( $hook, $args );
|
|
|
|
|
|
|
|
if ( $event ) {
|
|
|
|
$schedule = $event->schedule;
|
2006-09-26 03:14:49 +02:00
|
|
|
}
|
Cron: Add hooks and a function to allow hijacking cron implementation.
This allows sites with a large cron option or a custom cron implementation to hijack the cron option to store cron data using custom functionality.
`wp_get_scheduled_event()` is new function to retrieve the event object for a given event based on the hook name, arguments and timestamp. If no timestamp is specified the next occurence is returned.
Preflight filters are added to all functions that read from or modify the cron option: `pre_schedule_event`, `pre_reschedule_event`, `pre_unschedule_event`, `pre_clear_scheduled_hook`, `pre_unschedule_hook`, `pre_get_scheduled_event` and `pre_next_scheduled`.
Additionally, the post scheduling hooks `next_scheduled` and `get_schedule` to allow plugins to modify an event after retrieving it from WordPress.
Props rmccue, DavidAnderson, ethitter, peterwilsoncc.
Fixes #32656.
Built from https://develop.svn.wordpress.org/trunk@43540
git-svn-id: http://core.svn.wordpress.org/trunk@43369 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-07-27 04:23:25 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Filter the schedule for a hook.
|
|
|
|
*
|
|
|
|
* @since 5.0.0
|
|
|
|
*
|
|
|
|
* @param string|bool $schedule Schedule for the hook. False if not found.
|
|
|
|
* @param string $hook Action hook to execute when cron is run.
|
|
|
|
* @param array $args Optional. Arguments to pass to the hook's callback function.
|
|
|
|
*/
|
|
|
|
return apply_filters( 'get_schedule', $schedule, $hook, $args );
|
2006-09-26 03:14:49 +02:00
|
|
|
}
|
|
|
|
|
2006-09-14 01:54:15 +02:00
|
|
|
//
|
|
|
|
// Private functions
|
|
|
|
//
|
|
|
|
|
2008-09-04 21:12:40 +02:00
|
|
|
/**
|
|
|
|
* Retrieve cron info array option.
|
|
|
|
*
|
|
|
|
* @since 2.1.0
|
|
|
|
* @access private
|
|
|
|
*
|
2015-05-25 08:25:25 +02:00
|
|
|
* @return false|array CRON info array.
|
2008-09-04 21:12:40 +02:00
|
|
|
*/
|
2017-12-01 00:11:00 +01:00
|
|
|
function _get_cron_array() {
|
|
|
|
$cron = get_option( 'cron' );
|
|
|
|
if ( ! is_array( $cron ) ) {
|
2006-09-14 01:54:15 +02:00
|
|
|
return false;
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2006-09-14 01:54:15 +02:00
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( ! isset( $cron['version'] ) ) {
|
|
|
|
$cron = _upgrade_cron_array( $cron );
|
|
|
|
}
|
2006-09-14 01:54:15 +02:00
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
unset( $cron['version'] );
|
2006-09-14 01:54:15 +02:00
|
|
|
|
|
|
|
return $cron;
|
|
|
|
}
|
|
|
|
|
2008-09-04 21:12:40 +02:00
|
|
|
/**
|
|
|
|
* Updates the CRON option with the new CRON array.
|
|
|
|
*
|
|
|
|
* @since 2.1.0
|
2018-12-30 05:51:51 +01:00
|
|
|
* @since 5.1.0 Return value modified to outcome of update_option().
|
Cron API: Return meaningful values from cron functions.
Return values added to Cron API functions to indicate outcome:
* `wp_schedule_single_event()`, `wp_schedule_event()`, `wp_reschedule_event()` and `wp_unschedule_event()`: boolean indicating success or failure,
* `wp_clear_scheduled_hook()`: integer indicating number of jobs cleared (zero or more), `false` if one or more jobs fail to clear,
* `wp_unschedule_hook()`: integer indicating number of jobs cleared (zero or more), `false` if the jobs fail to clear,
* `spawn_cron()`: boolean indicating whether job spawned,
* `wp_cron()`: integer indicating number of jobs spawned (zero or more), `false` if one or more jobs fail to spawned,
* `_set_cron_array()`: boolean outcome of `update_option()`.
Props evansolomon, jrf, peterwilsoncc, pento for code review.
Fixes #21072.
Built from https://develop.svn.wordpress.org/trunk@43050
git-svn-id: http://core.svn.wordpress.org/trunk@42879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-01 04:05:23 +02:00
|
|
|
*
|
2008-09-04 21:12:40 +02:00
|
|
|
* @access private
|
|
|
|
*
|
2016-05-22 19:39:28 +02:00
|
|
|
* @param array $cron Cron info array from _get_cron_array().
|
Cron API: Return meaningful values from cron functions.
Return values added to Cron API functions to indicate outcome:
* `wp_schedule_single_event()`, `wp_schedule_event()`, `wp_reschedule_event()` and `wp_unschedule_event()`: boolean indicating success or failure,
* `wp_clear_scheduled_hook()`: integer indicating number of jobs cleared (zero or more), `false` if one or more jobs fail to clear,
* `wp_unschedule_hook()`: integer indicating number of jobs cleared (zero or more), `false` if the jobs fail to clear,
* `spawn_cron()`: boolean indicating whether job spawned,
* `wp_cron()`: integer indicating number of jobs spawned (zero or more), `false` if one or more jobs fail to spawned,
* `_set_cron_array()`: boolean outcome of `update_option()`.
Props evansolomon, jrf, peterwilsoncc, pento for code review.
Fixes #21072.
Built from https://develop.svn.wordpress.org/trunk@43050
git-svn-id: http://core.svn.wordpress.org/trunk@42879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-01 04:05:23 +02:00
|
|
|
* @return bool True if cron array updated, false on failure.
|
2008-09-04 21:12:40 +02:00
|
|
|
*/
|
2017-12-01 00:11:00 +01:00
|
|
|
function _set_cron_array( $cron ) {
|
2006-09-14 01:54:15 +02:00
|
|
|
$cron['version'] = 2;
|
Cron API: Return meaningful values from cron functions.
Return values added to Cron API functions to indicate outcome:
* `wp_schedule_single_event()`, `wp_schedule_event()`, `wp_reschedule_event()` and `wp_unschedule_event()`: boolean indicating success or failure,
* `wp_clear_scheduled_hook()`: integer indicating number of jobs cleared (zero or more), `false` if one or more jobs fail to clear,
* `wp_unschedule_hook()`: integer indicating number of jobs cleared (zero or more), `false` if the jobs fail to clear,
* `spawn_cron()`: boolean indicating whether job spawned,
* `wp_cron()`: integer indicating number of jobs spawned (zero or more), `false` if one or more jobs fail to spawned,
* `_set_cron_array()`: boolean outcome of `update_option()`.
Props evansolomon, jrf, peterwilsoncc, pento for code review.
Fixes #21072.
Built from https://develop.svn.wordpress.org/trunk@43050
git-svn-id: http://core.svn.wordpress.org/trunk@42879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-01 04:05:23 +02:00
|
|
|
return update_option( 'cron', $cron );
|
2006-09-14 01:54:15 +02:00
|
|
|
}
|
|
|
|
|
2008-09-04 21:12:40 +02:00
|
|
|
/**
|
|
|
|
* Upgrade a Cron info array.
|
|
|
|
*
|
|
|
|
* This function upgrades the Cron info array to version 2.
|
|
|
|
*
|
|
|
|
* @since 2.1.0
|
|
|
|
* @access private
|
|
|
|
*
|
2016-05-22 19:39:28 +02:00
|
|
|
* @param array $cron Cron info array from _get_cron_array().
|
2008-09-04 21:12:40 +02:00
|
|
|
* @return array An upgraded Cron info array.
|
|
|
|
*/
|
2017-12-01 00:11:00 +01:00
|
|
|
function _upgrade_cron_array( $cron ) {
|
|
|
|
if ( isset( $cron['version'] ) && 2 == $cron['version'] ) {
|
2006-09-14 01:54:15 +02:00
|
|
|
return $cron;
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2006-09-14 01:54:15 +02:00
|
|
|
|
|
|
|
$new_cron = array();
|
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
foreach ( (array) $cron as $timestamp => $hooks ) {
|
2008-08-06 22:31:54 +02:00
|
|
|
foreach ( (array) $hooks as $hook => $args ) {
|
2017-12-01 00:11:00 +01:00
|
|
|
$key = md5( serialize( $args['args'] ) );
|
|
|
|
$new_cron[ $timestamp ][ $hook ][ $key ] = $args;
|
2006-09-14 01:54:15 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$new_cron['version'] = 2;
|
|
|
|
update_option( 'cron', $new_cron );
|
|
|
|
return $new_cron;
|
2010-12-02 17:27:16 +01:00
|
|
|
}
|