mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-04 20:54:29 +00:00
Block Editor: Preload wp/v2/media with OPTIONS for caps check.
Also introduces a `block_editor_preload_paths` filter for plugins and themes to preload additional data. Merges [43833] from the 5.0 branch to trunk. Props imath, mattheu, danielbachhuber. Fixes #45194. git-svn-id: https://develop.svn.wordpress.org/trunk@44172 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -721,4 +721,25 @@ class Tests_REST_API extends WP_UnitTestCase {
|
||||
function test_rest_preload_api_request_no_notices_php_52() {
|
||||
$this->assertTrue( is_array( rest_preload_api_request( 0, '/' ) ) );
|
||||
}
|
||||
|
||||
function test_rest_preload_api_request_with_method() {
|
||||
$rest_server = $GLOBALS['wp_rest_server'];
|
||||
$GLOBALS['wp_rest_server'] = null;
|
||||
|
||||
$preload_paths = array(
|
||||
'/wp/v2/types',
|
||||
array( '/wp/v2/media', 'OPTIONS' ),
|
||||
);
|
||||
|
||||
$preload_data = array_reduce(
|
||||
$preload_paths,
|
||||
'rest_preload_api_request',
|
||||
array()
|
||||
);
|
||||
|
||||
$this->assertSame( array_keys( $preload_data ), array( '/wp/v2/types', 'OPTIONS' ) );
|
||||
$this->assertTrue( isset( $preload_data['OPTIONS']['/wp/v2/media'] ) );
|
||||
|
||||
$GLOBALS['wp_rest_server'] = $rest_server;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user