fix: enhance load_textdomain method to support forced loading of text domain#9760
fix: enhance load_textdomain method to support forced loading of text domain#9760coderGtm wants to merge 1 commit intoWordPress:trunkfrom
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
🐞 Problem
When a plugin loads the same textdomain as a theme before the theme does, the theme’s translations may not load at all. This is because WordPress considers the textdomain already loaded and silently skips it — even if the .mo file is different. This leads to missing translations in themes.
Tracked in Trac #63725
✅ Solution
This PR introduces a $force parameter to the WP_Theme::load_textdomain() method, allowing themes to explicitly reload their own textdomain — even if it was previously loaded by a plugin.
🔧 Changes
Enhancement: Added optional
$forceparameter to WP_Theme::load_textdomain() to enable reloading of already-loaded textdomains.Behavioral Update: When
$forceis true, the method bypasses the is_textdomain_loaded() check and reloads the .mo file.📌 Notes
This change provides theme authors a way to recover from textdomain conflicts caused by plugins loading the same domain early.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.