From 0f3c9c54a03021c445be4f9a7381e17044211132 Mon Sep 17 00:00:00 2001 From: Dominik Schilling Date: Mon, 7 Jan 2019 14:42:46 +0000 Subject: [PATCH] I18N: Expose JSON translation file paths in `load_script_textdomain()`. Removes `file_exist()` checks before calling `load_script_translations()` to let the determined paths be passed to `load_script_translations()` which provides its own file check and the possibility to filter the path. Merge of [44418] to the 5.0 branch. Props swissspidy, johnbillion, ocean90. Fixes #45769. Built from https://develop.svn.wordpress.org/branches/5.0@44419 git-svn-id: http://core.svn.wordpress.org/branches/5.0@44249 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/l10n.php | 25 +++++++++++++++++++------ wp-includes/version.php | 2 +- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/wp-includes/l10n.php b/wp-includes/l10n.php index 37cb0b980f..659fc87bdf 100644 --- a/wp-includes/l10n.php +++ b/wp-includes/l10n.php @@ -897,8 +897,13 @@ function load_script_textdomain( $handle, $domain, $path = null ) { // If a path was given and the handle file exists simply return it. $file_base = $domain === 'default' ? $locale : $domain . '-' . $locale; $handle_filename = $file_base . '-' . $handle . '.json'; - if ( $path && file_exists( $path . '/' . $handle_filename ) ) { - return load_script_translations( $path . '/' . $handle_filename, $handle, $domain ); + + if ( $path ) { + $translations = load_script_translations( $path . '/' . $handle_filename, $handle, $domain ); + + if ( $translations ) { + return $translations; + } } $src = $wp_scripts->registered[ $handle ]->src; @@ -958,11 +963,19 @@ function load_script_textdomain( $handle, $domain, $path = null ) { } $md5_filename = $file_base . '-' . md5( $relative ) . '.json'; - if ( $path && file_exists( $path . '/' . $md5_filename ) ) { - return load_script_translations( $path . '/' . $md5_filename, $handle, $domain ); + + if ( $path ) { + $translations = load_script_translations( $path . '/' . $md5_filename, $handle, $domain ); + + if ( $translations ) { + return $translations; + } } - if ( file_exists( $languages_path . '/' . $md5_filename ) ) { - return load_script_translations( $languages_path . '/' . $md5_filename, $handle, $domain ); + + $translations = load_script_translations( $languages_path . '/' . $md5_filename, $handle, $domain ); + + if ( $translations ) { + return $translations; } return load_script_translations( false, $handle, $domain ); diff --git a/wp-includes/version.php b/wp-includes/version.php index b5c1d454a6..5283b8ad0c 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '5.0.3-alpha-44409'; +$wp_version = '5.0.3-alpha-44419'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.