Opened 9 years ago
Closed 9 years ago
#33835 closed defect (bug) (invalid)
action switch_theme, after_switch_theme should not be trigged when switch_theme for child site.
Reported by: | nguyenvanduocit | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.3 |
Component: | Networks and Sites | Keywords: | reporter-feedback |
Focuses: | multisite | Cc: |
Description
If you hook to after_switch_theme ( on network's theme ) for initialize some default values, then your switch theme for child site by this line :
switch_to_blog( $child_site_Id ); switch_theme( $new_theme_name ); restore_current_blog();
The hook after_switch_theme will be trigger on network's theme.
I think it is incorrect.
Change History (2)
Note: See
TracTickets for help on using
tickets.
Hi @nguyenvanduocit, thanks for the report. I'm not able to reproduce the described issue.
I did the following in a multisite setup where the same theme was activated for 2 sites.
In
mu-plugins/index.php
, I added a hook to switch the site and then switch that site's theme:In theme-one, the theme that was activated on all sites, including the network, I added:
And in theme-two, the theme I was switching to:
I loaded
foo.bar/wp-admin/network/sites.php
to trigger the initial mu-plugins action and then *removed* the action frommu-plugins/index.php
so that it would not trigger on the next page view.I then loaded the front page of site 2, which now had theme-two activated and was shown "Theme-Two".
If I redo the experiment with Theme Two as a child of Theme One, and used
echo
instead ofdie
, I see that both the child theme and the parent theme will fire as expected.Are you getting different results than this? If so, can you describe steps to reproduce?