wp_next_scheduled

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

WordPress Version: 6.2

/**
 * Retrieves the next timestamp for an event.
 *
 * @since 2.1.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.
 *                     Default empty array.
 * @return int|false The Unix timestamp of the next time the event will occur. False if the event doesn't exist.
 */
function wp_next_scheduled($hook, $args = array())
{
    $next_event = wp_get_scheduled_event($hook, $args);
    if (!$next_event) {
        return false;
    }
    return $next_event->timestamp;
}

WordPress Version: 5.7

/**
 * Retrieve the next timestamp for an event.
 *
 * @since 2.1.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.
 *                     Default empty array.
 * @return int|false The Unix timestamp of the next time the event will occur. False if the event doesn't exist.
 */
function wp_next_scheduled($hook, $args = array())
{
    $next_event = wp_get_scheduled_event($hook, $args);
    if (!$next_event) {
        return false;
    }
    return $next_event->timestamp;
}

WordPress Version: 5.4

/**
 * Retrieve the next timestamp for an event.
 *
 * @since 2.1.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.
 * @return int|false The Unix timestamp of the next time the event will occur. False if the event doesn't exist.
 */
function wp_next_scheduled($hook, $args = array())
{
    $next_event = wp_get_scheduled_event($hook, $args);
    if (!$next_event) {
        return false;
    }
    return $next_event->timestamp;
}

WordPress Version: 5.1

/**
 * Retrieve the next timestamp for an event.
 *
 * @since 2.1.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.
 * @return false|int The Unix timestamp of the next time the event will occur. False if the event doesn't exist.
 */
function wp_next_scheduled($hook, $args = array())
{
    $next_event = wp_get_scheduled_event($hook, $args);
    if (!$next_event) {
        return false;
    }
    return $next_event->timestamp;
}

WordPress Version: 4.7

/**
 * Retrieve the next timestamp for an event.
 *
 * @since 2.1.0
 *
 * @param string $hook Action hook to execute when event is run.
 * @param array $args Optional. Arguments to pass to the hook's callback function.
 * @return false|int The Unix timestamp of the next time the scheduled event will occur.
 */
function wp_next_scheduled($hook, $args = array())
{
    $crons = _get_cron_array();
    $key = md5(serialize($args));
    if (empty($crons)) {
        return false;
    }
    foreach ($crons as $timestamp => $cron) {
        if (isset($cron[$hook][$key])) {
            return $timestamp;
        }
    }
    return false;
}

WordPress Version: 4.3

/**
 * Retrieve the next timestamp for a cron event.
 *
 * @since 2.1.0
 *
 * @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 false|int The UNIX timestamp of the next time the scheduled event will occur.
 */
function wp_next_scheduled($hook, $args = array())
{
    $crons = _get_cron_array();
    $key = md5(serialize($args));
    if (empty($crons)) {
        return false;
    }
    foreach ($crons as $timestamp => $cron) {
        if (isset($cron[$hook][$key])) {
            return $timestamp;
        }
    }
    return false;
}

WordPress Version: 3.7

/**
 * Retrieve the next timestamp for a cron event.
 *
 * @since 2.1.0
 *
 * @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 bool|int The UNIX timestamp of the next time the scheduled event will occur.
 */
function wp_next_scheduled($hook, $args = array())
{
    $crons = _get_cron_array();
    $key = md5(serialize($args));
    if (empty($crons)) {
        return false;
    }
    foreach ($crons as $timestamp => $cron) {
        if (isset($cron[$hook][$key])) {
            return $timestamp;
        }
    }
    return false;
}