Make WordPress Core


Ignore:
Timestamp:
11/03/2016 02:17:39 AM (10 years ago)
Author:
rachelbaker
Message:

REST API: Clean-up our validation callbacks and add missing array items properties in our endpoint schemas.

Props joehoyle, jnylen0.
Fixes #38617.

File:
1 edited

Legend:

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

    r39101 r39105  
    11151115                                        'format'       => 'ipv4',
    11161116                                        'context'      => array( 'edit' ),
    1117                                         'arg_options'  => array(
    1118                                                 'default'           => '127.0.0.1',
    1119                                         ),
     1117                                        'default'      => '127.0.0.1',
    11201118                                ),
    11211119                                'author_name'     => array(
    … …  
    11891187                                        'type'         => 'integer',
    11901188                                        'context'      => array( 'view', 'edit', 'embed' ),
    1191                                         'arg_options'  => array(
    1192                                                 'default'           => 0,
    1193                                         ),
     1189                                        'default'      => 0,
    11941190                                ),
    11951191                                'post'             => array(
    … …  
    11971193                                        'type'         => 'integer',
    11981194                                        'context'      => array( 'view', 'edit' ),
    1199                                         'arg_options'  => array(
    1200                                                 'default'           => 0,
    1201                                         ),
     1195                                        'default'      => 0,
    12021196                                ),
    12031197                                'status'           => array(
    … …  
    12651259                        'type'              => 'string',
    12661260                        'format'            => 'date-time',
    1267                         'validate_callback' => 'rest_validate_request_arg',
    12681261                );
    12691262
    12701263                $query_params['author'] = array(
    12711264                        'description'       => __( 'Limit result set to comments assigned to specific user ids. Requires authorization.' ),
    1272                         'sanitize_callback' => 'wp_parse_id_list',
    12731265                        'type'              => 'array',
     1266                        'items'             => array(
     1267                                'type'          => 'integer',
     1268                        ),
    12741269                );
    12751270
    12761271                $query_params['author_exclude'] = array(
    12771272                        'description'       => __( 'Ensure result set excludes comments assigned to specific user ids. Requires authorization.' ),
    1278                         'sanitize_callback' => 'wp_parse_id_list',
    12791273                        'type'              => 'array',
     1274                        'items'             => array(
     1275                                'type'          => 'integer',
     1276                        ),
    12801277                );
    12811278
    … …  
    12841281                        'description'       => __( 'Limit result set to that from a specific author email. Requires authorization.' ),
    12851282                        'format'            => 'email',
    1286                         'sanitize_callback' => 'sanitize_email',
    12871283                        'type'              => 'string',
    12881284                );
    … …  
    12921288                        'type'              => 'string',
    12931289                        'format'            => 'date-time',
    1294                         'validate_callback' => 'rest_validate_request_arg',
    12951290                );
    12961291
    … …  
    12981293                        'description'        => __( 'Ensure result set excludes specific ids.' ),
    12991294                        'type'               => 'array',
     1295                        'items'              => array(
     1296                                'type'           => 'integer',
     1297                        ),
    13001298                        'default'            => array(),
    1301                         'sanitize_callback'  => 'wp_parse_id_list',
    13021299                );
    13031300
    … …  
    13051302                        'description'        => __( 'Limit result set to specific ids.' ),
    13061303                        'type'               => 'array',
     1304                        'items'              => array(
     1305                                'type'           => 'integer',
     1306                        ),
    13071307                        'default'            => array(),
    1308                         'sanitize_callback'  => 'wp_parse_id_list',
    13091308                );
    13101309
    … …  
    13121311                        'default'           => null,
    13131312                        'description'       => __( 'Limit result set to that of a particular comment karma. Requires authorization.' ),
    1314                         'sanitize_callback' => 'absint',
    13151313                        'type'              => 'integer',
    1316                         'validate_callback'  => 'rest_validate_request_arg',
    13171314                );
    13181315
    … …  
    13201317                        'description'        => __( 'Offset the result set by a specific number of comments.' ),
    13211318                        'type'               => 'integer',
    1322                         'sanitize_callback'  => 'absint',
    1323                         'validate_callback'  => 'rest_validate_request_arg',
    13241319                );
    13251320
    … …  
    13271322                        'description'           => __( 'Order sort attribute ascending or descending.' ),
    13281323                        'type'                  => 'string',
    1329                         'sanitize_callback'     => 'sanitize_key',
    1330                         'validate_callback'     => 'rest_validate_request_arg',
    13311324                        'default'               => 'desc',
    13321325                        'enum'                  => array(
    … …  
    13391332                        'description'           => __( 'Sort collection by object attribute.' ),
    13401333                        'type'                  => 'string',
    1341                         'sanitize_callback'     => 'sanitize_key',
    1342                         'validate_callback'     => 'rest_validate_request_arg',
    13431334                        'default'               => 'date_gmt',
    13441335                        'enum'                  => array(
    … …  
    13561347                        'default'           => array(),
    13571348                        'description'       => __( 'Limit result set to resources of specific parent ids.' ),
    1358                         'sanitize_callback' => 'wp_parse_id_list',
    13591349                        'type'              => 'array',
     1350                        'items'             => array(
     1351                                'type'          => 'integer',
     1352                        ),
    13601353                );
    13611354
    … …  
    13631356                        'default'           => array(),
    13641357                        'description'       => __( 'Ensure result set excludes specific parent ids.' ),
    1365                         'sanitize_callback' => 'wp_parse_id_list',
    13661358                        'type'              => 'array',
     1359                        'items'             => array(
     1360                                'type'          => 'integer',
     1361                        ),
    13671362                );
    13681363
    … …  
    13711366                        'description'       => __( 'Limit result set to resources assigned to specific post ids.' ),
    13721367                        'type'              => 'array',
    1373                         'sanitize_callback' => 'wp_parse_id_list',
     1368                        'items'             => array(
     1369                                'type'          => 'integer',
     1370                        ),
    13741371                );
    13751372
Note: See TracChangeset for help on using the changeset viewer.