Automattic\WooCommerce\StoreApi
Authentication::is_only_post_request
Returns true only for POST requests that are NOT overridden to another method via the X-HTTP-Method-Override header (used by wp.apiFetch for PUT/DELETE).
Метод класса: Authentication{}
Хуков нет.
Возвращает
bool.
Использование
// private - только в коде основоного (родительского) класса $result = $this->is_only_post_request();
Заметки
| Смотрите: https://github.com/wordpress/gutenberg/blob/trunk/packages/api-fetch/src/middlewares/http-v1.ts#L21-L43 |
Код Authentication::is_only_post_request() Authentication::is only post request WC 11.2.2
private function is_only_post_request() {
// Check that REQUEST_METHOD is POST.
if ( ! isset( $_SERVER['REQUEST_METHOD'] ) || 'POST' !== $_SERVER['REQUEST_METHOD'] ) {
return false;
}
// Check X-HTTP-Method-Override header if it exists and is not empty - it must also be POST.
if ( isset( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] ) ) {
$method_override = strtoupper( sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] ) ) );
if ( '' !== $method_override && 'POST' !== $method_override ) {
return false;
}
}
return true;
}