Make WordPress Core

Opened 14 years ago

Closed 11 years ago

#22401 closed enhancement (fixed)

Add information about old theme to 'theme_switched' action

Reported by: evansolomon Owned by: DrewAPicture
Priority: normal Milestone: 4.5
Component: Themes Version: 3.3
Severity: normal Keywords: has-patch
Cc: Focuses:

Description

Currently the 'theme_switch' action passes data about the theme you're switching to, but not the theme you're switching from. Adding it there would make it easier to juggle functionality that needs to know about new and old themes. Right now some of this happens by ​setting an option ('theme_switched') and ​checking for it on ​init, then deleting the option. That could be simplified by just passing the old theme's data in theme_switched.

There's an added benefit that we avoid checking for an option on every single request that usually won't be there.

Attachments (3)

22401.patch​ (1.7 KB ) - added by evansolomon 14 years ago.
22401.reindented.patch​ (1.8 KB ) - added by slobodanmanic 13 years ago.
22401.diff​ (545 bytes ) - added by MikeHansenMe 11 years ago.

Download all attachments as: .zip

Change History (19)

@evansolomon
14 years ago

#1 @rmccue
14 years ago

Looking at the patch, it looks like check_theme_switched() needs to be reindented?

#3 @slobodanmanic
13 years ago

  • Keywords has-patch added; needs-patch removed

Fixes check_theme_switched() function indentation.

#4 @slobodanmanic
13 years ago

  • Cc slobodan.manic@… added

#5 @chriscct7
11 years ago

  • Keywords needs-refresh added

#6 @obenland
11 years ago

I anticipate back compat issue if we moved after_switch_theme to the same page load as switch_theme since we're changing the context in which the action is fired. Default themes checking for the required WP version couldn't self deactivate anymore for example.

No objections to adding old theme info to switch_theme though.

#7 @lancewillett
11 years ago

+1 Adding the old theme info would be helpful. An example use case is logging when people switch themes on a multisite environment — seeing patterns from old to new.

#8 @obenland
11 years ago

  • Milestone Awaiting Review → 4.5
  • Version → 3.3

@MikeHansenMe
11 years ago

#9 @MikeHansenMe
11 years ago

  • Keywords needs-refresh removed

#10 @obenland
11 years ago

  • Owner set to obenland
  • Status new → accepted

#11 @DrewAPicture
11 years ago

  • Keywords needs-docs added

22401.diff​ needs a changelog entry for the new parameter.

#12 @DrewAPicture
11 years ago

In 36502:

Themes: Pass information about the old theme in the form of a WP_Theme object when the switch_theme action is fired.

Props MikeHansenMe.
See #22401.

#13 @DrewAPicture
11 years ago

  • Keywords needs-docs removed

#14 @obenland
11 years ago

  • Owner changed from obenland to DrewAPicture
  • Status accepted → assigned

This ticket was mentioned in ​Slack in #core by jorbin. ​View the logs.


11 years ago

#16 @jorbin
11 years ago

  • Resolution → fixed
  • Status assigned → closed

If there is remaining work that wasn't noted, please reopen (or create new tickets)

Note: See TracTickets for help on using tickets.