wp_doing_ajax

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

wp_doing_ajax: 這個函式用來確定當前的請求是否是WordPress中的AJAX請求。它可以用來根據當前請求是否是AJAX請求而有條件地執行程式碼。

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

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

常見問題

FAQs
檢視更多 >