Make WordPress Core

Ticket #39300: 39300.3.diff

File 39300.3.diff, 9.5 KB (added by jnylen0, 9 years ago)

Also update the docblocks for the other 3 similar filters

  • src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php

    diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php
    index bd0c920..a3438c5 100644
    a b class WP_REST_Comments_Controller extends WP_REST_Controller { 
    14371437                 *
    14381438                 * @since 4.7.0
    14391439                 *
    1440                  * @param $params JSON Schema-formatted collection parameters.
     1440                 * @param array $query_params JSON Schema-formatted collection parameters.
    14411441                 */
    14421442                return apply_filters( 'rest_comment_collection_params', $query_params );
    14431443        }
  • src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php

    diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
    index 4c49504..c037ae2 100644
    a b class WP_REST_Posts_Controller extends WP_REST_Controller { 
    19851985         * @return array Collection parameters.
    19861986         */
    19871987        public function get_collection_params() {
    1988                 $params = parent::get_collection_params();
     1988                $query_params = parent::get_collection_params();
    19891989
    1990                 $params['context']['default'] = 'view';
     1990                $query_params['context']['default'] = 'view';
    19911991
    1992                 $params['after'] = array(
     1992                $query_params['after'] = array(
    19931993                        'description'        => __( 'Limit response to posts published after a given ISO8601 compliant date.' ),
    19941994                        'type'               => 'string',
    19951995                        'format'             => 'date-time',
    19961996                );
    19971997
    19981998                if ( post_type_supports( $this->post_type, 'author' ) ) {
    1999                         $params['author'] = array(
     1999                        $query_params['author'] = array(
    20002000                                'description'         => __( 'Limit result set to posts assigned to specific authors.' ),
    20012001                                'type'                => 'array',
    20022002                                'items'               => array(
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    20042004                                ),
    20052005                                'default'             => array(),
    20062006                        );
    2007                         $params['author_exclude'] = array(
     2007                        $query_params['author_exclude'] = array(
    20082008                                'description'         => __( 'Ensure result set excludes posts assigned to specific authors.' ),
    20092009                                'type'                => 'array',
    20102010                                'items'               => array(
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    20142014                        );
    20152015                }
    20162016
    2017                 $params['before'] = array(
     2017                $query_params['before'] = array(
    20182018                        'description'        => __( 'Limit response to posts published before a given ISO8601 compliant date.' ),
    20192019                        'type'               => 'string',
    20202020                        'format'             => 'date-time',
    20212021                );
    20222022
    2023                 $params['exclude'] = array(
     2023                $query_params['exclude'] = array(
    20242024                        'description'        => __( 'Ensure result set excludes specific IDs.' ),
    20252025                        'type'               => 'array',
    20262026                        'items'              => array(
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    20292029                        'default'            => array(),
    20302030                );
    20312031
    2032                 $params['include'] = array(
     2032                $query_params['include'] = array(
    20332033                        'description'        => __( 'Limit result set to specific IDs.' ),
    20342034                        'type'               => 'array',
    20352035                        'items'              => array(
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    20392039                );
    20402040
    20412041                if ( 'page' === $this->post_type || post_type_supports( $this->post_type, 'page-attributes' ) ) {
    2042                         $params['menu_order'] = array(
     2042                        $query_params['menu_order'] = array(
    20432043                                'description'        => __( 'Limit result set to posts with a specific menu_order value.' ),
    20442044                                'type'               => 'integer',
    20452045                        );
    20462046                }
    20472047
    2048                 $params['offset'] = array(
     2048                $query_params['offset'] = array(
    20492049                        'description'        => __( 'Offset the result set by a specific number of items.' ),
    20502050                        'type'               => 'integer',
    20512051                );
    20522052
    2053                 $params['order'] = array(
     2053                $query_params['order'] = array(
    20542054                        'description'        => __( 'Order sort attribute ascending or descending.' ),
    20552055                        'type'               => 'string',
    20562056                        'default'            => 'desc',
    20572057                        'enum'               => array( 'asc', 'desc' ),
    20582058                );
    20592059
    2060                 $params['orderby'] = array(
     2060                $query_params['orderby'] = array(
    20612061                        'description'        => __( 'Sort collection by object attribute.' ),
    20622062                        'type'               => 'string',
    20632063                        'default'            => 'date',
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    20722072                );
    20732073
    20742074                if ( 'page' === $this->post_type || post_type_supports( $this->post_type, 'page-attributes' ) ) {
    2075                         $params['orderby']['enum'][] = 'menu_order';
     2075                        $query_params['orderby']['enum'][] = 'menu_order';
    20762076                }
    20772077
    2078                 $post_type_obj = get_post_type_object( $this->post_type );
     2078                $post_type = get_post_type_object( $this->post_type );
    20792079
    2080                 if ( $post_type_obj->hierarchical || 'attachment' === $this->post_type ) {
    2081                         $params['parent'] = array(
     2080                if ( $post_type->hierarchical || 'attachment' === $this->post_type ) {
     2081                        $query_params['parent'] = array(
    20822082                                'description'       => __( 'Limit result set to those of particular parent IDs.' ),
    20832083                                'type'              => 'array',
    20842084                                'items'             => array(
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    20862086                                ),
    20872087                                'default'           => array(),
    20882088                        );
    2089                         $params['parent_exclude'] = array(
     2089                        $query_params['parent_exclude'] = array(
    20902090                                'description'       => __( 'Limit result set to all items except those of a particular parent ID.' ),
    20912091                                'type'              => 'array',
    20922092                                'items'             => array(
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    20962096                        );
    20972097                }
    20982098
    2099                 $params['slug'] = array(
     2099                $query_params['slug'] = array(
    21002100                        'description'       => __( 'Limit result set to posts with one or more specific slugs.' ),
    21012101                        'type'              => 'array',
    21022102                        'items'             => array(
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    21052105                        'sanitize_callback' => 'wp_parse_slug_list',
    21062106                );
    21072107
    2108                 $params['status'] = array(
     2108                $query_params['status'] = array(
    21092109                        'default'           => 'publish',
    21102110                        'description'       => __( 'Limit result set to posts assigned one or more statuses.' ),
    21112111                        'type'              => 'array',
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    21212121                foreach ( $taxonomies as $taxonomy ) {
    21222122                        $base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name;
    21232123
    2124                         $params[ $base ] = array(
     2124                        $query_params[ $base ] = array(
    21252125                                /* translators: %s: taxonomy name */
    21262126                                'description'       => sprintf( __( 'Limit result set to all items that have the specified term assigned in the %s taxonomy.' ), $base ),
    21272127                                'type'              => 'array',
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    21312131                                'default'           => array(),
    21322132                        );
    21332133
    2134                         $params[ $base . '_exclude' ] = array(
     2134                        $query_params[ $base . '_exclude' ] = array(
    21352135                                /* translators: %s: taxonomy name */
    21362136                                'description' => sprintf( __( 'Limit result set to all items except those that have the specified term assigned in the %s taxonomy.' ), $base ),
    21372137                                'type'        => 'array',
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    21432143                }
    21442144
    21452145                if ( 'post' === $this->post_type ) {
    2146                         $params['sticky'] = array(
     2146                        $query_params['sticky'] = array(
    21472147                                'description'       => __( 'Limit result set to items that are sticky.' ),
    21482148                                'type'              => 'boolean',
    21492149                        );
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    21612161                 *
    21622162                 * @since 4.7.0
    21632163                 *
    2164                  * @param $params JSON Schema-formatted collection parameters.
    2165                  * @param WP_Post_Type $post_type_obj Post type object.
     2164                 * @param array        $query_params JSON Schema-formatted collection parameters.
     2165                 * @param WP_Post_Type $post_type    Post type object.
    21662166                 */
    2167                 return apply_filters( "rest_{$this->post_type}_collection_params", $params, $post_type_obj );
     2167                return apply_filters( "rest_{$this->post_type}_collection_params", $query_params, $post_type );
    21682168        }
    21692169
    21702170        /**
  • src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php

    diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php
    index 6ca86ca..b8a1390 100644
    a b class WP_REST_Terms_Controller extends WP_REST_Controller { 
    971971                 *
    972972                 * @since 4.7.0
    973973                 *
    974                  * @param $params JSON Schema-formatted collection parameters.
    975                  * @param WP_Taxonomy $taxonomy_obj Taxonomy object.
     974                 * @param array       $query_params JSON Schema-formatted collection parameters.
     975                 * @param WP_Taxonomy $taxonomy    Taxonomy object.
    976976                 */
    977                 return apply_filters( 'rest_{$this->taxonomy}_collection_params', $query_params, $taxonomy );
     977                return apply_filters( "rest_{$this->taxonomy}_collection_params", $query_params, $taxonomy );
    978978        }
    979979
    980980        /**
  • src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php

    diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php
    index 01542a9..3179ef3 100644
    a b class WP_REST_Users_Controller extends WP_REST_Controller { 
    13511351                 *
    13521352                 * @since 4.7.0
    13531353                 *
    1354                  * @param $params JSON Schema-formatted collection parameters.
     1354                 * @param array $query_params JSON Schema-formatted collection parameters.
    13551355                 */
    13561356                return apply_filters( 'rest_user_collection_params', $query_params );
    13571357        }