313 } |
313 } |
314 |
314 |
315 /** |
315 /** |
316 * Reschedules a recurring event. |
316 * Reschedules a recurring event. |
317 * |
317 * |
318 * Mainly for internal use, this takes the UTC timestamp of a previously run |
318 * Mainly for internal use, this takes the Unix timestamp (UTC) of a previously run |
319 * recurring event and reschedules it for its next run. |
319 * recurring event and reschedules it for its next run. |
320 * |
320 * |
321 * To change upcoming scheduled events, use wp_schedule_event() to |
321 * To change upcoming scheduled events, use wp_schedule_event() to |
322 * change the recurrence frequency. |
322 * change the recurrence frequency. |
323 * |
323 * |
483 * |
483 * |
484 * @since 5.1.0 |
484 * @since 5.1.0 |
485 * @since 5.7.0 The `$wp_error` parameter was added, and a `WP_Error` object can now be returned. |
485 * @since 5.7.0 The `$wp_error` parameter was added, and a `WP_Error` object can now be returned. |
486 * |
486 * |
487 * @param null|bool|WP_Error $pre Value to return instead. Default null to continue unscheduling the event. |
487 * @param null|bool|WP_Error $pre Value to return instead. Default null to continue unscheduling the event. |
488 * @param int $timestamp Timestamp for when to run the event. |
488 * @param int $timestamp Unix timestamp (UTC) for when to run the event. |
489 * @param string $hook Action hook, the execution of which will be unscheduled. |
489 * @param string $hook Action hook, the execution of which will be unscheduled. |
490 * @param array $args Arguments to pass to the hook's callback function. |
490 * @param array $args Arguments to pass to the hook's callback function. |
491 * @param bool $wp_error Whether to return a WP_Error on failure. |
491 * @param bool $wp_error Whether to return a WP_Error on failure. |
492 */ |
492 */ |
493 $pre = apply_filters( 'pre_unschedule_event', null, $timestamp, $hook, $args, $wp_error ); |
493 $pre = apply_filters( 'pre_unschedule_event', null, $timestamp, $hook, $args, $wp_error ); |
816 |
816 |
817 return $event; |
817 return $event; |
818 } |
818 } |
819 |
819 |
820 /** |
820 /** |
821 * Retrieves the next timestamp for an event. |
821 * Retrieves the timestamp of the next scheduled event for the given hook. |
822 * |
822 * |
823 * @since 2.1.0 |
823 * @since 2.1.0 |
824 * |
824 * |
825 * @param string $hook Action hook of the event. |
825 * @param string $hook Action hook of the event. |
826 * @param array $args Optional. Array containing each separate argument to pass to the hook's callback function. |
826 * @param array $args Optional. Array containing each separate argument to pass to the hook's callback function. |
827 * Although not passed to a callback, these arguments are used to uniquely identify the |
827 * Although not passed to a callback, these arguments are used to uniquely identify the |
828 * event, so they should be the same as those used when originally scheduling the event. |
828 * event, so they should be the same as those used when originally scheduling the event. |
829 * Default empty array. |
829 * Default empty array. |
830 * @return int|false The Unix timestamp of the next time the event will occur. False if the event doesn't exist. |
830 * @return int|false The Unix timestamp (UTC) of the next time the event will occur. False if the event doesn't exist. |
831 */ |
831 */ |
832 function wp_next_scheduled( $hook, $args = array() ) { |
832 function wp_next_scheduled( $hook, $args = array() ) { |
833 $next_event = wp_get_scheduled_event( $hook, $args ); |
833 $next_event = wp_get_scheduled_event( $hook, $args ); |
834 |
834 |
835 if ( ! $next_event ) { |
835 if ( ! $next_event ) { |
836 return false; |
836 return false; |
837 } |
837 } |
838 |
838 |
839 return $next_event->timestamp; |
839 /** |
|
840 * Filters the timestamp of the next scheduled event for the given hook. |
|
841 * |
|
842 * @since 6.8.0 |
|
843 * |
|
844 * @param int $timestamp Unix timestamp (UTC) for when to next run the event. |
|
845 * @param object $next_event { |
|
846 * An object containing an event's data. |
|
847 * |
|
848 * @type string $hook Action hook of the event. |
|
849 * @type int $timestamp Unix timestamp (UTC) for when to next run the event. |
|
850 * @type string $schedule How often the event should subsequently recur. |
|
851 * @type array $args Array containing each separate argument to pass to the hook |
|
852 * callback function. |
|
853 * @type int $interval Optional. The interval time in seconds for the schedule. Only |
|
854 * present for recurring events. |
|
855 * } |
|
856 * @param array $args Array containing each separate argument to pass to the hook |
|
857 * callback function. |
|
858 */ |
|
859 return apply_filters( 'wp_next_scheduled', $next_event->timestamp, $next_event, $hook, $args ); |
840 } |
860 } |
841 |
861 |
842 /** |
862 /** |
843 * Sends a request to run cron through HTTP request that doesn't halt page loading. |
863 * Sends a request to run cron through HTTP request that doesn't halt page loading. |
844 * |
864 * |
927 * @type int $timeout The request timeout in seconds. Default .01 seconds. |
947 * @type int $timeout The request timeout in seconds. Default .01 seconds. |
928 * @type bool $blocking Whether to set blocking for the request. Default false. |
948 * @type bool $blocking Whether to set blocking for the request. Default false. |
929 * @type bool $sslverify Whether SSL should be verified for the request. Default false. |
949 * @type bool $sslverify Whether SSL should be verified for the request. Default false. |
930 * } |
950 * } |
931 * } |
951 * } |
932 * @param string $doing_wp_cron The unix timestamp of the cron lock. |
952 * @param string $doing_wp_cron The Unix timestamp (UTC) of the cron lock. |
933 */ |
953 */ |
934 $cron_request = apply_filters( |
954 $cron_request = apply_filters( |
935 'cron_request', |
955 'cron_request', |
936 array( |
956 array( |
937 'url' => add_query_arg( 'doing_wp_cron', $doing_wp_cron, site_url( 'wp-cron.php' ) ), |
957 'url' => add_query_arg( 'doing_wp_cron', $doing_wp_cron, site_url( 'wp-cron.php' ) ), |
1238 $cron = array(); |
1258 $cron = array(); |
1239 } |
1259 } |
1240 |
1260 |
1241 $cron['version'] = 2; |
1261 $cron['version'] = 2; |
1242 |
1262 |
1243 $result = update_option( 'cron', $cron ); |
1263 $result = update_option( 'cron', $cron, true ); |
1244 |
1264 |
1245 if ( $wp_error && ! $result ) { |
1265 if ( $wp_error && ! $result ) { |
1246 return new WP_Error( |
1266 return new WP_Error( |
1247 'could_not_set', |
1267 'could_not_set', |
1248 __( 'The cron event list could not be saved.' ) |
1268 __( 'The cron event list could not be saved.' ) |