Skip to content

Export user created templates and template parts to custom directories - #84080

Open
sarthaknagoshe2002 wants to merge 1 commit into
WordPress:trunkfrom
sarthaknagoshe2002:fix/issue-72515
Open

sarthaknagoshe2002 wants to merge 1 commit into
WordPress:trunkfrom
sarthaknagoshe2002:fix/issue-72515

Conversation

@sarthaknagoshe2002

@sarthaknagoshe2002 sarthaknagoshe2002 commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

What?

Closes #72515

This PR updates the Site Editor's "Export Theme" functionality to properly separate purely custom, user created templates and template parts from standard theme files. User created files are now routed to custom-templates/ and custom-parts/ directories within the exported zip, accompanied by a CUSTOM-TEMPLATES-README.txt manifest.

Why?

With the introduction of the new Template API, there is a strict distinction between default theme templates and custom user generated templates. Previously, custom templates were mixed into the templates/ and parts/ directories alongside theme files, or completely ignored. This caused confusion and made it difficult for developers to identify which files were user generated in order to merge them back into their source controlled themes.

How?

  • Introduced gutenberg_get_template_export_directory() to classify templates.
    • User created templates go to custom-templates/ and custom-parts/.
    • Theme templates and user edited theme templates stay in templates/ and parts/.
    • Unmodified plugin registered templates are intentionally skipped so they don't pollute the theme export.
  • Generates a CUSTOM-TEMPLATES-README.txt at the root of the archive outlining how developers can adopt these custom files, including noting which ones need a customTemplates entry in theme.json.
  • Added a full PHPUnit test suite (Tests_Block_Template_Export) covering all routing, skipping, and formatting scenarios.

Testing Instructions

  1. Navigate to Appearance > Editor.
  2. Go to Templates and create a new Custom Template (e.g., my-custom-template). Add a few blocks and save.
  3. Go to Patterns > Template Parts and create a new custom template part. Save it.
  4. Modify an existing theme template (like Home or Index).
  5. Click the Options menu (the three vertical dots) in the top right corner of the Site Editor and click Export.
  6. Unzip the downloaded theme file.
  7. Verify that the custom template is inside a custom-templates/ directory, the custom part is inside a custom-parts/ directory, and your modified theme template is inside the standard templates/ directory.
  8. Open CUSTOM-TEMPLATES-README.txt and verify it correctly lists your custom files and instructions for adopting them.

Use of AI Tools

AI assistance was used for scaffolding the PHPUnit test suite and formatting the layout and text of the CUSTOM-TEMPLATES-README.txt manifest. All AI generated code, assertions, and documentation were manually reviewed, verified, and adjusted to strictly adhere to WordPress Core standards.

@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

🎉 Props

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: sarthaknagoshe2002 <sarthaknagoshe2002@git.wordpress.org>
Co-authored-by: eirichmond <erichmond@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

🏷️ Labels

This pull request needs exactly one label indicating its type, and has 0.

  • Required: any label starting with [Type].
  • Found: none.

Read more about Type labels in Gutenberg. If you cannot add labels yourself, a reviewer can do it for you.

@sarthaknagoshe2002
sarthaknagoshe2002 marked this pull request as ready for review October 5, 2026 13:22

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feedback: Improved export functionality needed for the new Template API

1 participant