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).
Method of the class: Authentication{}
No Hooks.
Returns
true|false.
Usage
// private - for code of main (parent) class only $result = $this->is_only_post_request();
Notes
Authentication::is_only_post_request() Authentication::is only post request code WC 10.8.1
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;
}