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 a0d395e..31f3025 100644
a
|
b
|
class WP_REST_Posts_Controller extends WP_REST_Controller { |
274 | 274 | $tax_exclude = $base . '_exclude'; |
275 | 275 | |
276 | 276 | if ( ! empty( $request[ $base ] ) ) { |
| 277 | if ( isset( $request[ $base ]['ids'] ) ) { |
| 278 | $terms = absint($request[ $base ]['ids']); |
| 279 | } else { |
| 280 | $terms = $request[ $base ]; |
| 281 | } |
| 282 | |
| 283 | if ( isset( $request[ $base ]['include_children'] ) ) { |
| 284 | $include_children = (bool) $request[ $base ]['include_children']; |
| 285 | } else { |
| 286 | $include_children = false; |
| 287 | } |
| 288 | |
277 | 289 | $query_args['tax_query'][] = array( |
278 | 290 | 'taxonomy' => $taxonomy->name, |
279 | 291 | 'field' => 'term_id', |
280 | | 'terms' => $request[ $base ], |
281 | | 'include_children' => false, |
| 292 | 'terms' => $terms, |
| 293 | 'include_children' => $include_children, |
282 | 294 | ); |
283 | 295 | } |
284 | 296 | |
… |
… |
class WP_REST_Posts_Controller extends WP_REST_Controller { |
2192 | 2204 | $query_params[ $base ] = array( |
2193 | 2205 | /* translators: %s: taxonomy name */ |
2194 | 2206 | 'description' => sprintf( __( 'Limit result set to all items that have the specified term assigned in the %s taxonomy.' ), $base ), |
2195 | | 'type' => 'array', |
2196 | | 'items' => array( |
2197 | | 'type' => 'integer', |
| 2207 | 'type' => 'object', |
| 2208 | 'properties' => array( |
| 2209 | 'ids' => array( |
| 2210 | 'description' => __( 'The term ids to limit the post to' ), |
| 2211 | 'type' => 'array', |
| 2212 | 'items' => array( |
| 2213 | 'type' => 'integer' |
| 2214 | ), |
| 2215 | 'default' => array() |
| 2216 | ), |
| 2217 | 'include_children' => array( |
| 2218 | 'description' => __( 'Whether or not to include the term children' ), |
| 2219 | 'type' => 'boolean', |
| 2220 | 'default' => false |
| 2221 | ) |
2198 | 2222 | ), |
2199 | 2223 | 'default' => array(), |
2200 | 2224 | ); |
diff --git a/tests/phpunit/tests/rest-api/rest-posts-controller.php b/tests/phpunit/tests/rest-api/rest-posts-controller.php
index de9b0db..c8dacc0 100644
a
|
b
|
class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te |
678 | 678 | $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); |
679 | 679 | } |
680 | 680 | |
| 681 | /** |
| 682 | * @ticket 39494 |
| 683 | */ |
| 684 | public function test_get_items_categories_with_updated_taxonomy_schema() { |
| 685 | $id1 = self::$post_id; |
| 686 | $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) ); |
| 687 | $id3 = $this->factory->post->create( array( 'post_status' => 'publish' ) ); |
| 688 | $cat1 = wp_insert_term( 'My Category', 'category' ); |
| 689 | $cat2 = wp_insert_term( 'Child Category', 'category', array( 'parent' => $cat1['term_id'] ) ); |
| 690 | |
| 691 | wp_set_object_terms( $id1, array( $cat2['term_id'] ), 'category' ); |
| 692 | $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); |
| 693 | $request->set_param( 'categories', array( |
| 694 | 'ids' => array( $cat1['term_id'] ), |
| 695 | 'include_children' => true |
| 696 | ) ); |
| 697 | |
| 698 | $response = $this->server->dispatch( $request ); |
| 699 | $data = $response->get_data(); |
| 700 | $this->assertCount( 1, $data ); |
| 701 | $this->assertEquals( $id1, $data[0]['id'] ); |
| 702 | } |
| 703 | |
681 | 704 | public function test_get_items_sticky() { |
682 | 705 | $id1 = self::$post_id; |
683 | 706 | $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) ); |