WC_API_Server::is_json_request()privateWC 2.1

Check if the current request accepts a JSON response by checking the endpoint suffix (.json) or the HTTP ACCEPT header

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

Хуков нет.

Возвращает

true|false.

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

// private - только в коде основоного (родительского) класса
$result = $this->is_json_request();

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

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

Код WC_API_Server::is_json_request() WC 8.7.0

private function is_json_request() {

	// check path
	if ( false !== stripos( $this->path, '.json' ) ) {
		return true;
	}

	// check ACCEPT header, only 'application/json' is acceptable, see RFC 4627
	if ( isset( $this->headers['ACCEPT'] ) && 'application/json' == $this->headers['ACCEPT'] ) {
		return true;
	}

	return false;
}