From 912ac10f4b880d5fb51b8dcc98af8db49fb3d9f0 Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Fri, 11 Nov 2022 01:27:10 +0000 Subject: [PATCH] I18N: Initialize textdomain registry in `wp_load_translations_early()`. Initialize `WP_Textdomain_Registry` in `wp_load_translations_early()`. This ensures the global `$wp_textdomain_registry` is set up prior to loading the translations. Props azurseisme, TimothyBlynJacobs, costdev, ocean90, flixos90, swissspidy. Fixes #57051. Built from https://develop.svn.wordpress.org/trunk@54803 git-svn-id: http://core.svn.wordpress.org/trunk@54355 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/load.php | 8 +++++++- wp-includes/version.php | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/wp-includes/load.php b/wp-includes/load.php index bb0db65b94..3cf4b0d207 100644 --- a/wp-includes/load.php +++ b/wp-includes/load.php @@ -1321,10 +1321,11 @@ function get_current_network_id() { * @since 3.4.0 * @access private * + * @global WP_Textdomain_Registry $wp_textdomain_registry WordPress Textdomain Registry. * @global WP_Locale $wp_locale WordPress date and time locale object. */ function wp_load_translations_early() { - global $wp_locale; + global $wp_locale, $wp_textdomain_registry; static $loaded = false; if ( $loaded ) { @@ -1342,6 +1343,7 @@ function wp_load_translations_early() { // Translation and localization. require_once ABSPATH . WPINC . '/pomo/mo.php'; require_once ABSPATH . WPINC . '/l10n.php'; + require_once ABSPATH . WPINC . '/class-wp-textdomain-registry.php'; require_once ABSPATH . WPINC . '/class-wp-locale.php'; require_once ABSPATH . WPINC . '/class-wp-locale-switcher.php'; @@ -1351,6 +1353,10 @@ function wp_load_translations_early() { $locales = array(); $locations = array(); + if ( ! $wp_textdomain_registry instanceof WP_Textdomain_Registry ) { + $wp_textdomain_registry = new WP_Textdomain_Registry(); + } + while ( true ) { if ( defined( 'WPLANG' ) ) { if ( '' === WPLANG ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index f176665365..8567d156df 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.2-alpha-54802'; +$wp_version = '6.2-alpha-54803'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.