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
Using wp_set_option_autoload() for theme options #5692
Changes from all commits
c2e90fa
03ac847
f74e05b
acc8b43
8e42b10
e681980
e819421
a6f123c
598a065
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -866,6 +866,13 @@ function switch_theme( $stylesheet ) { | |||||||||||||||||||||
|
||||||||||||||||||||||
update_option( 'theme_switched', $old_theme->get_stylesheet() ); | ||||||||||||||||||||||
|
||||||||||||||||||||||
// Set autoload=no for the previous theme | ||||||||||||||||||||||
$old_theme_stylesheet = $old_theme->get_stylesheet(); | ||||||||||||||||||||||
wp_set_option_autoload( "theme_mods_$old_theme_stylesheet", 'no' ); | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This adjustment alters the autoload option for the previous theme. If the user had activated multiple themes previously, it becomes essential to verify and modify the autoload value for those themes as well. What do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mukeshpanchal27 I think this is only an issue for existing sites that had multiple themes active before updating to WordPress 6.5. So I think this is better addressed separately via your new ticket https://core.trac.wordpress.org/ticket/59975 and #5711. Any site that starts with WordPress 6.5 should not have this problem as every time the theme is switched the previous theme's theme mods are set to not autoload. So there should at no point be more than one theme with autoloaded theme mods.
Comment on lines
+870
to
+871
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to also cover a potential parent theme here (i.e. if the old
Suggested change
|
||||||||||||||||||||||
|
||||||||||||||||||||||
// Set autoload=yes for the switched theme if not already set | ||||||||||||||||||||||
wp_set_option_autoload( "theme_mods_$stylesheet", 'yes' ); | ||||||||||||||||||||||
Comment on lines
+873
to
+874
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here:
Suggested change
|
||||||||||||||||||||||
|
||||||||||||||||||||||
/* | ||||||||||||||||||||||
* Reset globals to force refresh the next time these directories are | ||||||||||||||||||||||
* accessed via `get_stylesheet_directory()` / `get_template_directory()`. | ||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing period after inline comment.