From a22b094047225dfaa507f2142afcc5218817fea5 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Wed, 29 May 2024 15:44:13 +0000 Subject: [PATCH] I18N: Add new `lang_dir_for_domain` filter. This new filter in `WP_Textdomain_Registry` allows plugins to override the determined languages folder when using just-in-time translation loading. Props swissspidy, chouby, johnbillion. Fixes #61206. Built from https://develop.svn.wordpress.org/trunk@58236 git-svn-id: http://core.svn.wordpress.org/trunk@57699 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-textdomain-registry.php | 17 ++++++++++++----- wp-includes/version.php | 2 +- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/wp-includes/class-wp-textdomain-registry.php b/wp-includes/class-wp-textdomain-registry.php index fe6d04b0a1..70e41eabfd 100644 --- a/wp-includes/class-wp-textdomain-registry.php +++ b/wp-includes/class-wp-textdomain-registry.php @@ -88,14 +88,21 @@ class WP_Textdomain_Registry { * @param string $domain Text domain. * @param string $locale Locale. * - * @return string|false MO file path or false if there is none available. + * @return string|false Languages directory path or false if there is none available. */ public function get( $domain, $locale ) { - if ( isset( $this->all[ $domain ][ $locale ] ) ) { - return $this->all[ $domain ][ $locale ]; - } + $path = $this->all[ $domain ][ $locale ] ?? $this->get_path_from_lang_dir( $domain, $locale ); - return $this->get_path_from_lang_dir( $domain, $locale ); + /** + * Filters the determined languages directory path for a specific domain and locale. + * + * @since 6.6.0 + * + * @param string|false $path Languages directory path for the given domain and locale. + * @param string $domain Text domain. + * @param string $locale Locale. + **/ + return apply_filters( 'lang_dir_for_domain', $path, $domain, $locale ); } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index 3a5867c6f1..a99bd7de9e 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.6-alpha-58235'; +$wp_version = '6.6-alpha-58236'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.