Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #718 - change method of updating theme paths #720

Merged
merged 1 commit into from
Dec 29, 2016

Conversation

swalkinshaw
Copy link
Member

After a deploy we were running switch_theme would had the side effect of sometimes making sidebar widgets inactive.

This uses a simpler, more direct method of updating stylesheet_root and template_root which should be less error-prone since it does less.

After a deploy we were running `switch_theme` would had the side effect
of sometimes making sidebar widgets inactive.

This uses a simpler, more direct method of updating `stylesheet_root` and
`template_root` which should be less error-prone since it does less.
@swalkinshaw swalkinshaw force-pushed the deploy-hook-improve-updating-theme-paths branch from 009c8d6 to 632bbe8 Compare December 29, 2016 16:46
@swalkinshaw swalkinshaw merged commit 95766ed into master Dec 29, 2016
@swalkinshaw swalkinshaw deleted the deploy-hook-improve-updating-theme-paths branch December 29, 2016 16:52
@coreyworrell
Copy link

The reason menus and sidebar widgets become inactive is because of the two functions registered in wp-includes/default-filters.php

add_action( 'after_switch_theme', '_wp_menus_changed' );
add_action( 'after_switch_theme', '_wp_sidebars_changed' );

I still have no idea why the issue only happens occasionally, but it appears that you can bypass those by pretending the theme switch came from the Customizer:

wp-includes/theme.php [check_theme_switched()] (this is bound to init action, so it would only happen on first page load after the deployment)

if ( get_option( 'theme_switched_via_customizer' ) ) {
	remove_action( 'after_switch_theme', '_wp_menus_changed' );
	remove_action( 'after_switch_theme', '_wp_sidebars_changed' );
	update_option( 'theme_switched_via_customizer', false );
}

The new method you have here should probably work fine too, but if you didn't want to hard code a path in there then the following should work:

wp eval 'wp_clean_themes_cache(); update_option("theme_switched_via_customizer", true); switch_theme(get_stylesheet());'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants