Make WordPress Core

Ticket #38665: 38665.diff

File 38665.diff, 2.4 KB (added by barryceelen, 9 years ago)
  • wp-admin/includes/user.php

    diff --git wp-admin/includes/user.php wp-admin/includes/user.php
    index 6bf826b..31acb14 100644
    function edit_user( $user_id = 0 ) { 
    9090                        $user->$method = sanitize_text_field( $_POST[$method] );
    9191        }
    9292
     93        if ( isset( $_POST['locale'] ) ) {
     94                $locale = sanitize_text_field( $_POST['locale'] );
     95                if ( ! in_array( $locale, get_available_languages(), true ) ) {
     96                        $locale = '';
     97                }
     98
     99                $user->locale = ( '' === $locale ) ? 'en_US' : $locale;
     100        }
     101
    93102        if ( $update ) {
    94103                $user->rich_editing = isset( $_POST['rich_editing'] ) && 'false' == $_POST['rich_editing'] ? 'false' : 'true';
    95104                $user->admin_color = isset( $_POST['admin_color'] ) ? sanitize_text_field( $_POST['admin_color'] ) : 'fresh';
    96105                $user->show_admin_bar_front = isset( $_POST['admin_bar_front'] ) ? 'true' : 'false';
    97                 $user->locale = '';
    98 
    99                 if ( isset( $_POST['locale'] ) ) {
    100                         $locale = sanitize_text_field( $_POST['locale'] );
    101                         if ( ! in_array( $locale, get_available_languages(), true ) ) {
    102                                 $locale = '';
    103                         }
    104 
    105                         $user->locale = ( '' === $locale ) ? 'en_US' : $locale;
    106                 }
    107106        }
    108107
    109108        $user->comment_shortcuts = isset( $_POST['comment_shortcuts'] ) && 'true' == $_POST['comment_shortcuts'] ? 'true' : '';
  • wp-admin/user-new.php

    diff --git wp-admin/user-new.php wp-admin/user-new.php
    index e039d71..5456947 100644
    $new_user_ignore_pass = $creating && isset( $_POST['noconfirmation'] ) ? wp_unsl 
    422422                <th scope="row"><label for="url"><?php _e('Website') ?></label></th>
    423423                <td><input name="url" type="url" id="url" class="code" value="<?php echo esc_attr( $new_user_uri ); ?>" /></td>
    424424        </tr>
     425        <?php
     426        $languages = get_available_languages();
     427        if ( $languages ) : ?>
     428        <tr class="form-field">
     429                <th scope="row">
     430                        <?php /* translators: The user language selection field label */ ?>
     431                        <label for="locale"><?php _e( 'Language' ); ?></label>
     432                </th>
     433                <td>
     434                        <?php
     435                        $locale = get_locale();
     436
     437                        if ( 'en_US' === $locale ) {
     438                                $locale = false;
     439                        }
     440
     441                        wp_dropdown_languages( array(
     442                                'name'                        => 'locale',
     443                                'id'                          => 'locale',
     444                                'selected'                    => $locale,
     445                                'languages'                   => $languages,
     446                                'show_available_translations' => false
     447                        ) );
     448                        ?>
     449                </td>
     450        </tr>
     451        <?php
     452        endif;
     453        ?>
    425454        <tr class="form-field form-required user-pass1-wrap">
    426455                <th scope="row">
    427456                        <label for="pass1">