Make WordPress Core

Opened 2 years ago

Last modified 2 years ago

#54838 new enhancement

Automatically enable some templates from inactive themes

Reported by: manfcarlo's profile manfcarlo Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Themes Keywords: has-patch
Focuses: Cc:

Description

In the experimental days of FSE, any customisations that were made or new templates that were added to one block theme, would actually persist after switching to another block theme. This was obviously not a good user experience, because one could ostensibly switch their theme and be left all but stuck with their old one.

Accordingly, the behaviour was changed to make all templates and template parts associate with one theme only. Now, when switching to another block theme, the site gets a fresh start without any of the old theme's customisations remaining.

Of course, the desired behaviour is somewhere in between these two extremes. Most notably, if a user creates their own template through the template editor that was introduced in 5.8, they are unlikely to want to lose it when switching theme. This has been documented in this issue and this issue as well as the user feedback.

Automatic rules of precedence are already used to select the correct template based on customised vs theme-provided, parent theme vs child theme, PHP template vs block template, in addition to the basic template hierarchy. Could a similar approach be used to automatically select the correct template based on active theme vs inactive theme, without overwhelming users with too many options?

My idea is to automatically enable templates and template parts from inactive themes only if they meet the following criteria:

  • they are post-based rather than file-based (since these are unaffected by deleting the inactive theme)
  • they do not match any file in their own theme (since these are unlikely to be minor customisations that the user intended for that theme only)
  • they do not match any file-based or post-based slug in the active theme (since these will not mask anything from the active theme)

Change History (2)

This ticket was mentioned in PR #2179 on WordPress/wordpress-develop by carlomanf.


2 years ago
#1

  • Keywords has-patch added

Fixes WordPress/gutenberg#31954
Fixes WordPress/gutenberg#25071

Trac ticket: https://core.trac.wordpress.org/ticket/54838

#2 @SergeyBiryukov
2 years ago

  • Component changed from General to Themes
Note: See TracTickets for help on using tickets.