Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions packages/editor/src/dataviews/store/private-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,19 +133,28 @@ export const registerPostTypeSchema =
.resolveSelect( coreStore )
.getCurrentTheme();

let canDuplicate =
! [ 'wp_block', 'wp_template_part' ].includes(
postTypeConfig.slug
) &&
canCreate &&
duplicatePost;

// @ts-ignore
if ( ! globalThis.IS_GUTENBERG_PLUGIN ) {
// Outside Gutenberg, disable duplication except for wp_template.
if ( 'wp_template' !== postTypeConfig.slug ) {
canDuplicate = undefined;
}
}

const actions = [
postTypeConfig.viewable ? viewPost : undefined,
!! postTypeConfig.supports?.revisions
? viewPostRevisions
: undefined,
// @ts-ignore
globalThis.IS_GUTENBERG_PLUGIN
? ! [ 'wp_block', 'wp_template_part' ].includes(
postTypeConfig.slug
) &&
canCreate &&
duplicatePost
: undefined,
canDuplicate,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this make the duplicate action available for any post type (but wp_block, wp_template_part, page) in WordPress?

Note these actions are also used in the inspector of the post editor:

Screenshot 2025-10-21 at 11 28 52

We could enabling it just for templates, regardless of environment (gutenberg/wordpress).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch @oandregal, it is making it available for posts too on the inspector. cc: @ellatrix

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I didn't know this affects the post editor

postTypeConfig.slug === 'wp_template_part' &&
canCreate &&
currentTheme?.is_block_theme
Expand Down
Loading