Skip to content

Conversation

@mikachan
Copy link
Member

@mikachan mikachan commented Dec 30, 2025

This updates get_theme_templates to handle active and inactive templates.

Updates clear_user_templates_customizations() to check if template activation is enabled

  • If enabled: queries posts directly to get all custom templates (including inactive)
  • If not enabled: uses the standard get_block_templates() function
  • Ensures inactive custom templates are deleted

Updates clear_user_template_parts_customizations() to check if template activation is enabled

  • And handles inactive template parts when clearing customisations

Updates get_theme_templates() for exports

When exporting with export_type = 'all' and template activation is enabled:

  • Queries posts directly to include inactive custom templates
  • Falls back to creating template objects from post data if get_block_template() doesn't return inactive templates
  • Merges with theme templates (avoiding duplicates)
  • Maintains backward compatibility when template activation is not enabled

One issue with exporting the inactive templates is that there is currently nothing that defines them as "inactive". Once exported, they behave like any other template. I'm not sure how best to handle this. Maybe they could be listed in the theme.json file? Or we could use metadata in the template file.

Testing Instructions:

  1. Ensure Template Activation experiment is enabled in Gutenberg > Experiments > "Template activation"
  2. Create some custom templates (both active and inactive)
  3. Try resetting the theme via the plugin; the custom templates should be removed
  4. Try exporting the theme via the plugin, and ensure that the inactive templates are included

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.

2 participants