Make WordPress Core

Opened 12 years ago

Closed 9 years ago

#22401 closed enhancement (fixed)

Add information about old theme to 'theme_switched' action

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

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 12 years ago.
22401.reindented.patch (1.8 KB) - added by slobodanmanic 11 years ago.
22401.diff (545 bytes) - added by MikeHansenMe 9 years ago.

Download all attachments as: .zip

Change History (19)

@evansolomon
12 years ago

#1 @rmccue
12 years ago

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

#3 @slobodanmanic
11 years ago

  • Keywords has-patch added; needs-patch removed

Fixes check_theme_switched() function indentation.

#4 @slobodanmanic
11 years ago

  • Cc slobodan.manic@… added

#5 @chriscct7
9 years ago

  • Keywords needs-refresh added

#6 @obenland
9 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
9 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
9 years ago

  • Milestone changed from Awaiting Review to 4.5
  • Version set to 3.3

@MikeHansenMe
9 years ago

#9 @MikeHansenMe
9 years ago

  • Keywords needs-refresh removed

#10 @obenland
9 years ago

  • Owner set to obenland
  • Status changed from new to accepted

#11 @DrewAPicture
9 years ago

  • Keywords needs-docs added

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

#12 @DrewAPicture
9 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
9 years ago

  • Keywords needs-docs removed

#14 @obenland
9 years ago

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

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


9 years ago

#16 @jorbin
9 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

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

Note: See TracTickets for help on using tickets.