Skip to content

Commit

Permalink
one problem at a time
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Oct 29, 2024
1 parent 520b75b commit 5be281b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 11 deletions.
7 changes: 2 additions & 5 deletions lib/compat/wordpress-6.8/preload.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@
*/
function gutenberg_block_editor_preload_paths_6_8( $paths, $context ) {
if ( 'core/edit-site' === $context->name ) {
// Core already preloads both of these for `core/edit-post`.
$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 );
add_filter( 'block_editor_rest_api_preload_paths', 'gutenberg_block_editor_preload_paths_6_8', 10, 2 );
6 changes: 1 addition & 5 deletions packages/core-data/src/entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -418,11 +418,7 @@ async function loadSiteEntity() {
};

const site = await apiFetch( {
// 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`.
// Please check the preloaded paths whenever this is changed.
path: entity.baseURL + '?context=schema',
path: entity.baseURL,
method: 'OPTIONS',
} );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ function useResolveEditedEntityAndContext( { postId, postType } ) {
frontPageTemplateId,
} = useSelect( ( select ) => {
const { getEntityRecord, getEntityRecords } = select( coreDataStore );
// Please check the preloaded paths whenever this is changed.
const siteData = getEntityRecord( 'root', 'site' );
const base = getEntityRecord( 'root', '__unstableBase' );
const templates = getEntityRecords( 'postType', TEMPLATE_POST_TYPE, {
Expand Down

0 comments on commit 5be281b

Please sign in to comment.