Make WordPress Core

Changeset 41733


Ignore:
Timestamp:
10/04/2017 03:07:26 PM (7 years ago)
Author:
SergeyBiryukov
Message:

I18N: In wp_dropdown_languages(), change the parsed arguments variable to $parsed_args, to prevent stomping the original $args array.

Props Mte90.
See #40829.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/l10n.php

    r41289 r41733  
    11341134function wp_dropdown_languages( $args = array() ) {
    11351135
    1136     $args = wp_parse_args( $args, array(
     1136    $parsed_args = wp_parse_args( $args, array(
    11371137        'id'           => '',
    11381138        'name'         => '',
     
    11461146
    11471147    // English (United States) uses an empty string for the value attribute.
    1148     if ( 'en_US' === $args['selected'] ) {
    1149         $args['selected'] = '';
    1150     }
    1151 
    1152     $translations = $args['translations'];
     1148    if ( 'en_US' === $parsed_args['selected'] ) {
     1149        $parsed_args['selected'] = '';
     1150    }
     1151
     1152    $translations = $parsed_args['translations'];
    11531153    if ( empty( $translations ) ) {
    11541154        require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );
     
    11571157
    11581158    /*
    1159      * $args['languages'] should only contain the locales. Find the locale in
     1159     * $parsed_args['languages'] should only contain the locales. Find the locale in
    11601160     * $translations to get the native name. Fall back to locale.
    11611161     */
    11621162    $languages = array();
    1163     foreach ( $args['languages'] as $locale ) {
     1163    foreach ( $parsed_args['languages'] as $locale ) {
    11641164        if ( isset( $translations[ $locale ] ) ) {
    11651165            $translation = $translations[ $locale ];
     
    11811181    }
    11821182
    1183     $translations_available = ( ! empty( $translations ) && $args['show_available_translations'] );
    1184 
    1185     $output = sprintf( '<select name="%s" id="%s">', esc_attr( $args['name'] ), esc_attr( $args['id'] ) );
     1183    $translations_available = ( ! empty( $translations ) && $parsed_args['show_available_translations'] );
     1184
     1185    $output = sprintf( '<select name="%s" id="%s">', esc_attr( $parsed_args['name'] ), esc_attr( $parsed_args['id'] ) );
    11861186
    11871187    // Holds the HTML markup.
     
    11931193    }
    11941194
    1195     if ( $args['show_option_site_default'] ) {
     1195    if ( $parsed_args['show_option_site_default'] ) {
    11961196        $structure[] = sprintf(
    11971197            '<option value="site-default" data-installed="1"%s>%s</option>',
    1198             selected( 'site-default', $args['selected'], false ),
     1198            selected( 'site-default', $parsed_args['selected'], false ),
    11991199            _x( 'Site Default', 'default site language' )
    12001200        );
     
    12031203    $structure[] = sprintf(
    12041204        '<option value="" lang="en" data-installed="1"%s>English (United States)</option>',
    1205         selected( '', $args['selected'], false )
     1205        selected( '', $parsed_args['selected'], false )
    12061206    );
    12071207
     
    12111211            esc_attr( $language['language'] ),
    12121212            esc_attr( $language['lang'] ),
    1213             selected( $language['language'], $args['selected'], false ),
     1213            selected( $language['language'], $parsed_args['selected'], false ),
    12141214            esc_html( $language['native_name'] )
    12151215        );
     
    12271227                esc_attr( $translation['language'] ),
    12281228                esc_attr( current( $translation['iso'] ) ),
    1229                 selected( $translation['language'], $args['selected'], false ),
     1229                selected( $translation['language'], $parsed_args['selected'], false ),
    12301230                esc_html( $translation['native_name'] )
    12311231            );
     
    12381238    $output .= '</select>';
    12391239
    1240     if ( $args['echo'] ) {
     1240    if ( $parsed_args['echo'] ) {
    12411241        echo $output;
    12421242    }
Note: See TracChangeset for help on using the changeset viewer.