Make WordPress Core

Ticket #38811: 38811.patch

File 38811.patch, 41.5 KB (added by ramiy, 8 years ago)
  • wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php

     
    7676                        $post_parent_type = get_post_type_object( $parent->post_type );
    7777
    7878                        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() ) );
    8080                        }
    8181                }
    8282
     
    378378                $schema = parent::get_item_schema();
    379379
    380380                $schema['properties']['alt_text'] = array(
    381                         'description'     => __( 'Alternative text to display when resource is not displayed.' ),
     381                        'description'     => __( 'Alternative text to display when attachment is not displayed.' ),
    382382                        'type'            => 'string',
    383383                        'context'         => array( 'view', 'edit', 'embed' ),
    384384                        'arg_options'     => array(
     
    387387                );
    388388
    389389                $schema['properties']['caption'] = array(
    390                         'description' => __( 'The caption for the resource.' ),
     390                        'description' => __( 'The attachment caption.' ),
    391391                        'type'        => 'object',
    392392                        'context'     => array( 'view', 'edit', 'embed' ),
    393393                        'arg_options' => array(
     
    395395                        ),
    396396                        'properties'  => array(
    397397                                '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.' ),
    399399                                        'type'        => 'string',
    400400                                        'context'     => array( 'edit' ),
    401401                                ),
    402402                                'rendered' => array(
    403                                         'description' => __( 'HTML caption for the resource, transformed for display.' ),
     403                                        'description' => __( 'HTML caption for the attachment, transformed for display.' ),
    404404                                        'type'        => 'string',
    405405                                        'context'     => array( 'view', 'edit', 'embed' ),
    406406                                        'readonly'    => true,
     
    409409                );
    410410
    411411                $schema['properties']['description'] = array(
    412                         'description' => __( 'The description for the resource.' ),
     412                        'description' => __( 'The attachment description.' ),
    413413                        'type'        => 'object',
    414414                        'context'     => array( 'view', 'edit' ),
    415415                        'arg_options' => array(
     
    431431                );
    432432
    433433                $schema['properties']['media_type'] = array(
    434                         'description'     => __( 'Type of resource.' ),
     434                        'description'     => __( 'Attachment type.' ),
    435435                        'type'            => 'string',
    436436                        'enum'            => array( 'image', 'file' ),
    437437                        'context'         => array( 'view', 'edit', 'embed' ),
     
    439439                );
    440440
    441441                $schema['properties']['mime_type'] = array(
    442                         'description'     => __( 'MIME type of resource.' ),
     442                        'description'     => __( 'The attachment MIME type.' ),
    443443                        'type'            => 'string',
    444444                        'context'         => array( 'view', 'edit', 'embed' ),
    445445                        'readonly'        => true,
     
    446446                );
    447447
    448448                $schema['properties']['media_details'] = array(
    449                         'description'     => __( 'Details about the resource file, specific to its type.' ),
     449                        'description'     => __( 'Details about the media file, specific to its type.' ),
    450450                        'type'            => 'object',
    451451                        'context'         => array( 'view', 'edit', 'embed' ),
    452452                        'readonly'        => true,
     
    453453                );
    454454
    455455                $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.' ),
    457457                        'type'            => 'integer',
    458458                        'context'         => array( 'view', 'edit' ),
    459459                );
    460460
    461461                $schema['properties']['source_url'] = array(
    462                         'description'     => __( 'URL to the original resource file.' ),
     462                        'description'     => __( 'URL to the original attachment file.' ),
    463463                        'type'            => 'string',
    464464                        'format'          => 'uri',
    465465                        'context'         => array( 'view', 'edit', 'embed' ),
  • wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php

     
    12941294                $query_params['context']['default'] = 'view';
    12951295
    12961296                $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.' ),
    12981298                        'type'              => 'string',
    12991299                        'format'            => 'date-time',
    13001300                );
     
    13231323                );
    13241324
    13251325                $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.' ),
    13271327                        'type'              => 'string',
    13281328                        'format'            => 'date-time',
    13291329                );
     
    13781378
    13791379                $query_params['parent'] = array(
    13801380                        'default'           => array(),
    1381                         'description'       => __( 'Limit result set to resources of specific parent IDs.' ),
     1381                        'description'       => __( 'Limit result set to comments of specific parent IDs.' ),
    13821382                        'type'              => 'array',
    13831383                        'items'             => array(
    13841384                                'type'          => 'integer',
     
    13961396
    13971397                $query_params['post']   = array(
    13981398                        '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.' ),
    14001400                        'type'              => 'array',
    14011401                        'items'             => array(
    14021402                                'type'          => 'integer',
  • wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php

     
    125125                $status = get_post_status_object( $request['status'] );
    126126
    127127                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 ) );
    129129                }
    130130
    131131                $check = $this->check_read_permission( $status );
    132132
    133133                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() ) );
    135135                }
    136136
    137137                return true;
     
    177177                $obj = get_post_status_object( $request['status'] );
    178178
    179179                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 ) );
    181181                }
    182182
    183183                $data = $this->prepare_item_for_response( $obj, $request );
     
    248248                        'type'                 => 'object',
    249249                        'properties'           => array(
    250250                                'name'             => array(
    251                                         'description'  => __( 'The title for the resource.' ),
     251                                        'description'  => __( 'The title for the status.' ),
    252252                                        'type'         => 'string',
    253253                                        'context'      => array( 'embed', 'view', 'edit' ),
    254254                                        'readonly'     => true,
    255255                                ),
    256256                                'private'          => array(
    257                                         'description'  => __( 'Whether posts with this resource should be private.' ),
     257                                        'description'  => __( 'Whether posts with this status should be private.' ),
    258258                                        'type'         => 'boolean',
    259259                                        'context'      => array( 'edit' ),
    260260                                        'readonly'     => true,
    261261                                ),
    262262                                'protected'        => array(
    263                                         'description'  => __( 'Whether posts with this resource should be protected.' ),
     263                                        'description'  => __( 'Whether posts with this status should be protected.' ),
    264264                                        'type'         => 'boolean',
    265265                                        'context'      => array( 'edit' ),
    266266                                        'readonly'     => true,
    267267                                ),
    268268                                'public'           => array(
    269                                         'description'  => __( 'Whether posts of this resource should 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.' ),
    270270                                        'type'         => 'boolean',
    271271                                        'context'      => array( 'view', 'edit' ),
    272272                                        'readonly'     => true,
    273273                                ),
    274274                                'queryable'        => array(
    275                                         'description'  => __( 'Whether posts with this resource should be publicly-queryable.' ),
     275                                        'description'  => __( 'Whether posts with this status should be publicly-queryable.' ),
    276276                                        'type'         => 'boolean',
    277277                                        'context'      => array( 'view', 'edit' ),
    278278                                        'readonly'     => true,
     
    284284                                        'readonly'     => true,
    285285                                ),
    286286                                'slug'             => array(
    287                                         'description'  => __( 'An alphanumeric identifier for the resource.' ),
     287                                        'description'  => __( 'An alphanumeric identifier for the status.' ),
    288288                                        'type'         => 'string',
    289289                                        'context'      => array( 'embed', 'view', 'edit' ),
    290290                                        'readonly'     => true,
  • wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php

     
    119119                $obj = get_post_type_object( $request['type'] );
    120120
    121121                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 ) );
    123123                }
    124124
    125125                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() ) );
    127127                }
    128128
    129129                if ( 'edit' === $request['context'] && ! current_user_can( $obj->cap->edit_posts ) ) {
     
    204204                        'type'                 => 'object',
    205205                        'properties'           => array(
    206206                                'capabilities'     => array(
    207                                         'description'  => __( 'All capabilities used by the resource.' ),
     207                                        'description'  => __( 'All capabilities used by the post type.' ),
    208208                                        'type'         => 'object',
    209209                                        'context'      => array( 'edit' ),
    210210                                        'readonly'     => true,
    211211                                ),
    212212                                'description'      => array(
    213                                         'description'  => __( 'A human-readable description of the resource.' ),
     213                                        'description'  => __( 'A human-readable description of the post type.' ),
    214214                                        'type'         => 'string',
    215215                                        'context'      => array( 'view', 'edit' ),
    216216                                        'readonly'     => true,
    217217                                ),
    218218                                'hierarchical'     => array(
    219                                         'description'  => __( 'Whether or not the resource should have children.' ),
     219                                        'description'  => __( 'Whether or not the post type should have children.' ),
    220220                                        'type'         => 'boolean',
    221221                                        'context'      => array( 'view', 'edit' ),
    222222                                        'readonly'     => true,
    223223                                ),
    224224                                '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.' ),
    226226                                        'type'         => 'object',
    227227                                        'context'      => array( 'edit' ),
    228228                                        'readonly'     => true,
    229229                                ),
    230230                                'name'             => array(
    231                                         'description'  => __( 'The title for the resource.' ),
     231                                        'description'  => __( 'The title for the post type.' ),
    232232                                        'type'         => 'string',
    233233                                        'context'      => array( 'view', 'edit', 'embed' ),
    234234                                        'readonly'     => true,
    235235                                ),
    236236                                'slug'             => array(
    237                                         'description'  => __( 'An alphanumeric identifier for the resource.' ),
     237                                        'description'  => __( 'An alphanumeric identifier for the post type.' ),
    238238                                        'type'         => 'string',
    239239                                        'context'      => array( 'view', 'edit', 'embed' ),
    240240                                        'readonly'     => true,
    241241                                ),
    242242                                'taxonomies'       => array(
    243                                         'description'  => __( 'Taxonomies associated with resource.' ),
     243                                        'description'  => __( 'Taxonomies associated with post type.' ),
    244244                                        'type'         => 'array',
    245245                                        'items'        => array(
    246246                                                'type' => 'string',
     
    249249                                        'readonly'     => true,
    250250                                ),
    251251                                'rest_base'            => array(
    252                                         'description'  => __( 'REST base route for the resource.' ),
     252                                        'description'  => __( 'REST base route for the post type.' ),
    253253                                        'type'         => 'string',
    254254                                        'context'      => array( 'view', 'edit', 'embed' ),
    255255                                        'readonly'     => true,
  • wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php

     
    19631963                $params['context']['default'] = 'view';
    19641964
    19651965                $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.' ),
    19671967                        'type'               => 'string',
    19681968                        'format'             => 'date-time',
    19691969                );
     
    19881988                }
    19891989
    19901990                $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.' ),
    19921992                        'type'               => 'string',
    19931993                        'format'             => 'date-time',
    19941994                );
     
    20132013
    20142014                if ( 'page' === $this->post_type || post_type_supports( $this->post_type, 'page-attributes' ) ) {
    20152015                        $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.' ),
    20172017                                'type'               => 'integer',
    20182018                        );
    20192019                }
  • wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php

     
    1111 * Core class used to access revisions via the REST API.
    1212 *
    1313 * @since 4.7.0
    14  *
     14 *0
    1515 * @see WP_REST_Controller
    1616 */
    1717class WP_REST_Revisions_Controller extends WP_REST_Controller {
     
    9797                                        'force' => array(
    9898                                                'type'        => 'boolean',
    9999                                                'default'     => false,
    100                                                 'description' => __( 'Required to be true, as resource does not support trashing.' ),
     100                                                'description' => __( 'Required to be true, as revisions do not support trashing.' ),
    101101                                        ),
    102102                                ),
    103103                        ),
     
    227227        public function delete_item( $request ) {
    228228                $force = isset( $request['force'] ) ? (bool) $request['force'] : false;
    229229
    230                 // We don't support trashing for this resource type.
     230                // We don't support trashing for revisions.
    231231                if ( ! $force ) {
    232232                        return new WP_Error( 'rest_trash_not_supported', __( 'Revisions do not support trashing. Set force=true to delete.' ), array( 'status' => 501 ) );
    233233                }
  • wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php

     
    160160        public function get_item( $request ) {
    161161                $tax_obj = get_taxonomy( $request['taxonomy'] );
    162162                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 ) );
    164164                }
    165165                $data = $this->prepare_item_for_response( $tax_obj, $request );
    166166                return rest_ensure_response( $data );
     
    235235                        'type'                 => 'object',
    236236                        'properties'           => array(
    237237                                'capabilities'     => array(
    238                                         'description'  => __( 'All capabilities used by the resource.' ),
     238                                        'description'  => __( 'All capabilities used by the taxonomy.' ),
    239239                                        'type'         => 'object',
    240240                                        'context'      => array( 'edit' ),
    241241                                        'readonly'     => true,
    242242                                ),
    243243                                'description'      => array(
    244                                         'description'  => __( 'A human-readable description of the resource.' ),
     244                                        'description'  => __( 'A human-readable description of the taxonomy.' ),
    245245                                        'type'         => 'string',
    246246                                        'context'      => array( 'view', 'edit' ),
    247247                                        'readonly'     => true,
    248248                                ),
    249249                                'hierarchical'     => array(
    250                                         'description'  => __( 'Whether or not the resource should have children.' ),
     250                                        'description'  => __( 'Whether or not the taxonomy should have children.' ),
    251251                                        'type'         => 'boolean',
    252252                                        'context'      => array( 'view', 'edit' ),
    253253                                        'readonly'     => true,
    254254                                ),
    255255                                'labels'           => array(
    256                                         'description'  => __( 'Human-readable labels for the resource for various contexts.' ),
     256                                        'description'  => __( 'Human-readable labels for the taxonomy for various contexts.' ),
    257257                                        'type'         => 'object',
    258258                                        'context'      => array( 'edit' ),
    259259                                        'readonly'     => true,
    260260                                ),
    261261                                'name'             => array(
    262                                         'description'  => __( 'The title for the resource.' ),
     262                                        'description'  => __( 'The title for the taxonomy.' ),
    263263                                        'type'         => 'string',
    264264                                        'context'      => array( 'view', 'edit', 'embed' ),
    265265                                        'readonly'     => true,
    266266                                ),
    267267                                'slug'             => array(
    268                                         'description'  => __( 'An alphanumeric identifier for the resource.' ),
     268                                        'description'  => __( 'An alphanumeric identifier for the taxonomy.' ),
    269269                                        'type'         => 'string',
    270270                                        'context'      => array( 'view', 'edit', 'embed' ),
    271271                                        'readonly'     => true,
     
    277277                                        'readonly'     => true,
    278278                                ),
    279279                                'types'            => array(
    280                                         'description'  => __( 'Types associated with resource.' ),
     280                                        'description'  => __( 'Types associated with the taxonomy.' ),
    281281                                        'type'         => 'array',
    282282                                        'items'        => array(
    283283                                                'type' => 'string',
     
    286286                                        'readonly'     => true,
    287287                                ),
    288288                                'rest_base'            => array(
    289                                         'description'  => __( 'REST base route for the resource.' ),
     289                                        'description'  => __( 'REST base route for the taxonomy.' ),
    290290                                        'type'         => 'string',
    291291                                        'context'      => array( 'view', 'edit', 'embed' ),
    292292                                        'readonly'     => true,
     
    308308                $new_params = array();
    309309                $new_params['context'] = $this->get_context_param( array( 'default' => 'view' ) );
    310310                $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.' ),
    312312                        'type'         => 'string',
    313313                );
    314314                return $new_params;
  • wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php

     
    118118                                        'force' => array(
    119119                                                'type'        => 'boolean',
    120120                                                'default'     => false,
    121                                                 'description' => __( 'Required to be true, as resource does not support trashing.' ),
     121                                                'description' => __( 'Required to be true, as terms do not support trashing.' ),
    122122                                        ),
    123123                                ),
    124124                        ),
     
    321321                $term = get_term( (int) $request['id'], $this->taxonomy );
    322322
    323323                if ( ! $term || $term->taxonomy !== $this->taxonomy ) {
    324                         return new WP_Error( 'rest_term_invalid', __( "Resource doesn't exist." ), array( 'status' => 404 ) );
     324                        return new WP_Error( 'rest_term_invalid', __( "Term doesn't exist." ), array( 'status' => 404 ) );
    325325                }
    326326
    327327                if ( is_wp_error( $term ) ) {
     
    350350
    351351                $taxonomy_obj = get_taxonomy( $this->taxonomy );
    352352                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() ) );
    354354                }
    355355
    356356                return true;
     
    368368        public function create_item( $request ) {
    369369                if ( isset( $request['parent'] ) ) {
    370370                        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 ) );
    372372                        }
    373373
    374374                        $parent = get_term( (int) $request['parent'], $this->taxonomy );
    375375
    376376                        if ( ! $parent ) {
    377                                 return new WP_Error( 'rest_term_invalid', __( "Parent resource doesn't exist." ), array( 'status' => 400 ) );
     377                                return new WP_Error( 'rest_term_invalid', __( "Parent term doesn't exist." ), array( 'status' => 400 ) );
    378378                        }
    379379                }
    380380
     
    453453                $term = get_term( (int) $request['id'], $this->taxonomy );
    454454
    455455                if ( ! $term ) {
    456                         return new WP_Error( 'rest_term_invalid', __( "Resource doesn't exist." ), array( 'status' => 404 ) );
     456                        return new WP_Error( 'rest_term_invalid', __( "Term doesn't exist." ), array( 'status' => 404 ) );
    457457                }
    458458
    459459                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() ) );
    461461                }
    462462
    463463                return true;
     
    475475        public function update_item( $request ) {
    476476                if ( isset( $request['parent'] ) ) {
    477477                        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 ) );
    479479                        }
    480480
    481481                        $parent = get_term( (int) $request['parent'], $this->taxonomy );
    482482
    483483                        if ( ! $parent ) {
    484                                 return new WP_Error( 'rest_term_invalid', __( "Parent resource doesn't exist." ), array( 'status' => 400 ) );
     484                                return new WP_Error( 'rest_term_invalid', __( "Parent term doesn't exist." ), array( 'status' => 400 ) );
    485485                        }
    486486                }
    487487
     
    542542                $term = get_term( (int) $request['id'], $this->taxonomy );
    543543
    544544                if ( ! $term ) {
    545                         return new WP_Error( 'rest_term_invalid', __( "Resource doesn't exist." ), array( 'status' => 404 ) );
     545                        return new WP_Error( 'rest_term_invalid', __( "Term doesn't exist." ), array( 'status' => 404 ) );
    546546                }
    547547
    548548                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() ) );
    550550                }
    551551
    552552                return true;
     
    565565
    566566                $force = isset( $request['force'] ) ? (bool) $request['force'] : false;
    567567
    568                 // We don't support trashing for this resource type.
     568                // We don't support trashing for terms.
    569569                if ( ! $force ) {
    570570                        return new WP_Error( 'rest_trash_not_supported', __( 'Terms do not support trashing. Set force=true to delete.' ), array( 'status' => 501 ) );
    571571                }
     
    579579                $retval = wp_delete_term( $term->term_id, $term->taxonomy );
    580580
    581581                if ( ! $retval ) {
    582                         return new WP_Error( 'rest_cannot_delete', __( 'The resource cannot be deleted.' ), array( 'status' => 500 ) );
     582                        return new WP_Error( 'rest_cannot_delete', __( 'The term cannot be deleted.' ), array( 'status' => 500 ) );
    583583                }
    584584
    585585                $response = new WP_REST_Response();
     
    806806                        'type'       => 'object',
    807807                        'properties' => array(
    808808                                'id'          => array(
    809                                         'description'  => __( 'Unique identifier for the resource.' ),
     809                                        'description'  => __( 'Unique identifier for the term.' ),
    810810                                        'type'         => 'integer',
    811811                                        'context'      => array( 'view', 'embed', 'edit' ),
    812812                                        'readonly'     => true,
    813813                                ),
    814814                                'count'       => array(
    815                                         'description'  => __( 'Number of published posts for the resource.' ),
     815                                        'description'  => __( 'Number of published posts for the term.' ),
    816816                                        'type'         => 'integer',
    817817                                        'context'      => array( 'view', 'edit' ),
    818818                                        'readonly'     => true,
    819819                                ),
    820820                                'description' => array(
    821                                         'description'  => __( 'HTML description of the resource.' ),
     821                                        'description'  => __( 'HTML description of the term.' ),
    822822                                        'type'         => 'string',
    823823                                        'context'      => array( 'view', 'edit' ),
    824824                                ),
    825825                                'link'        => array(
    826                                         'description'  => __( 'URL of the resource.' ),
     826                                        'description'  => __( 'URL of the term.' ),
    827827                                        'type'         => 'string',
    828828                                        'format'       => 'uri',
    829829                                        'context'      => array( 'view', 'embed', 'edit' ),
     
    830830                                        'readonly'     => true,
    831831                                ),
    832832                                'name'        => array(
    833                                         'description'  => __( 'HTML title for the resource.' ),
     833                                        'description'  => __( 'HTML title for the term.' ),
    834834                                        'type'         => 'string',
    835835                                        'context'      => array( 'view', 'embed', 'edit' ),
    836836                                        'arg_options'  => array(
     
    839839                                        'required'     => true,
    840840                                ),
    841841                                'slug'        => array(
    842                                         'description'  => __( 'An alphanumeric identifier for the resource unique to its type.' ),
     842                                        'description'  => __( 'An alphanumeric identifier for the term unique to its type.' ),
    843843                                        'type'         => 'string',
    844844                                        'context'      => array( 'view', 'embed', 'edit' ),
    845845                                        'arg_options'  => array(
     
    847847                                        ),
    848848                                ),
    849849                                'taxonomy'    => array(
    850                                         'description'  => __( 'Type attribution for the resource.' ),
     850                                        'description'  => __( 'Type attribution for the term.' ),
    851851                                        'type'         => 'string',
    852852                                        'enum'         => array_keys( get_taxonomies() ),
    853853                                        'context'      => array( 'view', 'embed', 'edit' ),
     
    860860
    861861                if ( $taxonomy->hierarchical ) {
    862862                        $schema['properties']['parent'] = array(
    863                                 'description'  => __( 'The ID for the parent of the resource.' ),
     863                                'description'  => __( 'The parent term ID.' ),
    864864                                'type'         => 'integer',
    865865                                'context'      => array( 'view', 'edit' ),
    866866                        );
     
    921921                );
    922922
    923923                $query_params['orderby'] = array(
    924                         'description'       => __( 'Sort collection by resource attribute.' ),
     924                        'description'       => __( 'Sort collection by term attribute.' ),
    925925                        'type'              => 'string',
    926926                        'default'           => 'name',
    927927                        'enum'              => array(
     
    936936                );
    937937
    938938                $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.' ),
    940940                        'type'              => 'boolean',
    941941                        'default'           => false,
    942942                );
     
    943943
    944944                if ( $taxonomy->hierarchical ) {
    945945                        $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.' ),
    947947                                'type'              => 'integer',
    948948                        );
    949949                }
    950950
    951951                $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.' ),
    953953                        'type'              => 'integer',
    954954                        'default'           => null,
    955955                );
    956956
    957957                $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.' ),
    959959                        'type'              => 'string',
    960960                );
    961961
  • wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php

     
    8787                                        'force'    => array(
    8888                                                'type'        => 'boolean',
    8989                                                'default'     => false,
    90                                                 'description' => __( 'Required to be true, as resource does not support trashing.' ),
     90                                                'description' => __( 'Required to be true, as users do not support trashing.' ),
    9191                                        ),
    9292                                        'reassign' => array(
    9393                                                'type'        => 'integer',
     
    120120                                        'force'    => array(
    121121                                                'type'        => 'boolean',
    122122                                                'default'     => false,
    123                                                 'description' => __( 'Required to be true, as resource does not support trashing.' ),
     123                                                'description' => __( 'Required to be true, as users do not support trashing.' ),
    124124                                        ),
    125125                                        'reassign' => array(
    126126                                                'type'        => 'integer',
     
    312312                $types = get_post_types( array( 'show_in_rest' => true ), 'names' );
    313313
    314314                if ( empty( $id ) || empty( $user->ID ) ) {
    315                         return new WP_Error( 'rest_user_invalid_id', __( 'Invalid resource ID.' ), array( 'status' => 404 ) );
     315                        return new WP_Error( 'rest_user_invalid_id', __( 'Invalid user ID.' ), array( 'status' => 404 ) );
    316316                }
    317317
    318318                if ( get_current_user_id() === $id ) {
     
    342342                $user = get_userdata( $id );
    343343
    344344                if ( empty( $id ) || empty( $user->ID ) ) {
    345                         return new WP_Error( 'rest_user_invalid_id', __( 'Invalid resource ID.' ), array( 'status' => 404 ) );
     345                        return new WP_Error( 'rest_user_invalid_id', __( 'Invalid user ID.' ), array( 'status' => 404 ) );
    346346                }
    347347
    348348                $user = $this->prepare_item_for_response( $user, $request );
     
    387387        public function create_item_permissions_check( $request ) {
    388388
    389389                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() ) );
    391391                }
    392392
    393393                return true;
     
    404404         */
    405405        public function create_item( $request ) {
    406406                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 ) );
    408408                }
    409409
    410410                $schema = $this->get_item_schema();
     
    440440                        $user_id = wpmu_create_user( $user->user_login, $user->user_pass, $user->user_email );
    441441
    442442                        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 ) );
    444444                        }
    445445
    446446                        $user->ID = $user_id;
     
    515515                $id = (int) $request['id'];
    516516
    517517                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() ) );
    519519                }
    520520
    521521                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() ) );
    523523                }
    524524
    525525                return true;
     
    539539                $user = get_userdata( $id );
    540540
    541541                if ( ! $user ) {
    542                         return new WP_Error( 'rest_user_invalid_id', __( 'Invalid resource ID.' ), array( 'status' => 404 ) );
     542                        return new WP_Error( 'rest_user_invalid_id', __( 'Invalid user ID.' ), array( 'status' => 404 ) );
    543543                }
    544544
    545545                if ( email_exists( $request['email'] ) && $request['email'] !== $user->user_email ) {
     
    654654                $id = (int) $request['id'];
    655655
    656656                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() ) );
    658658                }
    659659
    660660                return true;
     
    682682                $user = get_userdata( $id );
    683683
    684684                if ( ! $user ) {
    685                         return new WP_Error( 'rest_user_invalid_id', __( 'Invalid resource ID.' ), array( 'status' => 404 ) );
     685                        return new WP_Error( 'rest_user_invalid_id', __( 'Invalid user ID.' ), array( 'status' => 404 ) );
    686686                }
    687687
    688688                if ( ! empty( $reassign ) ) {
    689689                        if ( $reassign === $id || ! get_userdata( $reassign ) ) {
    690                                 return new WP_Error( 'rest_user_invalid_reassign', __( 'Invalid resource ID for reassignment.' ), array( 'status' => 400 ) );
     690                                return new WP_Error( 'rest_user_invalid_reassign', __( 'Invalid user ID for reassignment.' ), array( 'status' => 400 ) );
    691691                        }
    692692                }
    693693
     
    701701                $result = wp_delete_user( $id, $reassign );
    702702
    703703                if ( ! $result ) {
    704                         return new WP_Error( 'rest_cannot_delete', __( 'The resource cannot be deleted.' ), array( 'status' => 500 ) );
     704                        return new WP_Error( 'rest_cannot_delete', __( 'The user cannot be deleted.' ), array( 'status' => 500 ) );
    705705                }
    706706
    707707                $response = new WP_REST_Response();
     
    995995                                && get_current_user_id() === $user_id
    996996                                && ! $potential_role->has_cap( 'edit_users' )
    997997                        ) {
    998                                 return new WP_Error( 'rest_user_invalid_role', __( 'Sorry, you are not allowed to give resource that 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() ) );
    999999                        }
    10001000
    10011001                        /** Include admin functions to get access to get_editable_roles() */
     
    10051005                        $editable_roles = get_editable_roles();
    10061006
    10071007                        if ( empty( $editable_roles[ $role ] ) ) {
    1008                                 return new WP_Error( 'rest_user_invalid_role', __( 'Sorry, you are not allowed to give resource that 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 ) );
    10091009                        }
    10101010                }
    10111011
     
    10821082                        'type'       => 'object',
    10831083                        'properties' => array(
    10841084                                'id'          => array(
    1085                                         'description' => __( 'Unique identifier for the resource.' ),
     1085                                        'description' => __( 'Unique identifier for the user.' ),
    10861086                                        'type'        => 'integer',
    10871087                                        'context'     => array( 'embed', 'view', 'edit' ),
    10881088                                        'readonly'    => true,
    10891089                                ),
    10901090                                'username'    => array(
    1091                                         'description' => __( 'Login name for the resource.' ),
     1091                                        'description' => __( 'Login name for the user.' ),
    10921092                                        'type'        => 'string',
    10931093                                        'context'     => array( 'edit' ),
    10941094                                        'required'    => true,
     
    10971097                                        ),
    10981098                                ),
    10991099                                'name'        => array(
    1100                                         'description' => __( 'Display name for the resource.' ),
     1100                                        'description' => __( 'Display name for the user.' ),
    11011101                                        'type'        => 'string',
    11021102                                        'context'     => array( 'embed', 'view', 'edit' ),
    11031103                                        'arg_options' => array(
     
    11051105                                        ),
    11061106                                ),
    11071107                                'first_name'  => array(
    1108                                         'description' => __( 'First name for the resource.' ),
     1108                                        'description' => __( 'First name for the user.' ),
    11091109                                        'type'        => 'string',
    11101110                                        'context'     => array( 'edit' ),
    11111111                                        'arg_options' => array(
     
    11131113                                        ),
    11141114                                ),
    11151115                                'last_name'   => array(
    1116                                         'description' => __( 'Last name for the resource.' ),
     1116                                        'description' => __( 'Last name for the user.' ),
    11171117                                        'type'        => 'string',
    11181118                                        'context'     => array( 'edit' ),
    11191119                                        'arg_options' => array(
     
    11211121                                        ),
    11221122                                ),
    11231123                                'email'       => array(
    1124                                         'description' => __( 'The email address for the resource.' ),
     1124                                        'description' => __( 'The email address for the user.' ),
    11251125                                        'type'        => 'string',
    11261126                                        'format'      => 'email',
    11271127                                        'context'     => array( 'edit' ),
     
    11281128                                        'required'    => true,
    11291129                                ),
    11301130                                'url'         => array(
    1131                                         'description' => __( 'URL of the resource.' ),
     1131                                        'description' => __( 'URL of the user.' ),
    11321132                                        'type'        => 'string',
    11331133                                        'format'      => 'uri',
    11341134                                        'context'     => array( 'embed', 'view', 'edit' ),
    11351135                                ),
    11361136                                'description' => array(
    1137                                         'description' => __( 'Description of the resource.' ),
     1137                                        'description' => __( 'Description of the user.' ),
    11381138                                        'type'        => 'string',
    11391139                                        'context'     => array( 'embed', 'view', 'edit' ),
    11401140                                ),
    11411141                                'link'        => array(
    1142                                         'description' => __( 'Author URL of the resource.' ),
     1142                                        'description' => __( 'Author URL of the user.' ),
    11431143                                        'type'        => 'string',
    11441144                                        'format'      => 'uri',
    11451145                                        'context'     => array( 'embed', 'view', 'edit' ),
     
    11461146                                        'readonly'    => true,
    11471147                                ),
    11481148                                'locale'    => array(
    1149                                         'description' => __( 'Locale for the resource.' ),
     1149                                        'description' => __( 'Locale for the user.' ),
    11501150                                        'type'        => 'string',
    11511151                                        'enum'        => array_merge( array( '', 'en_US' ), get_available_languages() ),
    11521152                                        'context'     => array( 'edit' ),
    11531153                                ),
    11541154                                'nickname'    => array(
    1155                                         'description' => __( 'The nickname for the resource.' ),
     1155                                        'description' => __( 'The nickname for the user.' ),
    11561156                                        'type'        => 'string',
    11571157                                        'context'     => array( 'edit' ),
    11581158                                        'arg_options' => array(
     
    11601160                                        ),
    11611161                                ),
    11621162                                'slug'        => array(
    1163                                         'description' => __( 'An alphanumeric identifier for the resource.' ),
     1163                                        'description' => __( 'An alphanumeric identifier for the user.' ),
    11641164                                        'type'        => 'string',
    11651165                                        'context'     => array( 'embed', 'view', 'edit' ),
    11661166                                        'arg_options' => array(
     
    11681168                                        ),
    11691169                                ),
    11701170                                'registered_date' => array(
    1171                                         'description' => __( 'Registration date for the resource.' ),
     1171                                        'description' => __( 'Registration date for the user.' ),
    11721172                                        'type'        => 'string',
    11731173                                        'format'      => 'date-time',
    11741174                                        'context'     => array( 'edit' ),
     
    11751175                                        'readonly'    => true,
    11761176                                ),
    11771177                                'roles'           => array(
    1178                                         'description' => __( 'Roles assigned to the resource.' ),
     1178                                        'description' => __( 'Roles assigned to the user.' ),
    11791179                                        'type'        => 'array',
    11801180                                        'items'       => array(
    11811181                                                'type'    => 'string',
     
    11831183                                        'context'     => array( 'edit' ),
    11841184                                ),
    11851185                                'password'        => array(
    1186                                         'description' => __( 'Password for the resource (never included).' ),
     1186                                        'description' => __( 'Password for the user (never included).' ),
    11871187                                        'type'        => 'string',
    11881188                                        'context'     => array(), // Password is never displayed.
    11891189                                        'required'    => true,
     
    11921192                                        ),
    11931193                                ),
    11941194                                'capabilities'    => array(
    1195                                         'description' => __( 'All capabilities assigned to the resource.' ),
     1195                                        'description' => __( 'All capabilities assigned to the user.' ),
    11961196                                        'type'        => 'object',
    11971197                                        'context'     => array( 'edit' ),
    11981198                                        'readonly'    => true,
    11991199                                ),
    12001200                                'extra_capabilities' => array(
    1201                                         'description' => __( 'Any extra capabilities assigned to the resource.' ),
     1201                                        'description' => __( 'Any extra capabilities assigned to the user.' ),
    12021202                                        'type'        => 'object',
    12031203                                        'context'     => array( 'edit' ),
    12041204                                        'readonly'    => true,
     
    12221222                        }
    12231223
    12241224                        $schema['properties']['avatar_urls']  = array(
    1225                                 'description' => __( 'Avatar URLs for the resource.' ),
     1225                                'description' => __( 'Avatar URLs for the user.' ),
    12261226                                'type'        => 'object',
    12271227                                'context'     => array( 'embed', 'view', 'edit' ),
    12281228                                'readonly'    => true,
     
    12941294                );
    12951295
    12961296                $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.' ),
    12981298                        'type'               => 'string',
    12991299                );
    13001300
    13011301                $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.' ),
    13031303                        'type'               => 'array',
    13041304                        'items'              => array(
    13051305                                'type'           => 'string',