REST API: Add locale to user resource.

Props ocean90, joehoyle.
Fixes #38528.

Built from https://develop.svn.wordpress.org/trunk@39090


git-svn-id: http://core.svn.wordpress.org/trunk@39032 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Ryan McCue 2016-11-02 06:24:29 +00:00
parent a911bf7e2c
commit 862724274e
2 changed files with 15 additions and 1 deletions

View File

@ -696,6 +696,10 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
$data['link'] = get_author_posts_url( $user->ID, $user->user_nicename );
}
if ( ! empty( $schema['properties']['locale'] ) ) {
$data['locale'] = get_user_locale( $user );
}
if ( ! empty( $schema['properties']['nickname'] ) ) {
$data['nickname'] = $user->nickname;
}
@ -833,6 +837,10 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
$prepared_user->user_url = $request['url'];
}
if ( isset( $request['locale'] ) && ! empty( $schema['properties']['locale'] ) ) {
$prepared_user->locale = $request['locale'];
}
// setting roles will be handled outside of this function.
if ( isset( $request['roles'] ) ) {
$prepared_user->role = false;
@ -978,6 +986,12 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
'context' => array( 'embed', 'view', 'edit' ),
'readonly' => true,
),
'locale' => array(
'description' => __( 'Locale for the resource.' ),
'type' => 'string',
'enum' => get_available_languages(),
'context' => array( 'edit' ),
),
'nickname' => array(
'description' => __( 'The nickname for the resource.' ),
'type' => 'string',

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.7-beta1-39089';
$wp_version = '4.7-beta1-39090';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.