Ticket #38811: 38811.patch
File 38811.patch, 41.5 KB (added by , 8 years ago) |
---|
-
wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php
76 76 $post_parent_type = get_post_type_object( $parent->post_type ); 77 77 78 78 if ( ! current_user_can( $post_parent_type->cap->edit_post, $request['post'] ) ) { 79 return new WP_Error( 'rest_cannot_edit', __( 'Sorry, you are not allowed to upload media to this resource.' ), array( 'status' => rest_authorization_required_code() ) );79 return new WP_Error( 'rest_cannot_edit', __( 'Sorry, you are not allowed to upload media to this post.' ), array( 'status' => rest_authorization_required_code() ) ); 80 80 } 81 81 } 82 82 … … 378 378 $schema = parent::get_item_schema(); 379 379 380 380 $schema['properties']['alt_text'] = array( 381 'description' => __( 'Alternative text to display when resourceis not displayed.' ),381 'description' => __( 'Alternative text to display when attachment is not displayed.' ), 382 382 'type' => 'string', 383 383 'context' => array( 'view', 'edit', 'embed' ), 384 384 'arg_options' => array( … … 387 387 ); 388 388 389 389 $schema['properties']['caption'] = array( 390 'description' => __( 'The caption for the resource.' ),390 'description' => __( 'The attachment caption.' ), 391 391 'type' => 'object', 392 392 'context' => array( 'view', 'edit', 'embed' ), 393 393 'arg_options' => array( … … 395 395 ), 396 396 'properties' => array( 397 397 'raw' => array( 398 'description' => __( 'Caption for the resource, as it exists in the database.' ),398 'description' => __( 'Caption for the attachment, as it exists in the database.' ), 399 399 'type' => 'string', 400 400 'context' => array( 'edit' ), 401 401 ), 402 402 'rendered' => array( 403 'description' => __( 'HTML caption for the resource, transformed for display.' ),403 'description' => __( 'HTML caption for the attachment, transformed for display.' ), 404 404 'type' => 'string', 405 405 'context' => array( 'view', 'edit', 'embed' ), 406 406 'readonly' => true, … … 409 409 ); 410 410 411 411 $schema['properties']['description'] = array( 412 'description' => __( 'The description for the resource.' ),412 'description' => __( 'The attachment description.' ), 413 413 'type' => 'object', 414 414 'context' => array( 'view', 'edit' ), 415 415 'arg_options' => array( … … 431 431 ); 432 432 433 433 $schema['properties']['media_type'] = array( 434 'description' => __( ' Type of resource.' ),434 'description' => __( 'Attachment type.' ), 435 435 'type' => 'string', 436 436 'enum' => array( 'image', 'file' ), 437 437 'context' => array( 'view', 'edit', 'embed' ), … … 439 439 ); 440 440 441 441 $schema['properties']['mime_type'] = array( 442 'description' => __( ' MIME type of resource.' ),442 'description' => __( 'The attachment MIME type.' ), 443 443 'type' => 'string', 444 444 'context' => array( 'view', 'edit', 'embed' ), 445 445 'readonly' => true, … … 446 446 ); 447 447 448 448 $schema['properties']['media_details'] = array( 449 'description' => __( 'Details about the resourcefile, specific to its type.' ),449 'description' => __( 'Details about the media file, specific to its type.' ), 450 450 'type' => 'object', 451 451 'context' => array( 'view', 'edit', 'embed' ), 452 452 'readonly' => true, … … 453 453 ); 454 454 455 455 $schema['properties']['post'] = array( 456 'description' => __( 'The ID for the associated post of the resource.' ),456 'description' => __( 'The ID for the associated post of the attachment.' ), 457 457 'type' => 'integer', 458 458 'context' => array( 'view', 'edit' ), 459 459 ); 460 460 461 461 $schema['properties']['source_url'] = array( 462 'description' => __( 'URL to the original resourcefile.' ),462 'description' => __( 'URL to the original attachment file.' ), 463 463 'type' => 'string', 464 464 'format' => 'uri', 465 465 'context' => array( 'view', 'edit', 'embed' ), -
wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php
1294 1294 $query_params['context']['default'] = 'view'; 1295 1295 1296 1296 $query_params['after'] = array( 1297 'description' => __( 'Limit response to resources published after a given ISO8601 compliant date.' ),1297 'description' => __( 'Limit response to comments published after a given ISO8601 compliant date.' ), 1298 1298 'type' => 'string', 1299 1299 'format' => 'date-time', 1300 1300 ); … … 1323 1323 ); 1324 1324 1325 1325 $query_params['before'] = array( 1326 'description' => __( 'Limit response to resources published before a given ISO8601 compliant date.' ),1326 'description' => __( 'Limit response to comments published before a given ISO8601 compliant date.' ), 1327 1327 'type' => 'string', 1328 1328 'format' => 'date-time', 1329 1329 ); … … 1378 1378 1379 1379 $query_params['parent'] = array( 1380 1380 'default' => array(), 1381 'description' => __( 'Limit result set to resources of specific parent IDs.' ),1381 'description' => __( 'Limit result set to comments of specific parent IDs.' ), 1382 1382 'type' => 'array', 1383 1383 'items' => array( 1384 1384 'type' => 'integer', … … 1396 1396 1397 1397 $query_params['post'] = array( 1398 1398 'default' => array(), 1399 'description' => __( 'Limit result set to resources assigned to specific post IDs.' ),1399 'description' => __( 'Limit result set to comments assigned to specific post IDs.' ), 1400 1400 'type' => 'array', 1401 1401 'items' => array( 1402 1402 'type' => 'integer', -
wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php
125 125 $status = get_post_status_object( $request['status'] ); 126 126 127 127 if ( empty( $status ) ) { 128 return new WP_Error( 'rest_status_invalid', __( 'Invalid resource.' ), array( 'status' => 404 ) );128 return new WP_Error( 'rest_status_invalid', __( 'Invalid status.' ), array( 'status' => 404 ) ); 129 129 } 130 130 131 131 $check = $this->check_read_permission( $status ); 132 132 133 133 if ( ! $check ) { 134 return new WP_Error( 'rest_cannot_read_status', __( 'Cannot view resource.' ), array( 'status' => rest_authorization_required_code() ) );134 return new WP_Error( 'rest_cannot_read_status', __( 'Cannot view status.' ), array( 'status' => rest_authorization_required_code() ) ); 135 135 } 136 136 137 137 return true; … … 177 177 $obj = get_post_status_object( $request['status'] ); 178 178 179 179 if ( empty( $obj ) ) { 180 return new WP_Error( 'rest_status_invalid', __( 'Invalid resource.' ), array( 'status' => 404 ) );180 return new WP_Error( 'rest_status_invalid', __( 'Invalid status.' ), array( 'status' => 404 ) ); 181 181 } 182 182 183 183 $data = $this->prepare_item_for_response( $obj, $request ); … … 248 248 'type' => 'object', 249 249 'properties' => array( 250 250 'name' => array( 251 'description' => __( 'The title for the resource.' ),251 'description' => __( 'The title for the status.' ), 252 252 'type' => 'string', 253 253 'context' => array( 'embed', 'view', 'edit' ), 254 254 'readonly' => true, 255 255 ), 256 256 'private' => array( 257 'description' => __( 'Whether posts with this resourceshould be private.' ),257 'description' => __( 'Whether posts with this status should be private.' ), 258 258 'type' => 'boolean', 259 259 'context' => array( 'edit' ), 260 260 'readonly' => true, 261 261 ), 262 262 'protected' => array( 263 'description' => __( 'Whether posts with this resourceshould be protected.' ),263 'description' => __( 'Whether posts with this status should be protected.' ), 264 264 'type' => 'boolean', 265 265 'context' => array( 'edit' ), 266 266 'readonly' => true, 267 267 ), 268 268 'public' => array( 269 'description' => __( 'Whether posts of this resourceshould be shown in the front end of the site.' ),269 'description' => __( 'Whether posts of this status should be shown in the front end of the site.' ), 270 270 'type' => 'boolean', 271 271 'context' => array( 'view', 'edit' ), 272 272 'readonly' => true, 273 273 ), 274 274 'queryable' => array( 275 'description' => __( 'Whether posts with this resourceshould be publicly-queryable.' ),275 'description' => __( 'Whether posts with this status should be publicly-queryable.' ), 276 276 'type' => 'boolean', 277 277 'context' => array( 'view', 'edit' ), 278 278 'readonly' => true, … … 284 284 'readonly' => true, 285 285 ), 286 286 'slug' => array( 287 'description' => __( 'An alphanumeric identifier for the resource.' ),287 'description' => __( 'An alphanumeric identifier for the status.' ), 288 288 'type' => 'string', 289 289 'context' => array( 'embed', 'view', 'edit' ), 290 290 'readonly' => true, -
wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php
119 119 $obj = get_post_type_object( $request['type'] ); 120 120 121 121 if ( empty( $obj ) ) { 122 return new WP_Error( 'rest_type_invalid', __( 'Invalid resource.' ), array( 'status' => 404 ) );122 return new WP_Error( 'rest_type_invalid', __( 'Invalid post type.' ), array( 'status' => 404 ) ); 123 123 } 124 124 125 125 if ( empty( $obj->show_in_rest ) ) { 126 return new WP_Error( 'rest_cannot_read_type', __( 'Cannot view resource.' ), array( 'status' => rest_authorization_required_code() ) );126 return new WP_Error( 'rest_cannot_read_type', __( 'Cannot view post type.' ), array( 'status' => rest_authorization_required_code() ) ); 127 127 } 128 128 129 129 if ( 'edit' === $request['context'] && ! current_user_can( $obj->cap->edit_posts ) ) { … … 204 204 'type' => 'object', 205 205 'properties' => array( 206 206 'capabilities' => array( 207 'description' => __( 'All capabilities used by the resource.' ),207 'description' => __( 'All capabilities used by the post type.' ), 208 208 'type' => 'object', 209 209 'context' => array( 'edit' ), 210 210 'readonly' => true, 211 211 ), 212 212 'description' => array( 213 'description' => __( 'A human-readable description of the resource.' ),213 'description' => __( 'A human-readable description of the post type.' ), 214 214 'type' => 'string', 215 215 'context' => array( 'view', 'edit' ), 216 216 'readonly' => true, 217 217 ), 218 218 'hierarchical' => array( 219 'description' => __( 'Whether or not the resource should have children.' ),219 'description' => __( 'Whether or not the post type should have children.' ), 220 220 'type' => 'boolean', 221 221 'context' => array( 'view', 'edit' ), 222 222 'readonly' => true, 223 223 ), 224 224 'labels' => array( 225 'description' => __( 'Human-readable labels for the resource for various contexts.' ),225 'description' => __( 'Human-readable labels for the post type for various contexts.' ), 226 226 'type' => 'object', 227 227 'context' => array( 'edit' ), 228 228 'readonly' => true, 229 229 ), 230 230 'name' => array( 231 'description' => __( 'The title for the resource.' ),231 'description' => __( 'The title for the post type.' ), 232 232 'type' => 'string', 233 233 'context' => array( 'view', 'edit', 'embed' ), 234 234 'readonly' => true, 235 235 ), 236 236 'slug' => array( 237 'description' => __( 'An alphanumeric identifier for the resource.' ),237 'description' => __( 'An alphanumeric identifier for the post type.' ), 238 238 'type' => 'string', 239 239 'context' => array( 'view', 'edit', 'embed' ), 240 240 'readonly' => true, 241 241 ), 242 242 'taxonomies' => array( 243 'description' => __( 'Taxonomies associated with resource.' ),243 'description' => __( 'Taxonomies associated with post type.' ), 244 244 'type' => 'array', 245 245 'items' => array( 246 246 'type' => 'string', … … 249 249 'readonly' => true, 250 250 ), 251 251 'rest_base' => array( 252 'description' => __( 'REST base route for the resource.' ),252 'description' => __( 'REST base route for the post type.' ), 253 253 'type' => 'string', 254 254 'context' => array( 'view', 'edit', 'embed' ), 255 255 'readonly' => true, -
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
1963 1963 $params['context']['default'] = 'view'; 1964 1964 1965 1965 $params['after'] = array( 1966 'description' => __( 'Limit response to resources published after a given ISO8601 compliant date.' ),1966 'description' => __( 'Limit response to posts published after a given ISO8601 compliant date.' ), 1967 1967 'type' => 'string', 1968 1968 'format' => 'date-time', 1969 1969 ); … … 1988 1988 } 1989 1989 1990 1990 $params['before'] = array( 1991 'description' => __( 'Limit response to resources published before a given ISO8601 compliant date.' ),1991 'description' => __( 'Limit response to posts published before a given ISO8601 compliant date.' ), 1992 1992 'type' => 'string', 1993 1993 'format' => 'date-time', 1994 1994 ); … … 2013 2013 2014 2014 if ( 'page' === $this->post_type || post_type_supports( $this->post_type, 'page-attributes' ) ) { 2015 2015 $params['menu_order'] = array( 2016 'description' => __( 'Limit result set to resources with a specific menu_order value.' ),2016 'description' => __( 'Limit result set to posts with a specific menu_order value.' ), 2017 2017 'type' => 'integer', 2018 2018 ); 2019 2019 } -
wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php
11 11 * Core class used to access revisions via the REST API. 12 12 * 13 13 * @since 4.7.0 14 * 14 *0 15 15 * @see WP_REST_Controller 16 16 */ 17 17 class WP_REST_Revisions_Controller extends WP_REST_Controller { … … 97 97 'force' => array( 98 98 'type' => 'boolean', 99 99 'default' => false, 100 'description' => __( 'Required to be true, as re source doesnot support trashing.' ),100 'description' => __( 'Required to be true, as revisions do not support trashing.' ), 101 101 ), 102 102 ), 103 103 ), … … 227 227 public function delete_item( $request ) { 228 228 $force = isset( $request['force'] ) ? (bool) $request['force'] : false; 229 229 230 // We don't support trashing for this resource type.230 // We don't support trashing for revisions. 231 231 if ( ! $force ) { 232 232 return new WP_Error( 'rest_trash_not_supported', __( 'Revisions do not support trashing. Set force=true to delete.' ), array( 'status' => 501 ) ); 233 233 } -
wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php
160 160 public function get_item( $request ) { 161 161 $tax_obj = get_taxonomy( $request['taxonomy'] ); 162 162 if ( empty( $tax_obj ) ) { 163 return new WP_Error( 'rest_taxonomy_invalid', __( 'Invalid resource.' ), array( 'status' => 404 ) );163 return new WP_Error( 'rest_taxonomy_invalid', __( 'Invalid taxonomy.' ), array( 'status' => 404 ) ); 164 164 } 165 165 $data = $this->prepare_item_for_response( $tax_obj, $request ); 166 166 return rest_ensure_response( $data ); … … 235 235 'type' => 'object', 236 236 'properties' => array( 237 237 'capabilities' => array( 238 'description' => __( 'All capabilities used by the resource.' ),238 'description' => __( 'All capabilities used by the taxonomy.' ), 239 239 'type' => 'object', 240 240 'context' => array( 'edit' ), 241 241 'readonly' => true, 242 242 ), 243 243 'description' => array( 244 'description' => __( 'A human-readable description of the resource.' ),244 'description' => __( 'A human-readable description of the taxonomy.' ), 245 245 'type' => 'string', 246 246 'context' => array( 'view', 'edit' ), 247 247 'readonly' => true, 248 248 ), 249 249 'hierarchical' => array( 250 'description' => __( 'Whether or not the resourceshould have children.' ),250 'description' => __( 'Whether or not the taxonomy should have children.' ), 251 251 'type' => 'boolean', 252 252 'context' => array( 'view', 'edit' ), 253 253 'readonly' => true, 254 254 ), 255 255 'labels' => array( 256 'description' => __( 'Human-readable labels for the resourcefor various contexts.' ),256 'description' => __( 'Human-readable labels for the taxonomy for various contexts.' ), 257 257 'type' => 'object', 258 258 'context' => array( 'edit' ), 259 259 'readonly' => true, 260 260 ), 261 261 'name' => array( 262 'description' => __( 'The title for the resource.' ),262 'description' => __( 'The title for the taxonomy.' ), 263 263 'type' => 'string', 264 264 'context' => array( 'view', 'edit', 'embed' ), 265 265 'readonly' => true, 266 266 ), 267 267 'slug' => array( 268 'description' => __( 'An alphanumeric identifier for the resource.' ),268 'description' => __( 'An alphanumeric identifier for the taxonomy.' ), 269 269 'type' => 'string', 270 270 'context' => array( 'view', 'edit', 'embed' ), 271 271 'readonly' => true, … … 277 277 'readonly' => true, 278 278 ), 279 279 'types' => array( 280 'description' => __( 'Types associated with resource.' ),280 'description' => __( 'Types associated with the taxonomy.' ), 281 281 'type' => 'array', 282 282 'items' => array( 283 283 'type' => 'string', … … 286 286 'readonly' => true, 287 287 ), 288 288 'rest_base' => array( 289 'description' => __( 'REST base route for the resource.' ),289 'description' => __( 'REST base route for the taxonomy.' ), 290 290 'type' => 'string', 291 291 'context' => array( 'view', 'edit', 'embed' ), 292 292 'readonly' => true, … … 308 308 $new_params = array(); 309 309 $new_params['context'] = $this->get_context_param( array( 'default' => 'view' ) ); 310 310 $new_params['type'] = array( 311 'description' => __( 'Limit results to resources associated with a specific post type.' ),311 'description' => __( 'Limit results to taxonomies associated with a specific post type.' ), 312 312 'type' => 'string', 313 313 ); 314 314 return $new_params; -
wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php
118 118 'force' => array( 119 119 'type' => 'boolean', 120 120 'default' => false, 121 'description' => __( 'Required to be true, as resource doesnot support trashing.' ),121 'description' => __( 'Required to be true, as terms do not support trashing.' ), 122 122 ), 123 123 ), 124 124 ), … … 321 321 $term = get_term( (int) $request['id'], $this->taxonomy ); 322 322 323 323 if ( ! $term || $term->taxonomy !== $this->taxonomy ) { 324 return new WP_Error( 'rest_term_invalid', __( " Resourcedoesn't exist." ), array( 'status' => 404 ) );324 return new WP_Error( 'rest_term_invalid', __( "Term doesn't exist." ), array( 'status' => 404 ) ); 325 325 } 326 326 327 327 if ( is_wp_error( $term ) ) { … … 350 350 351 351 $taxonomy_obj = get_taxonomy( $this->taxonomy ); 352 352 if ( ! current_user_can( $taxonomy_obj->cap->manage_terms ) ) { 353 return new WP_Error( 'rest_cannot_create', __( 'Sorry, you are not allowed to create new resource.' ), array( 'status' => rest_authorization_required_code() ) );353 return new WP_Error( 'rest_cannot_create', __( 'Sorry, you are not allowed to create new terms.' ), array( 'status' => rest_authorization_required_code() ) ); 354 354 } 355 355 356 356 return true; … … 368 368 public function create_item( $request ) { 369 369 if ( isset( $request['parent'] ) ) { 370 370 if ( ! is_taxonomy_hierarchical( $this->taxonomy ) ) { 371 return new WP_Error( 'rest_taxonomy_not_hierarchical', __( 'Can not set resource parent, taxonomy is not hierarchical.' ), array( 'status' => 400 ) );371 return new WP_Error( 'rest_taxonomy_not_hierarchical', __( 'Can not set parent term, taxonomy is not hierarchical.' ), array( 'status' => 400 ) ); 372 372 } 373 373 374 374 $parent = get_term( (int) $request['parent'], $this->taxonomy ); 375 375 376 376 if ( ! $parent ) { 377 return new WP_Error( 'rest_term_invalid', __( "Parent resourcedoesn't exist." ), array( 'status' => 400 ) );377 return new WP_Error( 'rest_term_invalid', __( "Parent term doesn't exist." ), array( 'status' => 400 ) ); 378 378 } 379 379 } 380 380 … … 453 453 $term = get_term( (int) $request['id'], $this->taxonomy ); 454 454 455 455 if ( ! $term ) { 456 return new WP_Error( 'rest_term_invalid', __( " Resourcedoesn't exist." ), array( 'status' => 404 ) );456 return new WP_Error( 'rest_term_invalid', __( "Term doesn't exist." ), array( 'status' => 404 ) ); 457 457 } 458 458 459 459 if ( ! current_user_can( 'edit_term', $term->term_id ) ) { 460 return new WP_Error( 'rest_cannot_update', __( 'Sorry, you are not allowed to update resource.' ), array( 'status' => rest_authorization_required_code() ) );460 return new WP_Error( 'rest_cannot_update', __( 'Sorry, you are not allowed to edit terms.' ), array( 'status' => rest_authorization_required_code() ) ); 461 461 } 462 462 463 463 return true; … … 475 475 public function update_item( $request ) { 476 476 if ( isset( $request['parent'] ) ) { 477 477 if ( ! is_taxonomy_hierarchical( $this->taxonomy ) ) { 478 return new WP_Error( 'rest_taxonomy_not_hierarchical', __( 'Can not set resource parent, taxonomy is not hierarchical.' ), array( 'status' => 400 ) );478 return new WP_Error( 'rest_taxonomy_not_hierarchical', __( 'Can not set parent term, taxonomy is not hierarchical.' ), array( 'status' => 400 ) ); 479 479 } 480 480 481 481 $parent = get_term( (int) $request['parent'], $this->taxonomy ); 482 482 483 483 if ( ! $parent ) { 484 return new WP_Error( 'rest_term_invalid', __( "Parent resourcedoesn't exist." ), array( 'status' => 400 ) );484 return new WP_Error( 'rest_term_invalid', __( "Parent term doesn't exist." ), array( 'status' => 400 ) ); 485 485 } 486 486 } 487 487 … … 542 542 $term = get_term( (int) $request['id'], $this->taxonomy ); 543 543 544 544 if ( ! $term ) { 545 return new WP_Error( 'rest_term_invalid', __( " Resourcedoesn't exist." ), array( 'status' => 404 ) );545 return new WP_Error( 'rest_term_invalid', __( "Term doesn't exist." ), array( 'status' => 404 ) ); 546 546 } 547 547 548 548 if ( ! current_user_can( 'delete_term', $term->term_id ) ) { 549 return new WP_Error( 'rest_cannot_delete', __( 'Sorry, you are not allowed to delete this resource.' ), array( 'status' => rest_authorization_required_code() ) );549 return new WP_Error( 'rest_cannot_delete', __( 'Sorry, you are not allowed to delete this term.' ), array( 'status' => rest_authorization_required_code() ) ); 550 550 } 551 551 552 552 return true; … … 565 565 566 566 $force = isset( $request['force'] ) ? (bool) $request['force'] : false; 567 567 568 // We don't support trashing for t his resource type.568 // We don't support trashing for terms. 569 569 if ( ! $force ) { 570 570 return new WP_Error( 'rest_trash_not_supported', __( 'Terms do not support trashing. Set force=true to delete.' ), array( 'status' => 501 ) ); 571 571 } … … 579 579 $retval = wp_delete_term( $term->term_id, $term->taxonomy ); 580 580 581 581 if ( ! $retval ) { 582 return new WP_Error( 'rest_cannot_delete', __( 'The resourcecannot be deleted.' ), array( 'status' => 500 ) );582 return new WP_Error( 'rest_cannot_delete', __( 'The term cannot be deleted.' ), array( 'status' => 500 ) ); 583 583 } 584 584 585 585 $response = new WP_REST_Response(); … … 806 806 'type' => 'object', 807 807 'properties' => array( 808 808 'id' => array( 809 'description' => __( 'Unique identifier for the resource.' ),809 'description' => __( 'Unique identifier for the term.' ), 810 810 'type' => 'integer', 811 811 'context' => array( 'view', 'embed', 'edit' ), 812 812 'readonly' => true, 813 813 ), 814 814 'count' => array( 815 'description' => __( 'Number of published posts for the resource.' ),815 'description' => __( 'Number of published posts for the term.' ), 816 816 'type' => 'integer', 817 817 'context' => array( 'view', 'edit' ), 818 818 'readonly' => true, 819 819 ), 820 820 'description' => array( 821 'description' => __( 'HTML description of the resource.' ),821 'description' => __( 'HTML description of the term.' ), 822 822 'type' => 'string', 823 823 'context' => array( 'view', 'edit' ), 824 824 ), 825 825 'link' => array( 826 'description' => __( 'URL of the resource.' ),826 'description' => __( 'URL of the term.' ), 827 827 'type' => 'string', 828 828 'format' => 'uri', 829 829 'context' => array( 'view', 'embed', 'edit' ), … … 830 830 'readonly' => true, 831 831 ), 832 832 'name' => array( 833 'description' => __( 'HTML title for the resource.' ),833 'description' => __( 'HTML title for the term.' ), 834 834 'type' => 'string', 835 835 'context' => array( 'view', 'embed', 'edit' ), 836 836 'arg_options' => array( … … 839 839 'required' => true, 840 840 ), 841 841 'slug' => array( 842 'description' => __( 'An alphanumeric identifier for the resourceunique to its type.' ),842 'description' => __( 'An alphanumeric identifier for the term unique to its type.' ), 843 843 'type' => 'string', 844 844 'context' => array( 'view', 'embed', 'edit' ), 845 845 'arg_options' => array( … … 847 847 ), 848 848 ), 849 849 'taxonomy' => array( 850 'description' => __( 'Type attribution for the resource.' ),850 'description' => __( 'Type attribution for the term.' ), 851 851 'type' => 'string', 852 852 'enum' => array_keys( get_taxonomies() ), 853 853 'context' => array( 'view', 'embed', 'edit' ), … … 860 860 861 861 if ( $taxonomy->hierarchical ) { 862 862 $schema['properties']['parent'] = array( 863 'description' => __( 'The ID for the parent of the resource.' ),863 'description' => __( 'The parent term ID.' ), 864 864 'type' => 'integer', 865 865 'context' => array( 'view', 'edit' ), 866 866 ); … … 921 921 ); 922 922 923 923 $query_params['orderby'] = array( 924 'description' => __( 'Sort collection by resourceattribute.' ),924 'description' => __( 'Sort collection by term attribute.' ), 925 925 'type' => 'string', 926 926 'default' => 'name', 927 927 'enum' => array( … … 936 936 ); 937 937 938 938 $query_params['hide_empty'] = array( 939 'description' => __( 'Whether to hide resources not assigned to any posts.' ),939 'description' => __( 'Whether to hide terms not assigned to any posts.' ), 940 940 'type' => 'boolean', 941 941 'default' => false, 942 942 ); … … 943 943 944 944 if ( $taxonomy->hierarchical ) { 945 945 $query_params['parent'] = array( 946 'description' => __( 'Limit result set to resources assigned to a specific parent.' ),946 'description' => __( 'Limit result set to terms assigned to a specific parent.' ), 947 947 'type' => 'integer', 948 948 ); 949 949 } 950 950 951 951 $query_params['post'] = array( 952 'description' => __( 'Limit result set to resources assigned to a specific post.' ),952 'description' => __( 'Limit result set to terms assigned to a specific post.' ), 953 953 'type' => 'integer', 954 954 'default' => null, 955 955 ); 956 956 957 957 $query_params['slug'] = array( 958 'description' => __( 'Limit result set to resources with a specific slug.' ),958 'description' => __( 'Limit result set to terms with a specific slug.' ), 959 959 'type' => 'string', 960 960 ); 961 961 -
wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php
87 87 'force' => array( 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( 93 93 'type' => 'integer', … … 120 120 'force' => 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( 126 126 'type' => 'integer', … … 312 312 $types = get_post_types( array( 'show_in_rest' => true ), 'names' ); 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 318 318 if ( get_current_user_id() === $id ) { … … 342 342 $user = get_userdata( $id ); 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 348 348 $user = $this->prepare_item_for_response( $user, $request ); … … 387 387 public function create_item_permissions_check( $request ) { 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 393 393 return true; … … 404 404 */ 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 410 410 $schema = $this->get_item_schema(); … … 440 440 $user_id = wpmu_create_user( $user->user_login, $user->user_pass, $user->user_email ); 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 446 446 $user->ID = $user_id; … … 515 515 $id = (int) $request['id']; 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 525 525 return true; … … 539 539 $user = get_userdata( $id ); 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 545 545 if ( email_exists( $request['email'] ) && $request['email'] !== $user->user_email ) { … … 654 654 $id = (int) $request['id']; 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 660 660 return true; … … 682 682 $user = get_userdata( $id ); 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 } 693 693 … … 701 701 $result = wp_delete_user( $id, $reassign ); 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 707 707 $response = new WP_REST_Response(); … … 995 995 && get_current_user_id() === $user_id 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 1001 1001 /** Include admin functions to get access to get_editable_roles() */ … … 1005 1005 $editable_roles = get_editable_roles(); 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 } 1011 1011 … … 1082 1082 'type' => 'object', 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' ), 1088 1088 'readonly' => true, 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' ), 1094 1094 'required' => true, … … 1097 1097 ), 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' ), 1103 1103 'arg_options' => array( … … 1105 1105 ), 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' ), 1111 1111 'arg_options' => array( … … 1113 1113 ), 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' ), 1119 1119 'arg_options' => array( … … 1121 1121 ), 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', 1127 1127 'context' => array( 'edit' ), … … 1128 1128 'required' => true, 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', 1134 1134 'context' => array( 'embed', 'view', 'edit' ), 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', 1145 1145 'context' => array( 'embed', 'view', 'edit' ), … … 1146 1146 'readonly' => true, 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() ), 1152 1152 'context' => array( 'edit' ), 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' ), 1158 1158 'arg_options' => array( … … 1160 1160 ), 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' ), 1166 1166 'arg_options' => array( … … 1168 1168 ), 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', 1174 1174 'context' => array( 'edit' ), … … 1175 1175 'readonly' => true, 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( 1181 1181 'type' => 'string', … … 1183 1183 'context' => array( 'edit' ), 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. 1189 1189 'required' => true, … … 1192 1192 ), 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' ), 1198 1198 'readonly' => true, 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' ), 1204 1204 'readonly' => true, … … 1222 1222 } 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' ), 1228 1228 'readonly' => true, … … 1294 1294 ); 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( 1305 1305 'type' => 'string',