Changeset 48656
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-block-directory-controller.php
r48242 r48656 130 130 'author' => wp_strip_all_tags( $plugin['author'] ), 131 131 'icon' => ( isset( $plugin['icons']['1x'] ) ? $plugin['icons']['1x'] : 'block-default' ), 132 'assets' => array(),133 132 'last_updated' => gmdate( 'Y-m-d\TH:i:s', strtotime( $plugin['last_updated'] ) ), 134 133 'humanized_updated' => sprintf( … … 138 137 ), 139 138 ); 140 141 foreach ( $plugin['block_assets'] as $asset ) {142 // Allow for fully qualified URLs in future143 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 }155 139 156 140 $this->add_additional_fields_to_object( $block, $request ); … … 296 280 'type' => 'string', 297 281 '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 ),308 282 ), 309 283 ), -
trunk/tests/phpunit/tests/rest-api/rest-block-directory-controller.php
r48333 r48656 163 163 'author' => 'sorta brilliant', 164 164 '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 ),171 165 'last_updated' => gmdate( 'Y-m-d\TH:i:s', strtotime( $plugin['last_updated'] ) ), 172 166 'humanized_updated' => sprintf( '%s ago', human_time_diff( strtotime( $plugin['last_updated'] ) ) ), … … 193 187 $properties = $data['schema']['properties']; 194 188 195 $this->assertCount( 1 4, $properties );189 $this->assertCount( 13, $properties ); 196 190 $this->assertArrayHasKey( 'name', $properties ); 197 191 $this->assertArrayHasKey( 'title', $properties ); … … 207 201 $this->assertArrayHasKey( 'last_updated', $properties ); 208 202 $this->assertArrayHasKey( 'humanized_updated', $properties ); 209 $this->assertArrayHasKey( 'assets', $properties );210 203 } 211 204
Note: See TracChangeset
for help on using the changeset viewer.