From bdea1930c77cbbdd00f4e73bd50d253a5a30aed7 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Mon, 21 Oct 2024 14:13:14 +0000 Subject: [PATCH] I18N: Fix script languages path on Multisite. This is a follow-up to [59126] (itself a follow-up to [57922]), which caused a regression when determining the right path when loading script translations. Props swissspidy, themes-1, staurand. Fixes #62016. Built from https://develop.svn.wordpress.org/trunk@59264 git-svn-id: http://core.svn.wordpress.org/trunk@58656 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/l10n.php | 10 ++++++---- wp-includes/version.php | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/wp-includes/l10n.php b/wp-includes/l10n.php index e4acf40b38..bee3581618 100644 --- a/wp-includes/l10n.php +++ b/wp-includes/l10n.php @@ -1151,6 +1151,7 @@ function load_script_textdomain( $handle, $domain = 'default', $path = '' ) { $content_url = wp_parse_url( content_url() ); $plugins_url = wp_parse_url( plugins_url() ); $site_url = wp_parse_url( site_url() ); + $theme_root = get_theme_root(); // If the host is the same or it's a relative URL. if ( @@ -1167,12 +1168,13 @@ function load_script_textdomain( $handle, $domain = 'default', $path = '' ) { $relative = explode( '/', $relative ); /* - * Ensure correct languages path when using a custom `WP_PLUGIN_DIR` / `WP_PLUGIN_URL` configuration. + * Ensure correct languages path when using a custom `WP_PLUGIN_DIR` / `WP_PLUGIN_URL` configuration, + * a custom theme root, and/or using Multisite with subdirectories. * See https://core.trac.wordpress.org/ticket/60891 and https://core.trac.wordpress.org/ticket/62016. */ - $plugins_dir = array_slice( explode( '/', $plugins_url['path'] ), 2 ); - $plugins_dir = trim( $plugins_dir[0], '/' ); - $dirname = $plugins_dir === $relative[0] ? 'plugins' : 'themes'; + + $theme_dir = array_slice( explode( '/', $theme_root ), -1 ); + $dirname = $theme_dir[0] === $relative[0] ? 'themes' : 'plugins'; $languages_path = WP_LANG_DIR . '/' . $dirname; diff --git a/wp-includes/version.php b/wp-includes/version.php index aa680d13b8..46790dcaa6 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.7-beta3-59263'; +$wp_version = '6.7-beta3-59264'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.