I18N: In `wp_dropdown_languages()`, change the parsed arguments variable to `$parsed_args`, to prevent stomping the original `$args` array.
Props Mte90. See #40829. Built from https://develop.svn.wordpress.org/trunk@41733 git-svn-id: http://core.svn.wordpress.org/trunk@41567 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
7e29c9646a
commit
35617e12dd
|
@ -1133,7 +1133,7 @@ function wp_get_pomo_file_data( $po_file ) {
|
||||||
*/
|
*/
|
||||||
function wp_dropdown_languages( $args = array() ) {
|
function wp_dropdown_languages( $args = array() ) {
|
||||||
|
|
||||||
$args = wp_parse_args( $args, array(
|
$parsed_args = wp_parse_args( $args, array(
|
||||||
'id' => '',
|
'id' => '',
|
||||||
'name' => '',
|
'name' => '',
|
||||||
'languages' => array(),
|
'languages' => array(),
|
||||||
|
@ -1145,22 +1145,22 @@ function wp_dropdown_languages( $args = array() ) {
|
||||||
) );
|
) );
|
||||||
|
|
||||||
// English (United States) uses an empty string for the value attribute.
|
// English (United States) uses an empty string for the value attribute.
|
||||||
if ( 'en_US' === $args['selected'] ) {
|
if ( 'en_US' === $parsed_args['selected'] ) {
|
||||||
$args['selected'] = '';
|
$parsed_args['selected'] = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$translations = $args['translations'];
|
$translations = $parsed_args['translations'];
|
||||||
if ( empty( $translations ) ) {
|
if ( empty( $translations ) ) {
|
||||||
require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );
|
require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );
|
||||||
$translations = wp_get_available_translations();
|
$translations = wp_get_available_translations();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $args['languages'] should only contain the locales. Find the locale in
|
* $parsed_args['languages'] should only contain the locales. Find the locale in
|
||||||
* $translations to get the native name. Fall back to locale.
|
* $translations to get the native name. Fall back to locale.
|
||||||
*/
|
*/
|
||||||
$languages = array();
|
$languages = array();
|
||||||
foreach ( $args['languages'] as $locale ) {
|
foreach ( $parsed_args['languages'] as $locale ) {
|
||||||
if ( isset( $translations[ $locale ] ) ) {
|
if ( isset( $translations[ $locale ] ) ) {
|
||||||
$translation = $translations[ $locale ];
|
$translation = $translations[ $locale ];
|
||||||
$languages[] = array(
|
$languages[] = array(
|
||||||
|
@ -1180,9 +1180,9 @@ function wp_dropdown_languages( $args = array() ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$translations_available = ( ! empty( $translations ) && $args['show_available_translations'] );
|
$translations_available = ( ! empty( $translations ) && $parsed_args['show_available_translations'] );
|
||||||
|
|
||||||
$output = sprintf( '<select name="%s" id="%s">', esc_attr( $args['name'] ), esc_attr( $args['id'] ) );
|
$output = sprintf( '<select name="%s" id="%s">', esc_attr( $parsed_args['name'] ), esc_attr( $parsed_args['id'] ) );
|
||||||
|
|
||||||
// Holds the HTML markup.
|
// Holds the HTML markup.
|
||||||
$structure = array();
|
$structure = array();
|
||||||
|
@ -1192,17 +1192,17 @@ function wp_dropdown_languages( $args = array() ) {
|
||||||
$structure[] = '<optgroup label="' . esc_attr_x( 'Installed', 'translations' ) . '">';
|
$structure[] = '<optgroup label="' . esc_attr_x( 'Installed', 'translations' ) . '">';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $args['show_option_site_default'] ) {
|
if ( $parsed_args['show_option_site_default'] ) {
|
||||||
$structure[] = sprintf(
|
$structure[] = sprintf(
|
||||||
'<option value="site-default" data-installed="1"%s>%s</option>',
|
'<option value="site-default" data-installed="1"%s>%s</option>',
|
||||||
selected( 'site-default', $args['selected'], false ),
|
selected( 'site-default', $parsed_args['selected'], false ),
|
||||||
_x( 'Site Default', 'default site language' )
|
_x( 'Site Default', 'default site language' )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$structure[] = sprintf(
|
$structure[] = sprintf(
|
||||||
'<option value="" lang="en" data-installed="1"%s>English (United States)</option>',
|
'<option value="" lang="en" data-installed="1"%s>English (United States)</option>',
|
||||||
selected( '', $args['selected'], false )
|
selected( '', $parsed_args['selected'], false )
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ( $languages as $language ) {
|
foreach ( $languages as $language ) {
|
||||||
|
@ -1210,7 +1210,7 @@ function wp_dropdown_languages( $args = array() ) {
|
||||||
'<option value="%s" lang="%s"%s data-installed="1">%s</option>',
|
'<option value="%s" lang="%s"%s data-installed="1">%s</option>',
|
||||||
esc_attr( $language['language'] ),
|
esc_attr( $language['language'] ),
|
||||||
esc_attr( $language['lang'] ),
|
esc_attr( $language['lang'] ),
|
||||||
selected( $language['language'], $args['selected'], false ),
|
selected( $language['language'], $parsed_args['selected'], false ),
|
||||||
esc_html( $language['native_name'] )
|
esc_html( $language['native_name'] )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1226,7 +1226,7 @@ function wp_dropdown_languages( $args = array() ) {
|
||||||
'<option value="%s" lang="%s"%s>%s</option>',
|
'<option value="%s" lang="%s"%s>%s</option>',
|
||||||
esc_attr( $translation['language'] ),
|
esc_attr( $translation['language'] ),
|
||||||
esc_attr( current( $translation['iso'] ) ),
|
esc_attr( current( $translation['iso'] ) ),
|
||||||
selected( $translation['language'], $args['selected'], false ),
|
selected( $translation['language'], $parsed_args['selected'], false ),
|
||||||
esc_html( $translation['native_name'] )
|
esc_html( $translation['native_name'] )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1237,7 +1237,7 @@ function wp_dropdown_languages( $args = array() ) {
|
||||||
|
|
||||||
$output .= '</select>';
|
$output .= '</select>';
|
||||||
|
|
||||||
if ( $args['echo'] ) {
|
if ( $parsed_args['echo'] ) {
|
||||||
echo $output;
|
echo $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.9-alpha-41732';
|
$wp_version = '4.9-alpha-41733';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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