From 51c5e1eb2d2a0d2b453f6a22d53c2897c6d22e2e Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Tue, 21 Jan 2025 11:44:21 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@59670 git-svn-id: https://core.svn.wordpress.org/trunk@59013 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/version.php | 2 +- wp-settings.php | 26 +++++++++++++------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/wp-includes/version.php b/wp-includes/version.php index 8971a2fb10..b8045579e0 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.8-alpha-59669'; +$wp_version = '6.8-alpha-59670'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. diff --git a/wp-settings.php b/wp-settings.php index 635f6de248..ec08ff1149 100644 --- a/wp-settings.php +++ b/wp-settings.php @@ -525,6 +525,17 @@ foreach ( wp_get_active_and_valid_plugins() as $plugin ) { wp_register_plugin_realpath( $plugin ); + $plugin_data = get_plugin_data( $plugin, false, false ); + + $textdomain = $plugin_data['TextDomain']; + if ( $textdomain ) { + if ( $plugin_data['DomainPath'] ) { + $GLOBALS['wp_textdomain_registry']->set_custom_path( $textdomain, dirname( $plugin ) . $plugin_data['DomainPath'] ); + } else { + $GLOBALS['wp_textdomain_registry']->set_custom_path( $textdomain, dirname( $plugin ) ); + } + } + $_wp_plugin_file = $plugin; include_once $plugin; $plugin = $_wp_plugin_file; // Avoid stomping of the $plugin variable in a plugin. @@ -537,17 +548,6 @@ * @param string $plugin Full path to the plugin's main file. */ do_action( 'plugin_loaded', $plugin ); - - $plugin_data = get_plugin_data( $plugin, false, false ); - - $textdomain = $plugin_data['TextDomain']; - if ( $textdomain ) { - if ( $plugin_data['DomainPath'] ) { - $GLOBALS['wp_textdomain_registry']->set_custom_path( $textdomain, dirname( $plugin ) . $plugin_data['DomainPath'] ); - } else { - $GLOBALS['wp_textdomain_registry']->set_custom_path( $textdomain, dirname( $plugin ) ); - } - } } unset( $plugin, $_wp_plugin_file, $plugin_data, $textdomain ); @@ -684,11 +684,11 @@ foreach ( wp_get_active_and_valid_themes() as $theme ) { $wp_theme = wp_get_theme( basename( $theme ) ); + $wp_theme->load_textdomain(); + if ( file_exists( $theme . '/functions.php' ) ) { include $theme . '/functions.php'; } - - $wp_theme->load_textdomain(); } unset( $theme, $wp_theme );