WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/03/2016 07:03:41 AM (4 years ago)
Author:
swissspidy
Message:

I18N: Introduce a user-specific language setting.

By enabling the user to select their preferred locale when editing the profile, we allow for greater personalization of the WordPress admin and therefore a better user experience.

The back end will be displayed in the user's individual locale while the locale used on the front end equals the one set for the whole site. If the user didn't specify a locale, the site's locale will be used as a fallback. The new locale property of the WP_User class can be used to retrieve the user's locale setting.

Props ocean90, ipm-frommen, swissspidy.
Fixes #29783.

File:
1 edited

Legend:

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

    r38682 r38705  
    13591359 * @since 3.6.0 The `aim`, `jabber`, and `yim` fields were removed as default user contact
    13601360 *              methods for new installs. See wp_get_user_contact_methods().
     1361 * @since 4.7.0 The user's locale can be passed to `$userdata`.
    13611362 *
    13621363 * @global wpdb $wpdb WordPress database abstraction object.
     
    13931394 *                                             site's front end. Default true.
    13941395 *     @type string      $role                 User's role.
     1396 *     @type string      $locale               User's locale. Default empty.
    13951397 * }
    13961398 * @return int|WP_Error The newly created user's ID or a WP_Error object if the user could not
     
    16061608
    16071609    $meta['show_admin_bar_front'] = empty( $userdata['show_admin_bar_front'] ) ? 'true' : $userdata['show_admin_bar_front'];
     1610
     1611    $meta['locale'] = isset( $userdata['locale'] ) ? $userdata['locale'] : '';
    16081612
    16091613    $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));
     
    19661970 */
    19671971function _get_additional_user_keys( $user ) {
    1968     $keys = array( 'first_name', 'last_name', 'nickname', 'description', 'rich_editing', 'comment_shortcuts', 'admin_color', 'use_ssl', 'show_admin_bar_front' );
     1972    $keys = array( 'first_name', 'last_name', 'nickname', 'description', 'rich_editing', 'comment_shortcuts', 'admin_color', 'use_ssl', 'show_admin_bar_front', 'locale' );
    19691973    return array_merge( $keys, array_keys( wp_get_user_contact_methods( $user ) ) );
    19701974}
Note: See TracChangeset for help on using the changeset viewer.