Skip to content

Commit

Permalink
Editor: Remove edit template menu item from block settings menu in bl…
Browse files Browse the repository at this point in the history
…ocks outside template. (#65560)

Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: kevin940726 <kevin940726@git.wordpress.org>
  • Loading branch information
5 people committed Sep 23, 2024
1 parent 51d0f20 commit 058cc63
Showing 1 changed file with 13 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ function ContentOnlySettingsMenuItems( { clientId, onClose } ) {
getBlockParentsByBlockName,
getSettings,
getBlockAttributes,
getBlockParents,
} = select( blockEditorStore );
const { getCurrentTemplateId, getRenderingMode } =
select( editorStore );
const patternParent = getBlockParentsByBlockName(
clientId,
'core/block',
Expand All @@ -41,23 +44,17 @@ function ContentOnlySettingsMenuItems( { clientId, onClose } ) {
'wp_block',
getBlockAttributes( patternParent ).ref
);
} else {
const { getCurrentTemplateId } = select( editorStore );
const templateId = getCurrentTemplateId();
const { getBlockParents } = unlock(
select( blockEditorStore )
} else if (
getRenderingMode() === 'template-locked' &&
! getBlockParents( clientId ).some( ( parent ) =>
postContentBlocks.includes( parent )
)
) {
record = select( coreStore ).getEntityRecord(
'postType',
'wp_template',
getCurrentTemplateId()
);
if (
! getBlockParents( clientId ).some( ( parent ) =>
postContentBlocks.includes( parent )
)
) {
record = select( coreStore ).getEntityRecord(
'postType',
'wp_template',
templateId
);
}
}
if ( ! record ) {
return {};
Expand Down

0 comments on commit 058cc63

Please sign in to comment.