Make WordPress Core

Ticket #38710: 38710.diff

File 38710.diff, 3.0 KB (added by jnylen0, 7 years ago)

Add collection parameters filters for comments, terms, users

  • 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 2b7057c..4345b12 100644
    a b class WP_REST_Comments_Controller extends WP_REST_Controller { 
    13901390                        'validate_callback' => 'rest_validate_request_arg',
    13911391                );
    13921392
    1393                 return $query_params;
     1393                /**
     1394                 * Filter collection parameters for the comments controller.
     1395                 *
     1396                 * This filter registers the collection parameter, but does not map the
     1397                 * collection parameter to an internal WP_Comment_Query parameter. Use the
     1398                 * `rest_comment_query` filter to set WP_Comment_Query parameters.
     1399                 *
     1400                 * @since 4.7.0
     1401                 *
     1402                 * @param $params JSON Schema-formatted collection parameters.
     1403                 */
     1404                return apply_filters( 'rest_comment_collection_params', $query_params );
    13941405        }
    13951406
    13961407        /**
  • 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 cfe3f6d..5a7e544 100644
    a b class WP_REST_Terms_Controller extends WP_REST_Controller { 
    962962                        'type'              => 'string',
    963963                );
    964964
    965                 return $query_params;
     965                /**
     966                 * Filter collection parameters for the terms controller.
     967                 *
     968                 * The dynamic part of the filter `$this->taxonomy` refers to the taxonomy
     969                 * slug for the controller.
     970                 *
     971                 * This filter registers the collection parameter, but does not map the
     972                 * collection parameter to an internal WP_Term_Query parameter.  Use the
     973                 * `rest_{$this->taxonomy}_query` filter to set WP_Term_Query parameters.
     974                 *
     975                 * @since 4.7.0
     976                 *
     977                 * @param $params JSON Schema-formatted collection parameters.
     978                 * @param WP_Taxonomy $taxonomy_obj Taxonomy object.
     979                 */
     980                return apply_filters( 'rest_{$this->taxonomy}_collection_params', $query_params, $taxonomy );
    966981        }
    967982
    968983        /**
  • 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 9fece46..9b43425 100644
    a b class WP_REST_Users_Controller extends WP_REST_Controller { 
    12281228                        ),
    12291229                );
    12301230
    1231                 return $query_params;
     1231                /**
     1232                 * Filter collection parameters for the users controller.
     1233                 *
     1234                 * This filter registers the collection parameter, but does not map the
     1235                 * collection parameter to an internal WP_User_Query parameter.  Use the
     1236                 * `rest_user_query` filter to set WP_User_Query arguments.
     1237                 *
     1238                 * @since 4.7.0
     1239                 *
     1240                 * @param $params JSON Schema-formatted collection parameters.
     1241                 */
     1242                return apply_filters( 'rest_user_collection_params', $query_params );
    12321243        }
    12331244}