Skip to content

Commit

Permalink
Avoid showing Edit Template menu items for post content children
Browse files Browse the repository at this point in the history
  • Loading branch information
talldan committed Oct 24, 2024
1 parent 207efd6 commit 6015e32
Showing 1 changed file with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,25 @@ function ContentOnlySettingsMenuItems( { clientId, onClose } ) {
getBlockAttributes( patternParent ).ref
);
} else {
const { getCurrentTemplateId } = select( editorStore );
const templateId = getCurrentTemplateId();
const { getContentLockingParent } = unlock(
select( blockEditorStore )
);
if ( ! getContentLockingParent( clientId ) && templateId ) {
record = select( coreStore ).getEntityRecord(
'postType',
'wp_template',
templateId
const postContentParent = getBlockParentsByBlockName(
clientId,
'core/post-content',
true
)[ 0 ];

if ( ! postContentParent ) {
const { getCurrentTemplateId } = select( editorStore );
const templateId = getCurrentTemplateId();
const { getContentLockingParent } = unlock(
select( blockEditorStore )
);
if ( ! getContentLockingParent( clientId ) && templateId ) {
record = select( coreStore ).getEntityRecord(
'postType',
'wp_template',
templateId
);
}
}
}
const _canEditTemplates = select( coreStore ).canUser( 'create', {
Expand Down

0 comments on commit 6015e32

Please sign in to comment.