wpseek.com
Un motore di ricerca WordPress per sviluppatori e autori di temi



wp_is_json_request › WordPress Function

Da5.0.0
Deprecaton/a
wp_is_json_request ( Nessun parametro )
Ritorna:
  • (bool) True if `Accepts` or `Content-Type` headers contain `application/json`. False otherwise.
Definito a:
Codex:

Checks whether current request is a JSON request, or is expecting a JSON response.



Sorgenti

function wp_is_json_request() {
	if ( isset( $_SERVER['HTTP_ACCEPT'] ) && wp_is_json_media_type( $_SERVER['HTTP_ACCEPT'] ) ) {
		return true;
	}

	if ( isset( $_SERVER['CONTENT_TYPE'] ) && wp_is_json_media_type( $_SERVER['CONTENT_TYPE'] ) ) {
		return true;
	}

	return false;
}