[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/rest-api/ -> class-wp-rest-response.php (summary)

REST API: WP_REST_Response class

File Size: 293 lines (7 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

WP_REST_Response:: (12 methods):
  add_link()
  remove_link()
  add_links()
  get_links()
  link_header()
  get_matched_route()
  set_matched_route()
  get_matched_handler()
  set_matched_handler()
  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.

param: string $rel        Link relation. Either an IANA registered type,
param: string $href       Target URI for the link.
param: array  $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 $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 $links Map of link relation to list of links.

get_links()   X-Ref
Retrieves links for the response.

return: array List of links.

link_header( $rel, $link, $other = array()   X-Ref
Sets a single link header.

param: string $rel   Link relation. Either an IANA registered type, or an absolute URL.
param: string $link  Target IRI for the link.
param: array  $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: null|array 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 $handler The matched handler.

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 Compact URIs.



Generated : Sat Dec 21 08:20:01 2024 Cross-referenced by PHPXref