Make WordPress Core

Ticket #29783: 29783.patch

File 29783.patch, 4.4 KB (added by ocean90, 10 years ago)
  • src/wp-admin/includes/user.php

     
    9494                $user->rich_editing = isset( $_POST['rich_editing'] ) && 'false' == $_POST['rich_editing'] ? 'false' : 'true';
    9595                $user->admin_color = isset( $_POST['admin_color'] ) ? sanitize_text_field( $_POST['admin_color'] ) : 'fresh';
    9696                $user->show_admin_bar_front = isset( $_POST['admin_bar_front'] ) ? 'true' : 'false';
     97                $user->site_language = isset( $_POST['site_language'] ) ? $_POST['site_language'] : 'default';
    9798        }
    9899
    99100        $user->comment_shortcuts = isset( $_POST['comment_shortcuts'] ) && 'true' == $_POST['comment_shortcuts'] ? 'true' : '';
  • src/wp-admin/options-general.php

     
    340340                <th width="33%" scope="row"><label for="WPLANG"><?php _e( 'Site Language' ); ?></label></th>
    341341                <td>
    342342                        <?php
    343                         $locale = get_locale();
     343                        add_filter( 'get_user_option_site_language', '__return_false' );
     344                        $locale = get_locale( false );
     345                        remove_filter( 'get_user_option_site_language', '__return_false' );
    344346                        if ( ! in_array( $locale, $languages ) ) {
    345347                                $locale = '';
    346348                        }
  • src/wp-admin/user-edit.php

     
    291291</td>
    292292</tr>
    293293<?php
     294$languages = get_available_languages();
     295if ( $languages ) : ?>
     296<tr class="user-language-wrap">
     297        <th scope="row">
     298                <label for="site_language"><?php _e( 'Site Language' ); ?></label>
     299        </th>
     300        <td>
     301                <?php
     302                $lang = get_user_option( 'site_language', $profileuser->ID );
     303                if ( '' === $lang ) { // en_US
     304                        $lang = false;
     305                } elseif ( 'default' === $lang || ! in_array( $lang, $languages ) ) {
     306                        $lang = get_locale();
     307                }
     308
     309                wp_dropdown_languages( array(
     310                        'name'         => 'site_language',
     311                        'id'           => 'site_language',
     312                        'selected'     => $lang,
     313                        'languages'    => $languages,
     314                        'show_available_translations' => false
     315                ) );
     316                ?>
     317        </td>
     318</tr>
     319<?php
     320endif;
     321
    294322/**
    295323 * Fires at the end of the 'Personal Options' settings table on the user editing screen.
    296324 *
  • src/wp-includes/l10n.php

     
    2121 *
    2222 * @since 1.5.0
    2323 *
     24 * @param  bool   $cached Whether to return the cached locale. Default true.
    2425 * @return string The locale of the blog or from the 'locale' hook.
    2526 */
    26 function get_locale() {
     27function get_locale( $cached = true ) {
    2728        global $locale, $wp_local_package;
    2829
    29         if ( isset( $locale ) ) {
     30        if ( $cached && isset( $locale ) ) {
    3031                /**
    3132                 * Filter WordPress install's locale ID.
    3233                 *
     
    6364                }
    6465        }
    6566
     67        if ( is_user_logged_in() ) {
     68                $user_language = get_user_option( 'site_language', get_current_user_id() );
     69
     70                if ( false !== $user_language && 'default' !== $user_language ) {
     71                        $locale = $user_language;
     72                }
     73        }
     74
    6675        if ( empty( $locale ) ) {
    6776                $locale = 'en_US';
    6877        }
  • src/wp-includes/user.php

     
    18691869
    18701870        $meta['show_admin_bar_front'] = empty( $userdata['show_admin_bar_front'] ) ? 'true' : $userdata['show_admin_bar_front'];
    18711871
     1872        $meta['site_language'] = isset( $userdata['site_language'] ) ? $userdata['site_language']: 'default';
     1873
    18721874        $user_nicename_check = $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->users WHERE user_nicename = %s AND user_login != %s LIMIT 1" , $user_nicename, $user_login));
    18731875
    18741876        if ( $user_nicename_check ) {
     
    20412043 * @return array
    20422044 */
    20432045function _get_additional_user_keys( $user ) {
    2044         $keys = array( 'first_name', 'last_name', 'nickname', 'description', 'rich_editing', 'comment_shortcuts', 'admin_color', 'use_ssl', 'show_admin_bar_front' );
     2046        $keys = array( 'first_name', 'last_name', 'nickname', 'description', 'rich_editing', 'comment_shortcuts', 'admin_color', 'use_ssl', 'show_admin_bar_front', 'site_language' );
    20452047        return array_merge( $keys, array_keys( wp_get_user_contact_methods( $user ) ) );
    20462048}
    20472049