Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (8 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php

    r41735 r42343  
    4444    public function register_routes() {
    4545
    46         register_rest_route( $this->namespace, '/' . $this->rest_base, array(
    47             array(
    48                 'methods'   => WP_REST_Server::READABLE,
    49                 'callback'  => array( $this, 'get_items' ),
    50                 'permission_callback' => array( $this, 'get_items_permissions_check' ),
    51                 'args'      => $this->get_collection_params(),
    52             ),
    53             array(
    54                 'methods'  => WP_REST_Server::CREATABLE,
    55                 'callback' => array( $this, 'create_item' ),
    56                 'permission_callback' => array( $this, 'create_item_permissions_check' ),
    57                 'args'     => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ),
    58             ),
    59             'schema' => array( $this, 'get_public_item_schema' ),
    60         ) );
    61 
    62         register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array(
    63             'args' => array(
    64                 'id' => array(
    65                     'description' => __( 'Unique identifier for the object.' ),
    66                     'type'        => 'integer',
    67                 ),
    68             ),
    69             array(
    70                 'methods'  => WP_REST_Server::READABLE,
    71                 'callback' => array( $this, 'get_item' ),
    72                 'permission_callback' => array( $this, 'get_item_permissions_check' ),
    73                 'args'     => array(
    74                     'context'          => $this->get_context_param( array( 'default' => 'view' ) ),
    75                     'password' => array(
    76                         'description' => __( 'The password for the parent post of the comment (if the post is password protected).' ),
    77                         'type'        => 'string',
     46        register_rest_route(
     47            $this->namespace, '/' . $this->rest_base, array(
     48                array(
     49                    'methods'             => WP_REST_Server::READABLE,
     50                    'callback'            => array( $this, 'get_items' ),
     51                    'permission_callback' => array( $this, 'get_items_permissions_check' ),
     52                    'args'                => $this->get_collection_params(),
     53                ),
     54                array(
     55                    'methods'             => WP_REST_Server::CREATABLE,
     56                    'callback'            => array( $this, 'create_item' ),
     57                    'permission_callback' => array( $this, 'create_item_permissions_check' ),
     58                    'args'                => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ),
     59                ),
     60                'schema' => array( $this, 'get_public_item_schema' ),
     61            )
     62        );
     63
     64        register_rest_route(
     65            $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array(
     66                'args'   => array(
     67                    'id' => array(
     68                        'description' => __( 'Unique identifier for the object.' ),
     69                        'type'        => 'integer',
    7870                    ),
    7971                ),
    80             ),
    81             array(
    82                 'methods'  => WP_REST_Server::EDITABLE,
    83                 'callback' => array( $this, 'update_item' ),
    84                 'permission_callback' => array( $this, 'update_item_permissions_check' ),
    85                 'args'     => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ),
    86             ),
    87             array(
    88                 'methods'  => WP_REST_Server::DELETABLE,
    89                 'callback' => array( $this, 'delete_item' ),
    90                 'permission_callback' => array( $this, 'delete_item_permissions_check' ),
    91                 'args'     => array(
    92                     'force'    => array(
    93                         'type'        => 'boolean',
    94                         'default'     => false,
    95                         'description' => __( 'Whether to bypass trash and force deletion.' ),
     72                array(
     73                    'methods'             => WP_REST_Server::READABLE,
     74                    'callback'            => array( $this, 'get_item' ),
     75                    'permission_callback' => array( $this, 'get_item_permissions_check' ),
     76                    'args'                => array(
     77                        'context'  => $this->get_context_param( array( 'default' => 'view' ) ),
     78                        'password' => array(
     79                            'description' => __( 'The password for the parent post of the comment (if the post is password protected).' ),
     80                            'type'        => 'string',
     81                        ),
    9682                    ),
    97                     'password' => array(
    98                         'description' => __( 'The password for the parent post of the comment (if the post is password protected).' ),
    99                         'type'        => 'string',
     83                ),
     84                array(
     85                    'methods'             => WP_REST_Server::EDITABLE,
     86                    'callback'            => array( $this, 'update_item' ),
     87                    'permission_callback' => array( $this, 'update_item_permissions_check' ),
     88                    'args'                => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ),
     89                ),
     90                array(
     91                    'methods'             => WP_REST_Server::DELETABLE,
     92                    'callback'            => array( $this, 'delete_item' ),
     93                    'permission_callback' => array( $this, 'delete_item_permissions_check' ),
     94                    'args'                => array(
     95                        'force'    => array(
     96                            'type'        => 'boolean',
     97                            'default'     => false,
     98                            'description' => __( 'Whether to bypass trash and force deletion.' ),
     99                        ),
     100                        'password' => array(
     101                            'description' => __( 'The password for the parent post of the comment (if the post is password protected).' ),
     102                            'type'        => 'string',
     103                        ),
    100104                    ),
    101105                ),
    102             ),
    103             'schema' => array( $this, 'get_public_item_schema' ),
    104         ) );
     106                'schema' => array( $this, 'get_public_item_schema' ),
     107            )
     108        );
    105109    }
    106110
     
    246250        $prepared_args = apply_filters( 'rest_comment_query', $prepared_args, $request );
    247251
    248         $query = new WP_Comment_Query;
     252        $query        = new WP_Comment_Query;
    249253        $query_result = $query->query( $prepared_args );
    250254
     
    256260            }
    257261
    258             $data = $this->prepare_item_for_response( $comment, $request );
     262            $data       = $this->prepare_item_for_response( $comment, $request );
    259263            $comments[] = $this->prepare_response_for_collection( $data );
    260264        }
     
    267271            unset( $prepared_args['number'], $prepared_args['offset'] );
    268272
    269             $query = new WP_Comment_Query;
     273            $query                  = new WP_Comment_Query;
    270274            $prepared_args['count'] = true;
    271275
    272276            $total_comments = $query->query( $prepared_args );
    273             $max_pages = ceil( $total_comments / $request['per_page'] );
     277            $max_pages      = ceil( $total_comments / $request['per_page'] );
    274278        }
    275279
     
    315319        }
    316320
    317         $id = (int) $id;
     321        $id      = (int) $id;
    318322        $comment = get_comment( $id );
    319323        if ( empty( $comment ) ) {
     
    376380        }
    377381
    378         $data = $this->prepare_item_for_response( $comment, $request );
     382        $data     = $this->prepare_item_for_response( $comment, $request );
    379383        $response = rest_ensure_response( $data );
    380384
     
    416420        // Limit who can set comment `author`, `author_ip` or `status` to anything other than the default.
    417421        if ( isset( $request['author'] ) && get_current_user_id() !== $request['author'] && ! current_user_can( 'moderate_comments' ) ) {
    418             return new WP_Error( 'rest_comment_invalid_author',
     422            return new WP_Error(
     423                'rest_comment_invalid_author',
    419424                /* translators: %s: request parameter */
    420425                sprintf( __( "Sorry, you are not allowed to edit '%s' for comments." ), 'author' ),
     
    425430        if ( isset( $request['author_ip'] ) && ! current_user_can( 'moderate_comments' ) ) {
    426431            if ( empty( $_SERVER['REMOTE_ADDR'] ) || $request['author_ip'] !== $_SERVER['REMOTE_ADDR'] ) {
    427                 return new WP_Error( 'rest_comment_invalid_author_ip',
     432                return new WP_Error(
     433                    'rest_comment_invalid_author_ip',
    428434                    /* translators: %s: request parameter */
    429435                    sprintf( __( "Sorry, you are not allowed to edit '%s' for comments." ), 'author_ip' ),
     
    434440
    435441        if ( isset( $request['status'] ) && ! current_user_can( 'moderate_comments' ) ) {
    436             return new WP_Error( 'rest_comment_invalid_status',
     442            return new WP_Error(
     443                'rest_comment_invalid_status',
    437444                /* translators: %s: request parameter */
    438445                sprintf( __( "Sorry, you are not allowed to edit '%s' for comments." ), 'status' ),
     
    516523            $user = wp_get_current_user();
    517524
    518             $prepared_comment['user_id'] = $user->ID;
    519             $prepared_comment['comment_author'] = $user->display_name;
     525            $prepared_comment['user_id']              = $user->ID;
     526            $prepared_comment['comment_author']       = $user->display_name;
    520527            $prepared_comment['comment_author_email'] = $user->user_email;
    521             $prepared_comment['comment_author_url'] = $user->user_url;
     528            $prepared_comment['comment_author_url']   = $user->user_url;
    522529        }
    523530
     
    632639        $response->header( 'Location', rest_url( sprintf( '%s/%s/%d', $this->namespace, $this->rest_base, $comment_id ) ) );
    633640
    634 
    635641        return $response;
    636642    }
     
    805811        if ( $force ) {
    806812            $previous = $this->prepare_item_for_response( $comment, $request );
    807             $result = wp_delete_comment( $comment->comment_ID, true );
     813            $result   = wp_delete_comment( $comment->comment_ID, true );
    808814            $response = new WP_REST_Response();
    809             $response->set_data( array( 'deleted' => true, 'previous' => $previous->get_data() ) );
     815            $response->set_data(
     816                array(
     817                    'deleted'  => true,
     818                    'previous' => $previous->get_data(),
     819                )
     820            );
    810821        } else {
    811822            // If this type doesn't support trashing, error out.
     
    819830            }
    820831
    821             $result = wp_trash_comment( $comment->comment_ID );
    822             $comment = get_comment( $comment->comment_ID );
     832            $result   = wp_trash_comment( $comment->comment_ID );
     833            $comment  = get_comment( $comment->comment_ID );
    823834            $response = $this->prepare_item_for_response( $comment, $request );
    824835        }
     
    853864    public function prepare_item_for_response( $comment, $request ) {
    854865        $data = array(
    855             'id'                 => (int) $comment->comment_ID,
    856             'post'               => (int) $comment->comment_post_ID,
    857             'parent'             => (int) $comment->comment_parent,
    858             'author'             => (int) $comment->user_id,
    859             'author_name'        => $comment->comment_author,
    860             'author_email'       => $comment->comment_author_email,
    861             'author_url'         => $comment->comment_author_url,
    862             'author_ip'          => $comment->comment_author_IP,
    863             'author_user_agent'  => $comment->comment_agent,
    864             'date'               => mysql_to_rfc3339( $comment->comment_date ),
    865             'date_gmt'           => mysql_to_rfc3339( $comment->comment_date_gmt ),
    866             'content'            => array(
     866            'id'                => (int) $comment->comment_ID,
     867            'post'              => (int) $comment->comment_post_ID,
     868            'parent'            => (int) $comment->comment_parent,
     869            'author'            => (int) $comment->user_id,
     870            'author_name'       => $comment->comment_author,
     871            'author_email'      => $comment->comment_author_email,
     872            'author_url'        => $comment->comment_author_url,
     873            'author_ip'         => $comment->comment_author_IP,
     874            'author_user_agent' => $comment->comment_agent,
     875            'date'              => mysql_to_rfc3339( $comment->comment_date ),
     876            'date_gmt'          => mysql_to_rfc3339( $comment->comment_date_gmt ),
     877            'content'           => array(
    867878                /** This filter is documented in wp-includes/comment-template.php */
    868879                'rendered' => apply_filters( 'comment_text', $comment->comment_content, $comment ),
    869880                'raw'      => $comment->comment_content,
    870881            ),
    871             'link'               => get_comment_link( $comment ),
    872             'status'             => $this->prepare_status_response( $comment->comment_approved ),
    873             'type'               => get_comment_type( $comment->comment_ID ),
     882            'link'              => get_comment_link( $comment ),
     883            'status'            => $this->prepare_status_response( $comment->comment_approved ),
     884            'type'              => get_comment_type( $comment->comment_ID ),
    874885        );
    875886
     
    917928    protected function prepare_links( $comment ) {
    918929        $links = array(
    919             'self' => array(
     930            'self'       => array(
    920931                'href' => rest_url( sprintf( '%s/%s/%d', $this->namespace, $this->rest_base, $comment->comment_ID ) ),
    921932            ),
     
    936947
    937948            if ( ! empty( $post->ID ) ) {
    938                 $obj = get_post_type_object( $post->post_type );
     949                $obj  = get_post_type_object( $post->post_type );
    939950                $base = ! empty( $obj->rest_base ) ? $obj->rest_base : $obj->name;
    940951
     
    955966
    956967        // Only grab one comment to verify the comment has children.
    957         $comment_children = $comment->get_children( array(
    958             'number' => 1,
    959             'count'  => true
    960         ) );
     968        $comment_children = $comment->get_children(
     969            array(
     970                'number' => 1,
     971                'count'  => true,
     972            )
     973        );
    961974
    962975        if ( ! empty( $comment_children ) ) {
    963976            $args = array(
    964                 'parent' => $comment->comment_ID
     977                'parent' => $comment->comment_ID,
    965978            );
    966979
     
    10711084
    10721085            if ( $user->exists() ) {
    1073                 $prepared_comment['user_id'] = $user->ID;
    1074                 $prepared_comment['comment_author'] = $user->display_name;
     1086                $prepared_comment['user_id']              = $user->ID;
     1087                $prepared_comment['comment_author']       = $user->display_name;
    10751088                $prepared_comment['comment_author_email'] = $user->user_email;
    1076                 $prepared_comment['comment_author_url'] = $user->user_url;
     1089                $prepared_comment['comment_author_url']   = $user->user_url;
    10771090            } else {
    10781091                return new WP_Error( 'rest_comment_author_invalid', __( 'Invalid comment author ID.' ), array( 'status' => 400 ) );
     
    11421155    public function get_item_schema() {
    11431156        $schema = array(
    1144             '$schema'              => 'http://json-schema.org/draft-04/schema#',
    1145             'title'                => 'comment',
    1146             'type'                 => 'object',
    1147             'properties'           => array(
    1148                 'id'               => array(
    1149                     'description'  => __( 'Unique identifier for the object.' ),
    1150                     'type'         => 'integer',
    1151                     'context'      => array( 'view', 'edit', 'embed' ),
    1152                     'readonly'     => true,
    1153                 ),
    1154                 'author'           => array(
    1155                     'description'  => __( 'The ID of the user object, if author was a user.' ),
    1156                     'type'         => 'integer',
    1157                     'context'      => array( 'view', 'edit', 'embed' ),
    1158                 ),
    1159                 'author_email'     => array(
    1160                     'description'  => __( 'Email address for the object author.' ),
    1161                     'type'         => 'string',
    1162                     'format'       => 'email',
    1163                     'context'      => array( 'edit' ),
    1164                     'arg_options'  => array(
     1157            '$schema'    => 'http://json-schema.org/draft-04/schema#',
     1158            'title'      => 'comment',
     1159            'type'       => 'object',
     1160            'properties' => array(
     1161                'id'                => array(
     1162                    'description' => __( 'Unique identifier for the object.' ),
     1163                    'type'        => 'integer',
     1164                    'context'     => array( 'view', 'edit', 'embed' ),
     1165                    'readonly'    => true,
     1166                ),
     1167                'author'            => array(
     1168                    'description' => __( 'The ID of the user object, if author was a user.' ),
     1169                    'type'        => 'integer',
     1170                    'context'     => array( 'view', 'edit', 'embed' ),
     1171                ),
     1172                'author_email'      => array(
     1173                    'description' => __( 'Email address for the object author.' ),
     1174                    'type'        => 'string',
     1175                    'format'      => 'email',
     1176                    'context'     => array( 'edit' ),
     1177                    'arg_options' => array(
    11651178                        'sanitize_callback' => array( $this, 'check_comment_author_email' ),
    11661179                        'validate_callback' => null, // skip built-in validation of 'email'.
    11671180                    ),
    11681181                ),
    1169                 'author_ip'     => array(
    1170                     'description'  => __( 'IP address for the object author.' ),
    1171                     'type'         => 'string',
    1172                     'format'       => 'ip',
    1173                     'context'      => array( 'edit' ),
    1174                 ),
    1175                 'author_name'     => array(
    1176                     'description'  => __( 'Display name for the object author.' ),
    1177                     'type'         => 'string',
    1178                     'context'      => array( 'view', 'edit', 'embed' ),
    1179                     'arg_options'  => array(
     1182                'author_ip'         => array(
     1183                    'description' => __( 'IP address for the object author.' ),
     1184                    'type'        => 'string',
     1185                    'format'      => 'ip',
     1186                    'context'     => array( 'edit' ),
     1187                ),
     1188                'author_name'       => array(
     1189                    'description' => __( 'Display name for the object author.' ),
     1190                    'type'        => 'string',
     1191                    'context'     => array( 'view', 'edit', 'embed' ),
     1192                    'arg_options' => array(
    11801193                        'sanitize_callback' => 'sanitize_text_field',
    11811194                    ),
    11821195                ),
    1183                 'author_url'       => array(
    1184                     'description'  => __( 'URL for the object author.' ),
    1185                     'type'         => 'string',
    1186                     'format'       => 'uri',
    1187                     'context'      => array( 'view', 'edit', 'embed' ),
    1188                 ),
    1189                 'author_user_agent'     => array(
    1190                     'description'  => __( 'User agent for the object author.' ),
    1191                     'type'         => 'string',
    1192                     'context'      => array( 'edit' ),
    1193                     'arg_options'  => array(
     1196                'author_url'        => array(
     1197                    'description' => __( 'URL for the object author.' ),
     1198                    'type'        => 'string',
     1199                    'format'      => 'uri',
     1200                    'context'     => array( 'view', 'edit', 'embed' ),
     1201                ),
     1202                'author_user_agent' => array(
     1203                    'description' => __( 'User agent for the object author.' ),
     1204                    'type'        => 'string',
     1205                    'context'     => array( 'edit' ),
     1206                    'arg_options' => array(
    11941207                        'sanitize_callback' => 'sanitize_text_field',
    11951208                    ),
    11961209                ),
    1197                 'content'          => array(
    1198                     'description'     => __( 'The content for the object.' ),
    1199                     'type'            => 'object',
    1200                     'context'         => array( 'view', 'edit', 'embed' ),
    1201                     'arg_options'     => array(
     1210                'content'           => array(
     1211                    'description' => __( 'The content for the object.' ),
     1212                    'type'        => 'object',
     1213                    'context'     => array( 'view', 'edit', 'embed' ),
     1214                    'arg_options' => array(
    12021215                        'sanitize_callback' => null, // Note: sanitization implemented in self::prepare_item_for_database()
    12031216                        'validate_callback' => null, // Note: validation implemented in self::prepare_item_for_database()
    12041217                    ),
    1205                     'properties'      => array(
    1206                         'raw'         => array(
    1207                             'description'     => __( 'Content for the object, as it exists in the database.' ),
    1208                             'type'            => 'string',
    1209                             'context'         => array( 'edit' ),
     1218                    'properties'  => array(
     1219                        'raw'      => array(
     1220                            'description' => __( 'Content for the object, as it exists in the database.' ),
     1221                            'type'        => 'string',
     1222                            'context'     => array( 'edit' ),
    12101223                        ),
    1211                         'rendered'    => array(
    1212                             'description'     => __( 'HTML content for the object, transformed for display.' ),
    1213                             'type'            => 'string',
    1214                             'context'         => array( 'view', 'edit', 'embed' ),
    1215                             'readonly'        => true,
     1224                        'rendered' => array(
     1225                            'description' => __( 'HTML content for the object, transformed for display.' ),
     1226                            'type'        => 'string',
     1227                            'context'     => array( 'view', 'edit', 'embed' ),
     1228                            'readonly'    => true,
    12161229                        ),
    12171230                    ),
    12181231                ),
    1219                 'date'             => array(
    1220                     'description'  => __( "The date the object was published, in the site's timezone." ),
    1221                     'type'         => 'string',
    1222                     'format'       => 'date-time',
    1223                     'context'      => array( 'view', 'edit', 'embed' ),
    1224                 ),
    1225                 'date_gmt'         => array(
    1226                     'description'  => __( 'The date the object was published, as GMT.' ),
    1227                     'type'         => 'string',
    1228                     'format'       => 'date-time',
    1229                     'context'      => array( 'view', 'edit' ),
    1230                 ),
    1231                 'link'             => array(
    1232                     'description'  => __( 'URL to the object.' ),
    1233                     'type'         => 'string',
    1234                     'format'       => 'uri',
    1235                     'context'      => array( 'view', 'edit', 'embed' ),
    1236                     'readonly'     => true,
    1237                 ),
    1238                 'parent'           => array(
    1239                     'description'  => __( 'The ID for the parent of the object.' ),
    1240                     'type'         => 'integer',
    1241                     'context'      => array( 'view', 'edit', 'embed' ),
    1242                     'default'      => 0,
    1243                 ),
    1244                 'post'             => array(
    1245                     'description'  => __( 'The ID of the associated post object.' ),
    1246                     'type'         => 'integer',
    1247                     'context'      => array( 'view', 'edit' ),
    1248                     'default'      => 0,
    1249                 ),
    1250                 'status'           => array(
    1251                     'description'  => __( 'State of the object.' ),
    1252                     'type'         => 'string',
    1253                     'context'      => array( 'view', 'edit' ),
    1254                     'arg_options'  => array(
     1232                'date'              => array(
     1233                    'description' => __( "The date the object was published, in the site's timezone." ),
     1234                    'type'        => 'string',
     1235                    'format'      => 'date-time',
     1236                    'context'     => array( 'view', 'edit', 'embed' ),
     1237                ),
     1238                'date_gmt'          => array(
     1239                    'description' => __( 'The date the object was published, as GMT.' ),
     1240                    'type'        => 'string',
     1241                    'format'      => 'date-time',
     1242                    'context'     => array( 'view', 'edit' ),
     1243                ),
     1244                'link'              => array(
     1245                    'description' => __( 'URL to the object.' ),
     1246                    'type'        => 'string',
     1247                    'format'      => 'uri',
     1248                    'context'     => array( 'view', 'edit', 'embed' ),
     1249                    'readonly'    => true,
     1250                ),
     1251                'parent'            => array(
     1252                    'description' => __( 'The ID for the parent of the object.' ),
     1253                    'type'        => 'integer',
     1254                    'context'     => array( 'view', 'edit', 'embed' ),
     1255                    'default'     => 0,
     1256                ),
     1257                'post'              => array(
     1258                    'description' => __( 'The ID of the associated post object.' ),
     1259                    'type'        => 'integer',
     1260                    'context'     => array( 'view', 'edit' ),
     1261                    'default'     => 0,
     1262                ),
     1263                'status'            => array(
     1264                    'description' => __( 'State of the object.' ),
     1265                    'type'        => 'string',
     1266                    'context'     => array( 'view', 'edit' ),
     1267                    'arg_options' => array(
    12551268                        'sanitize_callback' => 'sanitize_key',
    12561269                    ),
    12571270                ),
    1258                 'type'             => array(
    1259                     'description'  => __( 'Type of Comment for the object.' ),
    1260                     'type'         => 'string',
    1261                     'context'      => array( 'view', 'edit', 'embed' ),
    1262                     'readonly'     => true,
     1271                'type'              => array(
     1272                    'description' => __( 'Type of Comment for the object.' ),
     1273                    'type'        => 'string',
     1274                    'context'     => array( 'view', 'edit', 'embed' ),
     1275                    'readonly'    => true,
    12631276                ),
    12641277            ),
     
    12801293
    12811294            $schema['properties']['author_avatar_urls'] = array(
    1282                 'description'   => __( 'Avatar URLs for the object author.' ),
    1283                 'type'          => 'object',
    1284                 'context'       => array( 'view', 'edit', 'embed' ),
    1285                 'readonly'      => true,
    1286                 'properties'    => $avatar_properties,
     1295                'description' => __( 'Avatar URLs for the object author.' ),
     1296                'type'        => 'object',
     1297                'context'     => array( 'view', 'edit', 'embed' ),
     1298                'readonly'    => true,
     1299                'properties'  => $avatar_properties,
    12871300            );
    12881301        }
     
    13061319
    13071320        $query_params['after'] = array(
    1308             'description'       => __( 'Limit response to comments published after a given ISO8601 compliant date.' ),
    1309             'type'              => 'string',
    1310             'format'            => 'date-time',
     1321            'description' => __( 'Limit response to comments published after a given ISO8601 compliant date.' ),
     1322            'type'        => 'string',
     1323            'format'      => 'date-time',
    13111324        );
    13121325
    13131326        $query_params['author'] = array(
    1314             'description'       => __( 'Limit result set to comments assigned to specific user IDs. Requires authorization.' ),
    1315             'type'              => 'array',
    1316             'items'             => array(
    1317                 'type'          => 'integer',
     1327            'description' => __( 'Limit result set to comments assigned to specific user IDs. Requires authorization.' ),
     1328            'type'        => 'array',
     1329            'items'       => array(
     1330                'type' => 'integer',
    13181331            ),
    13191332        );
    13201333
    13211334        $query_params['author_exclude'] = array(
    1322             'description'       => __( 'Ensure result set excludes comments assigned to specific user IDs. Requires authorization.' ),
    1323             'type'              => 'array',
    1324             'items'             => array(
    1325                 'type'          => 'integer',
     1335            'description' => __( 'Ensure result set excludes comments assigned to specific user IDs. Requires authorization.' ),
     1336            'type'        => 'array',
     1337            'items'       => array(
     1338                'type' => 'integer',
    13261339            ),
    13271340        );
    13281341
    13291342        $query_params['author_email'] = array(
    1330             'default'           => null,
    1331             'description'       => __( 'Limit result set to that from a specific author email. Requires authorization.' ),
    1332             'format'            => 'email',
    1333             'type'              => 'string',
     1343            'default'     => null,
     1344            'description' => __( 'Limit result set to that from a specific author email. Requires authorization.' ),
     1345            'format'      => 'email',
     1346            'type'        => 'string',
    13341347        );
    13351348
    13361349        $query_params['before'] = array(
    1337             'description'       => __( 'Limit response to comments published before a given ISO8601 compliant date.' ),
    1338             'type'              => 'string',
    1339             'format'            => 'date-time',
     1350            'description' => __( 'Limit response to comments published before a given ISO8601 compliant date.' ),
     1351            'type'        => 'string',
     1352            'format'      => 'date-time',
    13401353        );
    13411354
    13421355        $query_params['exclude'] = array(
    1343             'description'        => __( 'Ensure result set excludes specific IDs.' ),
    1344             'type'               => 'array',
    1345             'items'              => array(
    1346                 'type'           => 'integer',
     1356            'description' => __( 'Ensure result set excludes specific IDs.' ),
     1357            'type'        => 'array',
     1358            'items'       => array(
     1359                'type' => 'integer',
    13471360            ),
    1348             'default'            => array(),
     1361            'default'     => array(),
    13491362        );
    13501363
    13511364        $query_params['include'] = array(
    1352             'description'        => __( 'Limit result set to specific IDs.' ),
    1353             'type'               => 'array',
    1354             'items'              => array(
    1355                 'type'           => 'integer',
     1365            'description' => __( 'Limit result set to specific IDs.' ),
     1366            'type'        => 'array',
     1367            'items'       => array(
     1368                'type' => 'integer',
    13561369            ),
    1357             'default'            => array(),
     1370            'default'     => array(),
    13581371        );
    13591372
    13601373        $query_params['offset'] = array(
    1361             'description'        => __( 'Offset the result set by a specific number of items.' ),
    1362             'type'               => 'integer',
    1363         );
    1364 
    1365         $query_params['order']      = array(
    1366             'description'           => __( 'Order sort attribute ascending or descending.' ),
    1367             'type'                  => 'string',
    1368             'default'               => 'desc',
    1369             'enum'                  => array(
     1374            'description' => __( 'Offset the result set by a specific number of items.' ),
     1375            'type'        => 'integer',
     1376        );
     1377
     1378        $query_params['order'] = array(
     1379            'description' => __( 'Order sort attribute ascending or descending.' ),
     1380            'type'        => 'string',
     1381            'default'     => 'desc',
     1382            'enum'        => array(
    13701383                'asc',
    13711384                'desc',
     
    13731386        );
    13741387
    1375         $query_params['orderby']    = array(
    1376             'description'           => __( 'Sort collection by object attribute.' ),
    1377             'type'                  => 'string',
    1378             'default'               => 'date_gmt',
    1379             'enum'                  => array(
     1388        $query_params['orderby'] = array(
     1389            'description' => __( 'Sort collection by object attribute.' ),
     1390            'type'        => 'string',
     1391            'default'     => 'date_gmt',
     1392            'enum'        => array(
    13801393                'date',
    13811394                'date_gmt',
     
    13891402
    13901403        $query_params['parent'] = array(
    1391             'default'           => array(),
    1392             'description'       => __( 'Limit result set to comments of specific parent IDs.' ),
    1393             'type'              => 'array',
    1394             'items'             => array(
    1395                 'type'          => 'integer',
     1404            'default'     => array(),
     1405            'description' => __( 'Limit result set to comments of specific parent IDs.' ),
     1406            'type'        => 'array',
     1407            'items'       => array(
     1408                'type' => 'integer',
    13961409            ),
    13971410        );
    13981411
    13991412        $query_params['parent_exclude'] = array(
    1400             'default'           => array(),
    1401             'description'       => __( 'Ensure result set excludes specific parent IDs.' ),
    1402             'type'              => 'array',
    1403             'items'             => array(
    1404                 'type'          => 'integer',
     1413            'default'     => array(),
     1414            'description' => __( 'Ensure result set excludes specific parent IDs.' ),
     1415            'type'        => 'array',
     1416            'items'       => array(
     1417                'type' => 'integer',
    14051418            ),
    14061419        );
    14071420
    1408         $query_params['post']   = array(
    1409             'default'           => array(),
    1410             'description'       => __( 'Limit result set to comments assigned to specific post IDs.' ),
    1411             'type'              => 'array',
    1412             'items'             => array(
    1413                 'type'          => 'integer',
     1421        $query_params['post'] = array(
     1422            'default'     => array(),
     1423            'description' => __( 'Limit result set to comments assigned to specific post IDs.' ),
     1424            'type'        => 'array',
     1425            'items'       => array(
     1426                'type' => 'integer',
    14141427            ),
    14151428        );
     
    14671480
    14681481        switch ( $new_status ) {
    1469             case 'approved' :
     1482            case 'approved':
    14701483            case 'approve':
    14711484            case '1':
     
    14761489                $changed = wp_set_comment_status( $comment_id, 'hold' );
    14771490                break;
    1478             case 'spam' :
     1491            case 'spam':
    14791492                $changed = wp_spam_comment( $comment_id );
    14801493                break;
    1481             case 'unspam' :
     1494            case 'unspam':
    14821495                $changed = wp_unspam_comment( $comment_id );
    14831496                break;
    1484             case 'trash' :
     1497            case 'trash':
    14851498                $changed = wp_trash_comment( $comment_id );
    14861499                break;
    1487             case 'untrash' :
     1500            case 'untrash':
    14881501                $changed = wp_untrash_comment( $comment_id );
    14891502                break;
    1490             default :
     1503            default:
    14911504                $changed = false;
    14921505                break;
     
    15091522    protected function check_read_post_permission( $post, $request ) {
    15101523        $posts_controller = new WP_REST_Posts_Controller( $post->post_type );
    1511         $post_type = get_post_type_object( $post->post_type );
     1524        $post_type        = get_post_type_object( $post->post_type );
    15121525
    15131526        $has_password_filter = false;
    15141527
    15151528        // Only check password if a specific post was queried for or a single comment
    1516         $requested_post = ! empty( $request['post'] ) && ( !is_array( $request['post'] ) || 1 === count( $request['post'] ) );
     1529        $requested_post    = ! empty( $request['post'] ) && ( ! is_array( $request['post'] ) || 1 === count( $request['post'] ) );
    15171530        $requested_comment = ! empty( $request['id'] );
    15181531        if ( ( $requested_post || $requested_comment ) && $posts_controller->can_access_password_content( $post, $request ) ) {
Note: See TracChangeset for help on using the changeset viewer.