Checks whether current request is a JSON request, or is expecting a JSON response.
Source
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;
}
Changelog
Version | Description |
---|---|
5.0.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.