WordPress.org

Make WordPress Core

Changeset 28984


Ignore:
Timestamp:
07/03/2014 10:55:57 PM (4 years ago)
Author:
johnbillion
Message:

If we already have a value for WPLANG when installing, insert this language at the top of the language selector and pre-select it. See #28577

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/install.php

    r28983 r28984  
    6161    $body = wp_remote_retrieve_body( $response );
    6262    if ( $body && $body = json_decode( $body, true ) ) {
     63        $languages = array();
     64        // Key the language array with the language code
     65        foreach ( $body['languages'] as $language ) {
     66            $languages[$language['language']] = $language;
     67        }
     68        $body['languages'] = $languages;
    6369        return $body;
    6470    }
     
    211217            echo "\n";
    212218
     219            if ( defined( 'WPLANG' ) && ( '' !== WPLANG ) && ( 'en_US' !== WPLANG ) ) {
     220                if ( isset( $body['languages'][WPLANG] ) ) {
     221                    $language = $body['languages'][WPLANG];
     222                    echo '<input type="radio" name="language" checked="checked" class="' . esc_attr( $language['language'] ) . ' screen-reader-input" id="language_wplang" value="' . esc_attr( $language['language'] ) . '">';
     223                    echo '<label for="language_wplang">' . esc_html( $language['native_name'] ) . "</label>\n";
     224                }
     225            }
     226
    213227            foreach ( $body['languages'] as $language ) {
    214228                echo '<input type="radio" name="language" class="' . esc_attr( $language['language'] ) . ' screen-reader-input" id="language_'. esc_attr( $language['language'] ) .'" value="' . esc_attr( $language['language'] ) . '">';
    215229                echo '<label for="language_' . esc_attr( $language['language'] ) . '">' . esc_html( $language['native_name'] ) . "</label>\n";
    216230            }
    217 
    218231            echo "</fieldset>\n";
    219232            echo '<p class="step"><input type="submit" class="button button-primary button-hero" value="&raquo;" /></p>';
Note: See TracChangeset for help on using the changeset viewer.