[ Index ] |
WordPress 5.4.1 |
[ Index ] [ Classes ] [ Functions ] [ Variables ] [ Constants ] [ Statistics ] |
[Source view] [Print] [Project Stats]
REST API functions.
File Size: | 1599 lines (47 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
register_rest_route( $namespace, $route, $args = array() X-Ref |
Registers a REST API route. Note: Do not use before the {@see 'rest_api_init'} hook. param: string $namespace The first URL segment after core prefix. Should be unique to your package/plugin. param: string $route The base URL for route you are adding. param: array $args Optional. Either an array of options for the endpoint, or an array of arrays for param: bool $override Optional. If the route already exists, should we override it? True overrides, return: bool True on success, false on error. |
register_rest_field( $object_type, $attribute, $args = array() X-Ref |
Registers a new field on an existing WordPress object type. param: string|array $object_type Object(s) the field is being registered param: string $attribute The attribute name. param: array $args { |
rest_api_init() X-Ref |
Registers rewrite rules for the API. |
rest_api_register_rewrites() X-Ref |
Adds REST rewrite rules. |
rest_api_default_filters() X-Ref |
Registers the default REST API filters. Attached to the {@see 'rest_api_init'} action to make testing and disabling these filters easier. |
create_initial_rest_routes() X-Ref |
Registers default REST API routes. |
rest_api_loaded() X-Ref |
Loads the REST API. |
rest_get_url_prefix() X-Ref |
Retrieves the URL prefix for any API resource. return: string Prefix. |
get_rest_url( $blog_id = null, $path = '/', $scheme = 'rest' ) X-Ref |
Retrieves the URL to a REST endpoint on a site. Note: The returned URL is NOT escaped. param: int $blog_id Optional. Blog ID. Default of null returns URL for current blog. param: string $path Optional. REST route. Default '/'. param: string $scheme Optional. Sanitization scheme. Default 'rest'. return: string Full URL to the endpoint. |
rest_url( $path = '', $scheme = 'rest' ) X-Ref |
Retrieves the URL to a REST endpoint. Note: The returned URL is NOT escaped. param: string $path Optional. REST route. Default empty. param: string $scheme Optional. Sanitization scheme. Default 'rest'. return: string Full URL to the endpoint. |
rest_do_request( $request ) X-Ref |
Do a REST request. Used primarily to route internal requests through WP_REST_Server. param: WP_REST_Request|string $request Request. return: WP_REST_Response REST response. |
rest_get_server() X-Ref |
Retrieves the current REST server instance. Instantiates a new instance if none exists already. return: WP_REST_Server REST server instance. |
rest_ensure_request( $request ) X-Ref |
Ensures request arguments are a request object (for consistency). param: array|string|WP_REST_Request $request Request to check. return: WP_REST_Request REST request instance. |
rest_ensure_response( $response ) X-Ref |
Ensures a REST response is a response object (for consistency). This implements WP_HTTP_Response, allowing usage of `set_status`/`header`/etc without needing to double-check the object. Will also allow WP_Error to indicate error responses, so users should immediately check for this value. param: WP_HTTP_Response|WP_Error|mixed $response Response to check. return: WP_REST_Response|mixed If response generated an error, WP_Error, if response |
rest_handle_deprecated_function( $function, $replacement, $version ) X-Ref |
Handles _deprecated_function() errors. param: string $function The function that was called. param: string $replacement The function that should have been called. param: string $version Version. |
rest_handle_deprecated_argument( $function, $message, $version ) X-Ref |
Handles _deprecated_argument() errors. param: string $function The function that was called. param: string $message A message regarding the change. param: string $version Version. |
rest_send_cors_headers( $value ) X-Ref |
Sends Cross-Origin Resource Sharing headers with API requests. param: mixed $value Response data. return: mixed Response data. |
rest_handle_options_request( $response, $handler, $request ) X-Ref |
Handles OPTIONS requests for the server. This is handled outside of the server code, as it doesn't obey normal route mapping. param: mixed $response Current response, either response or `null` to indicate pass-through. param: WP_REST_Server $handler ResponseHandler instance (usually WP_REST_Server). param: WP_REST_Request $request The request that was used to make current response. return: WP_REST_Response Modified response, either response or `null` to indicate pass-through. |
rest_send_allow_header( $response, $server, $request ) X-Ref |
Sends the "Allow" header to state all methods that can be sent to the current route. param: WP_REST_Response $response Current response being served. param: WP_REST_Server $server ResponseHandler instance (usually WP_REST_Server). param: WP_REST_Request $request The request that was used to make current response. return: WP_REST_Response Response to be served, with "Allow" header if route has allowed methods. |
_rest_array_intersect_key_recursive( $array1, $array2 ) X-Ref |
Recursively computes the intersection of arrays using keys for comparison. param: array $array1 The array with master keys to check. param: array $array2 An array to compare keys against. return: array An associative array containing all the entries of array1 which have keys that are present in all arguments. |
rest_filter_response_fields( $response, $server, $request ) X-Ref |
Filter the API response to include only a white-listed set of response object fields. param: WP_REST_Response $response Current response being served. param: WP_REST_Server $server ResponseHandler instance (usually WP_REST_Server). param: WP_REST_Request $request The request that was used to make current response. return: WP_REST_Response Response to be served, trimmed down to contain a subset of fields. |
rest_is_field_included( $field, $fields ) X-Ref |
Given an array of fields to include in a response, some of which may be `nested.fields`, determine whether the provided field should be included in the response body. If a parent field is passed in, the presence of any nested field within that parent will cause the method to return `true`. For example "title" will return true if any of `title`, `title.raw` or `title.rendered` is provided. param: string $field A field to test for inclusion in the response body. param: array $fields An array of string fields supported by the endpoint. return: bool Whether to include the field or not. |
rest_output_rsd() X-Ref |
Adds the REST API URL to the WP RSD endpoint. |
rest_output_link_wp_head() X-Ref |
Outputs the REST API link tag into page header. |
rest_output_link_header() X-Ref |
Sends a Link header for the REST API. |
rest_cookie_check_errors( $result ) X-Ref |
Checks for errors when using cookie-based authentication. WordPress' built-in cookie authentication is always active for logged in users. However, the API has to check nonces for each request to ensure users are not vulnerable to CSRF. param: WP_Error|mixed $result Error from another authentication handler, return: WP_Error|mixed|bool WP_Error if the cookie is invalid, the $result, otherwise true. |
rest_cookie_collect_status() X-Ref |
Collects cookie authentication status. Collects errors from wp_validate_auth_cookie for use by rest_cookie_check_errors. |
rest_parse_date( $date, $force_utc = false ) X-Ref |
Parses an RFC3339 time into a Unix timestamp. param: string $date RFC3339 timestamp. param: bool $force_utc Optional. Whether to force UTC timezone instead of using return: int Unix timestamp. |
rest_get_date_with_gmt( $date, $is_utc = false ) X-Ref |
Parses a date into both its local and UTC equivalent, in MySQL datetime format. param: string $date RFC3339 timestamp. param: bool $is_utc Whether the provided date should be interpreted as UTC. Default false. return: array|null Local and UTC datetime strings, in MySQL datetime format (Y-m-d H:i:s), |
rest_authorization_required_code() X-Ref |
Returns a contextual HTTP error code for authorization failure. return: integer 401 if the user is not logged in, 403 if the user is logged in. |
rest_validate_request_arg( $value, $request, $param ) X-Ref |
Validate a request argument based on details registered to the route. param: mixed $value param: WP_REST_Request $request param: string $param return: true|WP_Error |
rest_sanitize_request_arg( $value, $request, $param ) X-Ref |
Sanitize a request argument based on details registered to the route. param: mixed $value param: WP_REST_Request $request param: string $param return: mixed |
rest_parse_request_arg( $value, $request, $param ) X-Ref |
Parse a request argument based on details registered to the route. Runs a validation check and sanitizes the value, primarily to be used via the `sanitize_callback` arguments in the endpoint args registration. param: mixed $value param: WP_REST_Request $request param: string $param return: mixed |
rest_is_ip_address( $ip ) X-Ref |
Determines if an IP address is valid. Handles both IPv4 and IPv6 addresses. param: string $ip IP address. return: string|false The valid IP address, otherwise false. |
rest_sanitize_boolean( $value ) X-Ref |
Changes a boolean-like value into the proper boolean value. param: bool|string|int $value The value being evaluated. return: boolean Returns the proper associated boolean value. |
rest_is_boolean( $maybe_bool ) X-Ref |
Determines if a given value is boolean-like. param: bool|string $maybe_bool The value being evaluated. return: boolean True if a boolean, otherwise false. |
rest_get_avatar_urls( $id_or_email ) X-Ref |
Retrieves the avatar urls in various sizes. param: mixed $id_or_email The Gravatar to retrieve a URL for. Accepts a user_id, gravatar md5 hash, return: array Avatar URLs keyed by size. Each value can be a URL string or boolean false. |
rest_get_avatar_sizes() X-Ref |
Retrieves the pixel sizes for avatars. return: int[] List of pixel sizes for avatars. Default `[ 24, 48, 96 ]`. |
rest_validate_value_from_schema( $value, $args, $param = '' ) X-Ref |
Validate a value based on a schema. param: mixed $value The value to validate. param: array $args Schema array to use for validation. param: string $param The parameter name, used in error messages. return: true|WP_Error |
rest_sanitize_value_from_schema( $value, $args ) X-Ref |
Sanitize a value based on a schema. param: mixed $value The value to sanitize. param: array $args Schema array to use for sanitization. return: true|WP_Error |
rest_preload_api_request( $memo, $path ) X-Ref |
Append result of internal request to REST API for purpose of preloading data to be attached to a page. Expected to be called in the context of `array_reduce`. param: array $memo Reduce accumulator. param: string $path REST API path to preload. return: array Modified reduce accumulator. |
rest_parse_embed_param( $embed ) X-Ref |
Parses the "_embed" parameter into the list of resources to embed. param: string|array $embed Raw "_embed" parameter value. return: true|string[] Either true to embed all embeds, or a list of relations to embed. |
Generated: Tue May 19 15:51:04 2020 | Cross-referenced by PHPXref 0.7.1 |