diff --git a/lib/compat/wordpress-6.1/edit-form-blocks.php b/lib/compat/wordpress-6.1/edit-form-blocks.php index 5edea87825a49..fd2414f228b20 100644 --- a/lib/compat/wordpress-6.1/edit-form-blocks.php +++ b/lib/compat/wordpress-6.1/edit-form-blocks.php @@ -15,6 +15,7 @@ function gutenberg_preload_template_permissions( $preload_paths, $context ) { if ( ! empty( $context->post ) ) { $preload_paths[] = array( rest_get_route_for_post_type_items( 'wp_template' ), 'OPTIONS' ); + $preload_paths[] = array( '/wp/v2/settings', 'OPTIONS' ); } return $preload_paths; diff --git a/packages/edit-post/src/editor.js b/packages/edit-post/src/editor.js index 057ca18363795..43852bc7c8f5c 100644 --- a/packages/edit-post/src/editor.js +++ b/packages/edit-post/src/editor.js @@ -56,7 +56,7 @@ function Editor( { getEditedPostTemplate, getHiddenBlockTypes, } = select( editPostStore ); - const { getEntityRecord, getPostType, getEntityRecords } = + const { getEntityRecord, getPostType, getEntityRecords, canUser } = select( coreStore ); const { getEditorSettings } = select( editorStore ); const { getBlockTypes } = select( blocksStore ); @@ -77,6 +77,7 @@ function Editor( { const supportsTemplateMode = getEditorSettings().supportsTemplateMode; const isViewable = getPostType( postType )?.viewable ?? false; + const canEditTemplate = canUser( 'create', 'templates' ); return { hasFixedToolbar: @@ -94,7 +95,7 @@ function Editor( { keepCaretInsideBlock: isFeatureActive( 'keepCaretInsideBlock' ), isTemplateMode: isEditingTemplate(), template: - supportsTemplateMode && isViewable + supportsTemplateMode && isViewable && canEditTemplate ? getEditedPostTemplate() : null, post: postObject, diff --git a/packages/editor/src/components/provider/use-block-editor-settings.js b/packages/editor/src/components/provider/use-block-editor-settings.js index 67cce96cde058..8d19074f9524c 100644 --- a/packages/editor/src/components/provider/use-block-editor-settings.js +++ b/packages/editor/src/components/provider/use-block-editor-settings.js @@ -41,7 +41,9 @@ function useBlockEditorSettings( settings, hasTemplate ) { const isWeb = Platform.OS === 'web'; const { canUser, getEntityRecord } = select( coreStore ); - const siteSettings = getEntityRecord( 'root', 'site' ); + const siteSettings = canUser( 'read', 'settings' ) + ? getEntityRecord( 'root', 'site' ) + : undefined; return { canUseUnfilteredHTML: canUserUseUnfilteredHTML(),