@@ -985,6 +985,9 @@ function load_default_textdomain( $locale = null ) {
985985 * @since 4.6.0 The function now tries to load the .mo file from the languages directory first.
986986 * @since 6.7.0 Translations are no longer immediately loaded, but handed off to the just-in-time loading mechanism.
987987 *
988+ * @global WP_Textdomain_Registry $wp_textdomain_registry WordPress Textdomain Registry.
989+ * @global array<string, WP_Translations|NOOP_Translations> $l10n An array of all currently loaded text domains.
990+ *
988991 * @param string $domain Unique identifier for retrieving translated strings
989992 * @param string|false $deprecated Optional. Deprecated. Use the $plugin_rel_path parameter instead.
990993 * Default false.
@@ -994,7 +997,8 @@ function load_default_textdomain( $locale = null ) {
994997 */
995998function load_plugin_textdomain ( $ domain , $ deprecated = false , $ plugin_rel_path = false ) {
996999 /** @var WP_Textdomain_Registry $wp_textdomain_registry */
997- global $ wp_textdomain_registry ;
1000+ /** @var array<string, WP_Translations|NOOP_Translations> $l10n */
1001+ global $ wp_textdomain_registry , $ l10n ;
9981002
9991003 if ( ! is_string ( $ domain ) ) {
10001004 return false ;
@@ -1011,6 +1015,11 @@ function load_plugin_textdomain( $domain, $deprecated = false, $plugin_rel_path
10111015
10121016 $ wp_textdomain_registry ->set_custom_path ( $ domain , $ path );
10131017
1018+ // If just-in-time loading was triggered before, reset the entry so it can be tried again.
1019+ if ( isset ( $ l10n [ $ domain ] ) && $ l10n [ $ domain ] instanceof NOOP_Translations ) {
1020+ unset( $ l10n [ $ domain ] );
1021+ }
1022+
10141023 return true ;
10151024}
10161025
@@ -1022,6 +1031,7 @@ function load_plugin_textdomain( $domain, $deprecated = false, $plugin_rel_path
10221031 * @since 6.7.0 Translations are no longer immediately loaded, but handed off to the just-in-time loading mechanism.
10231032 *
10241033 * @global WP_Textdomain_Registry $wp_textdomain_registry WordPress Textdomain Registry.
1034+ * @global array<string, WP_Translations|NOOP_Translations> $l10n An array of all currently loaded text domains.
10251035 *
10261036 * @param string $domain Text domain. Unique identifier for retrieving translated strings.
10271037 * @param string $mu_plugin_rel_path Optional. Relative to `WPMU_PLUGIN_DIR` directory in which the .mo
@@ -1030,7 +1040,8 @@ function load_plugin_textdomain( $domain, $deprecated = false, $plugin_rel_path
10301040 */
10311041function load_muplugin_textdomain ( $ domain , $ mu_plugin_rel_path = '' ) {
10321042 /** @var WP_Textdomain_Registry $wp_textdomain_registry */
1033- global $ wp_textdomain_registry ;
1043+ /** @var array<string, WP_Translations|NOOP_Translations> $l10n */
1044+ global $ wp_textdomain_registry , $ l10n ;
10341045
10351046 if ( ! is_string ( $ domain ) ) {
10361047 return false ;
@@ -1040,6 +1051,11 @@ function load_muplugin_textdomain( $domain, $mu_plugin_rel_path = '' ) {
10401051
10411052 $ wp_textdomain_registry ->set_custom_path ( $ domain , $ path );
10421053
1054+ // If just-in-time loading was triggered before, reset the entry so it can be tried again.
1055+ if ( isset ( $ l10n [ $ domain ] ) && $ l10n [ $ domain ] instanceof NOOP_Translations ) {
1056+ unset( $ l10n [ $ domain ] );
1057+ }
1058+
10431059 return true ;
10441060}
10451061
@@ -1056,6 +1072,7 @@ function load_muplugin_textdomain( $domain, $mu_plugin_rel_path = '' ) {
10561072 * @since 6.7.0 Translations are no longer immediately loaded, but handed off to the just-in-time loading mechanism.
10571073 *
10581074 * @global WP_Textdomain_Registry $wp_textdomain_registry WordPress Textdomain Registry.
1075+ * @global array<string, WP_Translations|NOOP_Translations> $l10n An array of all currently loaded text domains.
10591076 *
10601077 * @param string $domain Text domain. Unique identifier for retrieving translated strings.
10611078 * @param string|false $path Optional. Path to the directory containing the .mo file.
@@ -1064,7 +1081,8 @@ function load_muplugin_textdomain( $domain, $mu_plugin_rel_path = '' ) {
10641081 */
10651082function load_theme_textdomain ( $ domain , $ path = false ) {
10661083 /** @var WP_Textdomain_Registry $wp_textdomain_registry */
1067- global $ wp_textdomain_registry ;
1084+ /** @var array<string, WP_Translations|NOOP_Translations> $l10n */
1085+ global $ wp_textdomain_registry , $ l10n ;
10681086
10691087 if ( ! is_string ( $ domain ) ) {
10701088 return false ;
@@ -1076,6 +1094,11 @@ function load_theme_textdomain( $domain, $path = false ) {
10761094
10771095 $ wp_textdomain_registry ->set_custom_path ( $ domain , $ path );
10781096
1097+ // If just-in-time loading was triggered before, reset the entry so it can be tried again.
1098+ if ( isset ( $ l10n [ $ domain ] ) && $ l10n [ $ domain ] instanceof NOOP_Translations ) {
1099+ unset( $ l10n [ $ domain ] );
1100+ }
1101+
10791102 return true ;
10801103}
10811104
0 commit comments