Title: WP_Customize_Manager::doing_ajax
Published: April 25, 2014
Last modified: May 20, 2026

---

# WP_Customize_Manager::doing_ajax( string|null $action = null ): bool

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/wp_customize_manager/doing_ajax/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_customize_manager/doing_ajax/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_customize_manager/doing_ajax/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_customize_manager/doing_ajax/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_customize_manager/doing_ajax/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_customize_manager/doing_ajax/?output_format=md#wp--skip-link--target)

Returns true if it’s an Ajax request.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_customize_manager/doing_ajax/?output_format=md#parameters)󠁿

 `$action`string|nulloptional

Whether the supplied Ajax action is being run.

Default:`null`

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_customize_manager/doing_ajax/?output_format=md#return)󠁿

 bool True if it’s an Ajax request, false otherwise.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_customize_manager/doing_ajax/?output_format=md#source)󠁿

    ```php
    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;
    	}
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-customize-manager.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/class-wp-customize-manager.php#L426)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/class-wp-customize-manager.php#L426-L440)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_customize_manager/doing_ajax/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_doing_ajax()](https://developer.wordpress.org/reference/functions/wp_doing_ajax/)`wp-includes/load.php` |

Determines whether the current request is a WordPress Ajax request.

  | 
| [wp_unslash()](https://developer.wordpress.org/reference/functions/wp_unslash/)`wp-includes/formatting.php` |

Removes slashes from a string or recursively removes slashes from strings within an array.

  |

| Used by | Description | 
| [WP_Customize_Manager::wp_die()](https://developer.wordpress.org/reference/classes/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()](https://developer.wordpress.org/reference/classes/wp_customize_manager/wp_die_handler/)`wp-includes/class-wp-customize-manager.php` |

Returns the Ajax [wp_die()](https://developer.wordpress.org/reference/functions/wp_die/) handler if it’s a customized request.

  | 
| [WP_Customize_Manager::after_setup_theme()](https://developer.wordpress.org/reference/classes/wp_customize_manager/after_setup_theme/)`wp-includes/class-wp-customize-manager.php` |

Callback to validate a theme once it is loaded

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_customize_manager/doing_ajax/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.2.0](https://developer.wordpress.org/reference/since/4.2.0/) | Added `$action` param. | 
| [3.4.0](https://developer.wordpress.org/reference/since/3.4.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_customize_manager%2Fdoing_ajax%2F)
before being able to contribute a note or feedback.