I18N: Fix JIT translations for network-activated plugins in multisite#11243
I18N: Fix JIT translations for network-activated plugins in multisite#11243sanketio 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
Since WordPress 6.7 (59461), the just-in-time (JIT) translation loading mechanism registers text domains by reading each plugin's
Text DomainandDomain Pathheaders during bootstrap. However, this registration only happened for site-level active plugins (wp_get_active_and_valid_plugins()), completely skipping network-activated plugins (wp_get_active_network_plugins()) in multisite installations.As a result, PHP translation functions (
__(),_e(), etc.) silently fell back to untranslated strings for all network-activated plugins — even when correct translation files were present — because$wp_textdomain_registryhad no path registered for those domains and_load_textdomain_just_in_time()had nothing to work with.Changes
wp-settings.phprequire_once ABSPATH . 'wp-admin/includes/plugin.php'earlier in the bootstrap — from just before the site plugins loop to just before the must-use plugins loop — makingget_plugin_data()available for all plugin loading stages. Comment updated to reference both #62244 and #64249.TextDomainandDomainPathheaders viaget_plugin_data()and calls$wp_textdomain_registry->set_custom_path()accordingly.$plugin_dataand$textdomainto theunset()at the end of the network plugins block, consistent with the site plugins loop.Backward Compatibility
get_plugin_data()only reads the plugin file's comment header — no database calls, no side effects.set_custom_path()is idempotent. Plugins already callingload_plugin_textdomain()explicitly as a workaround will continue to work correctly.require_onceearlier carries negligible risk —plugin.phpwas already hardened for early loading in #62244.References
Use of AI Tools
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.