Make WordPress Core

Ticket #38665: 38665.2.diff

File 38665.2.diff, 2.8 KB (added by johnbillion, 6 years ago)
  • src/wp-admin/includes/user.php

    diff --git a/src/wp-admin/includes/user.php b/src/wp-admin/includes/user.php
    index 4411880768..f99c50d85c 100644
    a b function edit_user( $user_id = 0 ) { 
    112112                }
    113113        }
    114114
     115        if ( isset( $_POST['locale'] ) ) {
     116                $locale = sanitize_text_field( $_POST['locale'] );
     117                if ( 'site-default' === $locale ) {
     118                        $locale = '';
     119                } elseif ( '' === $locale ) {
     120                        $locale = 'en_US';
     121                } elseif ( ! in_array( $locale, get_available_languages(), true ) ) {
     122                        $locale = '';
     123                }
     124
     125                $user->locale = $locale;
     126        }
     127
    115128        if ( $update ) {
    116129                $user->rich_editing         = isset( $_POST['rich_editing'] ) && 'false' === $_POST['rich_editing'] ? 'false' : 'true';
    117130                $user->syntax_highlighting  = isset( $_POST['syntax_highlighting'] ) && 'false' === $_POST['syntax_highlighting'] ? 'false' : 'true';
    118131                $user->admin_color          = isset( $_POST['admin_color'] ) ? sanitize_text_field( $_POST['admin_color'] ) : 'fresh';
    119132                $user->show_admin_bar_front = isset( $_POST['admin_bar_front'] ) ? 'true' : 'false';
    120133                $user->locale               = '';
    121 
    122                 if ( isset( $_POST['locale'] ) ) {
    123                         $locale = sanitize_text_field( $_POST['locale'] );
    124                         if ( 'site-default' === $locale ) {
    125                                 $locale = '';
    126                         } elseif ( '' === $locale ) {
    127                                 $locale = 'en_US';
    128                         } elseif ( ! in_array( $locale, get_available_languages(), true ) ) {
    129                                 $locale = '';
    130                         }
    131 
    132                         $user->locale = $locale;
    133                 }
    134134        }
    135135
    136136        $user->comment_shortcuts = isset( $_POST['comment_shortcuts'] ) && 'true' == $_POST['comment_shortcuts'] ? 'true' : '';
  • src/wp-admin/user-new.php

    diff --git a/src/wp-admin/user-new.php b/src/wp-admin/user-new.php
    index be4b5083bc..fe542e41b2 100644
    a b if ( current_user_can( 'create_users' ) ) { 
    498498                <th scope="row"><label for="url"><?php _e( 'Website' ); ?></label></th>
    499499                <td><input name="url" type="url" id="url" class="code" value="<?php echo esc_attr( $new_user_uri ); ?>" /></td>
    500500        </tr>
     501        <?php
     502        $languages = get_available_languages();
     503        if ( $languages ) : ?>
     504                <tr class="form-field user-language-wrap">
     505                        <th scope="row">
     506                                <?php /* translators: The user language selection field label */ ?>
     507                                <label for="locale"><?php _e( 'Language' ); ?><span class="dashicons dashicons-translation" aria-hidden="true"></span></label>
     508                        </th>
     509                        <td>
     510                                <?php
     511                                wp_dropdown_languages( array(
     512                                        'name'                        => 'locale',
     513                                        'id'                          => 'locale',
     514                                        'selected'                    => 'site-default',
     515                                        'languages'                   => $languages,
     516                                        'show_available_translations' => false,
     517                                        'show_option_site_default'    => true,
     518                                ) );
     519                                ?>
     520                        </td>
     521                </tr>
     522        <?php
     523        endif;
     524        ?>
    501525        <tr class="form-field form-required user-pass1-wrap">
    502526                <th scope="row">
    503527                        <label for="pass1">