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

Return true if it’s an Ajax request.


Description Description


Parameters Parameters

$action

(string|null) (Optional) Whether the supplied Ajax action is being run.

Default value: null


Top ↑

Return Return

(bool) True if it's an Ajax request, false otherwise.


Top ↑

Source Source

File: wp-includes/class-wp-customize-manager.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;
		}
	}

Top ↑

Changelog Changelog

Changelog
Version Description
4.2.0 Added $action param.
3.4.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.