I18N: Make domain argument optional in wp_set_script_translations() / WP_Scripts::set_translations().

Props swissspidy.
Fixes #45489.

git-svn-id: https://develop.svn.wordpress.org/trunk@44395 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dominik Schilling (ocean90)
2019-01-04 21:11:01 +00:00
parent b9c3486f73
commit 8cf4e9ce6a
4 changed files with 24 additions and 22 deletions

View File

@@ -499,14 +499,14 @@ class WP_Scripts extends WP_Dependencies {
* Sets a translation textdomain.
*
* @since 5.0.0
* @since 5.1.0 The `$domain` parameter was made optional.
*
* @param string $handle Name of the script to register a translation domain to.
* @param string $domain The textdomain.
* @param string $domain Optional. Text domain. Default 'default'.
* @param string $path Optional. The full file path to the directory containing translation files.
*
* @return bool True if the textdomain was registered, false if not.
* @return bool True if the text domain was registered, false if not.
*/
public function set_translations( $handle, $domain, $path = null ) {
public function set_translations( $handle, $domain = 'default', $path = null ) {
if ( ! isset( $this->registered[ $handle ] ) ) {
return false;
}
@@ -517,6 +517,7 @@ class WP_Scripts extends WP_Dependencies {
if ( ! in_array( 'wp-i18n', $obj->deps, true ) ) {
$obj->deps[] = 'wp-i18n';
}
return $obj->set_translations( $domain, $path );
}