REST API: Update “resource” strings to use the appropriate nouns.

Props ramiy.
Fixes #38811.

git-svn-id: https://develop.svn.wordpress.org/trunk@39342 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Joe Hoyle
2016-11-23 02:42:00 +00:00
parent d6d843dccd
commit 2341473a5f
9 changed files with 115 additions and 115 deletions
@@ -87,7 +87,7 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
'force' => array(
'type' => 'boolean',
'default' => false,
'description' => __( 'Required to be true, as resource does not support trashing.' ),
'description' => __( 'Required to be true, as users do not support trashing.' ),
),
'reassign' => array(
'type' => 'integer',
@@ -120,7 +120,7 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
'force' => array(
'type' => 'boolean',
'default' => false,
'description' => __( 'Required to be true, as resource does not support trashing.' ),
'description' => __( 'Required to be true, as users do not support trashing.' ),
),
'reassign' => array(
'type' => 'integer',
@@ -144,7 +144,7 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
public function get_items_permissions_check( $request ) {
// Check if roles is specified in GET request and if user can list users.
if ( ! empty( $request['roles'] ) && ! current_user_can( 'list_users' ) ) {
return new WP_Error( 'rest_user_cannot_view', __( 'Sorry, you are not allowed to filter by role.' ), array( 'status' => rest_authorization_required_code() ) );
return new WP_Error( 'rest_user_cannot_view', __( 'Sorry, you are not allowed to filter users by role.' ), array( 'status' => rest_authorization_required_code() ) );
}
if ( 'edit' === $request['context'] && ! current_user_can( 'list_users' ) ) {
@@ -152,7 +152,7 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
}
if ( in_array( $request['orderby'], array( 'email', 'registered_date' ), true ) && ! current_user_can( 'list_users' ) ) {
return new WP_Error( 'rest_forbidden_orderby', __( 'Sorry, you are not allowed to order by this parameter.' ), array( 'status' => rest_authorization_required_code() ) );
return new WP_Error( 'rest_forbidden_orderby', __( 'Sorry, you are not allowed to order users by this parameter.' ), array( 'status' => rest_authorization_required_code() ) );
}
return true;
@@ -312,7 +312,7 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
$types = get_post_types( array( 'show_in_rest' => true ), 'names' );
if ( empty( $id ) || empty( $user->ID ) ) {
return new WP_Error( 'rest_user_invalid_id', __( 'Invalid resource ID.' ), array( 'status' => 404 ) );
return new WP_Error( 'rest_user_invalid_id', __( 'Invalid user ID.' ), array( 'status' => 404 ) );
}
if ( get_current_user_id() === $id ) {
@@ -342,7 +342,7 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
$user = get_userdata( $id );
if ( empty( $id ) || empty( $user->ID ) ) {
return new WP_Error( 'rest_user_invalid_id', __( 'Invalid resource ID.' ), array( 'status' => 404 ) );
return new WP_Error( 'rest_user_invalid_id', __( 'Invalid user ID.' ), array( 'status' => 404 ) );
}
$user = $this->prepare_item_for_response( $user, $request );
@@ -387,7 +387,7 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
public function create_item_permissions_check( $request ) {
if ( ! current_user_can( 'create_users' ) ) {
return new WP_Error( 'rest_cannot_create_user', __( 'Sorry, you are not allowed to create new resource.' ), array( 'status' => rest_authorization_required_code() ) );
return new WP_Error( 'rest_cannot_create_user', __( 'Sorry, you are not allowed to create new users.' ), array( 'status' => rest_authorization_required_code() ) );
}
return true;
@@ -404,7 +404,7 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
*/
public function create_item( $request ) {
if ( ! empty( $request['id'] ) ) {
return new WP_Error( 'rest_user_exists', __( 'Cannot create existing resource.' ), array( 'status' => 400 ) );
return new WP_Error( 'rest_user_exists', __( 'Cannot create existing user.' ), array( 'status' => 400 ) );
}
$schema = $this->get_item_schema();
@@ -440,7 +440,7 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
$user_id = wpmu_create_user( $user->user_login, $user->user_pass, $user->user_email );
if ( ! $user_id ) {
return new WP_Error( 'rest_user_create', __( 'Error creating new resource.' ), array( 'status' => 500 ) );
return new WP_Error( 'rest_user_create', __( 'Error creating new user.' ), array( 'status' => 500 ) );
}
$user->ID = $user_id;
@@ -515,11 +515,11 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
$id = (int) $request['id'];
if ( ! current_user_can( 'edit_user', $id ) ) {
return new WP_Error( 'rest_cannot_edit', __( 'Sorry, you are not allowed to edit this resource.' ), array( 'status' => rest_authorization_required_code() ) );
return new WP_Error( 'rest_cannot_edit', __( 'Sorry, you are not allowed to edit this user.' ), array( 'status' => rest_authorization_required_code() ) );
}
if ( ! empty( $request['roles'] ) && ! current_user_can( 'edit_users' ) ) {
return new WP_Error( 'rest_cannot_edit_roles', __( 'Sorry, you are not allowed to edit roles of this resource.' ), array( 'status' => rest_authorization_required_code() ) );
return new WP_Error( 'rest_cannot_edit_roles', __( 'Sorry, you are not allowed to edit roles of this user.' ), array( 'status' => rest_authorization_required_code() ) );
}
return true;
@@ -539,7 +539,7 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
$user = get_userdata( $id );
if ( ! $user ) {
return new WP_Error( 'rest_user_invalid_id', __( 'Invalid resource ID.' ), array( 'status' => 404 ) );
return new WP_Error( 'rest_user_invalid_id', __( 'Invalid user ID.' ), array( 'status' => 404 ) );
}
if ( email_exists( $request['email'] ) && $request['email'] !== $user->user_email ) {
@@ -654,7 +654,7 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
$id = (int) $request['id'];
if ( ! current_user_can( 'delete_user', $id ) ) {
return new WP_Error( 'rest_user_cannot_delete', __( 'Sorry, you are not allowed to delete this resource.' ), array( 'status' => rest_authorization_required_code() ) );
return new WP_Error( 'rest_user_cannot_delete', __( 'Sorry, you are not allowed to delete this user.' ), array( 'status' => rest_authorization_required_code() ) );
}
return true;
@@ -674,7 +674,7 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
$reassign = isset( $request['reassign'] ) ? absint( $request['reassign'] ) : null;
$force = isset( $request['force'] ) ? (bool) $request['force'] : false;
// We don't support trashing for this type, error out.
// We don't support trashing for users.
if ( ! $force ) {
return new WP_Error( 'rest_trash_not_supported', __( 'Users do not support trashing. Set force=true to delete.' ), array( 'status' => 501 ) );
}
@@ -682,12 +682,12 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
$user = get_userdata( $id );
if ( ! $user ) {
return new WP_Error( 'rest_user_invalid_id', __( 'Invalid resource ID.' ), array( 'status' => 404 ) );
return new WP_Error( 'rest_user_invalid_id', __( 'Invalid user ID.' ), array( 'status' => 404 ) );
}
if ( ! empty( $reassign ) ) {
if ( $reassign === $id || ! get_userdata( $reassign ) ) {
return new WP_Error( 'rest_user_invalid_reassign', __( 'Invalid resource ID for reassignment.' ), array( 'status' => 400 ) );
return new WP_Error( 'rest_user_invalid_reassign', __( 'Invalid user ID for reassignment.' ), array( 'status' => 400 ) );
}
}
@@ -701,7 +701,7 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
$result = wp_delete_user( $id, $reassign );
if ( ! $result ) {
return new WP_Error( 'rest_cannot_delete', __( 'The resource cannot be deleted.' ), array( 'status' => 500 ) );
return new WP_Error( 'rest_cannot_delete', __( 'The user cannot be deleted.' ), array( 'status' => 500 ) );
}
$response = new WP_REST_Response();
@@ -995,7 +995,7 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
&& get_current_user_id() === $user_id
&& ! $potential_role->has_cap( 'edit_users' )
) {
return new WP_Error( 'rest_user_invalid_role', __( 'Sorry, you are not allowed to give resource that role.' ), array( 'status' => rest_authorization_required_code() ) );
return new WP_Error( 'rest_user_invalid_role', __( 'Sorry, you are not allowed to give users that role.' ), array( 'status' => rest_authorization_required_code() ) );
}
/** Include admin functions to get access to get_editable_roles() */
@@ -1005,7 +1005,7 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
$editable_roles = get_editable_roles();
if ( empty( $editable_roles[ $role ] ) ) {
return new WP_Error( 'rest_user_invalid_role', __( 'Sorry, you are not allowed to give resource that role.' ), array( 'status' => 403 ) );
return new WP_Error( 'rest_user_invalid_role', __( 'Sorry, you are not allowed to give users that role.' ), array( 'status' => 403 ) );
}
}
@@ -1082,13 +1082,13 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
'type' => 'object',
'properties' => array(
'id' => array(
'description' => __( 'Unique identifier for the resource.' ),
'description' => __( 'Unique identifier for the user.' ),
'type' => 'integer',
'context' => array( 'embed', 'view', 'edit' ),
'readonly' => true,
),
'username' => array(
'description' => __( 'Login name for the resource.' ),
'description' => __( 'Login name for the user.' ),
'type' => 'string',
'context' => array( 'edit' ),
'required' => true,
@@ -1097,7 +1097,7 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
),
),
'name' => array(
'description' => __( 'Display name for the resource.' ),
'description' => __( 'Display name for the user.' ),
'type' => 'string',
'context' => array( 'embed', 'view', 'edit' ),
'arg_options' => array(
@@ -1105,7 +1105,7 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
),
),
'first_name' => array(
'description' => __( 'First name for the resource.' ),
'description' => __( 'First name for the user.' ),
'type' => 'string',
'context' => array( 'edit' ),
'arg_options' => array(
@@ -1113,7 +1113,7 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
),
),
'last_name' => array(
'description' => __( 'Last name for the resource.' ),
'description' => __( 'Last name for the user.' ),
'type' => 'string',
'context' => array( 'edit' ),
'arg_options' => array(
@@ -1121,38 +1121,38 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
),
),
'email' => array(
'description' => __( 'The email address for the resource.' ),
'description' => __( 'The email address for the user.' ),
'type' => 'string',
'format' => 'email',
'context' => array( 'edit' ),
'required' => true,
),
'url' => array(
'description' => __( 'URL of the resource.' ),
'description' => __( 'URL of the user.' ),
'type' => 'string',
'format' => 'uri',
'context' => array( 'embed', 'view', 'edit' ),
),
'description' => array(
'description' => __( 'Description of the resource.' ),
'description' => __( 'Description of the user.' ),
'type' => 'string',
'context' => array( 'embed', 'view', 'edit' ),
),
'link' => array(
'description' => __( 'Author URL of the resource.' ),
'description' => __( 'Author URL of the user.' ),
'type' => 'string',
'format' => 'uri',
'context' => array( 'embed', 'view', 'edit' ),
'readonly' => true,
),
'locale' => array(
'description' => __( 'Locale for the resource.' ),
'description' => __( 'Locale for the user.' ),
'type' => 'string',
'enum' => array_merge( array( '', 'en_US' ), get_available_languages() ),
'context' => array( 'edit' ),
),
'nickname' => array(
'description' => __( 'The nickname for the resource.' ),
'description' => __( 'The nickname for the user.' ),
'type' => 'string',
'context' => array( 'edit' ),
'arg_options' => array(
@@ -1160,7 +1160,7 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
),
),
'slug' => array(
'description' => __( 'An alphanumeric identifier for the resource.' ),
'description' => __( 'An alphanumeric identifier for the user.' ),
'type' => 'string',
'context' => array( 'embed', 'view', 'edit' ),
'arg_options' => array(
@@ -1168,14 +1168,14 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
),
),
'registered_date' => array(
'description' => __( 'Registration date for the resource.' ),
'description' => __( 'Registration date for the user.' ),
'type' => 'string',
'format' => 'date-time',
'context' => array( 'edit' ),
'readonly' => true,
),
'roles' => array(
'description' => __( 'Roles assigned to the resource.' ),
'description' => __( 'Roles assigned to the user.' ),
'type' => 'array',
'items' => array(
'type' => 'string',
@@ -1183,7 +1183,7 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
'context' => array( 'edit' ),
),
'password' => array(
'description' => __( 'Password for the resource (never included).' ),
'description' => __( 'Password for the user (never included).' ),
'type' => 'string',
'context' => array(), // Password is never displayed.
'required' => true,
@@ -1192,13 +1192,13 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
),
),
'capabilities' => array(
'description' => __( 'All capabilities assigned to the resource.' ),
'description' => __( 'All capabilities assigned to the user.' ),
'type' => 'object',
'context' => array( 'edit' ),
'readonly' => true,
),
'extra_capabilities' => array(
'description' => __( 'Any extra capabilities assigned to the resource.' ),
'description' => __( 'Any extra capabilities assigned to the user.' ),
'type' => 'object',
'context' => array( 'edit' ),
'readonly' => true,
@@ -1222,7 +1222,7 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
}
$schema['properties']['avatar_urls'] = array(
'description' => __( 'Avatar URLs for the resource.' ),
'description' => __( 'Avatar URLs for the user.' ),
'type' => 'object',
'context' => array( 'embed', 'view', 'edit' ),
'readonly' => true,
@@ -1294,12 +1294,12 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
);
$query_params['slug'] = array(
'description' => __( 'Limit result set to resources with a specific slug.' ),
'description' => __( 'Limit result set to users with a specific slug.' ),
'type' => 'string',
);
$query_params['roles'] = array(
'description' => __( 'Limit result set to resources matching at least one specific role provided. Accepts csv list or single role.' ),
'description' => __( 'Limit result set to users matching at least one specific role provided. Accepts csv list or single role.' ),
'type' => 'array',
'items' => array(
'type' => 'string',