W3cubDocs

/WordPress

wp_get_schedule( string $hook, array $args = array() ): string|false

Retrieves the name of the recurrence schedule for an event.

Description

See also

Parameters

$hookstringrequired
Action hook to identify the event.
$argsarrayoptional
Arguments passed to the event’s callback function.

Default:array()

Return

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

Source

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

Hooks

apply_filters( ‘get_schedule’, string|false $schedule, string $hook, array $args )

Filters the schedule name for a hook.

Changelog

Version Description
5.1.0 'get_schedule' filter added.
2.1.0 Introduced.

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_get_schedule