mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +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:
@@ -49,8 +49,21 @@ $preload_paths = array(
|
||||
sprintf( '/wp/v2/%s/%s?context=edit', $rest_base, $post->ID ),
|
||||
sprintf( '/wp/v2/types/%s?context=edit', $post_type ),
|
||||
sprintf( '/wp/v2/users/me?post_type=%s&context=edit', $post_type ),
|
||||
array( '/wp/v2/media', 'OPTIONS' ),
|
||||
);
|
||||
|
||||
/**
|
||||
* Preload common data by specifying an array of REST API paths that will be preloaded.
|
||||
*
|
||||
* Filters the array of paths that will be preloaded.
|
||||
*
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param array $preload_paths Array of paths to preload.
|
||||
* @param object $post The post resource data.
|
||||
*/
|
||||
$preload_paths = apply_filters( 'block_editor_preload_paths', $preload_paths, $post );
|
||||
|
||||
/*
|
||||
* Ensure the global $post remains the same after API data is preloaded.
|
||||
* Because API preloading can call the_content and other filters, plugins
|
||||
|
||||
Reference in New Issue
Block a user