Skip to content

Commit

Permalink
Edit Post: Avoid fetching the edited template for non-viewable posts (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka authored Sep 5, 2023
1 parent 9d7892e commit c162b0d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/edit-post/src/components/visual-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,18 @@ export default function VisualEditor( { styles } ) {
select( editorStore );
const { getBlockTypes } = select( blocksStore );
const _isTemplateMode = isEditingTemplate();
const postTypeSlug = getCurrentPostType();
let _wrapperBlockName;

if ( getCurrentPostType() === 'wp_block' ) {
if ( postTypeSlug === 'wp_block' ) {
_wrapperBlockName = 'core/block';
} else if ( ! _isTemplateMode ) {
_wrapperBlockName = 'core/post-content';
}

const editorSettings = getEditorSettings();
const supportsTemplateMode = editorSettings.supportsTemplateMode;
const postType = select( coreStore ).getPostType( postTypeSlug );
const canEditTemplate = select( coreStore ).canUser(
'create',
'templates'
Expand All @@ -146,7 +148,7 @@ export default function VisualEditor( { styles } ) {
// Post template fetch returns a 404 on classic themes, which
// messes with e2e tests, so check it's a block theme first.
editedPostTemplate:
supportsTemplateMode && canEditTemplate
postType?.viewable && supportsTemplateMode && canEditTemplate
? getEditedPostTemplate()
: undefined,
wrapperBlockName: _wrapperBlockName,
Expand Down

0 comments on commit c162b0d

Please sign in to comment.