WP_REST_Request::is_json_content_type()publicWP 5.6.0

Checks if the request has specified a JSON Content-Type.

Метод класса: WP_REST_Request{}

Хуков нет.

Возвращает

true|false. True if the Content-Type header is JSON.

Использование

$WP_REST_Request = new WP_REST_Request();
$WP_REST_Request->is_json_content_type();

Список изменений

С версии 5.6.0 Введена.

Код WP_REST_Request::is_json_content_type() WP 6.5.2

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'] );
}