Make WordPress Core

Opened 14 months ago

Last modified 14 months ago

#40221 new defect (bug)

switch_theme action + Live Preview = confusion

Reported by: alexvorn2 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.7.3
Component: Themes Keywords:
Focuses: Cc:


The switch_theme function has inside a hook named the same: switch_theme, it is used for theme deactivation actions, but the problem is that after you activate the theme via Live Preview - this action is executed, so can create confusion.

(switch_theme hook is for theme deactivation functions - https://codex.wordpress.org/Plugin_API/Action_Reference/switch_theme)

When we activate a theme (not via Live Preview) - then this hook is executed together with old theme, not with new theme, but when we have a Live Preview with a new theme, then this hook will be used with the theme that is inside the Live Preview, with it's files. That's why this hook is called incorrectly.

So if this is not by design and it is a bug then the fix would be to skip this hook after a theme activation via Live Preview.

Change History (1)

#1 @alexvorn2
14 months ago

I tested and noticed that skipping the hook, after theme activation via Live Preview - will not solve the problem, we still need this hook to be executed on old theme somehow. Old theme can have some deactivation functions that are needed to be executed.

Note: See TracTickets for help on using tickets.