- Timestamp:
- 11/23/2016 02:42:00 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php
r39313 r39342 88 88 'type' => 'boolean', 89 89 'default' => false, 90 'description' => __( 'Required to be true, as resource doesnot support trashing.' ),90 'description' => __( 'Required to be true, as users do not support trashing.' ), 91 91 ), 92 92 'reassign' => array( … … 121 121 'type' => 'boolean', 122 122 'default' => false, 123 'description' => __( 'Required to be true, as resource doesnot support trashing.' ),123 'description' => __( 'Required to be true, as users do not support trashing.' ), 124 124 ), 125 125 'reassign' => array( … … 145 145 // Check if roles is specified in GET request and if user can list users. 146 146 if ( ! empty( $request['roles'] ) && ! current_user_can( 'list_users' ) ) { 147 return new WP_Error( 'rest_user_cannot_view', __( 'Sorry, you are not allowed to filter by role.' ), array( 'status' => rest_authorization_required_code() ) );147 return new WP_Error( 'rest_user_cannot_view', __( 'Sorry, you are not allowed to filter users by role.' ), array( 'status' => rest_authorization_required_code() ) ); 148 148 } 149 149 … … 153 153 154 154 if ( in_array( $request['orderby'], array( 'email', 'registered_date' ), true ) && ! current_user_can( 'list_users' ) ) { 155 return new WP_Error( 'rest_forbidden_orderby', __( 'Sorry, you are not allowed to order by this parameter.' ), array( 'status' => rest_authorization_required_code() ) );155 return new WP_Error( 'rest_forbidden_orderby', __( 'Sorry, you are not allowed to order users by this parameter.' ), array( 'status' => rest_authorization_required_code() ) ); 156 156 } 157 157 … … 313 313 314 314 if ( empty( $id ) || empty( $user->ID ) ) { 315 return new WP_Error( 'rest_user_invalid_id', __( 'Invalid resourceID.' ), array( 'status' => 404 ) );315 return new WP_Error( 'rest_user_invalid_id', __( 'Invalid user ID.' ), array( 'status' => 404 ) ); 316 316 } 317 317 … … 343 343 344 344 if ( empty( $id ) || empty( $user->ID ) ) { 345 return new WP_Error( 'rest_user_invalid_id', __( 'Invalid resourceID.' ), array( 'status' => 404 ) );345 return new WP_Error( 'rest_user_invalid_id', __( 'Invalid user ID.' ), array( 'status' => 404 ) ); 346 346 } 347 347 … … 388 388 389 389 if ( ! current_user_can( 'create_users' ) ) { 390 return new WP_Error( 'rest_cannot_create_user', __( 'Sorry, you are not allowed to create new resource.' ), array( 'status' => rest_authorization_required_code() ) );390 return new WP_Error( 'rest_cannot_create_user', __( 'Sorry, you are not allowed to create new users.' ), array( 'status' => rest_authorization_required_code() ) ); 391 391 } 392 392 … … 405 405 public function create_item( $request ) { 406 406 if ( ! empty( $request['id'] ) ) { 407 return new WP_Error( 'rest_user_exists', __( 'Cannot create existing resource.' ), array( 'status' => 400 ) );407 return new WP_Error( 'rest_user_exists', __( 'Cannot create existing user.' ), array( 'status' => 400 ) ); 408 408 } 409 409 … … 441 441 442 442 if ( ! $user_id ) { 443 return new WP_Error( 'rest_user_create', __( 'Error creating new resource.' ), array( 'status' => 500 ) );443 return new WP_Error( 'rest_user_create', __( 'Error creating new user.' ), array( 'status' => 500 ) ); 444 444 } 445 445 … … 516 516 517 517 if ( ! current_user_can( 'edit_user', $id ) ) { 518 return new WP_Error( 'rest_cannot_edit', __( 'Sorry, you are not allowed to edit this resource.' ), array( 'status' => rest_authorization_required_code() ) );518 return new WP_Error( 'rest_cannot_edit', __( 'Sorry, you are not allowed to edit this user.' ), array( 'status' => rest_authorization_required_code() ) ); 519 519 } 520 520 521 521 if ( ! empty( $request['roles'] ) && ! current_user_can( 'edit_users' ) ) { 522 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() ) );522 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() ) ); 523 523 } 524 524 … … 540 540 541 541 if ( ! $user ) { 542 return new WP_Error( 'rest_user_invalid_id', __( 'Invalid resourceID.' ), array( 'status' => 404 ) );542 return new WP_Error( 'rest_user_invalid_id', __( 'Invalid user ID.' ), array( 'status' => 404 ) ); 543 543 } 544 544 … … 655 655 656 656 if ( ! current_user_can( 'delete_user', $id ) ) { 657 return new WP_Error( 'rest_user_cannot_delete', __( 'Sorry, you are not allowed to delete this resource.' ), array( 'status' => rest_authorization_required_code() ) );657 return new WP_Error( 'rest_user_cannot_delete', __( 'Sorry, you are not allowed to delete this user.' ), array( 'status' => rest_authorization_required_code() ) ); 658 658 } 659 659 … … 675 675 $force = isset( $request['force'] ) ? (bool) $request['force'] : false; 676 676 677 // We don't support trashing for this type, error out.677 // We don't support trashing for users. 678 678 if ( ! $force ) { 679 679 return new WP_Error( 'rest_trash_not_supported', __( 'Users do not support trashing. Set force=true to delete.' ), array( 'status' => 501 ) ); … … 683 683 684 684 if ( ! $user ) { 685 return new WP_Error( 'rest_user_invalid_id', __( 'Invalid resourceID.' ), array( 'status' => 404 ) );685 return new WP_Error( 'rest_user_invalid_id', __( 'Invalid user ID.' ), array( 'status' => 404 ) ); 686 686 } 687 687 688 688 if ( ! empty( $reassign ) ) { 689 689 if ( $reassign === $id || ! get_userdata( $reassign ) ) { 690 return new WP_Error( 'rest_user_invalid_reassign', __( 'Invalid resourceID for reassignment.' ), array( 'status' => 400 ) );690 return new WP_Error( 'rest_user_invalid_reassign', __( 'Invalid user ID for reassignment.' ), array( 'status' => 400 ) ); 691 691 } 692 692 } … … 702 702 703 703 if ( ! $result ) { 704 return new WP_Error( 'rest_cannot_delete', __( 'The resourcecannot be deleted.' ), array( 'status' => 500 ) );704 return new WP_Error( 'rest_cannot_delete', __( 'The user cannot be deleted.' ), array( 'status' => 500 ) ); 705 705 } 706 706 … … 996 996 && ! $potential_role->has_cap( 'edit_users' ) 997 997 ) { 998 return new WP_Error( 'rest_user_invalid_role', __( 'Sorry, you are not allowed to give resourcethat role.' ), array( 'status' => rest_authorization_required_code() ) );998 return new WP_Error( 'rest_user_invalid_role', __( 'Sorry, you are not allowed to give users that role.' ), array( 'status' => rest_authorization_required_code() ) ); 999 999 } 1000 1000 … … 1006 1006 1007 1007 if ( empty( $editable_roles[ $role ] ) ) { 1008 return new WP_Error( 'rest_user_invalid_role', __( 'Sorry, you are not allowed to give resourcethat role.' ), array( 'status' => 403 ) );1008 return new WP_Error( 'rest_user_invalid_role', __( 'Sorry, you are not allowed to give users that role.' ), array( 'status' => 403 ) ); 1009 1009 } 1010 1010 } … … 1083 1083 'properties' => array( 1084 1084 'id' => array( 1085 'description' => __( 'Unique identifier for the resource.' ),1085 'description' => __( 'Unique identifier for the user.' ), 1086 1086 'type' => 'integer', 1087 1087 'context' => array( 'embed', 'view', 'edit' ), … … 1089 1089 ), 1090 1090 'username' => array( 1091 'description' => __( 'Login name for the resource.' ),1091 'description' => __( 'Login name for the user.' ), 1092 1092 'type' => 'string', 1093 1093 'context' => array( 'edit' ), … … 1098 1098 ), 1099 1099 'name' => array( 1100 'description' => __( 'Display name for the resource.' ),1100 'description' => __( 'Display name for the user.' ), 1101 1101 'type' => 'string', 1102 1102 'context' => array( 'embed', 'view', 'edit' ), … … 1106 1106 ), 1107 1107 'first_name' => array( 1108 'description' => __( 'First name for the resource.' ),1108 'description' => __( 'First name for the user.' ), 1109 1109 'type' => 'string', 1110 1110 'context' => array( 'edit' ), … … 1114 1114 ), 1115 1115 'last_name' => array( 1116 'description' => __( 'Last name for the resource.' ),1116 'description' => __( 'Last name for the user.' ), 1117 1117 'type' => 'string', 1118 1118 'context' => array( 'edit' ), … … 1122 1122 ), 1123 1123 'email' => array( 1124 'description' => __( 'The email address for the resource.' ),1124 'description' => __( 'The email address for the user.' ), 1125 1125 'type' => 'string', 1126 1126 'format' => 'email', … … 1129 1129 ), 1130 1130 'url' => array( 1131 'description' => __( 'URL of the resource.' ),1131 'description' => __( 'URL of the user.' ), 1132 1132 'type' => 'string', 1133 1133 'format' => 'uri', … … 1135 1135 ), 1136 1136 'description' => array( 1137 'description' => __( 'Description of the resource.' ),1137 'description' => __( 'Description of the user.' ), 1138 1138 'type' => 'string', 1139 1139 'context' => array( 'embed', 'view', 'edit' ), 1140 1140 ), 1141 1141 'link' => array( 1142 'description' => __( 'Author URL of the resource.' ),1142 'description' => __( 'Author URL of the user.' ), 1143 1143 'type' => 'string', 1144 1144 'format' => 'uri', … … 1147 1147 ), 1148 1148 'locale' => array( 1149 'description' => __( 'Locale for the resource.' ),1149 'description' => __( 'Locale for the user.' ), 1150 1150 'type' => 'string', 1151 1151 'enum' => array_merge( array( '', 'en_US' ), get_available_languages() ), … … 1153 1153 ), 1154 1154 'nickname' => array( 1155 'description' => __( 'The nickname for the resource.' ),1155 'description' => __( 'The nickname for the user.' ), 1156 1156 'type' => 'string', 1157 1157 'context' => array( 'edit' ), … … 1161 1161 ), 1162 1162 'slug' => array( 1163 'description' => __( 'An alphanumeric identifier for the resource.' ),1163 'description' => __( 'An alphanumeric identifier for the user.' ), 1164 1164 'type' => 'string', 1165 1165 'context' => array( 'embed', 'view', 'edit' ), … … 1169 1169 ), 1170 1170 'registered_date' => array( 1171 'description' => __( 'Registration date for the resource.' ),1171 'description' => __( 'Registration date for the user.' ), 1172 1172 'type' => 'string', 1173 1173 'format' => 'date-time', … … 1176 1176 ), 1177 1177 'roles' => array( 1178 'description' => __( 'Roles assigned to the resource.' ),1178 'description' => __( 'Roles assigned to the user.' ), 1179 1179 'type' => 'array', 1180 1180 'items' => array( … … 1184 1184 ), 1185 1185 'password' => array( 1186 'description' => __( 'Password for the resource(never included).' ),1186 'description' => __( 'Password for the user (never included).' ), 1187 1187 'type' => 'string', 1188 1188 'context' => array(), // Password is never displayed. … … 1193 1193 ), 1194 1194 'capabilities' => array( 1195 'description' => __( 'All capabilities assigned to the resource.' ),1195 'description' => __( 'All capabilities assigned to the user.' ), 1196 1196 'type' => 'object', 1197 1197 'context' => array( 'edit' ), … … 1199 1199 ), 1200 1200 'extra_capabilities' => array( 1201 'description' => __( 'Any extra capabilities assigned to the resource.' ),1201 'description' => __( 'Any extra capabilities assigned to the user.' ), 1202 1202 'type' => 'object', 1203 1203 'context' => array( 'edit' ), … … 1223 1223 1224 1224 $schema['properties']['avatar_urls'] = array( 1225 'description' => __( 'Avatar URLs for the resource.' ),1225 'description' => __( 'Avatar URLs for the user.' ), 1226 1226 'type' => 'object', 1227 1227 'context' => array( 'embed', 'view', 'edit' ), … … 1295 1295 1296 1296 $query_params['slug'] = array( 1297 'description' => __( 'Limit result set to resources with a specific slug.' ),1297 'description' => __( 'Limit result set to users with a specific slug.' ), 1298 1298 'type' => 'string', 1299 1299 ); 1300 1300 1301 1301 $query_params['roles'] = array( 1302 'description' => __( 'Limit result set to resources matching at least one specific role provided. Accepts csv list or single role.' ),1302 'description' => __( 'Limit result set to users matching at least one specific role provided. Accepts csv list or single role.' ), 1303 1303 'type' => 'array', 1304 1304 'items' => array(
Note: See TracChangeset
for help on using the changeset viewer.