WordPress.org

Make WordPress Core

Changeset 43973


Ignore:
Timestamp:
12/11/2018 04:00:37 AM (2 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:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/package-lock.json

    r43634 r43973  
    11{
    22    "name": "WordPress",
    3     "version": "5.0.0",
     3    "version": "5.1.0",
    44    "lockfileVersion": 1,
    55    "requires": true,
  • trunk/src/wp-admin/includes/template.php

    r43665 r43973  
    12571257    $page = $screen->id;
    12581258
    1259     $hidden = get_hidden_meta_boxes( $screen );
     1259    $hidden     = get_hidden_meta_boxes( $screen );
    12601260    ?>
    12611261    <div id="side-sortables" class="accordion-container">
  • trunk/src/wp-includes/media-template.php

    r43633 r43973  
    9797    <# if ( h ) { #>height="{{ h }}"<# } #>
    9898    <?php
    99     $props = array(
     99    $props       = array(
    100100        'poster'  => '',
    101101        'preload' => 'metadata',
  • 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        /**
  • trunk/tests/phpunit/tests/rest-api/rest-attachments-controller.php

    r43571 r43973  
    14681468
    14691469        $this->assertArrayHasKey( 'self', $links );
     1470        $this->assertArrayHasKey( 'author', $links );
     1471
     1472        $this->assertCount( 1, $links['author'] );
     1473        $this->assertArrayHasKey( 'embeddable', $links['author'][0]['attributes'] );
     1474        $this->assertTrue( $links['author'][0]['attributes']['embeddable'] );
    14701475    }
    14711476
  • trunk/tests/qunit/fixtures/wp-api-generated.js

    r43585 r43973  
    40804080            "self": [
    40814081                {
    4082                     "attributes": [],
    40834082                    "href": "http://example.org/index.php?rest_route=/wp/v2/media/8"
    40844083                }
     
    40864085            "collection": [
    40874086                {
    4088                     "attributes": [],
    40894087                    "href": "http://example.org/index.php?rest_route=/wp/v2/media"
    40904088                }
     
    40924090            "about": [
    40934091                {
    4094                     "attributes": [],
    40954092                    "href": "http://example.org/index.php?rest_route=/wp/v2/types/attachment"
    40964093                }
     
    40984095            "replies": [
    40994096                {
    4100                     "attributes": {
    4101                         "embeddable": true
    4102                     },
     4097                    "embeddable": true,
    41034098                    "href": "http://example.org/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8"
    41044099                }
Note: See TracChangeset for help on using the changeset viewer.