From 54ff1789231932346e5d7aa940a04e8399775215 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 4 Oct 2017 15:23:46 +0000 Subject: [PATCH] I18N: Make sure `wp_dropdown_languages()` does not print out empty `name` and `id` attributes. Props johnjamesjacoby, afercia. Fixes #40829. Built from https://develop.svn.wordpress.org/trunk@41734 git-svn-id: http://core.svn.wordpress.org/trunk@41568 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/l10n.php | 21 ++++++++++++++------- wp-includes/version.php | 2 +- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/wp-includes/l10n.php b/wp-includes/l10n.php index e831fe2b6c..a273b0c6dd 100644 --- a/wp-includes/l10n.php +++ b/wp-includes/l10n.php @@ -1117,8 +1117,8 @@ function wp_get_pomo_file_data( $po_file ) { * @param string|array $args { * Optional. Array or string of arguments for outputting the language selector. * - * @type string $id ID attribute of the select element. Default empty. - * @type string $name Name attribute of the select element. Default empty. + * @type string $id ID attribute of the select element. Default 'locale'. + * @type string $name Name attribute of the select element. Default 'locale'. * @type array $languages List of installed languages, contain only the locales. * Default empty array. * @type array $translations List of available translations. Default result of @@ -1134,8 +1134,8 @@ function wp_get_pomo_file_data( $po_file ) { function wp_dropdown_languages( $args = array() ) { $parsed_args = wp_parse_args( $args, array( - 'id' => '', - 'name' => '', + 'id' => 'locale', + 'name' => 'locale', 'languages' => array(), 'translations' => array(), 'selected' => '', @@ -1144,6 +1144,11 @@ function wp_dropdown_languages( $args = array() ) { 'show_option_site_default' => false, ) ); + // Bail if no ID or no name. + if ( ! $parsed_args['id'] || ! $parsed_args['name'] ) { + return; + } + // English (United States) uses an empty string for the value attribute. if ( 'en_US' === $parsed_args['selected'] ) { $parsed_args['selected'] = ''; @@ -1182,8 +1187,6 @@ function wp_dropdown_languages( $args = array() ) { $translations_available = ( ! empty( $translations ) && $parsed_args['show_available_translations'] ); - $output = sprintf( '', esc_attr( $parsed_args['name'] ), esc_attr( $parsed_args['id'] ) ); $output .= join( "\n", $structure ); - $output .= ''; if ( $parsed_args['echo'] ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index 988c7c358a..32323dce23 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.9-alpha-41733'; +$wp_version = '4.9-alpha-41734'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.