Skip to content

Commit

Permalink
Don't allow duplicating template parts in non-block-based themes (#64379
Browse files Browse the repository at this point in the history
)

Co-authored-by: t-hamano <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: MadtownLems <[email protected]>
  • Loading branch information
4 people committed Sep 4, 2024
1 parent 1b15571 commit 583c332
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/editor/src/components/post-actions/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1055,17 +1055,23 @@ 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 {
postTypeObject: _postTypeObject,
resource: _resource,
cachedCanUserResolvers: getCachedResolvers()?.canUser,
userCanCreatePostType: canUser( 'create', _resource ),
isBlockBasedTheme: getCurrentTheme()?.is_block_theme,
};
},
[ postType ]
Expand Down Expand Up @@ -1099,6 +1105,7 @@ export function usePostActions( { postType, onActionPerformed, context } ) {
: false,
isTemplateOrTemplatePart &&
userCanCreatePostType &&
isBlockBasedTheme &&
duplicateTemplatePartAction,
isPattern && userCanCreatePostType && duplicatePatternAction,
supportsTitle && renamePostActionForPostType,
Expand Down

0 comments on commit 583c332

Please sign in to comment.