wp_get_ready_cron_jobs

The timeline below displays how wordpress function wp_get_ready_cron_jobs has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.4

/**
 * 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.
 *
 * @since 5.1.0
 *
 * @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.
     *
     * @since 5.1.0
     *
     * @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);
    if (null !== $pre) {
        return $pre;
    }
    $crons = _get_cron_array();
    $gmt_time = microtime(true);
    $results = array();
    foreach ($crons as $timestamp => $cronhooks) {
        if ($timestamp > $gmt_time) {
            break;
        }
        $results[$timestamp] = $cronhooks;
    }
    return $results;
}

WordPress Version: 6.2

/**
 * 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.
 *
 * @since 5.1.0
 *
 * @return array[] Array of cron job arrays ready to be run.
 */
function wp_get_ready_cron_jobs()
{
    /**
     * Filter to preflight or hijack 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.
     *
     * @since 5.1.0
     *
     * @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);
    if (null !== $pre) {
        return $pre;
    }
    $crons = _get_cron_array();
    $gmt_time = microtime(true);
    $results = array();
    foreach ($crons as $timestamp => $cronhooks) {
        if ($timestamp > $gmt_time) {
            break;
        }
        $results[$timestamp] = $cronhooks;
    }
    return $results;
}

WordPress Version: 6.1

/**
 * Retrieve 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.
 *
 * @since 5.1.0
 *
 * @return array[] Array of cron job arrays ready to be run.
 */
function wp_get_ready_cron_jobs()
{
    /**
     * Filter to preflight or hijack 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.
     *
     * @since 5.1.0
     *
     * @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);
    if (null !== $pre) {
        return $pre;
    }
    $crons = _get_cron_array();
    $gmt_time = microtime(true);
    $results = array();
    foreach ($crons as $timestamp => $cronhooks) {
        if ($timestamp > $gmt_time) {
            break;
        }
        $results[$timestamp] = $cronhooks;
    }
    return $results;
}

WordPress Version: 5.9

/**
 * Retrieve 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.
 *
 * @since 5.1.0
 *
 * @return array[] Array of cron job arrays ready to be run.
 */
function wp_get_ready_cron_jobs()
{
    /**
     * Filter to preflight or hijack 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.
     *
     * @since 5.1.0
     *
     * @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);
    if (null !== $pre) {
        return $pre;
    }
    $crons = _get_cron_array();
    if (!is_array($crons)) {
        return array();
    }
    $gmt_time = microtime(true);
    $keys = array_keys($crons);
    if (isset($keys[0]) && $keys[0] > $gmt_time) {
        return array();
    }
    $results = array();
    foreach ($crons as $timestamp => $cronhooks) {
        if ($timestamp > $gmt_time) {
            break;
        }
        $results[$timestamp] = $cronhooks;
    }
    return $results;
}

WordPress Version: 5.1

/**
 * Retrieve 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.
 *
 * @since 5.1.0
 *
 * @return array Cron jobs ready to be run.
 */
function wp_get_ready_cron_jobs()
{
    /**
     * Filter to preflight or hijack 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.
     *
     * @since 5.1.0
     *
     * @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);
    if (null !== $pre) {
        return $pre;
    }
    $crons = _get_cron_array();
    if (false === $crons) {
        return array();
    }
    $gmt_time = microtime(true);
    $keys = array_keys($crons);
    if (isset($keys[0]) && $keys[0] > $gmt_time) {
        return array();
    }
    $results = array();
    foreach ($crons as $timestamp => $cronhooks) {
        if ($timestamp > $gmt_time) {
            break;
        }
        $results[$timestamp] = $cronhooks;
    }
    return $results;
}