WC_API_Server::is_json_request()
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 API Server::is json request WC 7.7.2
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; }