Skip to content

Commit c023d53

Browse files
anton-vlasenkoAnton Vlasenko
authored andcommitted
Add the WP_REST_Request::is_method() method.
1 parent 75c587f commit c023d53

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/wp-includes/rest-api/class-wp-rest-request.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,18 @@ public function get_headers() {
161161
return $this->headers;
162162
}
163163

164+
/**
165+
* Determines if the request is the given method.
166+
*
167+
* @since 6.8.0
168+
*
169+
* @param string $method HTTP method.
170+
* @return bool Whether the request is of the given method.
171+
*/
172+
public function is_method( $method ) {
173+
return $this->get_method() === strtoupper( $method );
174+
}
175+
164176
/**
165177
* Canonicalizes the header name.
166178
*

0 commit comments

Comments
 (0)