WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/08/2016 11:00:38 PM (20 months 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/tests/phpunit/tests/rest-api/rest-users-controller.php

    r39126 r39169  
    878878        $user = get_userdata( $user_id );
    879879        $this->assertEquals( 'en_US', $user->locale );
     880    }
     881
     882    /**
     883     * @ticket 38632
     884     */
     885    public function test_update_item_empty_locale() {
     886        $user_id = $this->factory->user->create( array( 'user_login' => 'test_json_user', 'user_email' => 'testjson@example.com', 'locale' => 'de_DE' ) );
     887        $this->allow_user_to_manage_multisite();
     888        wp_set_current_user( self::$user );
     889
     890        $request = new WP_REST_Request( 'PUT', '/wp/v2/users/' . $user_id );
     891        $request->set_param( 'locale', '' );
     892        $response = $this->server->dispatch( $request );
     893        $this->check_add_edit_user_response( $response, true );
     894
     895        $data = $response->get_data();
     896        $this->assertEquals( get_locale(), $data['locale'] );
     897        $user = get_userdata( $user_id );
     898        $this->assertEquals( '', $user->locale );
    880899    }
    881900
Note: See TracChangeset for help on using the changeset viewer.