From 9e8154f87bb3e318047c09fcec297a269b06efee Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Mon, 24 Aug 2026 16:38:22 +0200 Subject: [PATCH 1/2] Editor: Offer the theme export from both site editors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Export tool downloads the active theme with the user's template and style changes. It was an edit-site component mounted unconditionally, so the classic site editor offered it while editing anything — a page, a pattern — and the extensible site editor not at all. Move it to the editor package and gate it where it belongs: the menu item renders only while editing a template or a template part, the entities the exported theme is made of, and only for users the export endpoint accepts. Both site editors render it from the shared component, so the behavior is decided once. Co-Authored-By: Claude Fable 5 --- packages/edit-site/CHANGELOG.md | 4 ++++ .../src/components/more-menu/index.js | 4 ++-- packages/editor/CHANGELOG.md | 4 ++++ .../src/components/site-export/index.js} | 24 +++++++++++++++++++ packages/editor/src/private-apis.js | 2 ++ packages/lazy-editor/CHANGELOG.md | 4 ++++ .../src/components/editor/index.tsx | 9 +++++++ 7 files changed, 49 insertions(+), 2 deletions(-) rename packages/{edit-site/src/components/more-menu/site-export.js => editor/src/components/site-export/index.js} (72%) diff --git a/packages/edit-site/CHANGELOG.md b/packages/edit-site/CHANGELOG.md index 5d5118e142e887..af295a696eea72 100644 --- a/packages/edit-site/CHANGELOG.md +++ b/packages/edit-site/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Enhancements + +- Offer the Export tool only while editing a template or a template part, the entities the exported theme is made of. The menu item now lives in the editor package ([#PRNUM](https://github.com/WordPress/gutenberg/pull/PRNUM)). + ### Bug Fixes - Seed the root `ThemeProvider` with the admin color scheme primary color so portaled popovers and modals receive the scheme's accent colors ([#81653](https://github.com/WordPress/gutenberg/pull/81653)). diff --git a/packages/edit-site/src/components/more-menu/index.js b/packages/edit-site/src/components/more-menu/index.js index e0717a7a705a8c..9872146fd0b6a1 100644 --- a/packages/edit-site/src/components/more-menu/index.js +++ b/packages/edit-site/src/components/more-menu/index.js @@ -1,9 +1,9 @@ import { privateApis as editorPrivateApis } from '@wordpress/editor'; -import SiteExport from './site-export'; import WelcomeGuideMenuItem from './welcome-guide-menu-item'; import { unlock } from '../../lock-unlock'; -const { ToolsMoreMenuGroup, PreferencesModal } = unlock( editorPrivateApis ); +const { ToolsMoreMenuGroup, PreferencesModal, SiteExport } = + unlock( editorPrivateApis ); export default function MoreMenu() { return ( diff --git a/packages/editor/CHANGELOG.md b/packages/editor/CHANGELOG.md index f33c41a3b4ef5f..8dbac2d7821427 100644 --- a/packages/editor/CHANGELOG.md +++ b/packages/editor/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### New Features + +- Add a private `SiteExport` menu item, moved from `edit-site`. It offers downloading the theme with the user's changes, only while editing a template or a template part — the entities the exported theme is made of ([#PRNUM](https://github.com/WordPress/gutenberg/pull/PRNUM)). + ### Enhancements - Commands: Add a command palette entry that opens the current post on the front end once it is published, labelled with the post type's `view_item` label ([#66720](https://github.com/WordPress/gutenberg/pull/66720)). diff --git a/packages/edit-site/src/components/more-menu/site-export.js b/packages/editor/src/components/site-export/index.js similarity index 72% rename from packages/edit-site/src/components/more-menu/site-export.js rename to packages/editor/src/components/site-export/index.js index fee1a9d0631325..e6e1c778150b0c 100644 --- a/packages/edit-site/src/components/more-menu/site-export.js +++ b/packages/editor/src/components/site-export/index.js @@ -6,9 +6,33 @@ import { useDispatch, useSelect } from '@wordpress/data'; import { downloadBlob } from '@wordpress/blob'; import { store as coreStore } from '@wordpress/core-data'; import { store as noticesStore } from '@wordpress/notices'; +import { store as editorStore } from '../../store'; +import { + TEMPLATE_POST_TYPE, + TEMPLATE_PART_POST_TYPE, +} from '../../store/constants'; +/** + * Menu item offering to download the active theme, with the user's template + * and style changes, as a zip. + * + * Offered only while editing one of the entities the exported theme is made + * of — a template or a template part — and only to users the export endpoint + * accepts. The host places it in a menu group. + * + * @return {React.ReactNode} The menu item, or nothing where export does not + * apply. + */ export default function SiteExport() { const canExport = useSelect( ( select ) => { + const postType = select( editorStore ).getCurrentPostType(); + if ( + postType !== TEMPLATE_POST_TYPE && + postType !== TEMPLATE_PART_POST_TYPE + ) { + return false; + } + const targetHints = select( coreStore ).getCurrentTheme()?._links?.[ 'wp:export-theme' diff --git a/packages/editor/src/private-apis.js b/packages/editor/src/private-apis.js index 17afc203ff480c..18549e77a46928 100644 --- a/packages/editor/src/private-apis.js +++ b/packages/editor/src/private-apis.js @@ -13,6 +13,7 @@ import PreferencesModal from './components/preferences-modal'; import { usePostActions } from './components/post-actions/actions'; import usePostFields from './components/post-fields'; import ToolsMoreMenuGroup from './components/more-menu/tools-more-menu-group'; +import SiteExport from './components/site-export'; import ViewMoreMenuGroup from './components/more-menu/view-more-menu-group'; import ResizableEditor from './components/resizable-editor'; import { registerCoreBlockBindingsSources } from './bindings/api'; @@ -37,6 +38,7 @@ lock( privateApis, { usePostActions, usePostFields, ToolsMoreMenuGroup, + SiteExport, ViewMoreMenuGroup, ResizableEditor, UploadProgressSnackbar, diff --git a/packages/lazy-editor/CHANGELOG.md b/packages/lazy-editor/CHANGELOG.md index 982c3cdf27336d..c373bfee57abf5 100644 --- a/packages/lazy-editor/CHANGELOG.md +++ b/packages/lazy-editor/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### New Features + +- Render the editor's Export tool, so a theme can be downloaded with the user's changes while editing a template or a template part ([#PRNUM](https://github.com/WordPress/gutenberg/pull/PRNUM)). + ### Bug Fixes - Add the styles a host passes to the theme's and the user's instead of replacing them, so an editor canvas keeps the CSS a theme registers with `add_editor_style` ([#81747](https://github.com/WordPress/gutenberg/pull/81747)). diff --git a/packages/lazy-editor/src/components/editor/index.tsx b/packages/lazy-editor/src/components/editor/index.tsx index 687a8b19f251ab..416f170e2d22b8 100644 --- a/packages/lazy-editor/src/components/editor/index.tsx +++ b/packages/lazy-editor/src/components/editor/index.tsx @@ -13,6 +13,8 @@ const { Editor: PrivateEditor, BackButton, PreferencesModal, + ToolsMoreMenuGroup, + SiteExport, } = unlock( editorPrivateApis ); interface EditorProps { @@ -139,6 +141,13 @@ export function Editor( { nothing until one of them opens it. */ } + { /* + Self-gated: renders only while editing a template or template + part, the entities the exported theme is made of. + */ } + + + ); } From 9d276e743abf1d1bdb0f8d1821b565fe37f9eaad Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Mon, 24 Aug 2026 16:39:05 +0200 Subject: [PATCH 2/2] Editor: Link the CHANGELOG entries to their PR Co-Authored-By: Claude Fable 5 --- packages/edit-site/CHANGELOG.md | 2 +- packages/editor/CHANGELOG.md | 2 +- packages/lazy-editor/CHANGELOG.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/edit-site/CHANGELOG.md b/packages/edit-site/CHANGELOG.md index af295a696eea72..d5af36afa2c5d5 100644 --- a/packages/edit-site/CHANGELOG.md +++ b/packages/edit-site/CHANGELOG.md @@ -4,7 +4,7 @@ ### Enhancements -- Offer the Export tool only while editing a template or a template part, the entities the exported theme is made of. The menu item now lives in the editor package ([#PRNUM](https://github.com/WordPress/gutenberg/pull/PRNUM)). +- Offer the Export tool only while editing a template or a template part, the entities the exported theme is made of. The menu item now lives in the editor package ([#81992](https://github.com/WordPress/gutenberg/pull/81992)). ### Bug Fixes diff --git a/packages/editor/CHANGELOG.md b/packages/editor/CHANGELOG.md index 8dbac2d7821427..8771f992043d98 100644 --- a/packages/editor/CHANGELOG.md +++ b/packages/editor/CHANGELOG.md @@ -4,7 +4,7 @@ ### New Features -- Add a private `SiteExport` menu item, moved from `edit-site`. It offers downloading the theme with the user's changes, only while editing a template or a template part — the entities the exported theme is made of ([#PRNUM](https://github.com/WordPress/gutenberg/pull/PRNUM)). +- Add a private `SiteExport` menu item, moved from `edit-site`. It offers downloading the theme with the user's changes, only while editing a template or a template part — the entities the exported theme is made of ([#81992](https://github.com/WordPress/gutenberg/pull/81992)). ### Enhancements diff --git a/packages/lazy-editor/CHANGELOG.md b/packages/lazy-editor/CHANGELOG.md index c373bfee57abf5..ffe79cd73c40fa 100644 --- a/packages/lazy-editor/CHANGELOG.md +++ b/packages/lazy-editor/CHANGELOG.md @@ -4,7 +4,7 @@ ### New Features -- Render the editor's Export tool, so a theme can be downloaded with the user's changes while editing a template or a template part ([#PRNUM](https://github.com/WordPress/gutenberg/pull/PRNUM)). +- Render the editor's Export tool, so a theme can be downloaded with the user's changes while editing a template or a template part ([#81992](https://github.com/WordPress/gutenberg/pull/81992)). ### Bug Fixes