I18N: Use correct default value for JavaScript translations path.
The `$path` parameter of some script translation functions had a default value of `null`, even though the parameter is documented as a string. This commit corrects the default value for `$path` in: * `WP_Dependency::set_translations()` * `WP_Scripts::set_translations()` * `wp_set_script_translations()` Additionally, this commit removes an `is_string()` check for `$path` in `load_script_textdomain()`. Now that the default value for `$path` in that function has also been corrected to an empty string instead of `null`, that check is no longer necessary, as it would ''hide'' an error which should be ''fixed'' (at the source of the problem) instead. Follow-up to [54349]. Props jrf, johnjamesjacoby. See #55967, #55656. Built from https://develop.svn.wordpress.org/trunk@54351 git-svn-id: http://core.svn.wordpress.org/trunk@53910 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
14b6270285
commit
70f3a062db
|
@ -126,7 +126,7 @@ class _WP_Dependency {
|
||||||
* @param string $path Optional. The full file path to the directory containing translation files.
|
* @param string $path Optional. The full file path to the directory containing translation files.
|
||||||
* @return bool False if $domain is not a string, true otherwise.
|
* @return bool False if $domain is not a string, true otherwise.
|
||||||
*/
|
*/
|
||||||
public function set_translations( $domain, $path = null ) {
|
public function set_translations( $domain, $path = '' ) {
|
||||||
if ( ! is_string( $domain ) ) {
|
if ( ! is_string( $domain ) ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -573,7 +573,7 @@ class WP_Scripts extends WP_Dependencies {
|
||||||
* @param string $path Optional. The full file path to the directory containing translation files.
|
* @param string $path Optional. The full file path to the directory containing translation files.
|
||||||
* @return bool True if the text domain was registered, false if not.
|
* @return bool True if the text domain was registered, false if not.
|
||||||
*/
|
*/
|
||||||
public function set_translations( $handle, $domain = 'default', $path = null ) {
|
public function set_translations( $handle, $domain = 'default', $path = '' ) {
|
||||||
if ( ! isset( $this->registered[ $handle ] ) ) {
|
if ( ! isset( $this->registered[ $handle ] ) ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -605,7 +605,11 @@ class WP_Scripts extends WP_Dependencies {
|
||||||
}
|
}
|
||||||
|
|
||||||
$domain = $this->registered[ $handle ]->textdomain;
|
$domain = $this->registered[ $handle ]->textdomain;
|
||||||
$path = $this->registered[ $handle ]->translations_path;
|
$path = '';
|
||||||
|
|
||||||
|
if ( isset( $this->registered[ $handle ]->translations_path ) ) {
|
||||||
|
$path = $this->registered[ $handle ]->translations_path;
|
||||||
|
}
|
||||||
|
|
||||||
$json_translations = load_script_textdomain( $handle, $domain, $path );
|
$json_translations = load_script_textdomain( $handle, $domain, $path );
|
||||||
|
|
||||||
|
|
|
@ -237,7 +237,7 @@ function wp_localize_script( $handle, $object_name, $l10n ) {
|
||||||
* @param string $path Optional. The full file path to the directory containing translation files.
|
* @param string $path Optional. The full file path to the directory containing translation files.
|
||||||
* @return bool True if the text domain was successfully localized, false otherwise.
|
* @return bool True if the text domain was successfully localized, false otherwise.
|
||||||
*/
|
*/
|
||||||
function wp_set_script_translations( $handle, $domain = 'default', $path = null ) {
|
function wp_set_script_translations( $handle, $domain = 'default', $path = '' ) {
|
||||||
global $wp_scripts;
|
global $wp_scripts;
|
||||||
|
|
||||||
if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
|
if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
|
||||||
|
|
|
@ -1065,10 +1065,7 @@ function load_script_textdomain( $handle, $domain = 'default', $path = '' ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( is_string( $path ) ) {
|
$path = untrailingslashit( $path );
|
||||||
$path = untrailingslashit( $path );
|
|
||||||
}
|
|
||||||
|
|
||||||
$locale = determine_locale();
|
$locale = determine_locale();
|
||||||
|
|
||||||
// If a path was given and the handle file exists simply return it.
|
// If a path was given and the handle file exists simply return it.
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.1-beta2-54350';
|
$wp_version = '6.1-beta2-54351';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue