From 583c3324e6e1596e64046f347340fb14bdd199ee Mon Sep 17 00:00:00 2001 From: Vicente Canales <1157901+vcanales@users.noreply.github.com> Date: Wed, 4 Sep 2024 07:35:11 -0400 Subject: [PATCH] Don't allow duplicating template parts in non-block-based themes (#64379) Co-authored-by: t-hamano Co-authored-by: Mamaduka Co-authored-by: MadtownLems --- .../editor/src/components/post-actions/actions.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/editor/src/components/post-actions/actions.js b/packages/editor/src/components/post-actions/actions.js index 5286b5e65a820..000497cfc8626 100644 --- a/packages/editor/src/components/post-actions/actions.js +++ b/packages/editor/src/components/post-actions/actions.js @@ -1055,10 +1055,15 @@ export function usePostActions( { postType, onActionPerformed, context } ) { resource, cachedCanUserResolvers, userCanCreatePostType, + isBlockBasedTheme, } = useSelect( ( select ) => { - const { getPostType, getCachedResolvers, canUser } = - select( coreStore ); + const { + getPostType, + getCachedResolvers, + canUser, + getCurrentTheme, + } = select( coreStore ); const _postTypeObject = getPostType( postType ); const _resource = _postTypeObject?.rest_base || ''; return { @@ -1066,6 +1071,7 @@ export function usePostActions( { postType, onActionPerformed, context } ) { resource: _resource, cachedCanUserResolvers: getCachedResolvers()?.canUser, userCanCreatePostType: canUser( 'create', _resource ), + isBlockBasedTheme: getCurrentTheme()?.is_block_theme, }; }, [ postType ] @@ -1099,6 +1105,7 @@ export function usePostActions( { postType, onActionPerformed, context } ) { : false, isTemplateOrTemplatePart && userCanCreatePostType && + isBlockBasedTheme && duplicateTemplatePartAction, isPattern && userCanCreatePostType && duplicatePatternAction, supportsTitle && renamePostActionForPostType,