diff --git a/lib/compat/wordpress-6.6/rest-api.php b/lib/compat/wordpress-6.6/rest-api.php index bf462cd11ca4b4..40fdc681934370 100644 --- a/lib/compat/wordpress-6.6/rest-api.php +++ b/lib/compat/wordpress-6.6/rest-api.php @@ -29,3 +29,16 @@ function wp_api_template_access_controller( $args, $post_type ) { } } add_filter( 'register_post_type_args', 'wp_api_template_access_controller', 10, 2 ); + +function gutenberg_block_editor_preload_paths_6_6( $paths, $context ) { + if ( 'core/edit-site' === $context->name ) { + // When merging back to core, these should be added here: + // https://github.com/WordPress/wordpress-develop/blob/7159243c090e429a7d2a1fd2a9509e323f67a39d/src/wp-admin/site-editor.php#L90-L117 + $paths[] = array( '/wp/v2/settings', 'OPTIONS' ); + $paths[] = '/wp/v2/settings'; + $paths[] = array( '/wp/v2/templates', 'OPTIONS' ); + $paths[] = '/wp/v2/types?context=edit'; + } + return $paths; +} +add_filter( 'block_editor_rest_api_preload_paths', 'gutenberg_block_editor_preload_paths_6_6', 10, 2 ); diff --git a/packages/core-commands/src/hooks.js b/packages/core-commands/src/hooks.js index 6d744e3223234d..5a0b4f8c96b81a 100644 --- a/packages/core-commands/src/hooks.js +++ b/packages/core-commands/src/hooks.js @@ -5,6 +5,7 @@ import { store as coreStore } from '@wordpress/core-data'; import { useSelect } from '@wordpress/data'; export function useIsTemplatesAccessible() { + // This resource is preloaded. return useSelect( ( select ) => select( coreStore ).canUser( 'read', 'templates' ), [] diff --git a/packages/edit-site/src/components/editor/index.js b/packages/edit-site/src/components/editor/index.js index d6773e5a24d899..470bb578cbaf1b 100644 --- a/packages/edit-site/src/components/editor/index.js +++ b/packages/edit-site/src/components/editor/index.js @@ -146,6 +146,7 @@ export default function Editor( { isLoading, onClick } ) { isDistractionFree: get( 'core', 'distractionFree' ), showBlockBreadcrumbs: get( 'core', 'showBlockBreadcrumbs' ), showIconLabels: get( 'core', 'showIconLabels' ), + // This resource is preloaded. postTypeLabel: getPostTypeLabel(), }; }, [] ); diff --git a/packages/edit-site/src/components/sync-state-with-url/use-init-edited-entity-from-url.js b/packages/edit-site/src/components/sync-state-with-url/use-init-edited-entity-from-url.js index 8cfb0bca716f2f..bcbb0744a422d0 100644 --- a/packages/edit-site/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +++ b/packages/edit-site/src/components/sync-state-with-url/use-init-edited-entity-from-url.js @@ -35,10 +35,10 @@ function useResolveEditedEntityAndContext( { path, postId, postType } ) { url, frontPageTemplateId, } = useSelect( ( select ) => { - const { getSite, getUnstableBase, getEntityRecords } = - select( coreDataStore ); + const { getSite, getEntityRecords } = select( coreDataStore ); + // This resource is preloaded. const siteData = getSite(); - const base = getUnstableBase(); + // This resource is preloaded. const templates = getEntityRecords( 'postType', TEMPLATE_POST_TYPE, { per_page: -1, } ); @@ -63,10 +63,10 @@ function useResolveEditedEntityAndContext( { path, postId, postType } ) { : false; } return { - hasLoadedAllDependencies: !! base && !! siteData, + hasLoadedAllDependencies: !! siteData, homepageId: _homepageId, postsPageId: _postsPageId, - url: base?.home, + url: siteData?.home, frontPageTemplateId: _frontPageTemplateId, }; }, [] );