-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Site Editor: preload settings requests
- Loading branch information
Showing
3 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
/** | ||
* Preload necessary resources for the editors. | ||
* | ||
* @param array $paths REST API paths to preload. | ||
* @param WP_Block_Editor_Context $context Current block editor context | ||
* | ||
* @return array Filtered preload paths. | ||
*/ | ||
function gutenberg_block_editor_preload_paths_6_8( $paths, $context ) { | ||
if ( 'core/edit-site' === $context->name ) { | ||
$paths[] = '/wp/v2/settings'; | ||
$paths[] = array( '/wp/v2/settings', 'OPTIONS' ); | ||
// Append a pseudo context value to allow preloading twice. `canUser` | ||
// uses the same path. Ideally the raw result is cached and used by both | ||
// `canUser` and `loadSiteEntity`. | ||
$paths[] = array( '/wp/v2/settings?context=schema', 'OPTIONS' ); | ||
} | ||
return $paths; | ||
} | ||
add_filter( 'block_editor_rest_api_preload_paths', 'gutenberg_block_editor_preload_paths_6_8', 10, 2 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters