-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Global Styles: clean cached data when switching themes #30830
Conversation
so new data can be recalculated for the new one.
02d84b7
to
65b68de
Compare
Size Change: 0 B Total Size: 1.43 MB ℹ️ View Unchanged
|
Pushed tests for this so it's ready for review. |
* | ||
* @var Array | ||
*/ | ||
private static $theme_json_i18n = null; |
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.
This was extracted out to the class so it can be cleaned upon theme switches.
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.
Thanks @nosolosw! This does seem like a good solution 💯
I have a minor concern about maintainability -- if other static fields were to be added to this class, people would need to remember to reset them in clean_cached_data()
. But I can't come up with a good alternative, and it seems acceptable 🙂
Fixes #30478
Alternative to #30479
This PR hooks into the
switch_theme
action to clean the cached data, so it can be recalculated for the new theme. This is especially important for unit tests.