REST API: Persist attributes for attachment links

In [43437], the link definition implementation caused attachment links to be unexpectedly nested under an `attributes` key. This changeset restores the prior behavior.

Props TimothyBlynJacobs.
Fixes #44750.

Built from https://develop.svn.wordpress.org/branches/5.0@43681


git-svn-id: http://core.svn.wordpress.org/branches/5.0@43510 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
danielbachhuber 2018-10-08 18:19:28 +00:00
parent 62a35c8545
commit c1ddf45869
2 changed files with 7 additions and 2 deletions

View File

@ -372,7 +372,12 @@ class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller {
// Wrap the data in a response object. // Wrap the data in a response object.
$response = rest_ensure_response( $data ); $response = rest_ensure_response( $data );
$response->add_links( $links );
foreach ( $links as $rel => $rel_links ) {
foreach ( $rel_links as $link ) {
$response->add_link( $rel, $link['href'], $link['attributes'] );
}
}
/** /**
* Filters an attachment returned from the REST API. * Filters an attachment returned from the REST API.

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.0-alpha-43680'; $wp_version = '5.0-alpha-43681';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.