Changeset 44172
- Timestamp:
- 12/14/2018 06:01:24 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/5.0 merged: 43833
- Property svn:mergeinfo changed
-
trunk/src/wp-admin/edit-form-blocks.php
r44165 r44172 50 50 sprintf( '/wp/v2/types/%s?context=edit', $post_type ), 51 51 sprintf( '/wp/v2/users/me?post_type=%s&context=edit', $post_type ), 52 ); 52 array( '/wp/v2/media', 'OPTIONS' ), 53 ); 54 55 /** 56 * Preload common data by specifying an array of REST API paths that will be preloaded. 57 * 58 * Filters the array of paths that will be preloaded. 59 * 60 * @since 5.0.0 61 * 62 * @param array $preload_paths Array of paths to preload. 63 * @param object $post The post resource data. 64 */ 65 $preload_paths = apply_filters( 'block_editor_preload_paths', $preload_paths, $post ); 53 66 54 67 /* -
trunk/src/wp-includes/rest-api.php
r44150 r44172 1343 1343 } 1344 1344 1345 $method = 'GET'; 1346 if ( is_array( $path ) && 2 === count( $path ) ) { 1347 $method = end( $path ); 1348 $path = reset( $path ); 1349 1350 if ( ! in_array( $method, array( 'GET', 'OPTIONS' ), true ) ) { 1351 $method = 'GET'; 1352 } 1353 } 1354 1345 1355 $path_parts = parse_url( $path ); 1346 1356 if ( false === $path_parts ) { … … 1348 1358 } 1349 1359 1350 $request = new WP_REST_Request( 'GET', $path_parts['path'] );1360 $request = new WP_REST_Request( $method, $path_parts['path'] ); 1351 1361 if ( ! empty( $path_parts['query'] ) ) { 1352 1362 parse_str( $path_parts['query'], $query_params ); … … 1367 1377 } 1368 1378 1369 $memo[ $path ] = array( 1370 'body' => $data, 1371 'headers' => $response->headers, 1372 ); 1379 if ( 'OPTIONS' === $method ) { 1380 $response = rest_send_allow_header( $response, $server, $request ); 1381 1382 $memo[ $method ][ $path ] = array( 1383 'body' => $data, 1384 'headers' => $response->headers, 1385 ); 1386 } else { 1387 $memo[ $path ] = array( 1388 'body' => $data, 1389 'headers' => $response->headers, 1390 ); 1391 } 1373 1392 } 1374 1393 -
trunk/tests/phpunit/tests/rest-api.php
r44123 r44172 722 722 $this->assertTrue( is_array( rest_preload_api_request( 0, '/' ) ) ); 723 723 } 724 725 function test_rest_preload_api_request_with_method() { 726 $rest_server = $GLOBALS['wp_rest_server']; 727 $GLOBALS['wp_rest_server'] = null; 728 729 $preload_paths = array( 730 '/wp/v2/types', 731 array( '/wp/v2/media', 'OPTIONS' ), 732 ); 733 734 $preload_data = array_reduce( 735 $preload_paths, 736 'rest_preload_api_request', 737 array() 738 ); 739 740 $this->assertSame( array_keys( $preload_data ), array( '/wp/v2/types', 'OPTIONS' ) ); 741 $this->assertTrue( isset( $preload_data['OPTIONS']['/wp/v2/media'] ) ); 742 743 $GLOBALS['wp_rest_server'] = $rest_server; 744 } 724 745 }
Note: See TracChangeset
for help on using the changeset viewer.