| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Source view] [Print] [Project Stats]
REST API: WP_REST_Response class
| File Size: | 400 lines (12 kb) |
| Included or required: | 0 times |
| Referenced: | 0 times |
| Includes or requires: | 0 files |
WP_REST_Response:: (14 methods):
add_link()
remove_link()
add_links()
get_links()
link_header()
get_matched_route()
set_matched_route()
get_matched_handler()
set_matched_handler()
get_data_processing()
set_data_processing()
is_error()
as_error()
get_curies()
Class: WP_REST_Response - X-Ref
Core class used to implement a REST response object.| add_link( $rel, $href, $attributes = array() X-Ref |
| Adds a link to the response. {@internal The $rel parameter is first, as this looks nicer when sending multiple.} param: string $rel Link relation. Either an IANA registered type, param: string $href Target URI for the link. param: array<string, mixed> $attributes Optional. Link parameters to send along with the URL. Default empty array. |
| remove_link( $rel, $href = null ) X-Ref |
| Removes a link from the response. param: string $rel Link relation. Either an IANA registered type, or an absolute URL. param: string|null $href Optional. Only remove links for the relation matching the given href. |
| add_links( $links ) X-Ref |
| Adds multiple links to the response. Link data should be an associative array with link relation as the key. The value can either be an associative array of link attributes (including `href` with the URL for the response), or a list of these associative arrays. param: array<string, array<mixed>> $links Map of link relation to a link's attributes, or to a list of these. |
| get_links() X-Ref |
| Retrieves links for the response. return: array<string, array<string, mixed>[]> Map of link relation to list of links. |
| link_header( $rel, $link, $other = array() X-Ref |
| Sets a single link header. {@internal The $rel parameter is first, as this looks nicer when sending multiple.} param: string $rel Link relation. Either an IANA registered type, or an absolute URL. param: string $link Target IRI for the link. param: array<string, string> $other Optional. Other parameters to send, as an associative array. |
| get_matched_route() X-Ref |
| Retrieves the route that was used. return: string The matched route. |
| set_matched_route( $route ) X-Ref |
| Sets the route (regex for path) that caused the response. param: string $route Route name. |
| get_matched_handler() X-Ref |
| Retrieves the handler that was used to generate the response. return: array<string, mixed>|null The handler that was used to create the response. |
| set_matched_handler( $handler ) X-Ref |
| Sets the handler that was responsible for generating the response. param: array<string, mixed> $handler The matched handler. |
| get_data_processing() X-Ref |
| Retrieves whether each data processing feature is on for the response. The server sets the settings of the matched route when it dispatches a request, for responses returned by the `rest_pre_dispatch` filter too. Every feature is on until then. return: array<string, bool> { |
| set_data_processing( $processing ) X-Ref |
| Sets whether each data processing feature is on for the response. The setting takes the form of the `data_processing` route option: `false` turns off every feature, and an array turns off, or on, the features it names. Embedding needs the links, so `embed` is off whenever `links` is off. param: bool|array<string, bool> $processing Whether every feature is on, or whether the `fields`, `embed` |
| is_error() X-Ref |
| Checks if the response is an error, i.e. >= 400 response code. return: bool Whether the response is an error. |
| as_error() X-Ref |
| Retrieves a WP_Error object from the response. return: WP_Error|null WP_Error or null on not an errored response. |
| get_curies() X-Ref |
| Retrieves the CURIEs (compact URIs) used for relations. return: array<string, string|bool>[] Compact URIs. |
| Generated : Thu Oct 29 08:20:35 2026 | Cross-referenced by PHPXref |