WPDev.one
Core Class

WP_REST_Request

class WP_REST_Request // Constructor: function Object() { [native code] }

Core class used to implement a REST request object.

Methods 45 methods

Method / Return Description
__construct()
void

Constructor.

Parameters: $method: mixed, $route: mixed, $attributes: mixed
get_method()
string

Retrieves the HTTP method for the request.

set_method()
void

Sets HTTP method for the request.

Parameters: $method: mixed
get_headers()
array

Retrieves all headers from the request.

is_method()
bool

Determines if the request is the given method.

Parameters: $method: mixed
canonicalize_header_name()
string

Canonicalizes the header name.

Parameters: $key: mixed
get_header()
(string

Retrieves the given header from the request.

Parameters: $key: mixed
get_header_as_array()
(array

Retrieves header values from the request.

Parameters: $key: mixed
set_header()
void

Sets the header on request.

Parameters: $key: mixed, $value: mixed
add_header()
void

Appends a header value for the given header.

Parameters: $key: mixed, $value: mixed
remove_header()
void

Removes all values for a header.

Parameters: $key: mixed
set_headers()
void

Sets headers on the request.

Parameters: $headers: mixed, $override: mixed
get_content_type()
(array

Retrieves the Content-Type of the request.

is_json_content_type()
bool

Checks if the request has specified a JSON Content-Type.

get_parameter_order()
string[]

Retrieves the parameter priority order.

get_param()
(mixed

Retrieves a parameter from the request.

Parameters: $key: mixed
has_param()
bool

Checks if a parameter exists in the request.

Parameters: $key: mixed
set_param()
void

Sets a parameter on the request.

Parameters: $key: mixed, $value: mixed
get_params()
array

Retrieves merged parameters from the request.

get_url_params()
array

Retrieves parameters from the route itself.

set_url_params()
void

Sets parameters from the route.

Parameters: $params: mixed
get_query_params()
array

Retrieves parameters from the query string.

set_query_params()
void

Sets parameters from the query string.

Parameters: $params: mixed
get_body_params()
array

Retrieves parameters from the body.

set_body_params()
void

Sets parameters from the body.

Parameters: $params: mixed
get_file_params()
array

Retrieves multipart file parameters from the body.

set_file_params()
void

Sets multipart file parameters from the body.

Parameters: $params: mixed
get_default_params()
array

Retrieves the default parameters.

set_default_params()
void

Sets default parameters.

Parameters: $params: mixed
get_body()
string

Retrieves the request body content.

set_body()
void

Sets body content.

Parameters: $data: mixed
get_json_params()
array

Retrieves the parameters from a JSON-formatted body.

parse_json_params()
(true

Parses the JSON parameters.

parse_body_params()
void

Parses the request body parameters.

get_route()
string

Retrieves the route that matched the request.

set_route()
void

Sets the route that matched the request.

Parameters: $route: mixed
get_attributes()
array

Retrieves the attributes for the request.

set_attributes()
void

Sets the attributes for the request.

Parameters: $attributes: mixed
sanitize_params()
(true

Sanitizes (where possible) the params on the request.

has_valid_params()
(true

Checks whether this request is valid according to its attributes.

offsetExists()
bool

Checks if a parameter is set.

Parameters: $offset: mixed
offsetGet()
(mixed

Retrieves a parameter from the request.

Parameters: $offset: mixed
offsetSet()
void

Sets a parameter on the request.

Parameters: $offset: mixed, $value: mixed
offsetUnset()
void

Removes a parameter from the request.

Parameters: $offset: mixed
from_url()
(WP_REST_Request

Retrieves a WP_REST_Request object from a full URL.

Parameters: $url: mixed

Properties

Property / Type Description
$method
mixed
public
No description available.
$params
mixed
public
No description available.
$headers
mixed
public
No description available.
$body
mixed
public
No description available.
$route
mixed
public
No description available.
$attributes
mixed
public
No description available.
$parsed_json
mixed
public
No description available.
$parsed_body
mixed
public
No description available.

Class Information

Since Version
4.4.0
Source File
wp-includes/rest-api/class-wp-rest-request.php
Advertisement