Make WordPress Core

Opened 7 years ago

Closed 4 years ago

Last modified 4 years ago

#15648 closed enhancement (wontfix)

switch_theme action hook may provide the old template value

Reported by: drzraf Owned by:
Milestone: Priority: normal
Severity: trivial Version:
Component: Themes Keywords:
Focuses: Cc:


When someone change its theme, and both support custom header, then the banner and the text color are not preserved (these options are theme specific)

Anyway, one may want to preserve these values :

  • check if the new theme has its default value
  • check if the old theme values are compatible
  • ...
  • migrate the values

But in order to do this, WordPress should provide the value of the old theme in use. It would be easy to get it in switch_theme() and to send it as a second argument to the action hook.

Attachments (1)

switch_theme.15648.patch (791 bytes) - added by drzraf 7 years ago.
switch theme hook now provide both old and new templates and stylesheet used

Download all attachments as: .zip

Change History (5)

#1 @nacin
7 years ago

  • Keywords needs-patch added; theme switch custom header defaults removed
  • Milestone changed from Awaiting Review to Future Release
  • Type changed from feature request to enhancement

I hate that hook, since it passes get_current_theme(), which is a name rather than a slug, instead of stylesheet and template.

We can grab the old stylesheet and template value and pass those. Let's pass all four?

7 years ago

switch theme hook now provide both old and new templates and stylesheet used

#2 @drzraf
7 years ago

  • Cc raphael.droz@… added

simple patch attached. The only consumer of this hook in the core is "wp-includes/default-widgets.php" which doesn't use the arguments. Backward-compatibility may be an issue until one $(grep) for "add_action.*switch_theme" in the plugins & themes repositories to have a clear sight about what is using it isn't ?

#3 @obenland
4 years ago

  • Keywords needs-patch removed
  • Resolution set to wontfix
  • Status changed from new to closed

In r18655 we introduced a hook and enhanced it in r20163 with a WP_Themes object. Everything mentioned above should be possible to achieve through that.

#4 @obenland
4 years ago

  • Milestone Future Release deleted
Note: See TracTickets for help on using tickets.