wp_doing_cron

函式
wp_doing_cron ( No parameters )
返回值
  • (bool) True if it's a WordPress cron request, false otherwise.
定義位置
相關方法
doing_action_doing_it_wrongwp_cronwp_doing_ajax_wp_cron
引入
4.8.0
棄用
-

wp_doing_cron: 這個函式返回一個布林值,表示當前的請求是否作為WordPress cron系統的一部分被執行。WordPress cron系統是用來定期安排和執行某些任務的,比如檢查更新或釋出預定的文章: 這個函式可以用來檢查某個程式碼塊是否正在作為WordPress cron系統的一部分被執行,並根據該資訊採取適當的行動。

確定當前請求是否是一個WordPress cron請求。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function wp_doing_cron() {
/**
* Filters whether the current request is a WordPress cron request.
*
* @since 4.8.0
*
* @param bool $wp_doing_cron Whether the current request is a WordPress cron request.
*/
return apply_filters( 'wp_doing_cron', defined( 'DOING_CRON' ) && DOING_CRON );
}
function wp_doing_cron() { /** * Filters whether the current request is a WordPress cron request. * * @since 4.8.0 * * @param bool $wp_doing_cron Whether the current request is a WordPress cron request. */ return apply_filters( 'wp_doing_cron', defined( 'DOING_CRON' ) && DOING_CRON ); }
function wp_doing_cron() {
	/**
	 * Filters whether the current request is a WordPress cron request.
	 *
	 * @since 4.8.0
	 *
	 * @param bool $wp_doing_cron Whether the current request is a WordPress cron request.
	 */
	return apply_filters( 'wp_doing_cron', defined( 'DOING_CRON' ) && DOING_CRON );
}

常見問題

FAQs
檢視更多 >