[ Index ] |
PHP Cross Reference of WordPress |
[Source view] [Print] [Project Stats]
REST API: WP_REST_Request class
File Size: | 1060 lines (26 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
WP_REST_Request:: (44 methods):
__construct()
get_method()
set_method()
get_headers()
canonicalize_header_name()
get_header()
get_header_as_array()
set_header()
add_header()
remove_header()
set_headers()
get_content_type()
is_json_content_type()
get_parameter_order()
get_param()
has_param()
set_param()
get_params()
get_url_params()
set_url_params()
get_query_params()
set_query_params()
get_body_params()
set_body_params()
get_file_params()
set_file_params()
get_default_params()
set_default_params()
get_body()
set_body()
get_json_params()
parse_json_params()
parse_body_params()
get_route()
set_route()
get_attributes()
set_attributes()
sanitize_params()
has_valid_params()
offsetExists()
offsetGet()
offsetSet()
offsetUnset()
from_url()
Class: WP_REST_Request - X-Ref
Core class used to implement a REST request object.__construct( $method = '', $route = '', $attributes = array() X-Ref |
Constructor. param: string $method Optional. Request method. Default empty. param: string $route Optional. Request route. Default empty. param: array $attributes Optional. Request attributes. Default empty array. since: 4.4.0 |
get_method() X-Ref |
Retrieves the HTTP method for the request. return: string HTTP method. since: 4.4.0 |
set_method( $method ) X-Ref |
Sets HTTP method for the request. param: string $method HTTP method. since: 4.4.0 |
get_headers() X-Ref |
Retrieves all headers from the request. return: array Map of key to value. Key is always lowercase, as per HTTP specification. since: 4.4.0 |
canonicalize_header_name( $key ) X-Ref |
Canonicalizes the header name. Ensures that header names are always treated the same regardless of source. Header names are always case insensitive. Note that we treat `-` (dashes) and `_` (underscores) as the same character, as per header parsing rules in both Apache and nginx. param: string $key Header name. return: string Canonicalized name. since: 4.4.0 |
get_header( $key ) X-Ref |
Retrieves the given header from the request. If the header has multiple values, they will be concatenated with a comma as per the HTTP specification. Be aware that some non-compliant headers (notably cookie headers) cannot be joined this way. param: string $key Header name, will be canonicalized to lowercase. return: string|null String value if set, null otherwise. since: 4.4.0 |
get_header_as_array( $key ) X-Ref |
Retrieves header values from the request. param: string $key Header name, will be canonicalized to lowercase. return: array|null List of string values if set, null otherwise. since: 4.4.0 |
set_header( $key, $value ) X-Ref |
Sets the header on request. param: string $key Header name. param: string $value Header value, or list of values. since: 4.4.0 |
add_header( $key, $value ) X-Ref |
Appends a header value for the given header. param: string $key Header name. param: string $value Header value, or list of values. since: 4.4.0 |
remove_header( $key ) X-Ref |
Removes all values for a header. param: string $key Header name. since: 4.4.0 |
set_headers( $headers, $override = true ) X-Ref |
Sets headers on the request. param: array $headers Map of header name to value. param: bool $override If true, replace the request's headers. Otherwise, merge with existing. since: 4.4.0 |
get_content_type() X-Ref |
Retrieves the content-type of the request. return: array|null Map containing 'value' and 'parameters' keys since: 4.4.0 |
is_json_content_type() X-Ref |
Checks if the request has specified a JSON content-type. return: bool True if the content-type header is JSON. since: 5.6.0 |
get_parameter_order() X-Ref |
Retrieves the parameter priority order. Used when checking parameters in WP_REST_Request::get_param(). return: string[] Array of types to check, in order of priority. since: 4.4.0 |
get_param( $key ) X-Ref |
Retrieves a parameter from the request. param: string $key Parameter name. return: mixed|null Value if set, null otherwise. since: 4.4.0 |
has_param( $key ) X-Ref |
Checks if a parameter exists in the request. This allows distinguishing between an omitted parameter, and a parameter specifically set to null. param: string $key Parameter name. return: bool True if a param exists for the given key. since: 5.3.0 |
set_param( $key, $value ) X-Ref |
Sets a parameter on the request. If the given parameter key exists in any parameter type an update will take place, otherwise a new param will be created in the first parameter type (respecting get_parameter_order()). param: string $key Parameter name. param: mixed $value Parameter value. since: 4.4.0 |
get_params() X-Ref |
Retrieves merged parameters from the request. The equivalent of get_param(), but returns all parameters for the request. Handles merging all the available values into a single array. return: array Map of key to value. since: 4.4.0 |
get_url_params() X-Ref |
Retrieves parameters from the route itself. These are parsed from the URL using the regex. return: array Parameter map of key to value. since: 4.4.0 |
set_url_params( $params ) X-Ref |
Sets parameters from the route. Typically, this is set after parsing the URL. param: array $params Parameter map of key to value. since: 4.4.0 |
get_query_params() X-Ref |
Retrieves parameters from the query string. These are the parameters you'd typically find in `$_GET`. return: array Parameter map of key to value since: 4.4.0 |
set_query_params( $params ) X-Ref |
Sets parameters from the query string. Typically, this is set from `$_GET`. param: array $params Parameter map of key to value. since: 4.4.0 |
get_body_params() X-Ref |
Retrieves parameters from the body. These are the parameters you'd typically find in `$_POST`. return: array Parameter map of key to value. since: 4.4.0 |
set_body_params( $params ) X-Ref |
Sets parameters from the body. Typically, this is set from `$_POST`. param: array $params Parameter map of key to value. since: 4.4.0 |
get_file_params() X-Ref |
Retrieves multipart file parameters from the body. These are the parameters you'd typically find in `$_FILES`. return: array Parameter map of key to value since: 4.4.0 |
set_file_params( $params ) X-Ref |
Sets multipart file parameters from the body. Typically, this is set from `$_FILES`. param: array $params Parameter map of key to value. since: 4.4.0 |
get_default_params() X-Ref |
Retrieves the default parameters. These are the parameters set in the route registration. return: array Parameter map of key to value since: 4.4.0 |
set_default_params( $params ) X-Ref |
Sets default parameters. These are the parameters set in the route registration. param: array $params Parameter map of key to value. since: 4.4.0 |
get_body() X-Ref |
Retrieves the request body content. return: string Binary data from the request body. since: 4.4.0 |
set_body( $data ) X-Ref |
Sets body content. param: string $data Binary data from the request body. since: 4.4.0 |
get_json_params() X-Ref |
Retrieves the parameters from a JSON-formatted body. return: array Parameter map of key to value. since: 4.4.0 |
parse_json_params() X-Ref |
Parses the JSON parameters. Avoids parsing the JSON data until we need to access it. return: true|WP_Error True if the JSON data was passed or no JSON data was provided, WP_Error if invalid JSON was passed. since: 4.4.0 since: 4.7.0 Returns error instance if value cannot be decoded. |
parse_body_params() X-Ref |
Parses the request body parameters. Parses out URL-encoded bodies for request methods that aren't supported natively by PHP. In PHP 5.x, only POST has these parsed automatically. since: 4.4.0 |
get_route() X-Ref |
Retrieves the route that matched the request. return: string Route matching regex. since: 4.4.0 |
set_route( $route ) X-Ref |
Sets the route that matched the request. param: string $route Route matching regex. since: 4.4.0 |
get_attributes() X-Ref |
Retrieves the attributes for the request. These are the options for the route that was matched. return: array Attributes for the request. since: 4.4.0 |
set_attributes( $attributes ) X-Ref |
Sets the attributes for the request. param: array $attributes Attributes for the request. since: 4.4.0 |
sanitize_params() X-Ref |
Sanitizes (where possible) the params on the request. This is primarily based off the sanitize_callback param on each registered argument. return: true|WP_Error True if parameters were sanitized, WP_Error if an error occurred during sanitization. since: 4.4.0 |
has_valid_params() X-Ref |
Checks whether this request is valid according to its attributes. return: true|WP_Error True if there are no parameters to validate or if all pass validation, since: 4.4.0 |
offsetExists( $offset ) X-Ref |
Checks if a parameter is set. param: string $offset Parameter name. return: bool Whether the parameter is set. since: 4.4.0 |
offsetGet( $offset ) X-Ref |
Retrieves a parameter from the request. param: string $offset Parameter name. return: mixed|null Value if set, null otherwise. since: 4.4.0 |
offsetSet( $offset, $value ) X-Ref |
Sets a parameter on the request. param: string $offset Parameter name. param: mixed $value Parameter value. since: 4.4.0 |
offsetUnset( $offset ) X-Ref |
Removes a parameter from the request. param: string $offset Parameter name. since: 4.4.0 |
from_url( $url ) X-Ref |
Retrieves a WP_REST_Request object from a full URL. param: string $url URL with protocol, domain, path and query args. return: WP_REST_Request|false WP_REST_Request object on success, false on failure. since: 4.5.0 |
Generated: Sun Dec 22 01:00:02 2024 | Cross-referenced by PHPXref 0.7.1 |