Used By
Used By | Description |
---|---|
wp-includes/rest-api/class-wp-rest-server.php: WP_REST_Server::get_compact_response_links() | Retrieves the CURIEs (compact URIs) used for relations. |
Retrieves links from a response.
Extracts the links from a response into a structured hash, suitable for direct output.
(WP_REST_Response) (Required) Response to extract links from.
(array) Map of link relation to list of link hashes.
File: wp-includes/rest-api/class-wp-rest-server.php
public static function get_response_links( $response ) { $links = $response->get_links(); if ( empty( $links ) ) { return array(); } // Convert links to part of the data. $data = array(); foreach ( $links as $rel => $items ) { $data[ $rel ] = array(); foreach ( $items as $item ) { $attributes = $item['attributes']; $attributes['href'] = $item['href']; $data[ $rel ][] = $attributes; } } return $data; }
Version | Description |
---|---|
4.4.0 | Introduced. |
© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_rest_server/get_response_links