wp_get_ready_cron_jobs() WordPress Function

The wp_get_ready_cron_jobs() function is used to get an array of all cron jobs that are due to be run. This function is used internally by the WordPress cron system.

wp_get_ready_cron_jobs() #

Retrieve cron jobs ready to be run.


Description

Returns the results of _get_cron_array() limited to events ready to be run, ie, with a timestamp in the past.


Top ↑

Return

(array[]) Array of cron job arrays ready to be run.


Top ↑

Source

File: wp-includes/cron.php

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


Top ↑

Changelog

Changelog
VersionDescription
5.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.