Skip to content

Commit

Permalink
Returning the _links from the preloaded endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Jun 5, 2018
1 parent 5f2b411 commit e743830
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -504,8 +504,19 @@ function gutenberg_preload_api_request( $memo, $path ) {

$response = rest_do_request( $request );
if ( 200 === $response->status ) {
$server = rest_get_server();
$data = (array) $response->get_data();
if ( method_exists( $server, 'get_compact_response_links' ) ) {
$links = call_user_func( array( $server, 'get_compact_response_links' ), $response );
} else {
$links = call_user_func( array( $server, 'get_response_links' ), $response );
}
if ( ! empty( $links ) ) {
$data['_links'] = $links;
}

$memo[ $path ] = array(
'body' => $response->data,
'body' => $data,
'headers' => $response->headers,
);
}
Expand Down

0 comments on commit e743830

Please sign in to comment.