diff --git src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php
index 9d33eaa475..e3614d878d 100644
|
|
class WP_REST_Terms_Controller extends WP_REST_Controller { |
182 | 182 | 'per_page' => 'number', |
183 | 183 | 'search' => 'search', |
184 | 184 | 'slug' => 'slug', |
| 185 | 'slugs' => 'slug', |
185 | 186 | ); |
186 | 187 | |
187 | 188 | $prepared_args = array(); |
… |
… |
class WP_REST_Terms_Controller extends WP_REST_Controller { |
981 | 982 | 'type' => 'string', |
982 | 983 | ); |
983 | 984 | |
| 985 | $query_params['slugs'] = array( |
| 986 | 'description' => __( 'Limit result set to terms with a specific slug.' ), |
| 987 | 'type' => 'array', |
| 988 | 'items' => array( |
| 989 | 'type' => 'string' |
| 990 | ), |
| 991 | ); |
| 992 | |
984 | 993 | /** |
985 | 994 | * Filter collection parameters for the terms controller. |
986 | 995 | * |
diff --git tests/phpunit/tests/rest-api/rest-categories-controller.php tests/phpunit/tests/rest-api/rest-categories-controller.php
index fbf7d06018..931d7cfefe 100644
|
|
class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas |
69 | 69 | 'post', |
70 | 70 | 'search', |
71 | 71 | 'slug', |
| 72 | 'slugs', |
72 | 73 | ), $keys ); |
73 | 74 | } |
74 | 75 | |
… |
… |
class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas |
417 | 418 | $this->assertEquals( 'Apple', $data[0]['name'] ); |
418 | 419 | } |
419 | 420 | |
| 421 | public function test_get_items_slugs_arg() { |
| 422 | $this->factory->category->create( array( 'name' => 'Taco' ) ); |
| 423 | $this->factory->category->create( array( 'name' => 'Burrito' ) ); |
| 424 | $this->factory->category->create( array( 'name' => 'Enchilada' ) ); |
| 425 | $this->factory->category->create( array( 'name' => 'Pizza' ) ); |
| 426 | $this->factory->category->create( array( 'name' => 'Curry' ) ); |
| 427 | $request = new WP_REST_Request( 'GET', '/wp/v2/categories' ); |
| 428 | $request->set_param( 'slugs', array( |
| 429 | 'taco', |
| 430 | 'burrito', |
| 431 | 'enchilada', |
| 432 | ) ); |
| 433 | $response = $this->server->dispatch( $request ); |
| 434 | $this->assertEquals( 200, $response->get_status() ); |
| 435 | $data = $response->get_data(); |
| 436 | $this->assertEquals( 3, count( $data ) ); |
| 437 | $this->assertEquals( 'Burrito', $data[0]['name'] ); |
| 438 | $this->assertEquals( 'Enchilada', $data[1]['name'] ); |
| 439 | $this->assertEquals( 'Taco', $data[2]['name'] ); |
| 440 | } |
| 441 | |
420 | 442 | public function test_get_terms_parent_arg() { |
421 | 443 | $category1 = $this->factory->category->create( array( 'name' => 'Parent' ) ); |
422 | 444 | $this->factory->category->create( array( 'name' => 'Child', 'parent' => $category1 ) ); |
diff --git tests/phpunit/tests/rest-api/rest-tags-controller.php tests/phpunit/tests/rest-api/rest-tags-controller.php
index cb81b17159..b07e73ea92 100644
|
|
class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { |
82 | 82 | 'post', |
83 | 83 | 'search', |
84 | 84 | 'slug', |
| 85 | 'slugs', |
85 | 86 | ), $keys ); |
86 | 87 | } |
87 | 88 | |