From c1ddf45869830739a20e28711a55baed5dcaaf0b Mon Sep 17 00:00:00 2001 From: danielbachhuber Date: Mon, 8 Oct 2018 18:19:28 +0000 Subject: [PATCH] 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 --- .../endpoints/class-wp-rest-attachments-controller.php | 7 ++++++- wp-includes/version.php | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php index ac357a0ef1..f9cf02f344 100644 --- a/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php +++ b/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php @@ -372,7 +372,12 @@ class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { // Wrap the data in a response object. $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. diff --git a/wp-includes/version.php b/wp-includes/version.php index 4c001fcdcf..4d8a14922b 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @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.