From 522c6b83d1b6a5fc174ba0c297b97da6ab50854d Mon Sep 17 00:00:00 2001 From: Jb Audras Date: Thu, 2 Feb 2023 21:29:53 +0000 Subject: [PATCH] I18N: Pass `$locale` parameter to `override_load_textdomain` filter. In [53874] the `$locale` parameter was added to `load_textdomain()` so it can be used to properly fill `WP_Textdomain_Registry`. Since `$locale` may not be the same value as `determine_locale()` returns (e.g. when filtered by `plugin_locale` in `load_plugin_textdomain()`) this changeset also passes the `$locale` parameter to the filter so custom file loading implementations are using the same locale as `load_textdomain()` got. Follow-up to [53874]. Props ocean90, cadic, SergeyBiryukov, swissspidy, costdev. Fixes #57056. git-svn-id: https://develop.svn.wordpress.org/trunk@55196 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/l10n.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/wp-includes/l10n.php b/src/wp-includes/l10n.php index e83706df66..f3dbc282bb 100644 --- a/src/wp-includes/l10n.php +++ b/src/wp-includes/l10n.php @@ -725,12 +725,14 @@ function load_textdomain( $domain, $mofile, $locale = null ) { * Filters whether to override the .mo file loading. * * @since 2.9.0 + * @since 6.2.0 Added the `$locale` parameter. * - * @param bool $override Whether to override the .mo file loading. Default false. - * @param string $domain Text domain. Unique identifier for retrieving translated strings. - * @param string $mofile Path to the MO file. + * @param bool $override Whether to override the .mo file loading. Default false. + * @param string $domain Text domain. Unique identifier for retrieving translated strings. + * @param string $mofile Path to the MO file. + * @param string|null $locale Locale. */ - $plugin_override = apply_filters( 'override_load_textdomain', false, $domain, $mofile ); + $plugin_override = apply_filters( 'override_load_textdomain', false, $domain, $mofile, $locale ); if ( true === (bool) $plugin_override ) { unset( $l10n_unloaded[ $domain ] );