Retrieves the HTTP method for the request.
Source
public function get_method() {
return $this->method;
}
Changelog
Version | Description |
---|---|
4.4.0 | Introduced. |
Retrieves the HTTP method for the request.
public function get_method() {
return $this->method;
}
Version | Description |
---|---|
4.4.0 | Introduced. |
You must log in before being able to contribute a note or feedback.
The return value (HTTP Method) is returned in full uppercase such as “POST”, “GET”, “PATCH”, “DELETE”. As an example in your API route callback you can check for the method type when you’re expecting one of several potential methods:
Alternatively you might use a switch to check the method such as:
These examples are in the context of a callback from
register_rest_route()
which passes the$request
(instance ofWP_REST_Request
) to the callback.