WP_REST_Request::is_json_content_type()
Checks if the request has specified a JSON content-type.
{} It's a method of the class: WP_REST_Request{}
No Hooks.
Return
true|false
. True if the content-type header is JSON.
Usage
$WP_REST_Request = new WP_REST_Request(); $WP_REST_Request->is_json_content_type();
Changelog
Since 5.6.0 | Introduced. |
Code of WP_REST_Request::is_json_content_type() WP REST Request::is json content type WP 5.9.3
public function is_json_content_type() { $content_type = $this->get_content_type(); return isset( $content_type['value'] ) && wp_is_json_media_type( $content_type['value'] ); }