WP_REST_Server
class WP_REST_Server
// Constructor: function Object() { [native code] } Core class used to implement the WordPress REST API server.
Methods 37 methods
| Method / Return | Description |
|---|---|
| __construct() void | Instantiates the REST server. |
| check_authentication() (WP_Error | Checks the authentication headers if supplied. |
| error_to_response() WP_REST_Response | Converts an error to a response object.
Parameters: $error: mixed |
| json_error() string | Retrieves an appropriate error representation in JSON.
Parameters: $code: mixed, $message: mixed, $status: mixed |
| get_json_encode_options() int | Gets the encoding options passed to {@see wp_json_encode}.
Parameters: $request: WP_REST_Request |
| serve_request() (null | Handles serving a REST API request.
Parameters: $path: mixed |
| response_to_data() array | Converts a response to data to send.
Parameters: $response: mixed, $embed: mixed |
| get_response_links() array | Retrieves links from a response.
Parameters: $response: mixed |
| get_target_hints_for_link() (array | Gets the target links for a REST API Link.
Parameters: $link: mixed |
| get_compact_response_links() array | Retrieves the CURIEs (compact URIs) used for relations.
Parameters: $response: mixed |
| embed_links() array | Embeds the links from the data into the request.
Parameters: $data: mixed, $embed: mixed |
| envelope_response() WP_REST_Response | Wraps the response in an envelope.
Parameters: $response: mixed, $embed: mixed |
| register_route() void | Registers a route to the server.
Parameters: $route_namespace: mixed, $route: mixed, $route_args: mixed, $override: mixed |
| get_routes() array | Retrieves the route map.
Parameters: $route_namespace: mixed |
| get_namespaces() string[] | Retrieves namespaces registered on the server. |
| get_route_options() (array | Retrieves specified options for a route.
Parameters: $route: mixed |
| dispatch() WP_REST_Response | Matches the request to a callback and call it.
Parameters: $request: mixed |
| is_dispatching() bool | Returns whether the REST server is currently dispatching / responding to a request. |
| match_request_to_handler() (array | Matches a request object to its handler.
Parameters: $request: mixed |
| respond_to_request() WP_REST_Response | Dispatches the request to the callback handler.
Parameters: $request: mixed, $route: mixed, $handler: mixed, $response: mixed |
| get_json_last_error() (false | Returns if an error occurred during most recent JSON encode/decode. |
| get_index() WP_REST_Response | Retrieves the site index.
Parameters: $request: mixed |
| add_active_theme_link_to_index() void | Adds a link to the active theme for users who have proper permissions.
Parameters: $response: WP_REST_Response |
| add_site_logo_to_index() void | Exposes the site logo through the WordPress REST API.
Parameters: $response: WP_REST_Response |
| add_site_icon_to_index() void | Exposes the site icon through the WordPress REST API.
Parameters: $response: WP_REST_Response |
| add_image_to_index() void | Exposes an image through the WordPress REST API.
Parameters: $response: WP_REST_Response, $image_id: mixed, $type: mixed |
| get_namespace_index() (WP_REST_Response | Retrieves the index for a namespace.
Parameters: $request: mixed |
| get_data_for_routes() array[] | Retrieves the publicly-visible data for routes.
Parameters: $routes: mixed, $context: mixed |
| get_data_for_route() (array | Retrieves publicly-visible data for the route.
Parameters: $route: mixed, $callbacks: mixed, $context: mixed |
| get_max_batch_size() int | Gets the maximum number of requests that can be included in a batch. |
| serve_batch_request_v1() WP_REST_Response | Serves the batch/v1 request.
Parameters: $batch_request: WP_REST_Request |
| set_status() void | Sends an HTTP status code.
Parameters: $code: mixed |
| send_header() void | Sends an HTTP header.
Parameters: $key: mixed, $value: mixed |
| send_headers() void | Sends multiple HTTP headers.
Parameters: $headers: mixed |
| remove_header() void | Removes an HTTP header from the current response.
Parameters: $key: mixed |
| get_raw_data() string | Retrieves the raw request entity (body). |
| get_headers() array | Extracts headers from a PHP-style $_SERVER array.
Parameters: $server: mixed |
Properties
| Property / Type | Description |
|---|---|
| $namespaces mixed public | No description available. |
| $endpoints mixed public | No description available. |
| $route_options mixed public | No description available. |
| $embed_cache mixed public | No description available. |
| $dispatching_requests mixed public | No description available. |