WordPress.org

Make WordPress Core

Changeset 48656


Ignore:
Timestamp:
07/28/2020 04:08:56 AM (6 months ago)
Author:
TimothyBlynJacobs
Message:

REST API: Remove assets field from block directory controller.

Gutenberg no longer uses the assets field to fetch the assets for the installed block so this field can be dropped from the endpoint. This allows us to reintroduce it at a later point without needing to worry about backward compatibility.

See #50732.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-block-directory-controller.php

    r48242 r48656  
    130130            'author'              => wp_strip_all_tags( $plugin['author'] ),
    131131            'icon'                => ( isset( $plugin['icons']['1x'] ) ? $plugin['icons']['1x'] : 'block-default' ),
    132             'assets'              => array(),
    133132            'last_updated'        => gmdate( 'Y-m-d\TH:i:s', strtotime( $plugin['last_updated'] ) ),
    134133            'humanized_updated'   => sprintf(
     
    138137            ),
    139138        );
    140 
    141         foreach ( $plugin['block_assets'] as $asset ) {
    142             // Allow for fully qualified URLs in future
    143             if ( 'https' === wp_parse_url( $asset, PHP_URL_SCHEME ) && ! empty( wp_parse_url( $asset, PHP_URL_HOST ) ) ) {
    144                 $block['assets'][] = esc_url_raw(
    145                     $asset,
    146                     array( 'https' )
    147                 );
    148             } else {
    149                 $block['assets'][] = esc_url_raw(
    150                     add_query_arg( 'v', strtotime( $block['last_updated'] ), 'https://ps.w.org/' . $plugin['slug'] . $asset ),
    151                     array( 'https' )
    152                 );
    153             }
    154         }
    155139
    156140        $this->add_additional_fields_to_object( $block, $request );
     
    296280                    'type'        => 'string',
    297281                    'context'     => array( 'view' ),
    298                 ),
    299                 'assets'              => array(
    300                     'description' => __( 'An object representing the block CSS and JavaScript assets.' ),
    301                     'type'        => 'array',
    302                     'context'     => array( 'view' ),
    303                     'readonly'    => true,
    304                     'items'       => array(
    305                         'type'   => 'string',
    306                         'format' => 'uri',
    307                     ),
    308282                ),
    309283            ),
  • trunk/tests/phpunit/tests/rest-api/rest-block-directory-controller.php

    r48333 r48656  
    163163            'author'              => 'sorta brilliant',
    164164            'icon'                => 'https://ps.w.org/guidepost/assets/icon-128x128.jpg?rev=2235512',
    165             'assets'              => array(
    166                 'https://ps.w.org/guidepost/tags/1.2.1/build/index.js?v=1584940380',
    167                 'https://ps.w.org/guidepost/tags/1.2.1/build/guidepost-editor.css?v=1584940380',
    168                 'https://ps.w.org/guidepost/tags/1.2.1/build/guidepost-style.css?v=1584940380',
    169                 'https://ps.w.org/guidepost/tags/1.2.1/build/guidepost-theme.js?v=1584940380',
    170             ),
    171165            'last_updated'        => gmdate( 'Y-m-d\TH:i:s', strtotime( $plugin['last_updated'] ) ),
    172166            'humanized_updated'   => sprintf( '%s ago', human_time_diff( strtotime( $plugin['last_updated'] ) ) ),
     
    193187        $properties = $data['schema']['properties'];
    194188
    195         $this->assertCount( 14, $properties );
     189        $this->assertCount( 13, $properties );
    196190        $this->assertArrayHasKey( 'name', $properties );
    197191        $this->assertArrayHasKey( 'title', $properties );
     
    207201        $this->assertArrayHasKey( 'last_updated', $properties );
    208202        $this->assertArrayHasKey( 'humanized_updated', $properties );
    209         $this->assertArrayHasKey( 'assets', $properties );
    210203    }
    211204
Note: See TracChangeset for help on using the changeset viewer.