22 * |
22 * |
23 * @since 2.1.0 |
23 * @since 2.1.0 |
24 * @since 5.1.0 Return value modified to boolean indicating success or failure, |
24 * @since 5.1.0 Return value modified to boolean indicating success or failure, |
25 * {@see 'pre_schedule_event'} filter added to short-circuit the function. |
25 * {@see 'pre_schedule_event'} filter added to short-circuit the function. |
26 * |
26 * |
27 * @link https://codex.wordpress.org/Function_Reference/wp_schedule_single_event |
27 * @link https://developer.wordpress.org/reference/functions/wp_schedule_single_event/ |
28 * |
28 * |
29 * @param int $timestamp Unix timestamp (UTC) for when to next run the event. |
29 * @param int $timestamp Unix timestamp (UTC) for when to next run the event. |
30 * @param string $hook Action hook to execute when the event is run. |
30 * @param string $hook Action hook to execute when the event is run. |
31 * @param array $args Optional. Array containing each separate argument to pass to the hook's callback function. |
31 * @param array $args Optional. Array containing each separate argument to pass to the hook's callback function. |
32 * @return bool True if event successfully scheduled. False for failure. |
32 * @return bool True if event successfully scheduled. False for failure. |
33 */ |
33 */ |
34 function wp_schedule_single_event( $timestamp, $hook, $args = array() ) { |
34 function wp_schedule_single_event( $timestamp, $hook, $args = array() ) { |
35 // Make sure timestamp is a positive integer |
35 // Make sure timestamp is a positive integer. |
36 if ( ! is_numeric( $timestamp ) || $timestamp <= 0 ) { |
36 if ( ! is_numeric( $timestamp ) || $timestamp <= 0 ) { |
37 return false; |
37 return false; |
38 } |
38 } |
39 |
39 |
40 $event = (object) array( |
40 $event = (object) array( |
128 /** |
128 /** |
129 * Modify an event before it is scheduled. |
129 * Modify an event before it is scheduled. |
130 * |
130 * |
131 * @since 3.1.0 |
131 * @since 3.1.0 |
132 * |
132 * |
133 * @param stdClass $event { |
133 * @param stdClass|false $event { |
134 * An object containing an event's data. |
134 * An object containing an event's data, or boolean false to prevent the event from being scheduled. |
135 * |
135 * |
136 * @type string $hook Action hook to execute when the event is run. |
136 * @type string $hook Action hook to execute when the event is run. |
137 * @type int $timestamp Unix timestamp (UTC) for when to next run the event. |
137 * @type int $timestamp Unix timestamp (UTC) for when to next run the event. |
138 * @type string|false $schedule How often the event should subsequently recur. |
138 * @type string|false $schedule How often the event should subsequently recur. |
139 * @type array $args Array containing each separate argument to pass to the hook's callback function. |
139 * @type array $args Array containing each separate argument to pass to the hook's callback function. |
140 * @type int $interval The interval time in seconds for the schedule. Only present for recurring events. |
140 * @type int $interval The interval time in seconds for the schedule. Only present for recurring events. |
141 * } |
141 * } |
142 */ |
142 */ |
143 $event = apply_filters( 'schedule_event', $event ); |
143 $event = apply_filters( 'schedule_event', $event ); |
144 |
144 |
145 // A plugin disallowed this event |
145 // A plugin disallowed this event. |
146 if ( ! $event ) { |
146 if ( ! $event ) { |
147 return false; |
147 return false; |
148 } |
148 } |
149 |
149 |
150 $crons[ $event->timestamp ][ $event->hook ][ $key ] = array( |
150 $crons[ $event->timestamp ][ $event->hook ][ $key ] = array( |
175 * |
175 * |
176 * @since 2.1.0 |
176 * @since 2.1.0 |
177 * @since 5.1.0 Return value modified to boolean indicating success or failure, |
177 * @since 5.1.0 Return value modified to boolean indicating success or failure, |
178 * {@see 'pre_schedule_event'} filter added to short-circuit the function. |
178 * {@see 'pre_schedule_event'} filter added to short-circuit the function. |
179 * |
179 * |
180 * @link https://codex.wordpress.org/Function_Reference/wp_schedule_event |
180 * @link https://developer.wordpress.org/reference/functions/wp_schedule_event/ |
181 * |
181 * |
182 * @param int $timestamp Unix timestamp (UTC) for when to next run the event. |
182 * @param int $timestamp Unix timestamp (UTC) for when to next run the event. |
183 * @param string $recurrence How often the event should subsequently recur. See wp_get_schedules() for accepted values. |
183 * @param string $recurrence How often the event should subsequently recur. See wp_get_schedules() for accepted values. |
184 * @param string $hook Action hook to execute when the event is run. |
184 * @param string $hook Action hook to execute when the event is run. |
185 * @param array $args Optional. Array containing each separate argument to pass to the hook's callback function. |
185 * @param array $args Optional. Array containing each separate argument to pass to the hook's callback function. |
186 * @return bool True if event successfully scheduled. False for failure. |
186 * @return bool True if event successfully scheduled. False for failure. |
187 */ |
187 */ |
188 function wp_schedule_event( $timestamp, $recurrence, $hook, $args = array() ) { |
188 function wp_schedule_event( $timestamp, $recurrence, $hook, $args = array() ) { |
189 // Make sure timestamp is a positive integer |
189 // Make sure timestamp is a positive integer. |
190 if ( ! is_numeric( $timestamp ) || $timestamp <= 0 ) { |
190 if ( ! is_numeric( $timestamp ) || $timestamp <= 0 ) { |
191 return false; |
191 return false; |
192 } |
192 } |
193 |
193 |
194 $schedules = wp_get_schedules(); |
194 $schedules = wp_get_schedules(); |
249 * @param string $hook Action hook to execute when the event is run. |
249 * @param string $hook Action hook to execute when the event is run. |
250 * @param array $args Optional. Array containing each separate argument to pass to the hook's callback function. |
250 * @param array $args Optional. Array containing each separate argument to pass to the hook's callback function. |
251 * @return bool True if event successfully rescheduled. False for failure. |
251 * @return bool True if event successfully rescheduled. False for failure. |
252 */ |
252 */ |
253 function wp_reschedule_event( $timestamp, $recurrence, $hook, $args = array() ) { |
253 function wp_reschedule_event( $timestamp, $recurrence, $hook, $args = array() ) { |
254 // Make sure timestamp is a positive integer |
254 // Make sure timestamp is a positive integer. |
255 if ( ! is_numeric( $timestamp ) || $timestamp <= 0 ) { |
255 if ( ! is_numeric( $timestamp ) || $timestamp <= 0 ) { |
256 return false; |
256 return false; |
257 } |
257 } |
258 |
258 |
259 $schedules = wp_get_schedules(); |
259 $schedules = wp_get_schedules(); |
339 * Although not passed to a callback, these arguments are used to uniquely identify the |
339 * Although not passed to a callback, these arguments are used to uniquely identify the |
340 * event, so they should be the same as those used when originally scheduling the event. |
340 * event, so they should be the same as those used when originally scheduling the event. |
341 * @return bool True if event successfully unscheduled. False for failure. |
341 * @return bool True if event successfully unscheduled. False for failure. |
342 */ |
342 */ |
343 function wp_unschedule_event( $timestamp, $hook, $args = array() ) { |
343 function wp_unschedule_event( $timestamp, $hook, $args = array() ) { |
344 // Make sure timestamp is a positive integer |
344 // Make sure timestamp is a positive integer. |
345 if ( ! is_numeric( $timestamp ) || $timestamp <= 0 ) { |
345 if ( ! is_numeric( $timestamp ) || $timestamp <= 0 ) { |
346 return false; |
346 return false; |
347 } |
347 } |
348 |
348 |
349 /** |
349 /** |
382 /** |
382 /** |
383 * Unschedules all events attached to the hook with the specified arguments. |
383 * Unschedules all events attached to the hook with the specified arguments. |
384 * |
384 * |
385 * Warning: This function may return Boolean FALSE, but may also return a non-Boolean |
385 * Warning: This function may return Boolean FALSE, but may also return a non-Boolean |
386 * value which evaluates to FALSE. For information about casting to booleans see the |
386 * value which evaluates to FALSE. For information about casting to booleans see the |
387 * {@link https://php.net/manual/en/language.types.boolean.php PHP documentation}. Use |
387 * {@link https://www.php.net/manual/en/language.types.boolean.php PHP documentation}. Use |
388 * the `===` operator for testing the return value of this function. |
388 * the `===` operator for testing the return value of this function. |
389 * |
389 * |
390 * @since 2.1.0 |
390 * @since 2.1.0 |
391 * @since 5.1.0 Return value modified to indicate success or failure, |
391 * @since 5.1.0 Return value modified to indicate success or failure, |
392 * {@see 'pre_clear_scheduled_hook'} filter added to short-circuit the function. |
392 * {@see 'pre_clear_scheduled_hook'} filter added to short-circuit the function. |
393 * |
393 * |
394 * @param string $hook Action hook, the execution of which will be unscheduled. |
394 * @param string $hook Action hook, the execution of which will be unscheduled. |
395 * @param array $args Optional. Arguments that were to be passed to the hook's callback function. |
395 * @param array $args Optional. Arguments that were to be passed to the hook's callback function. |
396 * @return bool|int On success an integer indicating number of events unscheduled (0 indicates no |
396 * @return int|false On success an integer indicating number of events unscheduled (0 indicates no |
397 * events were registered with the hook and arguments combination), false if |
397 * events were registered with the hook and arguments combination), false if |
398 * unscheduling one or more events fail. |
398 * unscheduling one or more events fail. |
399 */ |
399 */ |
400 function wp_clear_scheduled_hook( $hook, $args = array() ) { |
400 function wp_clear_scheduled_hook( $hook, $args = array() ) { |
401 // Backward compatibility |
401 // Backward compatibility. |
402 // Previously this function took the arguments as discrete vars rather than an array like the rest of the API |
402 // Previously, this function took the arguments as discrete vars rather than an array like the rest of the API. |
403 if ( ! is_array( $args ) ) { |
403 if ( ! is_array( $args ) ) { |
404 _deprecated_argument( __FUNCTION__, '3.0.0', __( 'This argument has changed to an array to match the behavior of the other cron functions.' ) ); |
404 _deprecated_argument( __FUNCTION__, '3.0.0', __( 'This argument has changed to an array to match the behavior of the other cron functions.' ) ); |
405 $args = array_slice( func_get_args(), 1 ); |
405 $args = array_slice( func_get_args(), 1 ); // phpcs:ignore PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection |
406 } |
406 } |
407 |
407 |
408 /** |
408 /** |
409 * Filter to preflight or hijack clearing a scheduled hook. |
409 * Filter to preflight or hijack clearing a scheduled hook. |
410 * |
410 * |
415 * unscheduled (zero if no events were registered with the hook) or false |
415 * unscheduled (zero if no events were registered with the hook) or false |
416 * if unscheduling one or more events fails. |
416 * if unscheduling one or more events fails. |
417 * |
417 * |
418 * @since 5.1.0 |
418 * @since 5.1.0 |
419 * |
419 * |
420 * @param null|array $pre Value to return instead. Default null to continue unscheduling the event. |
420 * @param null|int|false $pre Value to return instead. Default null to continue unscheduling the event. |
421 * @param string $hook Action hook, the execution of which will be unscheduled. |
421 * @param string $hook Action hook, the execution of which will be unscheduled. |
422 * @param array $args Arguments to pass to the hook's callback function. |
422 * @param array $args Arguments to pass to the hook's callback function. |
423 */ |
423 */ |
424 $pre = apply_filters( 'pre_clear_scheduled_hook', null, $hook, $args ); |
424 $pre = apply_filters( 'pre_clear_scheduled_hook', null, $hook, $args ); |
425 if ( null !== $pre ) { |
425 if ( null !== $pre ) { |
426 return $pre; |
426 return $pre; |
427 } |
427 } |
428 |
428 |
429 // This logic duplicates wp_next_scheduled() |
429 /* |
430 // It's required due to a scenario where wp_unschedule_event() fails due to update_option() failing, |
430 * This logic duplicates wp_next_scheduled(). |
431 // and, wp_next_scheduled() returns the same schedule in an infinite loop. |
431 * It's required due to a scenario where wp_unschedule_event() fails due to update_option() failing, |
|
432 * and, wp_next_scheduled() returns the same schedule in an infinite loop. |
|
433 */ |
432 $crons = _get_cron_array(); |
434 $crons = _get_cron_array(); |
433 if ( empty( $crons ) ) { |
435 if ( empty( $crons ) ) { |
434 return 0; |
436 return 0; |
435 } |
437 } |
436 |
438 |
452 * |
454 * |
453 * Can be useful for plugins when deactivating to clean up the cron queue. |
455 * Can be useful for plugins when deactivating to clean up the cron queue. |
454 * |
456 * |
455 * Warning: This function may return Boolean FALSE, but may also return a non-Boolean |
457 * Warning: This function may return Boolean FALSE, but may also return a non-Boolean |
456 * value which evaluates to FALSE. For information about casting to booleans see the |
458 * value which evaluates to FALSE. For information about casting to booleans see the |
457 * {@link https://php.net/manual/en/language.types.boolean.php PHP documentation}. Use |
459 * {@link https://www.php.net/manual/en/language.types.boolean.php PHP documentation}. Use |
458 * the `===` operator for testing the return value of this function. |
460 * the `===` operator for testing the return value of this function. |
459 * |
461 * |
460 * @since 4.9.0 |
462 * @since 4.9.0 |
461 * @since 5.1.0 Return value added to indicate success or failure. |
463 * @since 5.1.0 Return value added to indicate success or failure. |
462 * |
464 * |
463 * @param string $hook Action hook, the execution of which will be unscheduled. |
465 * @param string $hook Action hook, the execution of which will be unscheduled. |
464 * @return bool|int On success an integer indicating number of events unscheduled (0 indicates no |
466 * @return int|false On success an integer indicating number of events unscheduled (0 indicates no |
465 * events were registered on the hook), false if unscheduling fails. |
467 * events were registered on the hook), false if unscheduling fails. |
466 */ |
468 */ |
467 function wp_unschedule_hook( $hook ) { |
469 function wp_unschedule_hook( $hook ) { |
468 /** |
470 /** |
469 * Filter to preflight or hijack clearing all events attached to the hook. |
471 * Filter to preflight or hijack clearing all events attached to the hook. |
470 * |
472 * |
475 * unscheduled (zero if no events were registered with the hook) or false |
477 * unscheduled (zero if no events were registered with the hook) or false |
476 * if unscheduling one or more events fails. |
478 * if unscheduling one or more events fails. |
477 * |
479 * |
478 * @since 5.1.0 |
480 * @since 5.1.0 |
479 * |
481 * |
480 * @param null|array $pre Value to return instead. Default null to continue unscheduling the hook. |
482 * @param null|int|false $pre Value to return instead. Default null to continue unscheduling the hook. |
481 * @param string $hook Action hook, the execution of which will be unscheduled. |
483 * @param string $hook Action hook, the execution of which will be unscheduled. |
482 */ |
484 */ |
483 $pre = apply_filters( 'pre_unschedule_hook', null, $hook ); |
485 $pre = apply_filters( 'pre_unschedule_hook', null, $hook ); |
484 if ( null !== $pre ) { |
486 if ( null !== $pre ) { |
485 return $pre; |
487 return $pre; |
486 } |
488 } |
526 * @param string $hook Action hook of the event. |
528 * @param string $hook Action hook of the event. |
527 * @param array $args Optional. Array containing each separate argument to pass to the hook's callback function. |
529 * @param array $args Optional. Array containing each separate argument to pass to the hook's callback function. |
528 * Although not passed to a callback, these arguments are used to uniquely identify the |
530 * Although not passed to a callback, these arguments are used to uniquely identify the |
529 * event, so they should be the same as those used when originally scheduling the event. |
531 * event, so they should be the same as those used when originally scheduling the event. |
530 * @param int|null $timestamp Optional. Unix timestamp (UTC) of the event. If not specified, the next scheduled event is returned. |
532 * @param int|null $timestamp Optional. Unix timestamp (UTC) of the event. If not specified, the next scheduled event is returned. |
531 * @return bool|object The event object. False if the event does not exist. |
533 * @return object|false The event object. False if the event does not exist. |
532 */ |
534 */ |
533 function wp_get_scheduled_event( $hook, $args = array(), $timestamp = null ) { |
535 function wp_get_scheduled_event( $hook, $args = array(), $timestamp = null ) { |
534 /** |
536 /** |
535 * Filter to preflight or hijack retrieving a scheduled event. |
537 * Filter to preflight or hijack retrieving a scheduled event. |
536 * |
538 * |
540 * Return false if the event does not exist, otherwise an event object |
542 * Return false if the event does not exist, otherwise an event object |
541 * should be returned. |
543 * should be returned. |
542 * |
544 * |
543 * @since 5.1.0 |
545 * @since 5.1.0 |
544 * |
546 * |
545 * @param null|bool $pre Value to return instead. Default null to continue retrieving the event. |
547 * @param null|false|object $pre Value to return instead. Default null to continue retrieving the event. |
546 * @param string $hook Action hook of the event. |
548 * @param string $hook Action hook of the event. |
547 * @param array $args Array containing each separate argument to pass to the hook's callback function. |
549 * @param array $args Array containing each separate argument to pass to the hook's callback function. |
548 * Although not passed to a callback, these arguments are used to uniquely identify the |
550 * Although not passed to a callback, these arguments are used to uniquely identify |
549 * event. |
551 * the event. |
550 * @param int|null $timestamp Unix timestamp (UTC) of the event. Null to retrieve next scheduled event. |
552 * @param int|null $timestamp Unix timestamp (UTC) of the event. Null to retrieve next scheduled event. |
551 */ |
553 */ |
552 $pre = apply_filters( 'pre_get_scheduled_event', null, $hook, $args, $timestamp ); |
554 $pre = apply_filters( 'pre_get_scheduled_event', null, $hook, $args, $timestamp ); |
553 if ( null !== $pre ) { |
555 if ( null !== $pre ) { |
554 return $pre; |
556 return $pre; |
604 * |
606 * |
605 * @param string $hook Action hook of the event. |
607 * @param string $hook Action hook of the event. |
606 * @param array $args Optional. Array containing each separate argument to pass to the hook's callback function. |
608 * @param array $args Optional. Array containing each separate argument to pass to the hook's callback function. |
607 * Although not passed to a callback, these arguments are used to uniquely identify the |
609 * Although not passed to a callback, these arguments are used to uniquely identify the |
608 * event, so they should be the same as those used when originally scheduling the event. |
610 * event, so they should be the same as those used when originally scheduling the event. |
609 * @return false|int The Unix timestamp of the next time the event will occur. False if the event doesn't exist. |
611 * @return int|false The Unix timestamp of the next time the event will occur. False if the event doesn't exist. |
610 */ |
612 */ |
611 function wp_next_scheduled( $hook, $args = array() ) { |
613 function wp_next_scheduled( $hook, $args = array() ) { |
612 $next_event = wp_get_scheduled_event( $hook, $args ); |
614 $next_event = wp_get_scheduled_event( $hook, $args ); |
613 if ( ! $next_event ) { |
615 if ( ! $next_event ) { |
614 return false; |
616 return false; |
674 |
676 |
675 ob_start(); |
677 ob_start(); |
676 wp_redirect( add_query_arg( 'doing_wp_cron', $doing_wp_cron, wp_unslash( $_SERVER['REQUEST_URI'] ) ) ); |
678 wp_redirect( add_query_arg( 'doing_wp_cron', $doing_wp_cron, wp_unslash( $_SERVER['REQUEST_URI'] ) ) ); |
677 echo ' '; |
679 echo ' '; |
678 |
680 |
679 // flush any buffers and send the headers |
681 // Flush any buffers and send the headers. |
680 while ( @ob_end_flush() ) { |
682 wp_ob_end_flush_all(); |
681 } |
|
682 flush(); |
683 flush(); |
683 |
684 |
684 WP_DEBUG ? include_once( ABSPATH . 'wp-cron.php' ) : @include_once( ABSPATH . 'wp-cron.php' ); |
685 include_once ABSPATH . 'wp-cron.php'; |
685 return true; |
686 return true; |
686 } |
687 } |
687 |
688 |
688 // Set the cron lock with the current unix timestamp, when the cron is being spawned. |
689 // Set the cron lock with the current unix timestamp, when the cron is being spawned. |
689 $doing_wp_cron = sprintf( '%.22F', $gmt_time ); |
690 $doing_wp_cron = sprintf( '%.22F', $gmt_time ); |
732 /** |
733 /** |
733 * Run scheduled callbacks or spawn cron for all scheduled events. |
734 * Run scheduled callbacks or spawn cron for all scheduled events. |
734 * |
735 * |
735 * Warning: This function may return Boolean FALSE, but may also return a non-Boolean |
736 * Warning: This function may return Boolean FALSE, but may also return a non-Boolean |
736 * value which evaluates to FALSE. For information about casting to booleans see the |
737 * value which evaluates to FALSE. For information about casting to booleans see the |
737 * {@link https://php.net/manual/en/language.types.boolean.php PHP documentation}. Use |
738 * {@link https://www.php.net/manual/en/language.types.boolean.php PHP documentation}. Use |
738 * the `===` operator for testing the return value of this function. |
739 * the `===` operator for testing the return value of this function. |
739 * |
740 * |
740 * @since 2.1.0 |
741 * @since 2.1.0 |
741 * @since 5.1.0 Return value added to indicate success or failure. |
742 * @since 5.1.0 Return value added to indicate success or failure. |
742 * |
743 * |
743 * @return bool|int On success an integer indicating number of events spawned (0 indicates no |
744 * @return bool|int On success an integer indicating number of events spawned (0 indicates no |
744 * events needed to be spawned), false if spawning fails for one or more events. |
745 * events needed to be spawned), false if spawning fails for one or more events. |
745 */ |
746 */ |
746 function wp_cron() { |
747 function wp_cron() { |
747 // Prevent infinite loops caused by lack of wp-cron.php |
748 // Prevent infinite loops caused by lack of wp-cron.php. |
748 if ( strpos( $_SERVER['REQUEST_URI'], '/wp-cron.php' ) !== false || ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ) ) { |
749 if ( strpos( $_SERVER['REQUEST_URI'], '/wp-cron.php' ) !== false || ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ) ) { |
749 return 0; |
750 return 0; |
750 } |
751 } |
751 |
752 |
752 $crons = wp_get_ready_cron_jobs(); |
753 $crons = wp_get_ready_cron_jobs(); |
782 } |
783 } |
783 |
784 |
784 /** |
785 /** |
785 * Retrieve supported event recurrence schedules. |
786 * Retrieve supported event recurrence schedules. |
786 * |
787 * |
787 * The default supported recurrences are 'hourly', 'twicedaily', and 'daily'. A plugin may |
788 * The default supported recurrences are 'hourly', 'twicedaily', 'daily', and 'weekly'. |
788 * add more by hooking into the {@see 'cron_schedules'} filter. The filter accepts an array |
789 * A plugin may add more by hooking into the {@see 'cron_schedules'} filter. |
789 * of arrays. The outer array has a key that is the name of the schedule or for |
790 * The filter accepts an array of arrays. The outer array has a key that is the name |
790 * example 'weekly'. The value is an array with two keys, one is 'interval' and |
791 * of the schedule, for example 'monthly'. The value is an array with two keys, |
791 * the other is 'display'. |
792 * one is 'interval' and the other is 'display'. |
792 * |
793 * |
793 * The 'interval' is a number in seconds of when the cron job should run. So for |
794 * The 'interval' is a number in seconds of when the cron job should run. |
794 * 'hourly', the time is 3600 or 60*60. For weekly, the value would be |
795 * So for 'hourly' the time is `HOUR_IN_SECONDS` (60 * 60 or 3600). For 'monthly', |
795 * 60*60*24*7 or 604800. The value of 'interval' would then be 604800. |
796 * the value would be `MONTH_IN_SECONDS` (30 * 24 * 60 * 60 or 2592000). |
796 * |
797 * |
797 * The 'display' is the description. For the 'weekly' key, the 'display' would |
798 * The 'display' is the description. For the 'monthly' key, the 'display' |
798 * be `__( 'Once Weekly' )`. |
799 * would be `__( 'Once Monthly' )`. |
799 * |
800 * |
800 * For your plugin, you will be passed an array. you can easily add your |
801 * For your plugin, you will be passed an array. You can easily add your |
801 * schedule by doing the following. |
802 * schedule by doing the following. |
802 * |
803 * |
803 * // Filter parameter variable name is 'array'. |
804 * // Filter parameter variable name is 'array'. |
804 * $array['weekly'] = array( |
805 * $array['monthly'] = array( |
805 * 'interval' => 604800, |
806 * 'interval' => MONTH_IN_SECONDS, |
806 * 'display' => __( 'Once Weekly' ) |
807 * 'display' => __( 'Once Monthly' ) |
807 * ); |
808 * ); |
808 * |
809 * |
809 * @since 2.1.0 |
810 * @since 2.1.0 |
|
811 * @since 5.4.0 The 'weekly' schedule was added. |
810 * |
812 * |
811 * @return array |
813 * @return array |
812 */ |
814 */ |
813 function wp_get_schedules() { |
815 function wp_get_schedules() { |
814 $schedules = array( |
816 $schedules = array( |
842 * |
849 * |
843 * @since 2.1.0 |
850 * @since 2.1.0 |
844 * @since 5.1.0 {@see 'get_schedule'} filter added. |
851 * @since 5.1.0 {@see 'get_schedule'} filter added. |
845 * |
852 * |
846 * @param string $hook Action hook to identify the event. |
853 * @param string $hook Action hook to identify the event. |
847 * @param array $args Optional. Arguments passed to the event's callback function. |
854 * @param array $args Optional. Arguments passed to the event's callback function. |
848 * @return string|false False, if no schedule. Schedule name on success. |
855 * @return string|false False, if no schedule. Schedule name on success. |
849 */ |
856 */ |
850 function wp_get_schedule( $hook, $args = array() ) { |
857 function wp_get_schedule( $hook, $args = array() ) { |
851 $schedule = false; |
858 $schedule = false; |
852 $event = wp_get_scheduled_event( $hook, $args ); |
859 $event = wp_get_scheduled_event( $hook, $args ); |