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
This commit is contained in:
Pascal Birchler 2024-10-21 14:13:14 +00:00
parent 224824fb85
commit bdea1930c7
2 changed files with 7 additions and 5 deletions

View File

@ -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;

View File

@ -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.