Uses
Uses | Description |
---|---|
wp-includes/rest-api.php: rest_get_server() | Retrieves the current REST server instance. |
Prepares a response for insertion into a collection.
(WP_REST_Response) (Required) Response object.
(array|mixed) Response data, ready for insertion into collection data.
File: wp-includes/rest-api/endpoints/class-wp-rest-controller.php
public function prepare_response_for_collection( $response ) { if ( ! ( $response instanceof WP_REST_Response ) ) { return $response; } $data = (array) $response->get_data(); $server = rest_get_server(); $links = $server::get_compact_response_links( $response ); if ( ! empty( $links ) ) { $data['_links'] = $links; } return $data; }
Version | Description |
---|---|
4.7.0 | Introduced. |
© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_rest_controller/prepare_response_for_collection