Changeset 49923
- Timestamp:
- 01/03/2021 02:37:23 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
r49790 r49923 263 263 } 264 264 265 // Force the post_type argument, since it's not a user input variable.266 $args['post_type'] = $this->post_type;267 268 /**269 * Filters WP_Query arguments when querying users via the REST API.270 *271 * The dynamic portion of the hook name, `$this->post_type`, refers to the post type slug.272 *273 * Possible filter names include:274 *275 * - `rest_post_query`276 * - `rest_page_query`277 * - `rest_attachment_query`278 *279 * Enables adding extra arguments or setting defaults for a post collection request.280 *281 * @since 4.7.0282 *283 * @link https://developer.wordpress.org/reference/classes/wp_query/284 *285 * @param array $args Array of arguments to be passed to WP_Query.286 * @param WP_REST_Request $request The REST API request.287 */288 $args = apply_filters( "rest_{$this->post_type}_query", $args, $request );289 $query_args = $this->prepare_items_query( $args, $request );290 291 265 $taxonomies = wp_list_filter( get_object_taxonomies( $this->post_type, 'objects' ), array( 'show_in_rest' => true ) ); 292 266 293 267 if ( ! empty( $request['tax_relation'] ) ) { 294 $ query_args['tax_query'] = array( 'relation' => $request['tax_relation'] );268 $args['tax_query'] = array( 'relation' => $request['tax_relation'] ); 295 269 } 296 270 … … 300 274 301 275 if ( ! empty( $request[ $base ] ) ) { 302 $ query_args['tax_query'][] = array(276 $args['tax_query'][] = array( 303 277 'taxonomy' => $taxonomy->name, 304 278 'field' => 'term_id', … … 309 283 310 284 if ( ! empty( $request[ $tax_exclude ] ) ) { 311 $ query_args['tax_query'][] = array(285 $args['tax_query'][] = array( 312 286 'taxonomy' => $taxonomy->name, 313 287 'field' => 'term_id', … … 318 292 } 319 293 } 294 295 // Force the post_type argument, since it's not a user input variable. 296 $args['post_type'] = $this->post_type; 297 298 /** 299 * Filters WP_Query arguments when querying users via the REST API. 300 * 301 * The dynamic portion of the hook name, `$this->post_type`, refers to the post type slug. 302 * 303 * Possible filter names include: 304 * 305 * - `rest_post_query` 306 * - `rest_page_query` 307 * - `rest_attachment_query` 308 * 309 * Enables adding extra arguments or setting defaults for a post collection request. 310 * 311 * @since 4.7.0 312 * @since 5.7.0 Moved after the `tax_query` query arg is generated. 313 * 314 * @link https://developer.wordpress.org/reference/classes/wp_query/ 315 * 316 * @param array $args Array of arguments to be passed to WP_Query. 317 * @param WP_REST_Request $request The REST API request. 318 */ 319 $args = apply_filters( "rest_{$this->post_type}_query", $args, $request ); 320 $query_args = $this->prepare_items_query( $args, $request ); 320 321 321 322 $posts_query = new WP_Query();
Note: See TracChangeset
for help on using the changeset viewer.