On this page
WP_Customize_Manager::doing_ajax( string|null $action = null ): bool
Returns true if it’s an Ajax request.
Parameters
$actionstring|null Optional-
Whether the supplied Ajax action is being run.
Default:
null
Return
bool True if it's an Ajax request, false otherwise.
Source
File: wp-includes/class-wp-customize-manager.php. View all references
public function doing_ajax( $action = null ) {
if ( ! wp_doing_ajax() ) {
return false;
}
if ( ! $action ) {
return true;
} else {
/*
* Note: we can't just use doing_action( "wp_ajax_{$action}" ) because we need
* to check before admin-ajax.php gets to that point.
*/
return isset( $_REQUEST['action'] ) && wp_unslash( $_REQUEST['action'] ) === $action;
}
}
Related
Uses
| Uses | Description |
|---|---|
| wp_doing_ajax() wp-includes/load.php | Determines whether the current request is a WordPress Ajax request. |
| wp_unslash() wp-includes/formatting.php | Removes slashes from a string or recursively removes slashes from strings within an array. |
Used By
| Used By | Description |
|---|---|
| WP_Customize_Manager::wp_die() wp-includes/class-wp-customize-manager.php | Custom wp_die wrapper. Returns either the standard message for UI or the Ajax message. |
| WP_Customize_Manager::wp_die_handler() wp-includes/class-wp-customize-manager.php | Returns the Ajax wp_die() handler if it’s a customized request. |
| WP_Customize_Manager::after_setup_theme() wp-includes/class-wp-customize-manager.php | Callback to validate a theme once it is loaded |
Changelog
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_customize_manager/doing_ajax