WP_REST_Request::is_json_content_type
Checks if the request has specified a JSON Content-Type.
Method of the class: WP_REST_Request{}
No Hooks.
Returns
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. |
WP_REST_Request::is_json_content_type() WP REST Request::is json content type code WP 7.0
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'] );
}