Extracts the links from a response into a structured hash, suitable for
direct output.
public static get_response_links ( WP_REST_Response $response ) : array | ||
$response | WP_REST_Response | Response to extract links from. |
Результат | array | Map of link relation to list of link hashes. |
/** * Prepare a response for inserting into a collection. * * @param WP_REST_Response $response Response object. * @return array Response data, ready for insertion into collection data. */ public function prepare_response_for_collection($response) { if (!$response instanceof WP_REST_Response) { return $response; } $data = (array) $response->get_data(); $links = WP_REST_Server::get_response_links($response); if (!empty($links)) { $data['_links'] = $links; } return $data; }