Make WordPress Core


Ignore:
Timestamp:
11/08/2016 11:00:38 PM (8 years ago)
Author:
swissspidy
Message:

I18N: Add ability to change user's locale back to site's locale.

Previously there was no way to remove the user locale setting again, even though that might be desirable.

This adds a new 'Site Default' option to the user-specific language setting by introducing a new show_site_locale_default argument to wp_dropdown_languages().

Props ocean90.
See #29783.
Fixes #38632.

File:
1 edited

Legend:

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

    r38705 r39169  
    9999        if ( isset( $_POST['locale'] ) ) {
    100100            $locale = sanitize_text_field( $_POST['locale'] );
    101             if ( ! in_array( $locale, get_available_languages(), true ) ) {
     101            if ( 'site-default' === $locale ) {
    102102                $locale = '';
     103            } elseif ( ! in_array( $locale, get_available_languages(), true ) ) {
     104                $locale = 'en_US';
    103105            }
    104106
    105             $user->locale = ( '' === $locale ) ? 'en_US' : $locale;
     107            $user->locale = $locale;
    106108        }
    107109    }
Note: See TracChangeset for help on using the changeset viewer.