Skip to content

Commit 4b89ebe

Browse files
committed
I18N: Set textdomain registry information before loading plugins/theme.
This way, warnings for early translation calls can be emitted that aren't attached to any hook. Follow-up to [59461]. Props swissspidy. Fixes #62244.See #44937. git-svn-id: https://develop.svn.wordpress.org/trunk@59670 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 7be1074 commit 4b89ebe

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/wp-settings.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,17 @@
525525
foreach ( wp_get_active_and_valid_plugins() as $plugin ) {
526526
wp_register_plugin_realpath( $plugin );
527527

528+
$plugin_data = get_plugin_data( $plugin, false, false );
529+
530+
$textdomain = $plugin_data['TextDomain'];
531+
if ( $textdomain ) {
532+
if ( $plugin_data['DomainPath'] ) {
533+
$GLOBALS['wp_textdomain_registry']->set_custom_path( $textdomain, dirname( $plugin ) . $plugin_data['DomainPath'] );
534+
} else {
535+
$GLOBALS['wp_textdomain_registry']->set_custom_path( $textdomain, dirname( $plugin ) );
536+
}
537+
}
538+
528539
$_wp_plugin_file = $plugin;
529540
include_once $plugin;
530541
$plugin = $_wp_plugin_file; // Avoid stomping of the $plugin variable in a plugin.
@@ -537,17 +548,6 @@
537548
* @param string $plugin Full path to the plugin's main file.
538549
*/
539550
do_action( 'plugin_loaded', $plugin );
540-
541-
$plugin_data = get_plugin_data( $plugin, false, false );
542-
543-
$textdomain = $plugin_data['TextDomain'];
544-
if ( $textdomain ) {
545-
if ( $plugin_data['DomainPath'] ) {
546-
$GLOBALS['wp_textdomain_registry']->set_custom_path( $textdomain, dirname( $plugin ) . $plugin_data['DomainPath'] );
547-
} else {
548-
$GLOBALS['wp_textdomain_registry']->set_custom_path( $textdomain, dirname( $plugin ) );
549-
}
550-
}
551551
}
552552
unset( $plugin, $_wp_plugin_file, $plugin_data, $textdomain );
553553

@@ -684,11 +684,11 @@
684684
foreach ( wp_get_active_and_valid_themes() as $theme ) {
685685
$wp_theme = wp_get_theme( basename( $theme ) );
686686

687+
$wp_theme->load_textdomain();
688+
687689
if ( file_exists( $theme . '/functions.php' ) ) {
688690
include $theme . '/functions.php';
689691
}
690-
691-
$wp_theme->load_textdomain();
692692
}
693693
unset( $theme, $wp_theme );
694694

0 commit comments

Comments
 (0)