@wordpress/editor 14.33.1 → 14.33.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -99,13 +99,19 @@ const registerPostTypeSchema = (postType) => async ({ registry }) => {
99
99
  name: postType
100
100
  });
101
101
  const currentTheme = await registry.resolveSelect(import_core_data.store).getCurrentTheme();
102
+ let canDuplicate = !["wp_block", "wp_template_part"].includes(
103
+ postTypeConfig.slug
104
+ ) && canCreate && import_fields.duplicatePost;
105
+ if (!globalThis.IS_GUTENBERG_PLUGIN) {
106
+ if ("wp_template" !== postTypeConfig.slug) {
107
+ canDuplicate = void 0;
108
+ }
109
+ }
102
110
  const actions = [
103
111
  postTypeConfig.viewable ? import_fields.viewPost : void 0,
104
112
  !!postTypeConfig.supports?.revisions ? import_fields.viewPostRevisions : void 0,
105
113
  // @ts-ignore
106
- globalThis.IS_GUTENBERG_PLUGIN ? !["wp_block", "wp_template_part"].includes(
107
- postTypeConfig.slug
108
- ) && canCreate && import_fields.duplicatePost : void 0,
114
+ canDuplicate,
109
115
  postTypeConfig.slug === "wp_template_part" && canCreate && currentTheme?.is_block_theme ? import_fields.duplicateTemplatePart : void 0,
110
116
  canCreate && postTypeConfig.slug === "wp_block" ? import_fields.duplicatePattern : void 0,
111
117
  postTypeConfig.supports?.title ? import_fields.renamePost : void 0,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/dataviews/store/private-actions.ts"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { Action, Field } from '@wordpress/dataviews';\nimport { doAction } from '@wordpress/hooks';\nimport type { PostType } from '@wordpress/fields';\nimport {\n\tviewPost,\n\tviewPostRevisions,\n\tduplicatePost,\n\tduplicatePattern,\n\treorderPage,\n\texportPattern,\n\tpermanentlyDeletePost,\n\trestorePost,\n\ttrashPost,\n\trenamePost,\n\tresetPost,\n\tdeletePost,\n\tduplicateTemplatePart,\n\tfeaturedImageField,\n\tdateField,\n\tparentField,\n\tpasswordField,\n\tcommentStatusField,\n\tpingStatusField,\n\tdiscussionField,\n\tslugField,\n\tstatusField,\n\tauthorField,\n\ttitleField,\n\ttemplateField,\n\ttemplateTitleField,\n\tpageTitleField,\n\tpatternTitleField,\n} from '@wordpress/fields';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport postPreviewField from '../fields/content-preview';\nimport { unlock } from '../../lock-unlock';\n\nexport function registerEntityAction< Item >(\n\tkind: string,\n\tname: string,\n\tconfig: Action< Item >\n) {\n\treturn {\n\t\ttype: 'REGISTER_ENTITY_ACTION' as const,\n\t\tkind,\n\t\tname,\n\t\tconfig,\n\t};\n}\n\nexport function unregisterEntityAction(\n\tkind: string,\n\tname: string,\n\tactionId: string\n) {\n\treturn {\n\t\ttype: 'UNREGISTER_ENTITY_ACTION' as const,\n\t\tkind,\n\t\tname,\n\t\tactionId,\n\t};\n}\n\nexport function registerEntityField< Item >(\n\tkind: string,\n\tname: string,\n\tconfig: Field< Item >\n) {\n\treturn {\n\t\ttype: 'REGISTER_ENTITY_FIELD' as const,\n\t\tkind,\n\t\tname,\n\t\tconfig,\n\t};\n}\n\nexport function unregisterEntityField(\n\tkind: string,\n\tname: string,\n\tfieldId: string\n) {\n\treturn {\n\t\ttype: 'UNREGISTER_ENTITY_FIELD' as const,\n\t\tkind,\n\t\tname,\n\t\tfieldId,\n\t};\n}\n\nexport function setIsReady( kind: string, name: string ) {\n\treturn {\n\t\ttype: 'SET_IS_READY' as const,\n\t\tkind,\n\t\tname,\n\t};\n}\n\nexport const registerPostTypeSchema =\n\t( postType: string ) =>\n\tasync ( { registry }: { registry: any } ) => {\n\t\tconst isReady = unlock( registry.select( editorStore ) ).isEntityReady(\n\t\t\t'postType',\n\t\t\tpostType\n\t\t);\n\t\tif ( isReady ) {\n\t\t\treturn;\n\t\t}\n\n\t\tunlock( registry.dispatch( editorStore ) ).setIsReady(\n\t\t\t'postType',\n\t\t\tpostType\n\t\t);\n\n\t\tconst postTypeConfig = ( await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.getPostType( postType ) ) as PostType;\n\n\t\tconst canCreate = await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: postType,\n\t\t\t} );\n\t\tconst currentTheme = await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.getCurrentTheme();\n\n\t\tconst actions = [\n\t\t\tpostTypeConfig.viewable ? viewPost : undefined,\n\t\t\t!! postTypeConfig.supports?.revisions\n\t\t\t\t? viewPostRevisions\n\t\t\t\t: undefined,\n\t\t\t// @ts-ignore\n\t\t\tglobalThis.IS_GUTENBERG_PLUGIN\n\t\t\t\t? ! [ 'wp_block', 'wp_template_part' ].includes(\n\t\t\t\t\t\tpostTypeConfig.slug\n\t\t\t\t ) &&\n\t\t\t\t canCreate &&\n\t\t\t\t duplicatePost\n\t\t\t\t: undefined,\n\t\t\tpostTypeConfig.slug === 'wp_template_part' &&\n\t\t\tcanCreate &&\n\t\t\tcurrentTheme?.is_block_theme\n\t\t\t\t? duplicateTemplatePart\n\t\t\t\t: undefined,\n\t\t\tcanCreate && postTypeConfig.slug === 'wp_block'\n\t\t\t\t? duplicatePattern\n\t\t\t\t: undefined,\n\t\t\tpostTypeConfig.supports?.title ? renamePost : undefined,\n\t\t\tpostTypeConfig.supports?.[ 'page-attributes' ]\n\t\t\t\t? reorderPage\n\t\t\t\t: undefined,\n\t\t\tpostTypeConfig.slug === 'wp_block' ? exportPattern : undefined,\n\t\t\trestorePost,\n\t\t\tresetPost,\n\t\t\tdeletePost,\n\t\t\ttrashPost,\n\t\t\tpermanentlyDeletePost,\n\t\t].filter( Boolean );\n\n\t\tconst fields = [\n\t\t\tpostTypeConfig.supports?.thumbnail &&\n\t\t\t\tcurrentTheme?.theme_supports?.[ 'post-thumbnails' ] &&\n\t\t\t\tfeaturedImageField,\n\t\t\tpostTypeConfig.supports?.author && authorField,\n\t\t\tstatusField,\n\t\t\tdateField,\n\t\t\tslugField,\n\t\t\tpostTypeConfig.supports?.[ 'page-attributes' ] && parentField,\n\t\t\tpostTypeConfig.supports?.comments && commentStatusField,\n\t\t\tpostTypeConfig.supports?.trackbacks && pingStatusField,\n\t\t\t( postTypeConfig.supports?.comments ||\n\t\t\t\tpostTypeConfig.supports?.trackbacks ) &&\n\t\t\t\tdiscussionField,\n\t\t\ttemplateField,\n\t\t\tpasswordField,\n\t\t\tpostTypeConfig.supports?.editor &&\n\t\t\t\tpostTypeConfig.viewable &&\n\t\t\t\tpostPreviewField,\n\t\t].filter( Boolean );\n\t\tif ( postTypeConfig.supports?.title ) {\n\t\t\tlet _titleField;\n\t\t\tif ( postType === 'page' ) {\n\t\t\t\t_titleField = pageTitleField;\n\t\t\t} else if ( postType === 'wp_template' ) {\n\t\t\t\t_titleField = templateTitleField;\n\t\t\t} else if ( postType === 'wp_block' ) {\n\t\t\t\t_titleField = patternTitleField;\n\t\t\t} else {\n\t\t\t\t_titleField = titleField;\n\t\t\t}\n\t\t\tfields.push( _titleField );\n\t\t}\n\n\t\tregistry.batch( () => {\n\t\t\tactions.forEach( ( action ) => {\n\t\t\t\tunlock( registry.dispatch( editorStore ) ).registerEntityAction(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\taction\n\t\t\t\t);\n\t\t\t} );\n\t\t\tfields.forEach( ( field ) => {\n\t\t\t\tunlock( registry.dispatch( editorStore ) ).registerEntityField(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\tfield\n\t\t\t\t);\n\t\t\t} );\n\t\t} );\n\n\t\tdoAction( 'core.registerPostTypeSchema', postType );\n\t};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,uBAAmC;AAEnC,mBAAy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B,qCAAQ,SAAS,SAAU,aAAAA,KAAY,CAAE,EAAE;AAAA,QAC1C;AAAA,QACA;AAAA,QACA;AAAA,MACD;AAAA,IACD,CAAE;AAAA,EACH,CAAE;AAEF,6BAAU,+BAA+B,QAAS;AACnD;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { Action, Field } from '@wordpress/dataviews';\nimport { doAction } from '@wordpress/hooks';\nimport type { PostType } from '@wordpress/fields';\nimport {\n\tviewPost,\n\tviewPostRevisions,\n\tduplicatePost,\n\tduplicatePattern,\n\treorderPage,\n\texportPattern,\n\tpermanentlyDeletePost,\n\trestorePost,\n\ttrashPost,\n\trenamePost,\n\tresetPost,\n\tdeletePost,\n\tduplicateTemplatePart,\n\tfeaturedImageField,\n\tdateField,\n\tparentField,\n\tpasswordField,\n\tcommentStatusField,\n\tpingStatusField,\n\tdiscussionField,\n\tslugField,\n\tstatusField,\n\tauthorField,\n\ttitleField,\n\ttemplateField,\n\ttemplateTitleField,\n\tpageTitleField,\n\tpatternTitleField,\n} from '@wordpress/fields';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport postPreviewField from '../fields/content-preview';\nimport { unlock } from '../../lock-unlock';\n\nexport function registerEntityAction< Item >(\n\tkind: string,\n\tname: string,\n\tconfig: Action< Item >\n) {\n\treturn {\n\t\ttype: 'REGISTER_ENTITY_ACTION' as const,\n\t\tkind,\n\t\tname,\n\t\tconfig,\n\t};\n}\n\nexport function unregisterEntityAction(\n\tkind: string,\n\tname: string,\n\tactionId: string\n) {\n\treturn {\n\t\ttype: 'UNREGISTER_ENTITY_ACTION' as const,\n\t\tkind,\n\t\tname,\n\t\tactionId,\n\t};\n}\n\nexport function registerEntityField< Item >(\n\tkind: string,\n\tname: string,\n\tconfig: Field< Item >\n) {\n\treturn {\n\t\ttype: 'REGISTER_ENTITY_FIELD' as const,\n\t\tkind,\n\t\tname,\n\t\tconfig,\n\t};\n}\n\nexport function unregisterEntityField(\n\tkind: string,\n\tname: string,\n\tfieldId: string\n) {\n\treturn {\n\t\ttype: 'UNREGISTER_ENTITY_FIELD' as const,\n\t\tkind,\n\t\tname,\n\t\tfieldId,\n\t};\n}\n\nexport function setIsReady( kind: string, name: string ) {\n\treturn {\n\t\ttype: 'SET_IS_READY' as const,\n\t\tkind,\n\t\tname,\n\t};\n}\n\nexport const registerPostTypeSchema =\n\t( postType: string ) =>\n\tasync ( { registry }: { registry: any } ) => {\n\t\tconst isReady = unlock( registry.select( editorStore ) ).isEntityReady(\n\t\t\t'postType',\n\t\t\tpostType\n\t\t);\n\t\tif ( isReady ) {\n\t\t\treturn;\n\t\t}\n\n\t\tunlock( registry.dispatch( editorStore ) ).setIsReady(\n\t\t\t'postType',\n\t\t\tpostType\n\t\t);\n\n\t\tconst postTypeConfig = ( await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.getPostType( postType ) ) as PostType;\n\n\t\tconst canCreate = await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: postType,\n\t\t\t} );\n\t\tconst currentTheme = await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.getCurrentTheme();\n\n\t\tlet canDuplicate =\n\t\t\t! [ 'wp_block', 'wp_template_part' ].includes(\n\t\t\t\tpostTypeConfig.slug\n\t\t\t) &&\n\t\t\tcanCreate &&\n\t\t\tduplicatePost;\n\n\t\t// @ts-ignore\n\t\tif ( ! globalThis.IS_GUTENBERG_PLUGIN ) {\n\t\t\t// Outside Gutenberg, disable duplication except for wp_template.\n\t\t\tif ( 'wp_template' !== postTypeConfig.slug ) {\n\t\t\t\tcanDuplicate = undefined;\n\t\t\t}\n\t\t}\n\n\t\tconst actions = [\n\t\t\tpostTypeConfig.viewable ? viewPost : undefined,\n\t\t\t!! postTypeConfig.supports?.revisions\n\t\t\t\t? viewPostRevisions\n\t\t\t\t: undefined,\n\t\t\t// @ts-ignore\n\t\t\tcanDuplicate,\n\t\t\tpostTypeConfig.slug === 'wp_template_part' &&\n\t\t\tcanCreate &&\n\t\t\tcurrentTheme?.is_block_theme\n\t\t\t\t? duplicateTemplatePart\n\t\t\t\t: undefined,\n\t\t\tcanCreate && postTypeConfig.slug === 'wp_block'\n\t\t\t\t? duplicatePattern\n\t\t\t\t: undefined,\n\t\t\tpostTypeConfig.supports?.title ? renamePost : undefined,\n\t\t\tpostTypeConfig.supports?.[ 'page-attributes' ]\n\t\t\t\t? reorderPage\n\t\t\t\t: undefined,\n\t\t\tpostTypeConfig.slug === 'wp_block' ? exportPattern : undefined,\n\t\t\trestorePost,\n\t\t\tresetPost,\n\t\t\tdeletePost,\n\t\t\ttrashPost,\n\t\t\tpermanentlyDeletePost,\n\t\t].filter( Boolean );\n\n\t\tconst fields = [\n\t\t\tpostTypeConfig.supports?.thumbnail &&\n\t\t\t\tcurrentTheme?.theme_supports?.[ 'post-thumbnails' ] &&\n\t\t\t\tfeaturedImageField,\n\t\t\tpostTypeConfig.supports?.author && authorField,\n\t\t\tstatusField,\n\t\t\tdateField,\n\t\t\tslugField,\n\t\t\tpostTypeConfig.supports?.[ 'page-attributes' ] && parentField,\n\t\t\tpostTypeConfig.supports?.comments && commentStatusField,\n\t\t\tpostTypeConfig.supports?.trackbacks && pingStatusField,\n\t\t\t( postTypeConfig.supports?.comments ||\n\t\t\t\tpostTypeConfig.supports?.trackbacks ) &&\n\t\t\t\tdiscussionField,\n\t\t\ttemplateField,\n\t\t\tpasswordField,\n\t\t\tpostTypeConfig.supports?.editor &&\n\t\t\t\tpostTypeConfig.viewable &&\n\t\t\t\tpostPreviewField,\n\t\t].filter( Boolean );\n\t\tif ( postTypeConfig.supports?.title ) {\n\t\t\tlet _titleField;\n\t\t\tif ( postType === 'page' ) {\n\t\t\t\t_titleField = pageTitleField;\n\t\t\t} else if ( postType === 'wp_template' ) {\n\t\t\t\t_titleField = templateTitleField;\n\t\t\t} else if ( postType === 'wp_block' ) {\n\t\t\t\t_titleField = patternTitleField;\n\t\t\t} else {\n\t\t\t\t_titleField = titleField;\n\t\t\t}\n\t\t\tfields.push( _titleField );\n\t\t}\n\n\t\tregistry.batch( () => {\n\t\t\tactions.forEach( ( action ) => {\n\t\t\t\tunlock( registry.dispatch( editorStore ) ).registerEntityAction(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\taction\n\t\t\t\t);\n\t\t\t} );\n\t\t\tfields.forEach( ( field ) => {\n\t\t\t\tunlock( registry.dispatch( editorStore ) ).registerEntityField(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\tfield\n\t\t\t\t);\n\t\t\t} );\n\t\t} );\n\n\t\tdoAction( 'core.registerPostTypeSchema', postType );\n\t};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,uBAAmC;AAEnC,mBAAyB;AAEzB,oBA6BO;AAKP,mBAAqC;AACrC,6BAA6B;AAC7B,yBAAuB;AAEhB,SAAS,qBACf,MACA,MACA,QACC;AACD,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;AAEO,SAAS,uBACf,MACA,MACA,UACC;AACD,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;AAEO,SAAS,oBACf,MACA,MACA,QACC;AACD,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;AAEO,SAAS,sBACf,MACA,MACA,SACC;AACD,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;AAEO,SAAS,WAAY,MAAc,MAAe;AACxD,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;AAEO,MAAM,yB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AAA,IACnC;AAAA,IACA;AAAA,IACA;AAAA,IACA,eAAe,WAAY,iBAAkB,KAAK;AAAA,IAClD,eAAe,UAAU,YAAY;AAAA,IACrC,eAAe,UAAU,cAAc;AAAA,KACrC,eAAe,UAAU,YAC1B,eAAe,UAAU,eACzB;AAAA,IACD;AAAA,IACA;AAAA,IACA,eAAe,UAAU,UACxB,eAAe,YACf,uBAAAC;AAAA,EACF,EAAE,OAAQ,OAAQ;AAClB,MAAK,eAAe,UAAU,OAAQ;AACrC,QAAI;AACJ,QAAK,aAAa,QAAS;AAC1B,oBAAc;AAAA,IACf,WAAY,aAAa,eAAgB;AACxC,oBAAc;AAAA,IACf,WAAY,aAAa,YAAa;AACrC,oBAAc;AAAA,IACf,OAAO;AACN,oBAAc;AAAA,IACf;AACA,WAAO,KAAM,WAAY;AAAA,EAC1B;AAEA,WAAS,MAAO,MAAM;AACrB,YAAQ,QAAS,CAAE,WAAY;AAC9B,qCAAQ,SAAS,SAAU,aAAAF,KAAY,CAAE,EAAE;AAAA,QAC1C;AAAA,QACA;AAAA,QACA;AAAA,MACD;AAAA,IACD,CAAE;AACF,WAAO,QAAS,CAAE,UAAW;AAC5B,qCAAQ,SAAS,SAAU,aAAAA,KAAY,CAAE,EAAE;AAAA,QAC1C;AAAA,QACA;AAAA,QACA;AAAA,MACD;AAAA,IACD,CAAE;AAAA,EACH,CAAE;AAEF,6BAAU,+BAA+B,QAAS;AACnD;",
6
6
  "names": ["editorStore", "coreStore", "postPreviewField"]
7
7
  }
@@ -90,13 +90,19 @@ const registerPostTypeSchema = (postType) => async ({ registry }) => {
90
90
  name: postType
91
91
  });
92
92
  const currentTheme = await registry.resolveSelect(coreStore).getCurrentTheme();
93
+ let canDuplicate = !["wp_block", "wp_template_part"].includes(
94
+ postTypeConfig.slug
95
+ ) && canCreate && duplicatePost;
96
+ if (!globalThis.IS_GUTENBERG_PLUGIN) {
97
+ if ("wp_template" !== postTypeConfig.slug) {
98
+ canDuplicate = void 0;
99
+ }
100
+ }
93
101
  const actions = [
94
102
  postTypeConfig.viewable ? viewPost : void 0,
95
103
  !!postTypeConfig.supports?.revisions ? viewPostRevisions : void 0,
96
104
  // @ts-ignore
97
- globalThis.IS_GUTENBERG_PLUGIN ? !["wp_block", "wp_template_part"].includes(
98
- postTypeConfig.slug
99
- ) && canCreate && duplicatePost : void 0,
105
+ canDuplicate,
100
106
  postTypeConfig.slug === "wp_template_part" && canCreate && currentTheme?.is_block_theme ? duplicateTemplatePart : void 0,
101
107
  canCreate && postTypeConfig.slug === "wp_block" ? duplicatePattern : void 0,
102
108
  postTypeConfig.supports?.title ? renamePost : void 0,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/dataviews/store/private-actions.ts"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { Action, Field } from '@wordpress/dataviews';\nimport { doAction } from '@wordpress/hooks';\nimport type { PostType } from '@wordpress/fields';\nimport {\n\tviewPost,\n\tviewPostRevisions,\n\tduplicatePost,\n\tduplicatePattern,\n\treorderPage,\n\texportPattern,\n\tpermanentlyDeletePost,\n\trestorePost,\n\ttrashPost,\n\trenamePost,\n\tresetPost,\n\tdeletePost,\n\tduplicateTemplatePart,\n\tfeaturedImageField,\n\tdateField,\n\tparentField,\n\tpasswordField,\n\tcommentStatusField,\n\tpingStatusField,\n\tdiscussionField,\n\tslugField,\n\tstatusField,\n\tauthorField,\n\ttitleField,\n\ttemplateField,\n\ttemplateTitleField,\n\tpageTitleField,\n\tpatternTitleField,\n} from '@wordpress/fields';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport postPreviewField from '../fields/content-preview';\nimport { unlock } from '../../lock-unlock';\n\nexport function registerEntityAction< Item >(\n\tkind: string,\n\tname: string,\n\tconfig: Action< Item >\n) {\n\treturn {\n\t\ttype: 'REGISTER_ENTITY_ACTION' as const,\n\t\tkind,\n\t\tname,\n\t\tconfig,\n\t};\n}\n\nexport function unregisterEntityAction(\n\tkind: string,\n\tname: string,\n\tactionId: string\n) {\n\treturn {\n\t\ttype: 'UNREGISTER_ENTITY_ACTION' as const,\n\t\tkind,\n\t\tname,\n\t\tactionId,\n\t};\n}\n\nexport function registerEntityField< Item >(\n\tkind: string,\n\tname: string,\n\tconfig: Field< Item >\n) {\n\treturn {\n\t\ttype: 'REGISTER_ENTITY_FIELD' as const,\n\t\tkind,\n\t\tname,\n\t\tconfig,\n\t};\n}\n\nexport function unregisterEntityField(\n\tkind: string,\n\tname: string,\n\tfieldId: string\n) {\n\treturn {\n\t\ttype: 'UNREGISTER_ENTITY_FIELD' as const,\n\t\tkind,\n\t\tname,\n\t\tfieldId,\n\t};\n}\n\nexport function setIsReady( kind: string, name: string ) {\n\treturn {\n\t\ttype: 'SET_IS_READY' as const,\n\t\tkind,\n\t\tname,\n\t};\n}\n\nexport const registerPostTypeSchema =\n\t( postType: string ) =>\n\tasync ( { registry }: { registry: any } ) => {\n\t\tconst isReady = unlock( registry.select( editorStore ) ).isEntityReady(\n\t\t\t'postType',\n\t\t\tpostType\n\t\t);\n\t\tif ( isReady ) {\n\t\t\treturn;\n\t\t}\n\n\t\tunlock( registry.dispatch( editorStore ) ).setIsReady(\n\t\t\t'postType',\n\t\t\tpostType\n\t\t);\n\n\t\tconst postTypeConfig = ( await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.getPostType( postType ) ) as PostType;\n\n\t\tconst canCreate = await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: postType,\n\t\t\t} );\n\t\tconst currentTheme = await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.getCurrentTheme();\n\n\t\tconst actions = [\n\t\t\tpostTypeConfig.viewable ? viewPost : undefined,\n\t\t\t!! postTypeConfig.supports?.revisions\n\t\t\t\t? viewPostRevisions\n\t\t\t\t: undefined,\n\t\t\t// @ts-ignore\n\t\t\tglobalThis.IS_GUTENBERG_PLUGIN\n\t\t\t\t? ! [ 'wp_block', 'wp_template_part' ].includes(\n\t\t\t\t\t\tpostTypeConfig.slug\n\t\t\t\t ) &&\n\t\t\t\t canCreate &&\n\t\t\t\t duplicatePost\n\t\t\t\t: undefined,\n\t\t\tpostTypeConfig.slug === 'wp_template_part' &&\n\t\t\tcanCreate &&\n\t\t\tcurrentTheme?.is_block_theme\n\t\t\t\t? duplicateTemplatePart\n\t\t\t\t: undefined,\n\t\t\tcanCreate && postTypeConfig.slug === 'wp_block'\n\t\t\t\t? duplicatePattern\n\t\t\t\t: undefined,\n\t\t\tpostTypeConfig.supports?.title ? renamePost : undefined,\n\t\t\tpostTypeConfig.supports?.[ 'page-attributes' ]\n\t\t\t\t? reorderPage\n\t\t\t\t: undefined,\n\t\t\tpostTypeConfig.slug === 'wp_block' ? exportPattern : undefined,\n\t\t\trestorePost,\n\t\t\tresetPost,\n\t\t\tdeletePost,\n\t\t\ttrashPost,\n\t\t\tpermanentlyDeletePost,\n\t\t].filter( Boolean );\n\n\t\tconst fields = [\n\t\t\tpostTypeConfig.supports?.thumbnail &&\n\t\t\t\tcurrentTheme?.theme_supports?.[ 'post-thumbnails' ] &&\n\t\t\t\tfeaturedImageField,\n\t\t\tpostTypeConfig.supports?.author && authorField,\n\t\t\tstatusField,\n\t\t\tdateField,\n\t\t\tslugField,\n\t\t\tpostTypeConfig.supports?.[ 'page-attributes' ] && parentField,\n\t\t\tpostTypeConfig.supports?.comments && commentStatusField,\n\t\t\tpostTypeConfig.supports?.trackbacks && pingStatusField,\n\t\t\t( postTypeConfig.supports?.comments ||\n\t\t\t\tpostTypeConfig.supports?.trackbacks ) &&\n\t\t\t\tdiscussionField,\n\t\t\ttemplateField,\n\t\t\tpasswordField,\n\t\t\tpostTypeConfig.supports?.editor &&\n\t\t\t\tpostTypeConfig.viewable &&\n\t\t\t\tpostPreviewField,\n\t\t].filter( Boolean );\n\t\tif ( postTypeConfig.supports?.title ) {\n\t\t\tlet _titleField;\n\t\t\tif ( postType === 'page' ) {\n\t\t\t\t_titleField = pageTitleField;\n\t\t\t} else if ( postType === 'wp_template' ) {\n\t\t\t\t_titleField = templateTitleField;\n\t\t\t} else if ( postType === 'wp_block' ) {\n\t\t\t\t_titleField = patternTitleField;\n\t\t\t} else {\n\t\t\t\t_titleField = titleField;\n\t\t\t}\n\t\t\tfields.push( _titleField );\n\t\t}\n\n\t\tregistry.batch( () => {\n\t\t\tactions.forEach( ( action ) => {\n\t\t\t\tunlock( registry.dispatch( editorStore ) ).registerEntityAction(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\taction\n\t\t\t\t);\n\t\t\t} );\n\t\t\tfields.forEach( ( field ) => {\n\t\t\t\tunlock( registry.dispatch( editorStore ) ).registerEntityField(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\tfield\n\t\t\t\t);\n\t\t\t} );\n\t\t} );\n\n\t\tdoAction( 'core.registerPostTypeSchema', postType );\n\t};\n"],
5
- "mappings": "AAGA,SAAS,SAAS,iBAAiB;AAEnC,SAAS,gBAAgB;AAEzB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAKP,SAAS,SAAS,mBAAmB;AACrC,OAAO,sBAAsB;AAC7B,SAAS,cAAc;AAEhB,SAAS,qBACf,MACA,MACA,QACC;AACD,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;AAEO,SAAS,uBACf,MACA,MACA,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e,WAAY,iBAAkB,IAC1C,cACA;AAAA,IACH,eAAe,SAAS,aAAa,gBAAgB;AAAA,IACrD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,EAAE,OAAQ,OAAQ;AAElB,QAAM,SAAS;AAAA,IACd,eAAe,UAAU,aACxB,cAAc,iBAAkB,iBAAkB,KAClD;AAAA,IACD,eAAe,UAAU,UAAU;AAAA,IACnC;AAAA,IACA;AAAA,IACA;AAAA,IACA,eAAe,WAAY,iBAAkB,KAAK;AAAA,IAClD,eAAe,UAAU,YAAY;AAAA,IACrC,eAAe,UAAU,cAAc;AAAA,KACrC,eAAe,UAAU,YAC1B,eAAe,UAAU,eACzB;AAAA,IACD;AAAA,IACA;AAAA,IACA,eAAe,UAAU,UACxB,eAAe,YACf;AAAA,EACF,EAAE,OAAQ,OAAQ;AAClB,MAAK,eAAe,UAAU,OAAQ;AACrC,QAAI;AACJ,QAAK,aAAa,QAAS;AAC1B,oBAAc;AAAA,IACf,WAAY,aAAa,eAAgB;AACxC,oBAAc;AAAA,IACf,WAAY,aAAa,YAAa;AACrC,oBAAc;AAAA,IACf,OAAO;AACN,oBAAc;AAAA,IACf;AACA,WAAO,KAAM,WAAY;AAAA,EAC1B;AAEA,WAAS,MAAO,MAAM;AACrB,YAAQ,QAAS,CAAE,WAAY;AAC9B,aAAQ,SAAS,SAAU,WAAY,CAAE,EAAE;AAAA,QAC1C;AAAA,QACA;AAAA,QACA;AAAA,MACD;AAAA,IACD,CAAE;AACF,WAAO,QAAS,CAAE,UAAW;AAC5B,aAAQ,SAAS,SAAU,WAAY,CAAE,EAAE;AAAA,QAC1C;AAAA,QACA;AAAA,QACA;AAAA,MACD;AAAA,IACD,CAAE;AAAA,EACH,CAAE;AAEF,WAAU,+BAA+B,QAAS;AACnD;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { Action, Field } from '@wordpress/dataviews';\nimport { doAction } from '@wordpress/hooks';\nimport type { PostType } from '@wordpress/fields';\nimport {\n\tviewPost,\n\tviewPostRevisions,\n\tduplicatePost,\n\tduplicatePattern,\n\treorderPage,\n\texportPattern,\n\tpermanentlyDeletePost,\n\trestorePost,\n\ttrashPost,\n\trenamePost,\n\tresetPost,\n\tdeletePost,\n\tduplicateTemplatePart,\n\tfeaturedImageField,\n\tdateField,\n\tparentField,\n\tpasswordField,\n\tcommentStatusField,\n\tpingStatusField,\n\tdiscussionField,\n\tslugField,\n\tstatusField,\n\tauthorField,\n\ttitleField,\n\ttemplateField,\n\ttemplateTitleField,\n\tpageTitleField,\n\tpatternTitleField,\n} from '@wordpress/fields';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport postPreviewField from '../fields/content-preview';\nimport { unlock } from '../../lock-unlock';\n\nexport function registerEntityAction< Item >(\n\tkind: string,\n\tname: string,\n\tconfig: Action< Item >\n) {\n\treturn {\n\t\ttype: 'REGISTER_ENTITY_ACTION' as const,\n\t\tkind,\n\t\tname,\n\t\tconfig,\n\t};\n}\n\nexport function unregisterEntityAction(\n\tkind: string,\n\tname: string,\n\tactionId: string\n) {\n\treturn {\n\t\ttype: 'UNREGISTER_ENTITY_ACTION' as const,\n\t\tkind,\n\t\tname,\n\t\tactionId,\n\t};\n}\n\nexport function registerEntityField< Item >(\n\tkind: string,\n\tname: string,\n\tconfig: Field< Item >\n) {\n\treturn {\n\t\ttype: 'REGISTER_ENTITY_FIELD' as const,\n\t\tkind,\n\t\tname,\n\t\tconfig,\n\t};\n}\n\nexport function unregisterEntityField(\n\tkind: string,\n\tname: string,\n\tfieldId: string\n) {\n\treturn {\n\t\ttype: 'UNREGISTER_ENTITY_FIELD' as const,\n\t\tkind,\n\t\tname,\n\t\tfieldId,\n\t};\n}\n\nexport function setIsReady( kind: string, name: string ) {\n\treturn {\n\t\ttype: 'SET_IS_READY' as const,\n\t\tkind,\n\t\tname,\n\t};\n}\n\nexport const registerPostTypeSchema =\n\t( postType: string ) =>\n\tasync ( { registry }: { registry: any } ) => {\n\t\tconst isReady = unlock( registry.select( editorStore ) ).isEntityReady(\n\t\t\t'postType',\n\t\t\tpostType\n\t\t);\n\t\tif ( isReady ) {\n\t\t\treturn;\n\t\t}\n\n\t\tunlock( registry.dispatch( editorStore ) ).setIsReady(\n\t\t\t'postType',\n\t\t\tpostType\n\t\t);\n\n\t\tconst postTypeConfig = ( await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.getPostType( postType ) ) as PostType;\n\n\t\tconst canCreate = await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: postType,\n\t\t\t} );\n\t\tconst currentTheme = await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.getCurrentTheme();\n\n\t\tlet canDuplicate =\n\t\t\t! [ 'wp_block', 'wp_template_part' ].includes(\n\t\t\t\tpostTypeConfig.slug\n\t\t\t) &&\n\t\t\tcanCreate &&\n\t\t\tduplicatePost;\n\n\t\t// @ts-ignore\n\t\tif ( ! globalThis.IS_GUTENBERG_PLUGIN ) {\n\t\t\t// Outside Gutenberg, disable duplication except for wp_template.\n\t\t\tif ( 'wp_template' !== postTypeConfig.slug ) {\n\t\t\t\tcanDuplicate = undefined;\n\t\t\t}\n\t\t}\n\n\t\tconst actions = [\n\t\t\tpostTypeConfig.viewable ? viewPost : undefined,\n\t\t\t!! postTypeConfig.supports?.revisions\n\t\t\t\t? viewPostRevisions\n\t\t\t\t: undefined,\n\t\t\t// @ts-ignore\n\t\t\tcanDuplicate,\n\t\t\tpostTypeConfig.slug === 'wp_template_part' &&\n\t\t\tcanCreate &&\n\t\t\tcurrentTheme?.is_block_theme\n\t\t\t\t? duplicateTemplatePart\n\t\t\t\t: undefined,\n\t\t\tcanCreate && postTypeConfig.slug === 'wp_block'\n\t\t\t\t? duplicatePattern\n\t\t\t\t: undefined,\n\t\t\tpostTypeConfig.supports?.title ? renamePost : undefined,\n\t\t\tpostTypeConfig.supports?.[ 'page-attributes' ]\n\t\t\t\t? reorderPage\n\t\t\t\t: undefined,\n\t\t\tpostTypeConfig.slug === 'wp_block' ? exportPattern : undefined,\n\t\t\trestorePost,\n\t\t\tresetPost,\n\t\t\tdeletePost,\n\t\t\ttrashPost,\n\t\t\tpermanentlyDeletePost,\n\t\t].filter( Boolean );\n\n\t\tconst fields = [\n\t\t\tpostTypeConfig.supports?.thumbnail &&\n\t\t\t\tcurrentTheme?.theme_supports?.[ 'post-thumbnails' ] &&\n\t\t\t\tfeaturedImageField,\n\t\t\tpostTypeConfig.supports?.author && authorField,\n\t\t\tstatusField,\n\t\t\tdateField,\n\t\t\tslugField,\n\t\t\tpostTypeConfig.supports?.[ 'page-attributes' ] && parentField,\n\t\t\tpostTypeConfig.supports?.comments && commentStatusField,\n\t\t\tpostTypeConfig.supports?.trackbacks && pingStatusField,\n\t\t\t( postTypeConfig.supports?.comments ||\n\t\t\t\tpostTypeConfig.supports?.trackbacks ) &&\n\t\t\t\tdiscussionField,\n\t\t\ttemplateField,\n\t\t\tpasswordField,\n\t\t\tpostTypeConfig.supports?.editor &&\n\t\t\t\tpostTypeConfig.viewable &&\n\t\t\t\tpostPreviewField,\n\t\t].filter( Boolean );\n\t\tif ( postTypeConfig.supports?.title ) {\n\t\t\tlet _titleField;\n\t\t\tif ( postType === 'page' ) {\n\t\t\t\t_titleField = pageTitleField;\n\t\t\t} else if ( postType === 'wp_template' ) {\n\t\t\t\t_titleField = templateTitleField;\n\t\t\t} else if ( postType === 'wp_block' ) {\n\t\t\t\t_titleField = patternTitleField;\n\t\t\t} else {\n\t\t\t\t_titleField = titleField;\n\t\t\t}\n\t\t\tfields.push( _titleField );\n\t\t}\n\n\t\tregistry.batch( () => {\n\t\t\tactions.forEach( ( action ) => {\n\t\t\t\tunlock( registry.dispatch( editorStore ) ).registerEntityAction(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\taction\n\t\t\t\t);\n\t\t\t} );\n\t\t\tfields.forEach( ( field ) => {\n\t\t\t\tunlock( registry.dispatch( editorStore ) ).registerEntityField(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\tfield\n\t\t\t\t);\n\t\t\t} );\n\t\t} );\n\n\t\tdoAction( 'core.registerPostTypeSchema', postType );\n\t};\n"],
5
+ "mappings": "AAGA,SAAS,SAAS,iBAAiB;AAEnC,SAAS,gBAAgB;AAEzB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAKP,SAAS,SAAS,mBAAmB;AACrC,OAAO,sBAAsB;AAC7B,SAAS,cAAc;AAEhB,SAAS,qBACf,MACA,MACA,QACC;AACD,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;AAEO,SAAS,uBACf,MACA,MACA,UACC;AACD,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;AAEO,SAAS,oBACf,MACA,MACA,QACC;AACD,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;AAEO,SAAS,sBACf,MACA,MACA,SACC;AACD,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;AAEO,SAAS,WAAY,MAAc,MAAe;AACxD,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;AAEO,MAAM,yBACZ,CAAE,aACF,OAAQ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AK;AAAA,IAClD,eAAe,UAAU,YAAY;AAAA,IACrC,eAAe,UAAU,cAAc;AAAA,KACrC,eAAe,UAAU,YAC1B,eAAe,UAAU,eACzB;AAAA,IACD;AAAA,IACA;AAAA,IACA,eAAe,UAAU,UACxB,eAAe,YACf;AAAA,EACF,EAAE,OAAQ,OAAQ;AAClB,MAAK,eAAe,UAAU,OAAQ;AACrC,QAAI;AACJ,QAAK,aAAa,QAAS;AAC1B,oBAAc;AAAA,IACf,WAAY,aAAa,eAAgB;AACxC,oBAAc;AAAA,IACf,WAAY,aAAa,YAAa;AACrC,oBAAc;AAAA,IACf,OAAO;AACN,oBAAc;AAAA,IACf;AACA,WAAO,KAAM,WAAY;AAAA,EAC1B;AAEA,WAAS,MAAO,MAAM;AACrB,YAAQ,QAAS,CAAE,WAAY;AAC9B,aAAQ,SAAS,SAAU,WAAY,CAAE,EAAE;AAAA,QAC1C;AAAA,QACA;AAAA,QACA;AAAA,MACD;AAAA,IACD,CAAE;AACF,WAAO,QAAS,CAAE,UAAW;AAC5B,aAAQ,SAAS,SAAU,WAAY,CAAE,EAAE;AAAA,QAC1C;AAAA,QACA;AAAA,QACA;AAAA,MACD;AAAA,IACD,CAAE;AAAA,EACH,CAAE;AAEF,WAAU,+BAA+B,QAAS;AACnD;",
6
6
  "names": []
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"private-actions.d.ts","sourceRoot":"","sources":["../../../src/dataviews/store/private-actions.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAyC1D,wBAAgB,oBAAoB,CAAE,IAAI,EACzC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,CAAE,IAAI,CAAE;;;;;EAQtB;AAED,wBAAgB,sBAAsB,CACrC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM;;;;;EAQhB;A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package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/editor",
3
- "version": "14.33.1",
3
+ "version": "14.33.2",
4
4
  "description": "Enhanced block editor for WordPress posts.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -64,12 +64,12 @@
64
64
  "@wordpress/compose": "^7.33.0",
65
65
  "@wordpress/core-data": "^7.33.0",
66
66
  "@wordpress/data": "^10.33.0",
67
- "@wordpress/dataviews": "^10.0.0",
67
+ "@wordpress/dataviews": "^10.1.0",
68
68
  "@wordpress/date": "^5.33.0",
69
69
  "@wordpress/deprecated": "^4.33.0",
70
70
  "@wordpress/dom": "^4.33.0",
71
71
  "@wordpress/element": "^6.33.0",
72
- "@wordpress/fields": "^0.25.1",
72
+ "@wordpress/fields": "^0.25.2",
73
73
  "@wordpress/hooks": "^4.33.0",
74
74
  "@wordpress/html-entities": "^4.33.0",
75
75
  "@wordpress/i18n": "^6.6.0",
@@ -108,5 +108,5 @@
108
108
  "publishConfig": {
109
109
  "access": "public"
110
110
  },
111
- "gitHead": "0eca9b157f332afd4d1a53c62bd862ae9a159c57"
111
+ "gitHead": "2a8c29e6550fa1a246bfce534fbcc545d035a9a7"
112
112
  }
@@ -133,19 +133,28 @@ export const registerPostTypeSchema =
133
133
  .resolveSelect( coreStore )
134
134
  .getCurrentTheme();
135
135
 
136
+ let canDuplicate =
137
+ ! [ 'wp_block', 'wp_template_part' ].includes(
138
+ postTypeConfig.slug
139
+ ) &&
140
+ canCreate &&
141
+ duplicatePost;
142
+
143
+ // @ts-ignore
144
+ if ( ! globalThis.IS_GUTENBERG_PLUGIN ) {
145
+ // Outside Gutenberg, disable duplication except for wp_template.
146
+ if ( 'wp_template' !== postTypeConfig.slug ) {
147
+ canDuplicate = undefined;
148
+ }
149
+ }
150
+
136
151
  const actions = [
137
152
  postTypeConfig.viewable ? viewPost : undefined,
138
153
  !! postTypeConfig.supports?.revisions
139
154
  ? viewPostRevisions
140
155
  : undefined,
141
156
  // @ts-ignore
142
- globalThis.IS_GUTENBERG_PLUGIN
143
- ? ! [ 'wp_block', 'wp_template_part' ].includes(
144
- postTypeConfig.slug
145
- ) &&
146
- canCreate &&
147
- duplicatePost
148
- : undefined,
157
+ canDuplicate,
149
158
  postTypeConfig.slug === 'wp_template_part' &&
150
159
  canCreate &&
151
160
  currentTheme?.is_block_theme