: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
$crons = wp_get_ready_cron_jobs();
$gmt_time = microtime( true );
$keys = array_keys( $crons );
if ( isset( $keys[0] ) && $keys[0] > $gmt_time ) {
$schedules = wp_get_schedules();
foreach ( $crons as $timestamp => $cronhooks ) {
if ( $timestamp > $gmt_time ) {
foreach ( (array) $cronhooks as $hook => $args ) {
if ( isset( $schedules[ $hook ]['callback'] )
&& ! call_user_func( $schedules[ $hook ]['callback'] )
$results[] = spawn_cron( $gmt_time );
if ( in_array( false, $results, true ) ) {
return count( $results );
* Retrieves supported event recurrence schedules.
* The default supported recurrences are 'hourly', 'twicedaily', 'daily', and 'weekly'.
* 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, for example 'monthly'. 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 `HOUR_IN_SECONDS` (`60 * 60` or `3600`). For 'monthly',
* the value would be `MONTH_IN_SECONDS` (`30 * 24 * 60 * 60` or `2592000`).
* The 'display' is the description. For the 'monthly' key, the 'display'
* would be `__( 'Once Monthly' )`.
* For your plugin, you will be passed an array. You can add your
* schedule by doing the following:
* // Filter parameter variable name is 'array'.
* $array['monthly'] = array(
* 'interval' => MONTH_IN_SECONDS,
* 'display' => __( 'Once Monthly' )
* @since 5.4.0 The 'weekly' schedule was added.
* The array of cron schedules keyed by the schedule name.
* Cron schedule information.
* @type int $interval The schedule interval in seconds.
* @type string $display The schedule display name.
function wp_get_schedules() {
'interval' => HOUR_IN_SECONDS,
'display' => __( 'Once Hourly' ),
'interval' => 12 * HOUR_IN_SECONDS,
'display' => __( 'Twice Daily' ),
'interval' => DAY_IN_SECONDS,
'display' => __( 'Once Daily' ),
'interval' => WEEK_IN_SECONDS,
'display' => __( 'Once Weekly' ),
* Filters the non-default cron schedules.
* @param array $new_schedules {
* An array of non-default cron schedules keyed by the schedule name. Default empty array.
* Cron schedule information.
* @type int $interval The schedule interval in seconds.
* @type string $display The schedule display name.
return array_merge( apply_filters( 'cron_schedules', array() ), $schedules );
* Retrieves the name of the recurrence schedule for an event.
* @see wp_get_schedules() for available schedules.
* @since 5.1.0 {@see 'get_schedule'} filter added.
* @param string $hook Action hook to identify the event.
* @param array $args Optional. Arguments passed to the event's callback function.
* @return string|false Schedule name on success, false if no schedule.
function wp_get_schedule( $hook, $args = array() ) {
$event = wp_get_scheduled_event( $hook, $args );
$schedule = $event->schedule;
* Filters the schedule name for a hook.
* @param string|false $schedule Schedule for the hook. False if not found.
* @param string $hook Action hook to execute when cron is run.
* @param array $args Arguments to pass to the hook's callback function.
return apply_filters( 'get_schedule', $schedule, $hook, $args );
* Retrieves cron jobs ready to be run.
* Returns the results of _get_cron_array() limited to events ready to be run,
* ie, with a timestamp in the past.
* @return array[] Array of cron job arrays ready to be run.
function wp_get_ready_cron_jobs() {
* Filter to override retrieving ready cron jobs.
* Returning an array will short-circuit the normal retrieval of ready
* cron jobs, causing the function to return the filtered value instead.
* @param null|array[] $pre Array of ready cron tasks to return instead. Default null
* to continue using results from _get_cron_array().
$pre = apply_filters( 'pre_get_ready_cron_jobs', null );
$crons = _get_cron_array();
$gmt_time = microtime( true );
foreach ( $crons as $timestamp => $cronhooks ) {
if ( $timestamp > $gmt_time ) {
$results[ $timestamp ] = $cronhooks;
* Retrieves cron info array option.
* @since 6.1.0 Return type modified to consistently return an array.
* @return array[] Array of cron events.
function _get_cron_array() {
$cron = get_option( 'cron' );
if ( ! is_array( $cron ) ) {
if ( ! isset( $cron['version'] ) ) {
$cron = _upgrade_cron_array( $cron );
unset( $cron['version'] );
* Updates the cron option with the new cron array.
* @since 5.1.0 Return value modified to outcome of update_option().
* @since 5.7.0 The `$wp_error` parameter was added.
* @param array[] $cron Array of cron info arrays from _get_cron_array().
* @param bool $wp_error Optional. Whether to return a WP_Error on failure. Default false.
* @return bool|WP_Error True if cron array updated. False or WP_Error on failure.
function _set_cron_array( $cron, $wp_error = false ) {
if ( ! is_array( $cron ) ) {
$result = update_option( 'cron', $cron );
if ( $wp_error && ! $result ) {
__( 'The cron event list could not be saved.' )
* Upgrades a cron info array.
* This function upgrades the cron info array to version 2.
* @param array $cron Cron info array from _get_cron_array().
* @return array An upgraded cron info array.
function _upgrade_cron_array( $cron ) {
if ( isset( $cron['version'] ) && 2 === $cron['version'] ) {
foreach ( (array) $cron as $timestamp => $hooks ) {
foreach ( (array) $hooks as $hook => $args ) {
$key = md5( serialize( $args['args'] ) );
$new_cron[ $timestamp ][ $hook ][ $key ] = $args;
$new_cron['version'] = 2;
update_option( 'cron', $new_cron );