ACF_Rest_Request::set_http_method
Determine the HTTP method of the current request.
Method of the class: ACF_Rest_Request{}
No Hooks.
Returns
null. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->set_http_method();
ACF_Rest_Request::set_http_method() ACF Rest Request::set http method code ACF 6.0.4
private function set_http_method() {
$this->http_method = 'GET';
if ( ! empty( $_SERVER['REQUEST_METHOD'] ) ) {
$this->http_method = strtoupper( sanitize_text_field( $_SERVER['REQUEST_METHOD'] ) );
}
// phpcs:disable WordPress.Security.NonceVerification.Recommended -- Verified elsewhere.
// HTTP method override for clients that can't use PUT/PATCH/DELETE. This is identical to WordPress'
// handling in \WP_REST_Server::serve_request(). This block of code should always be identical to that
// in core.
if ( isset( $_GET['_method'] ) ) {
$this->http_method = strtoupper( sanitize_text_field( $_GET['_method'] ) );
} elseif ( isset( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] ) ) {
$this->http_method = strtoupper( sanitize_text_field( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] ) );
}
// phpcs:enable WordPress.Security.NonceVerification.Recommended
}