diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php
index 6dc78cb6d0..4598b82e00 100644
|
a
|
b
|
class WP_REST_Taxonomies_Controller extends WP_REST_Controller { |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | if ( in_array( 'types', $fields, true ) ) { |
| 213 | | $data['types'] = $taxonomy->object_type; |
| | 213 | $data['types'] = array_values( $taxonomy->object_type ); |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | if ( in_array( 'show_cloud', $fields, true ) ) { |
diff --git a/tests/phpunit/tests/rest-api/rest-taxonomies-controller.php b/tests/phpunit/tests/rest-api/rest-taxonomies-controller.php
index 4fd4935fb8..148e1ae9de 100644
|
a
|
b
|
class WP_Test_REST_Taxonomies_Controller extends WP_Test_REST_Controller_Testcas |
| 195 | 195 | ); |
| 196 | 196 | } |
| 197 | 197 | |
| | 198 | public function test_object_types_is_an_array_if_object_type_is_unregistered() { |
| | 199 | |
| | 200 | register_taxonomy_for_object_type( 'category', 'page' ); |
| | 201 | register_taxonomy_for_object_type( 'category', 'attachment' ); |
| | 202 | unregister_taxonomy_for_object_type( 'category', 'page' ); |
| | 203 | |
| | 204 | $request = new WP_REST_Request( 'GET', '/wp/v2/taxonomies/category' ); |
| | 205 | $response = rest_get_server()->dispatch( $request ); |
| | 206 | |
| | 207 | $types = $response->get_data()['types']; |
| | 208 | $this->assertArrayHasKey( 0, $types ); |
| | 209 | $this->assertEquals( 'post', $types[0] ); |
| | 210 | $this->assertArrayHasKey( 1, $types ); |
| | 211 | $this->assertEquals( 'attachment', $types[1] ); |
| | 212 | } |
| | 213 | |
| 198 | 214 | public function test_get_item_schema() { |
| 199 | 215 | $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/taxonomies' ); |
| 200 | 216 | $response = rest_get_server()->dispatch( $request ); |