diff --git a/wp-includes/l10n.php b/wp-includes/l10n.php index 1923c8c2a2..632f432f62 100644 --- a/wp-includes/l10n.php +++ b/wp-includes/l10n.php @@ -821,7 +821,7 @@ function load_textdomain( $domain, $mofile, $locale = null ) { if ( 'mo' !== $preferred_format ) { array_unshift( $translation_files, - substr_replace( $mofile, ".l10n.$preferred_format", - strlen( $preferred_format ) ) + substr_replace( $mofile, ".l10n.$preferred_format", - strlen( '.mo' ) ) ); } diff --git a/wp-includes/l10n/class-wp-translation-controller.php b/wp-includes/l10n/class-wp-translation-controller.php index fbe5fa7d0c..616dce5793 100644 --- a/wp-includes/l10n/class-wp-translation-controller.php +++ b/wp-includes/l10n/class-wp-translation-controller.php @@ -151,11 +151,13 @@ final class WP_Translation_Controller { } if ( null !== $locale ) { - foreach ( $this->loaded_translations[ $locale ][ $textdomain ] as $i => $moe ) { - if ( $file === $moe || $file === $moe->get_file() ) { - unset( $this->loaded_translations[ $locale ][ $textdomain ][ $i ] ); - unset( $this->loaded_files[ $moe->get_file() ][ $locale ][ $textdomain ] ); - return true; + if ( isset( $this->loaded_translations[ $locale ][ $textdomain ] ) ) { + foreach ( $this->loaded_translations[ $locale ][ $textdomain ] as $i => $moe ) { + if ( $file === $moe || $file === $moe->get_file() ) { + unset( $this->loaded_translations[ $locale ][ $textdomain ][ $i ] ); + unset( $this->loaded_files[ $moe->get_file() ][ $locale ][ $textdomain ] ); + return true; + } } } @@ -163,6 +165,10 @@ final class WP_Translation_Controller { } foreach ( $this->loaded_translations as $l => $domains ) { + if ( ! isset( $domains[ $textdomain ] ) ) { + continue; + } + foreach ( $domains[ $textdomain ] as $i => $moe ) { if ( $file === $moe || $file === $moe->get_file() ) { unset( $this->loaded_translations[ $l ][ $textdomain ][ $i ] ); @@ -185,18 +191,21 @@ final class WP_Translation_Controller { * @return bool True on success, false otherwise. */ public function unload_textdomain( string $textdomain = 'default', string $locale = null ): bool { + $unloaded = false; + if ( null !== $locale ) { - foreach ( $this->loaded_translations[ $locale ][ $textdomain ] as $moe ) { - unset( $this->loaded_files[ $moe->get_file() ][ $locale ][ $textdomain ] ); + if ( isset( $this->loaded_translations[ $locale ][ $textdomain ] ) ) { + $unloaded = true; + foreach ( $this->loaded_translations[ $locale ][ $textdomain ] as $moe ) { + unset( $this->loaded_files[ $moe->get_file() ][ $locale ][ $textdomain ] ); + } } unset( $this->loaded_translations[ $locale ][ $textdomain ] ); - return true; + return $unloaded; } - $unloaded = false; - foreach ( $this->loaded_translations as $l => $domains ) { if ( ! isset( $domains[ $textdomain ] ) ) { continue; diff --git a/wp-includes/version.php b/wp-includes/version.php index 10606651d3..18d8cb6360 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.5-alpha-57338'; +$wp_version = '6.5-alpha-57339'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.