REST API: Support embedding links in rest_preload_api_request().

Props lpawlik, spacedmonkey.
Fixes #51722.


git-svn-id: https://develop.svn.wordpress.org/trunk@50005 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Timothy Jacobs
2021-01-23 23:25:40 +00:00
parent d4eac17e3d
commit bb395706f4
2 changed files with 54 additions and 5 deletions

View File

@@ -2520,11 +2520,8 @@ function rest_preload_api_request( $memo, $path ) {
$response = rest_do_request( $request );
if ( 200 === $response->status ) {
$server = rest_get_server();
$data = (array) $response->get_data();
$links = $server::get_compact_response_links( $response );
if ( ! empty( $links ) ) {
$data['_links'] = $links;
}
$embed = $request->has_param( '_embed' ) ? rest_parse_embed_param( $request['_embed'] ) : false;
$data = (array) $server->response_to_data( $response, $embed );
if ( 'OPTIONS' === $method ) {
$response = rest_send_allow_header( $response, $server, $request );