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
查看更多 >