wp_get_ready_cron_jobs

函式
wp_get_ready_cron_jobs ( No parameters )
返回值
  • (array[]) Array of cron job arrays ready to be run.
定義位置
相關方法
wp_get_recent_postswp_page_reload_on_back_button_jswp_get_user_contact_methodswp_get_media_creation_timestampwp_get_layout_style
引入
5.1.0
棄用
-

wp_get_ready_cron_jobs: 這個函式用來檢索一個準備執行的計劃中的cron作業陣列。它根據當前時間檢查預定的cron工作,並返回一個即將執行的工作陣列。

檢索準備執行的cron作業。

返回_get_cron_array()的結果,僅限於準備執行的事件,即,時間戳在過去。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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();
$gmt_time = microtime( true );
$results = array();
foreach ( $crons as $timestamp => $cronhooks ) {
if ( $timestamp > $gmt_time ) {
break;
}
$results[ $timestamp ] = $cronhooks;
}
return $results;
}
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(); $gmt_time = microtime( true ); $results = array(); foreach ( $crons as $timestamp => $cronhooks ) { if ( $timestamp > $gmt_time ) { break; } $results[ $timestamp ] = $cronhooks; } return $results; }
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();
	$gmt_time = microtime( true );
	$results  = array();

	foreach ( $crons as $timestamp => $cronhooks ) {
		if ( $timestamp > $gmt_time ) {
			break;
		}

		$results[ $timestamp ] = $cronhooks;
	}

	return $results;
}

常見問題

FAQs
檢視更多 >