wppaste
WordPress

WP_REST_Request

Since
4.4.0
Source
wp-includes/rest-api/class-wp-rest-request.php:29
Core class used to implement a REST request object.

Description

Contains data from the request, to be passed to the callback.

Note: This implements ArrayAccess, and acts as an array of parameters when used in that manner. It does not use ArrayObject (as we cannot rely on SPL), so be aware it may have non-array behavior in some cases.

Note: When using features provided by ArrayAccess, be aware that WordPress deliberately does not distinguish between arguments of the same name for different request methods.
For instance, in a request with GET id=1 and POST id=2, $request['id'] will equal 2 (POST) not 1 (GET). For more precision between request methods, use WP_REST_Request::get_body_params(), WP_REST_Request::get_url_params(), etc.

Compatibility

WordPress
since 4.4.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Hooks and filters fired · 2

Every hook that fires from inside WP_REST_Request, in the order it appears in the class, grouped by the method that fires it.

Properties · 8

$methodstringprotected
HTTP method.
$paramsarrayprotected
Parameters passed to the request.
$headersarrayprotected
HTTP headers for the request.
$bodystringprotected
Body data.
$routestringprotected
Route matched for the request.
$attributesarrayprotected
Attributes (options) for the route that was matched.
$parsed_jsonboolprotected
Used to determine if the JSON data has been parsed yet.
$parsed_bodyboolprotected
Used to determine if the body data has been parsed yet.

Methods · 45

Changelog

Introduced in 4.4.0. One change between 6.7.7 and 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

6.8.8
Method is_method() added.verified against source
4.4.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-includes/rest-api/class-wp-rest-request.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.