mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-18 14:21:25 +01:00
I18N: Add support for custom WP_PLUGIN_URL
in load_script_textdomain()
.
Plugins may not be on the same host/path as the rest of the content. To support loading translations for this setup check if the script source matches `plugins_url()`. Also fixes an undefined index notice when a custom content URL has no path. Props odminstudios, ocean90. Fixes #46336, #46387. Built from https://develop.svn.wordpress.org/trunk@45685 git-svn-id: http://core.svn.wordpress.org/trunk@45496 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
0af752e360
commit
8059b362e8
@ -948,20 +948,43 @@ function load_script_textdomain( $handle, $domain = 'default', $path = null ) {
|
||||
|
||||
$src_url = wp_parse_url( $src );
|
||||
$content_url = wp_parse_url( content_url() );
|
||||
$plugins_url = wp_parse_url( plugins_url() );
|
||||
$site_url = wp_parse_url( site_url() );
|
||||
|
||||
// If the host is the same or it's a relative URL.
|
||||
if (
|
||||
strpos( $src_url['path'], $content_url['path'] ) === 0 &&
|
||||
( ! isset( $content_url['path'] ) || strpos( $src_url['path'], $content_url['path'] ) === 0 ) &&
|
||||
( ! isset( $src_url['host'] ) || $src_url['host'] === $content_url['host'] )
|
||||
) {
|
||||
// Make the src relative the specific plugin or theme.
|
||||
$relative = trim( substr( $src_url['path'], strlen( $content_url['path'] ) ), '/' );
|
||||
if ( isset( $content_url['path'] ) ) {
|
||||
$relative = substr( $src_url['path'], strlen( $content_url['path'] ) );
|
||||
} else {
|
||||
$relative = $src_url['path'];
|
||||
}
|
||||
$relative = trim( $relative, '/' );
|
||||
$relative = explode( '/', $relative );
|
||||
|
||||
$languages_path = WP_LANG_DIR . '/' . $relative[0];
|
||||
|
||||
$relative = array_slice( $relative, 2 );
|
||||
$relative = array_slice( $relative, 2 ); // Remove plugins/<plugin name> or themes/<theme name>.
|
||||
$relative = implode( '/', $relative );
|
||||
} elseif (
|
||||
( ! isset( $plugins_url['path'] ) || strpos( $src_url['path'], $plugins_url['path'] ) === 0 ) &&
|
||||
( ! isset( $src_url['host'] ) || $src_url['host'] === $plugins_url['host'] )
|
||||
) {
|
||||
// Make the src relative the specific plugin.
|
||||
if ( isset( $plugins_url['path'] ) ) {
|
||||
$relative = substr( $src_url['path'], strlen( $plugins_url['path'] ) );
|
||||
} else {
|
||||
$relative = $src_url['path'];
|
||||
}
|
||||
$relative = trim( $relative, '/' );
|
||||
$relative = explode( '/', $relative );
|
||||
|
||||
$languages_path = WP_LANG_DIR . '/plugins';
|
||||
|
||||
$relative = array_slice( $relative, 1 ); // Remove <plugin name>.
|
||||
$relative = implode( '/', $relative );
|
||||
} elseif ( ! isset( $src_url['host'] ) || $src_url['host'] === $site_url['host'] ) {
|
||||
if ( ! isset( $site_url['path'] ) ) {
|
||||
|
@ -13,7 +13,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.3-alpha-45684';
|
||||
$wp_version = '5.3-alpha-45685';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user