WordPress.org

Make WordPress Core


Ignore:
Timestamp:
12/11/2018 04:00:37 AM (3 years ago)
Author:
jorbin
Message:

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.

Merges [43681] to trunk.

Props TimothyBlynJacobs, danielbachhuber.
Fixes #44750.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php

    r43604 r43973  
    376376        // Wrap the data in a response object.
    377377        $response = rest_ensure_response( $data );
    378         $response->add_links( $links );
     378
     379        foreach ( $links as $rel => $rel_links ) {
     380            foreach ( $rel_links as $link ) {
     381                $response->add_link( $rel, $link['href'], $link['attributes'] );
     382            }
     383        }
    379384
    380385        /**
Note: See TracChangeset for help on using the changeset viewer.