wp_get_schedule() WordPress Function

The wp_get_schedule() function is used to return the recurrence schedule for an event in WordPress. This function is typically used by plugins and themes to schedule events.

wp_get_schedule( string $hook, array $args = array() ) #

Retrieve the recurrence schedule for an event.


Description

Top ↑

See also


Top ↑

Parameters

$hook

(string)(Required)Action hook to identify the event.

$args

(array)(Optional) Arguments passed to the event's callback function.

Default value: array()


Top ↑

Return

(string|false) Schedule name on success, false if no schedule.


Top ↑

Source

File: wp-includes/cron.php

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 );
}


Top ↑

Changelog

Changelog
VersionDescription
5.1.0'get_schedule' filter added.
2.1.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.