{"id":5760,"date":"2026-02-12T20:45:20","date_gmt":"2026-02-13T01:45:20","guid":{"rendered":"https:\/\/chubes.net\/?documentation=wp_rest_server"},"modified":"2026-03-13T03:29:09","modified_gmt":"2026-03-13T07:29:09","slug":"wp_rest_server","status":"publish","type":"documentation","link":"https:\/\/chubes.net\/docs\/wordpress-core\/rest-api\/wp_rest_server\/","title":{"rendered":"WP_REST_Server"},"content":{"rendered":"<p>Core class implementing the WordPress REST API server. Handles route registration, request dispatch, and response formatting.<\/p><p><strong>Source:<\/strong> <code>wp-includes\/rest-api\/class-wp-rest-server.php<\/code><br \/>\n<strong>Since:<\/strong> 4.4.0<\/p><h2 class=\"wp-block-heading\">Constants<\/h2><figure class=\"wp-block-table\"><table><thead><tr><th>Constant<\/th><th>Value<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>READABLE<\/code><\/td><td><code>'GET'<\/code><\/td><td>GET transport method<\/td><\/tr><tr><td><code>CREATABLE<\/code><\/td><td><code>'POST'<\/code><\/td><td>POST transport method<\/td><\/tr><tr><td><code>EDITABLE<\/code><\/td><td><code>'POST, PUT, PATCH'<\/code><\/td><td>Writable methods<\/td><\/tr><tr><td><code>DELETABLE<\/code><\/td><td><code>'DELETE'<\/code><\/td><td>DELETE transport method<\/td><\/tr><tr><td><code>ALLMETHODS<\/code><\/td><td><code>'GET, POST, PUT, PATCH, DELETE'<\/code><\/td><td>All methods<\/td><\/tr><\/tbody><\/table><\/figure><h2 class=\"wp-block-heading\">Properties<\/h2><figure class=\"wp-block-table\"><table><thead><tr><th>Property<\/th><th>Type<\/th><th>Visibility<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>$namespaces<\/code><\/td><td>array<\/td><td>protected<\/td><td>Namespaces registered to server<\/td><\/tr><tr><td><code>$endpoints<\/code><\/td><td>array<\/td><td>protected<\/td><td>Endpoints registered to server<\/td><\/tr><tr><td><code>$route_options<\/code><\/td><td>array<\/td><td>protected<\/td><td>Options for routes<\/td><\/tr><tr><td><code>$embed_cache<\/code><\/td><td>array<\/td><td>protected<\/td><td>Cache for embedded requests<\/td><\/tr><tr><td><code>$dispatching_requests<\/code><\/td><td>array<\/td><td>protected<\/td><td>Request stack being handled<\/td><\/tr><\/tbody><\/table><\/figure><hr class=\"wp-block-separator\"\/><h2 class=\"wp-block-heading\">Methods<\/h2><h3 class=\"wp-block-heading\">__construct()<\/h3><p>Instantiates the REST server with default routes.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">public function __construct()<\/code><\/pre><\/div><p>Registers default <code>\/<\/code> (index) and <code>\/batch\/v1<\/code> endpoints.<\/p><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">check_authentication()<\/h3><p>Checks authentication headers.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">public function check_authentication(): WP_Error|null|true<\/code><\/pre><\/div><p><strong>Returns:<\/strong><\/p><ul class=\"wp-block-list\"><li><code>WP_Error<\/code> if authentication error<\/li><li><code>null<\/code> if no authentication method used<\/li><li><code>true<\/code> if authentication succeeded<\/li><\/ul><p>Triggers <code>rest_authentication_errors<\/code> filter.<\/p><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">serve_request()<\/h3><p>Handles serving a REST API request.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">public function serve_request( string $path = null ): null|false<\/code><\/pre><\/div><figure class=\"wp-block-table\"><table><thead><tr><th>Parameter<\/th><th>Type<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>$path<\/code><\/td><td>string|null<\/td><td>Request route. Default uses <code>$_SERVER['PATH_INFO']<\/code><\/td><\/tr><\/tbody><\/table><\/figure><p><strong>Returns:<\/strong> <code>null<\/code> if served (or HEAD request), <code>false<\/code> on error.<\/p><p><strong>Flow:<\/strong><\/p><ol class=\"wp-block-list\"><li>Sets up request from <code>$_SERVER<\/code>, <code>$_GET<\/code>, <code>$_POST<\/code>, <code>$_FILES<\/code><\/li><li>Handles method override via <code>_method<\/code> param or <code>X-HTTP-Method-Override<\/code> header<\/li><li>Calls <code>check_authentication()<\/code><\/li><li>Dispatches request<\/li><li>Applies <code>rest_post_dispatch<\/code> filter<\/li><li>Handles envelope (<code>_envelope<\/code> param)<\/li><li>Sends headers and JSON response<\/li><\/ol><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">response_to_data()<\/h3><p>Converts a response to data for sending.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">public function response_to_data( WP_REST_Response $response, bool|string[] $embed ): array<\/code><\/pre><\/div><figure class=\"wp-block-table\"><table><thead><tr><th>Parameter<\/th><th>Type<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>$response<\/code><\/td><td>WP_REST_Response<\/td><td>Response object<\/td><\/tr><tr><td><code>$embed<\/code><\/td><td>bool|string[]<\/td><td>Whether to embed links<\/td><\/tr><\/tbody><\/table><\/figure><p><strong>Returns:<\/strong> Array with <code>_links<\/code> and optionally <code>_embedded<\/code>.<\/p><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">get_response_links() <small>(static)<\/small><\/h3><p>Extracts links from a response.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">public static function get_response_links( WP_REST_Response $response ): array<\/code><\/pre><\/div><figure class=\"wp-block-table\"><table><thead><tr><th>Parameter<\/th><th>Type<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>$response<\/code><\/td><td>WP_REST_Response<\/td><td>Response object<\/td><\/tr><\/tbody><\/table><\/figure><p><strong>Returns:<\/strong> Map of link relation to list of link hashes.<\/p><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">get_compact_response_links() <small>(static)<\/small><\/h3><p>Gets links with CURIE-shortened relations.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">public static function get_compact_response_links( WP_REST_Response $response ): array<\/code><\/pre><\/div><figure class=\"wp-block-table\"><table><thead><tr><th>Parameter<\/th><th>Type<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>$response<\/code><\/td><td>WP_REST_Response<\/td><td>Response object<\/td><\/tr><\/tbody><\/table><\/figure><p><strong>Returns:<\/strong> Links with <code>wp:<\/code> prefixes for WordPress relations.<\/p><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">envelope_response()<\/h3><p>Wraps response in an envelope.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">public function envelope_response( WP_REST_Response $response, bool|string[] $embed ): WP_REST_Response<\/code><\/pre><\/div><figure class=\"wp-block-table\"><table><thead><tr><th>Parameter<\/th><th>Type<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>$response<\/code><\/td><td>WP_REST_Response<\/td><td>Response to wrap<\/td><\/tr><tr><td><code>$embed<\/code><\/td><td>bool|string[]<\/td><td>Embed setting<\/td><\/tr><\/tbody><\/table><\/figure><p><strong>Returns:<\/strong> Response with <code>body<\/code>, <code>status<\/code>, and <code>headers<\/code> data.<\/p><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">register_route()<\/h3><p>Registers a route to the server.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">public function register_route( string $route_namespace, string $route, array $route_args, bool $override = false ): void<\/code><\/pre><\/div><figure class=\"wp-block-table\"><table><thead><tr><th>Parameter<\/th><th>Type<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>$route_namespace<\/code><\/td><td>string<\/td><td>Namespace<\/td><\/tr><tr><td><code>$route<\/code><\/td><td>string<\/td><td>Route path<\/td><\/tr><tr><td><code>$route_args<\/code><\/td><td>array<\/td><td>Route arguments<\/td><\/tr><tr><td><code>$override<\/code><\/td><td>bool<\/td><td>Override existing route<\/td><\/tr><\/tbody><\/table><\/figure><p><strong>Note:<\/strong> Use <code>register_rest_route()<\/code> wrapper function instead.<\/p><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">get_routes()<\/h3><p>Retrieves the route map.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">public function get_routes( string $route_namespace = &#039;&#039; ): array<\/code><\/pre><\/div><figure class=\"wp-block-table\"><table><thead><tr><th>Parameter<\/th><th>Type<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>$route_namespace<\/code><\/td><td>string<\/td><td>Filter to specific namespace<\/td><\/tr><\/tbody><\/table><\/figure><p><strong>Returns:<\/strong> Map of route regex to handlers.<\/p><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">get_namespaces()<\/h3><p>Retrieves registered namespaces.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">public function get_namespaces(): string[]<\/code><\/pre><\/div><p><strong>Returns:<\/strong> Array of namespace strings.<\/p><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">get_route_options()<\/h3><p>Retrieves options for a route.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">public function get_route_options( string $route ): array|null<\/code><\/pre><\/div><figure class=\"wp-block-table\"><table><thead><tr><th>Parameter<\/th><th>Type<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>$route<\/code><\/td><td>string<\/td><td>Route pattern<\/td><\/tr><\/tbody><\/table><\/figure><p><strong>Returns:<\/strong> Route options or <code>null<\/code> if not found.<\/p><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">dispatch()<\/h3><p>Matches request to handler and calls it.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">public function dispatch( WP_REST_Request $request ): WP_REST_Response<\/code><\/pre><\/div><figure class=\"wp-block-table\"><table><thead><tr><th>Parameter<\/th><th>Type<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>$request<\/code><\/td><td>WP_REST_Request<\/td><td>Request to dispatch<\/td><\/tr><\/tbody><\/table><\/figure><p><strong>Returns:<\/strong> Response from the matched callback.<\/p><p><strong>Flow:<\/strong><\/p><ol class=\"wp-block-list\"><li>Applies <code>rest_pre_dispatch<\/code> filter<\/li><li>Matches request to route<\/li><li>Validates and sanitizes parameters<\/li><li>Calls <code>respond_to_request()<\/code><\/li><\/ol><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">is_dispatching()<\/h3><p>Checks if server is currently handling a request.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">public function is_dispatching(): bool<\/code><\/pre><\/div><p><strong>Returns:<\/strong> <code>true<\/code> during dispatch, <code>false<\/code> otherwise.<\/p><p><strong>Since:<\/strong> 6.5.0<\/p><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">match_request_to_handler() <small>(protected)<\/small><\/h3><p>Matches a request to its handler.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">protected function match_request_to_handler( WP_REST_Request $request ): array|WP_Error<\/code><\/pre><\/div><figure class=\"wp-block-table\"><table><thead><tr><th>Parameter<\/th><th>Type<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>$request<\/code><\/td><td>WP_REST_Request<\/td><td>Request object<\/td><\/tr><\/tbody><\/table><\/figure><p><strong>Returns:<\/strong> <code>array( $route, $handler )<\/code> or <code>WP_Error<\/code>.<\/p><p><strong>Error Codes:<\/strong><\/p><ul class=\"wp-block-list\"><li><code>rest_no_route<\/code> \u2014 No matching route found (404)<\/li><\/ul><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">respond_to_request() <small>(protected)<\/small><\/h3><p>Dispatches request to the callback handler.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">protected function respond_to_request( WP_REST_Request $request, string $route, array $handler, WP_Error|null $response ): WP_REST_Response<\/code><\/pre><\/div><figure class=\"wp-block-table\"><table><thead><tr><th>Parameter<\/th><th>Type<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>$request<\/code><\/td><td>WP_REST_Request<\/td><td>Request object<\/td><\/tr><tr><td><code>$route<\/code><\/td><td>string<\/td><td>Matched route regex<\/td><\/tr><tr><td><code>$handler<\/code><\/td><td>array<\/td><td>Matched handler<\/td><\/tr><tr><td><code>$response<\/code><\/td><td>WP_Error|null<\/td><td>Pre-existing error<\/td><\/tr><\/tbody><\/table><\/figure><p><strong>Returns:<\/strong> Response from callback.<\/p><p><strong>Flow:<\/strong><\/p><ol class=\"wp-block-list\"><li><code>rest_request_before_callbacks<\/code> filter<\/li><li>Calls <code>permission_callback<\/code><\/li><li><code>rest_dispatch_request<\/code> filter<\/li><li>Calls <code>callback<\/code><\/li><li><code>rest_request_after_callbacks<\/code> filter<\/li><\/ol><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">get_index()<\/h3><p>Retrieves the site index (root endpoint).<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">public function get_index( WP_REST_Request $request ): WP_REST_Response<\/code><\/pre><\/div><figure class=\"wp-block-table\"><table><thead><tr><th>Parameter<\/th><th>Type<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>$request<\/code><\/td><td>WP_REST_Request<\/td><td>Request object<\/td><\/tr><\/tbody><\/table><\/figure><p><strong>Returns:<\/strong> Response with site info, namespaces, routes, authentication.<\/p><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">get_namespace_index()<\/h3><p>Retrieves index for a namespace.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">public function get_namespace_index( WP_REST_Request $request ): WP_REST_Response|WP_Error<\/code><\/pre><\/div><figure class=\"wp-block-table\"><table><thead><tr><th>Parameter<\/th><th>Type<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>$request<\/code><\/td><td>WP_REST_Request<\/td><td>Request with <code>namespace<\/code> param<\/td><\/tr><\/tbody><\/table><\/figure><p><strong>Returns:<\/strong> Response with namespace routes or error if not found.<\/p><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">get_data_for_routes()<\/h3><p>Retrieves publicly-visible data for routes.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">public function get_data_for_routes( array $routes, string $context = &#039;view&#039; ): array[]<\/code><\/pre><\/div><figure class=\"wp-block-table\"><table><thead><tr><th>Parameter<\/th><th>Type<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>$routes<\/code><\/td><td>array<\/td><td>Routes to describe<\/td><\/tr><tr><td><code>$context<\/code><\/td><td>string<\/td><td><code>view<\/code> or <code>help<\/code><\/td><\/tr><\/tbody><\/table><\/figure><p><strong>Returns:<\/strong> Route data keyed by route.<\/p><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">get_data_for_route()<\/h3><p>Retrieves publicly-visible data for a single route.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">public function get_data_for_route( string $route, array $callbacks, string $context = &#039;view&#039; ): array|null<\/code><\/pre><\/div><figure class=\"wp-block-table\"><table><thead><tr><th>Parameter<\/th><th>Type<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>$route<\/code><\/td><td>string<\/td><td>Route pattern<\/td><\/tr><tr><td><code>$callbacks<\/code><\/td><td>array<\/td><td>Route callbacks<\/td><\/tr><tr><td><code>$context<\/code><\/td><td>string<\/td><td>Data context<\/td><\/tr><\/tbody><\/table><\/figure><p><strong>Returns:<\/strong> Route data or <code>null<\/code> if hidden.<\/p><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">serve_batch_request_v1()<\/h3><p>Serves batch API requests.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">public function serve_batch_request_v1( WP_REST_Request $batch_request ): WP_REST_Response<\/code><\/pre><\/div><figure class=\"wp-block-table\"><table><thead><tr><th>Parameter<\/th><th>Type<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>$batch_request<\/code><\/td><td>WP_REST_Request<\/td><td>Batch request with <code>requests<\/code> array<\/td><\/tr><\/tbody><\/table><\/figure><p><strong>Returns:<\/strong> Response with <code>responses<\/code> array (207 Multi-Status).<\/p><p><strong>Request Format:<\/strong><\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">json<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-json\"><code class=\"language-json\">{\n    &quot;validation&quot;: &quot;normal&quot;,\n    &quot;requests&quot;: [\n        { &quot;path&quot;: &quot;\/wp\/v2\/posts\/1&quot;, &quot;method&quot;: &quot;PUT&quot;, &quot;body&quot;: {}, &quot;headers&quot;: {} }\n    ]\n}<\/code><\/pre><\/div><p><strong>Validation Modes:<\/strong><\/p><ul class=\"wp-block-list\"><li><code>normal<\/code> \u2014 Execute all, return individual results<\/li><li><code>require-all-validate<\/code> \u2014 Abort if any request fails validation<\/li><\/ul><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">send_header()<\/h3><p>Sends an HTTP header.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">public function send_header( string $key, string $value ): void<\/code><\/pre><\/div><figure class=\"wp-block-table\"><table><thead><tr><th>Parameter<\/th><th>Type<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>$key<\/code><\/td><td>string<\/td><td>Header name<\/td><\/tr><tr><td><code>$value<\/code><\/td><td>string<\/td><td>Header value<\/td><\/tr><\/tbody><\/table><\/figure><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">send_headers()<\/h3><p>Sends multiple HTTP headers.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">public function send_headers( array $headers ): void<\/code><\/pre><\/div><figure class=\"wp-block-table\"><table><thead><tr><th>Parameter<\/th><th>Type<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>$headers<\/code><\/td><td>array<\/td><td>Map of header name to value<\/td><\/tr><\/tbody><\/table><\/figure><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">remove_header()<\/h3><p>Removes an HTTP header.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">public function remove_header( string $key ): void<\/code><\/pre><\/div><figure class=\"wp-block-table\"><table><thead><tr><th>Parameter<\/th><th>Type<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>$key<\/code><\/td><td>string<\/td><td>Header name<\/td><\/tr><\/tbody><\/table><\/figure><p><strong>Since:<\/strong> 4.8.0<\/p><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">get_raw_data() <small>(static)<\/small><\/h3><p>Retrieves raw request body.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">public static function get_raw_data(): string<\/code><\/pre><\/div><p><strong>Returns:<\/strong> Raw <code>php:\/\/input<\/code> contents.<\/p><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">get_headers()<\/h3><p>Extracts headers from <code>$_SERVER<\/code> array.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">public function get_headers( array $server ): array<\/code><\/pre><\/div><figure class=\"wp-block-table\"><table><thead><tr><th>Parameter<\/th><th>Type<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>$server<\/code><\/td><td>array<\/td><td>Server variables<\/td><\/tr><\/tbody><\/table><\/figure><p><strong>Returns:<\/strong> Extracted headers.<\/p><p>Handles:<\/p><ul class=\"wp-block-list\"><li><code>HTTP_*<\/code> prefixed headers<\/li><li><code>CONTENT_TYPE<\/code>, <code>CONTENT_LENGTH<\/code>, <code>CONTENT_MD5<\/code><\/li><li><code>REDIRECT_HTTP_AUTHORIZATION<\/code> fallback<\/li><\/ul><hr class=\"wp-block-separator\"\/><h2 class=\"wp-block-heading\">Protected Methods<\/h2><h3 class=\"wp-block-heading\">error_to_response()<\/h3><p>Converts <code>WP_Error<\/code> to response object.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">protected function error_to_response( WP_Error $error ): WP_REST_Response<\/code><\/pre><\/div><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">json_error()<\/h3><p>Gets JSON error representation.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">protected function json_error( string $code, string $message, int|null $status = null ): string<\/code><\/pre><\/div><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">get_json_encode_options()<\/h3><p>Gets JSON encoding options.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">protected function get_json_encode_options( WP_REST_Request $request ): int<\/code><\/pre><\/div><p>Respects <code>_pretty<\/code> param for pretty printing.<\/p><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">embed_links()<\/h3><p>Embeds links into response data.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">protected function embed_links( array $data, bool|string[] $embed = true ): array<\/code><\/pre><\/div><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">get_json_last_error()<\/h3><p>Gets last JSON encoding error message.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">protected function get_json_last_error(): false|string<\/code><\/pre><\/div><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">set_status()<\/h3><p>Sends HTTP status code.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">protected function set_status( int $code ): void<\/code><\/pre><\/div><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">get_max_batch_size()<\/h3><p>Gets maximum batch request size.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">protected function get_max_batch_size(): int<\/code><\/pre><\/div><p><strong>Returns:<\/strong> Default 25, filterable via <code>rest_get_max_batch_size<\/code>.<\/p><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">add_active_theme_link_to_index()<\/h3><p>Adds active theme link to index response.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">protected function add_active_theme_link_to_index( WP_REST_Response $response ): void<\/code><\/pre><\/div><p><strong>Since:<\/strong> 5.7.0<\/p><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">add_site_logo_to_index()<\/h3><p>Adds site logo to index response.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">protected function add_site_logo_to_index( WP_REST_Response $response ): void<\/code><\/pre><\/div><p><strong>Since:<\/strong> 5.8.0<\/p><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">add_site_icon_to_index()<\/h3><p>Adds site icon to index response.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">protected function add_site_icon_to_index( WP_REST_Response $response ): void<\/code><\/pre><\/div><p><strong>Since:<\/strong> 5.9.0<\/p><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">add_image_to_index()<\/h3><p>Adds image data to index response.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">protected function add_image_to_index( WP_REST_Response $response, int $image_id, string $type ): void<\/code><\/pre><\/div><p><strong>Since:<\/strong> 5.9.0<\/p><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">get_target_hints_for_link() <small>(static)<\/small><\/h3><p>Gets target hints for a link.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">protected static function get_target_hints_for_link( array $link ): array|null<\/code><\/pre><\/div><p><strong>Since:<\/strong> 6.7.0<\/p>","protected":false},"excerpt":{"rendered":"<p>Core class implementing the WordPress REST API server. Handles route registration, request dispatch, and response formatting. Source: wp-includes\/rest-api\/class-wp-rest-server.php Since: 4.4.0 Constants Constant Value Description READABLE &#8216;GET&#8217; GET transport method CREATABLE&#8230;<\/p>\n","protected":false},"featured_media":0,"template":"","meta":{"footnotes":""},"tags":[],"project":[653],"project_type":[749],"class_list":["post-5760","documentation","type-documentation","status-publish","hentry","project-rest-api","project_type-wordpress-reference"],"project_info":{"id":589,"name":"WordPress Core","slug":"wordpress-core"},"project_type_info":{"id":749,"name":"WordPress Reference","slug":"wordpress-reference"},"_links":{"self":[{"href":"https:\/\/chubes.net\/wp-json\/wp\/v2\/documentation\/5760","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/chubes.net\/wp-json\/wp\/v2\/documentation"}],"about":[{"href":"https:\/\/chubes.net\/wp-json\/wp\/v2\/types\/documentation"}],"version-history":[{"count":5,"href":"https:\/\/chubes.net\/wp-json\/wp\/v2\/documentation\/5760\/revisions"}],"predecessor-version":[{"id":10960,"href":"https:\/\/chubes.net\/wp-json\/wp\/v2\/documentation\/5760\/revisions\/10960"}],"wp:attachment":[{"href":"https:\/\/chubes.net\/wp-json\/wp\/v2\/media?parent=5760"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chubes.net\/wp-json\/wp\/v2\/tags?post=5760"},{"taxonomy":"project","embeddable":true,"href":"https:\/\/chubes.net\/wp-json\/wp\/v2\/project?post=5760"},{"taxonomy":"project_type","embeddable":true,"href":"https:\/\/chubes.net\/wp-json\/wp\/v2\/project_type?post=5760"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}