Skip to content

I18N: Fix JIT translations for network-activated plugins in multisite#11243

Open
sanketio wants to merge 1 commit intoWordPress:trunkfrom
sanketio:fix/64249
Open

I18N: Fix JIT translations for network-activated plugins in multisite#11243
sanketio wants to merge 1 commit intoWordPress:trunkfrom
sanketio:fix/64249

Conversation

@sanketio
Copy link

Problem

Since WordPress 6.7 (59461), the just-in-time (JIT) translation loading mechanism registers text domains by reading each plugin's Text Domain and Domain Path headers 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_registry had no path registered for those domains and _load_textdomain_just_in_time() had nothing to work with.

Note: JavaScript translations were unaffected as they use a separate mechanism.

Changes

wp-settings.php

  • Moves require_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 — making get_plugin_data() available for all plugin loading stages. Comment updated to reference both #62244 and #64249.
  • Adds text domain registration inside the network-activated plugins loop, mirroring the logic already present in the site plugins loop: reads TextDomain and DomainPath headers via get_plugin_data() and calls $wp_textdomain_registry->set_custom_path() accordingly.
  • Adds $plugin_data and $textdomain to the unset() 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 calling load_plugin_textdomain() explicitly as a workaround will continue to work correctly.
  • Moving the require_once earlier carries negligible risk — plugin.php was 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.

@github-actions
Copy link

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props sanketparmar.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions
Copy link

Test using WordPress Playground

The 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

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

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.

1 participant