Make WordPress Core


Ignore:
Timestamp:
11/14/2016 04:41:40 PM (8 years ago)
Author:
joehoyle
Message:

REST API: Make all collection params filterable.

For developers wanting to add their own registered collection parameters, they can now use the rest_$type_collection_params filter. This brings consistency with the already existing rest_$post_type_collection_params.

Fixes #38710.
Props jnylen0.

File:
1 edited

Legend:

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

    r39192 r39223  
    960960        );
    961961
    962         return $query_params;
     962        /**
     963         * Filter collection parameters for the terms controller.
     964         *
     965         * The dynamic part of the filter `$this->taxonomy` refers to the taxonomy
     966         * slug for the controller.
     967         *
     968         * This filter registers the collection parameter, but does not map the
     969         * collection parameter to an internal WP_Term_Query parameter.  Use the
     970         * `rest_{$this->taxonomy}_query` filter to set WP_Term_Query parameters.
     971         *
     972         * @since 4.7.0
     973         *
     974         * @param $params JSON Schema-formatted collection parameters.
     975         * @param WP_Taxonomy $taxonomy_obj Taxonomy object.
     976         */
     977        return apply_filters( 'rest_{$this->taxonomy}_collection_params', $query_params, $taxonomy );
    963978    }
    964979
Note: See TracChangeset for help on using the changeset viewer.