Make WordPress Core

Changeset 63361


Ignore:
Timestamp:
08/27/2026 12:05:58 PM (6 weeks ago)
Author:
swissspidy
Message:

I18N: Fix just-in-time translation loading for network-activated plugins.

Just-in-time translation loading depends on text domain paths registered during bootstrap, but only site-level active plugins were registered. In multisite, PHP translation functions therefore returned untranslated strings for network-activated plugins even when the correct translation files were present.

Developed in: ​https://github.com/WordPress/wordpress-develop/pull/11243

Follow-up to r59461.

Props sanketparmar, okvee, pelentak.
See #62244.
Fixes #64249.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-settings.php

    r62829 r63361  
    503503$GLOBALS['wp_plugin_paths'] = array();
    504504
     505// To make get_plugin_data() available for both network-activated and site-activated plugins, see #62244 and #64249.
     506require_once ABSPATH . 'wp-admin/includes/plugin.php';
     507
    505508// Load must-use plugins.
    506509foreach ( wp_get_mu_plugins() as $mu_plugin ) {
    … …  
    524527        foreach ( wp_get_active_network_plugins() as $network_plugin ) {
    525528                wp_register_plugin_realpath( $network_plugin );
     529
     530                $plugin_data = get_plugin_data( $network_plugin, false, false );
     531
     532                $textdomain = $plugin_data['TextDomain'];
     533                if ( $textdomain ) {
     534                        if ( $plugin_data['DomainPath'] ) {
     535                                $GLOBALS['wp_textdomain_registry']->set_custom_path( $textdomain, dirname( $network_plugin ) . $plugin_data['DomainPath'] );
     536                        } else {
     537                                $GLOBALS['wp_textdomain_registry']->set_custom_path( $textdomain, dirname( $network_plugin ) );
     538                        }
     539                }
    526540
    527541                $_wp_plugin_file = $network_plugin;
    … …  
    538552                do_action( 'network_plugin_loaded', $network_plugin );
    539553        }
    540         unset( $network_plugin, $_wp_plugin_file );
     554        unset( $network_plugin, $_wp_plugin_file, $plugin_data, $textdomain );
    541555}
    542556
    … …  
    575589        wp_recovery_mode()->initialize();
    576590}
    577 
    578 // To make get_plugin_data() available in a way that's compatible with plugins also loading this file, see #62244.
    579 require_once ABSPATH . 'wp-admin/includes/plugin.php';
    580591
    581592// Load active plugins.
Note: See TracChangeset for help on using the changeset viewer.