wp_get_schedule

The timeline below displays how wordpress function wp_get_schedule 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 name of the recurrence schedule for an event.
 *
 * @see wp_get_schedules() for available schedules.
 *
 * @since 2.1.0
 * @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.
 *                     Default empty array.
 * @return string|false Schedule name on success, false if no schedule.
 */
function wp_get_schedule($hook, $args = array())
{
    $schedule = false;
    $event = wp_get_scheduled_event($hook, $args);
    if ($event) {
        $schedule = $event->schedule;
    }
    /**
     * Filters the schedule name for a hook.
     *
     * @since 5.1.0
     *
     * @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);
}

WordPress Version: 5.7

/**
 * Retrieve the recurrence schedule for an event.
 *
 * @see wp_get_schedules() for available schedules.
 *
 * @since 2.1.0
 * @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.
 *                     Default empty array.
 * @return string|false Schedule name on success, false if no schedule.
 */
function wp_get_schedule($hook, $args = array())
{
    $schedule = false;
    $event = wp_get_scheduled_event($hook, $args);
    if ($event) {
        $schedule = $event->schedule;
    }
    /**
     * Filters the schedule for a hook.
     *
     * @since 5.1.0
     *
     * @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);
}

WordPress Version: 5.6

/**
 * Retrieve the recurrence schedule for an event.
 *
 * @see wp_get_schedules() for available schedules.
 *
 * @since 2.1.0
 * @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 False, if no schedule. Schedule name on success.
 */
function wp_get_schedule($hook, $args = array())
{
    $schedule = false;
    $event = wp_get_scheduled_event($hook, $args);
    if ($event) {
        $schedule = $event->schedule;
    }
    /**
     * Filters the schedule for a hook.
     *
     * @since 5.1.0
     *
     * @param string|bool $schedule Schedule for the hook. False if not found.
     * @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 apply_filters('get_schedule', $schedule, $hook, $args);
}

WordPress Version: 5.5

/**
 * Retrieve the recurrence schedule for an event.
 *
 * @see wp_get_schedules() for available schedules.
 *
 * @since 2.1.0
 * @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 False, if no schedule. Schedule name on success.
 */
function wp_get_schedule($hook, $args = array())
{
    $schedule = false;
    $event = wp_get_scheduled_event($hook, $args);
    if ($event) {
        $schedule = $event->schedule;
    }
    /**
     * Filter the schedule for a hook.
     *
     * @since 5.1.0
     *
     * @param string|bool $schedule Schedule for the hook. False if not found.
     * @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 apply_filters('get_schedule', $schedule, $hook, $args);
}

WordPress Version: 5.1

/**
 * Retrieve the recurrence schedule for an event.
 *
 * @see wp_get_schedules() for available schedules.
 *
 * @since 2.1.0
 * @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 False, if no schedule. Schedule name on success.
 */
function wp_get_schedule($hook, $args = array())
{
    $schedule = false;
    $event = wp_get_scheduled_event($hook, $args);
    if ($event) {
        $schedule = $event->schedule;
    }
    /**
     * Filter the schedule for a hook.
     *
     * @since 5.1.0
     *
     * @param string|bool $schedule Schedule for the hook. False if not found.
     * @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 apply_filters('get_schedule', $schedule, $hook, $args);
}

WordPress Version: 4.7

/**
 * Retrieve the recurrence schedule for an event.
 *
 * @see wp_get_schedules() for available schedules.
 *
 * @since 2.1.0
 *
 * @param string $hook Action hook to identify the event.
 * @param array $args Optional. Arguments passed to the event's callback function.
 * @return string|false False, if no schedule. Schedule name on success.
 */
function wp_get_schedule($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 $cron[$hook][$key]['schedule'];
        }
    }
    return false;
}

WordPress Version: 4.3

/**
 * Retrieve Cron schedule for hook with arguments.
 *
 * @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 string|false False, if no schedule. Schedule on success.
 */
function wp_get_schedule($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 $cron[$hook][$key]['schedule'];
        }
    }
    return false;
}

WordPress Version: 3.7

/**
 * Retrieve Cron schedule for hook with arguments.
 *
 * @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 string|bool False, if no schedule. Schedule on success.
 */
function wp_get_schedule($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 $cron[$hook][$key]['schedule'];
        }
    }
    return false;
}