Make WordPress Core


Ignore:
Timestamp:
11/03/2016 02:17:39 AM (8 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-posts-controller.php

    r39104 r39105  
    19761976                    'type'    => 'integer',
    19771977                ),
    1978                 'arg_options' => array(
    1979                     'sanitize_callback' => 'wp_parse_id_list',
    1980                 ),
    1981                 'context'     => array( 'view', 'edit' ),
    1982             );
    1983             $schema['properties'][ $base . '_exclude' ] = array(
    1984                 'description' => sprintf( __( 'The terms in the %s taxonomy that should not be assigned to the object.' ), $taxonomy->name ),
    1985                 'type'        => 'array',
    1986                 'items'       => array(
    1987                     'type'    => 'integer',
    1988                 ),
    1989                 'arg_options' => array(
    1990                     'sanitize_callback' => 'wp_parse_id_list',
    1991                 ),
    19921978                'context'     => array( 'view', 'edit' ),
    19931979            );
     
    20142000            'type'               => 'string',
    20152001            'format'             => 'date-time',
    2016             'validate_callback'  => 'rest_validate_request_arg',
    20172002        );
    20182003
     
    20212006                'description'         => __( 'Limit result set to posts assigned to specific authors.' ),
    20222007                'type'                => 'array',
     2008                'items'               => array(
     2009                    'type'            => 'integer',
     2010                ),
    20232011                'default'             => array(),
    2024                 'sanitize_callback'   => 'wp_parse_id_list',
    20252012            );
    20262013            $params['author_exclude'] = array(
    20272014                'description'         => __( 'Ensure result set excludes posts assigned to specific authors.' ),
    20282015                'type'                => 'array',
     2016                'items'               => array(
     2017                    'type'            => 'integer',
     2018                ),
    20292019                'default'             => array(),
    2030                 'sanitize_callback'   => 'wp_parse_id_list',
    20312020            );
    20322021        }
     
    20362025            'type'               => 'string',
    20372026            'format'             => 'date-time',
    2038             'validate_callback'  => 'rest_validate_request_arg',
    20392027        );
    20402028
     
    20422030            'description'        => __( 'Ensure result set excludes specific ids.' ),
    20432031            'type'               => 'array',
     2032            'items'              => array(
     2033                'type'           => 'integer',
     2034            ),
    20442035            'default'            => array(),
    2045             'sanitize_callback'  => 'wp_parse_id_list',
    20462036        );
    20472037
     
    20492039            'description'        => __( 'Limit result set to specific ids.' ),
    20502040            'type'               => 'array',
     2041            'items'              => array(
     2042                'type'           => 'integer',
     2043            ),
    20512044            'default'            => array(),
    2052             'sanitize_callback'  => 'wp_parse_id_list',
    20532045        );
    20542046
     
    20572049                'description'        => __( 'Limit result set to resources with a specific menu_order value.' ),
    20582050                'type'               => 'integer',
    2059                 'sanitize_callback'  => 'absint',
    2060                 'validate_callback'  => 'rest_validate_request_arg',
    20612051            );
    20622052        }
     
    20652055            'description'        => __( 'Offset the result set by a specific number of items.' ),
    20662056            'type'               => 'integer',
    2067             'sanitize_callback'  => 'absint',
    2068             'validate_callback'  => 'rest_validate_request_arg',
    20692057        );
    20702058
     
    20742062            'default'            => 'desc',
    20752063            'enum'               => array( 'asc', 'desc' ),
    2076             'validate_callback'  => 'rest_validate_request_arg',
    20772064        );
    20782065
     
    20892076                'slug',
    20902077            ),
    2091             'validate_callback'  => 'rest_validate_request_arg',
    20922078        );
    20932079
     
    21022088                'description'       => __( 'Limit result set to those of particular parent ids.' ),
    21032089                'type'              => 'array',
    2104                 'sanitize_callback' => 'wp_parse_id_list',
     2090                'items'             => array(
     2091                    'type'          => 'integer',
     2092                ),
    21052093                'default'           => array(),
    21062094            );
     
    21082096                'description'       => __( 'Limit result set to all items except those of a particular parent id.' ),
    21092097                'type'              => 'array',
    2110                 'sanitize_callback' => 'wp_parse_id_list',
     2098                'items'             => array(
     2099                    'type'          => 'integer',
     2100                ),
    21112101                'default'           => array(),
    21122102            );
     
    21382128                'description'       => sprintf( __( 'Limit result set to all items that have the specified term assigned in the %s taxonomy.' ), $base ),
    21392129                'type'              => 'array',
    2140                 'sanitize_callback' => 'wp_parse_id_list',
     2130                'items'             => array(
     2131                    'type'          => 'integer',
     2132                ),
     2133                'default'           => array(),
     2134            );
     2135
     2136            $params[ $base . '_exclude' ] = array(
     2137                'description' => sprintf( __( 'Limit result set to all items except those that have the specified term assigned in the %s taxonomy.' ), $base ),
     2138                'type'        => 'array',
     2139                'items'       => array(
     2140                    'type'    => 'integer',
     2141                ),
    21412142                'default'           => array(),
    21422143            );
     
    21472148                'description'       => __( 'Limit result set to items that are sticky.' ),
    21482149                'type'              => 'boolean',
    2149                 'sanitize_callback' => 'rest_parse_request_arg',
    21502150            );
    21512151        }
Note: See TracChangeset for help on using the changeset viewer.