diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php
index 534aa8e..09ad6a9 100644
|
a
|
b
|
class WP_REST_Post_Types_Controller extends WP_REST_Controller { |
| 156 | 156 | 'name' => $post_type->label, |
| 157 | 157 | 'slug' => $post_type->name, |
| 158 | 158 | 'taxonomies' => array_values( $taxonomies ), |
| | 159 | 'rest_base' => $post_type->rest_base, |
| 159 | 160 | ); |
| 160 | 161 | $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; |
| 161 | 162 | $data = $this->add_additional_fields_to_object( $data, $request ); |
| … |
… |
class WP_REST_Post_Types_Controller extends WP_REST_Controller { |
| 251 | 252 | 'context' => array( 'view', 'edit' ), |
| 252 | 253 | 'readonly' => true, |
| 253 | 254 | ), |
| | 255 | 'rest_base' => array( |
| | 256 | 'description' => __( 'REST base route for the resource.' ), |
| | 257 | 'type' => 'array', |
| | 258 | 'context' => array( 'view', 'edit', 'embed' ), |
| | 259 | 'readonly' => true, |
| | 260 | ), |
| 254 | 261 | ), |
| 255 | 262 | ); |
| 256 | 263 | return $this->add_additional_fields_schema( $schema ); |
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 21c0b0e..f113a6c 100644
|
a
|
b
|
class WP_REST_Taxonomies_Controller extends WP_REST_Controller { |
| 187 | 187 | 'types' => $taxonomy->object_type, |
| 188 | 188 | 'show_cloud' => $taxonomy->show_tagcloud, |
| 189 | 189 | 'hierarchical' => $taxonomy->hierarchical, |
| | 190 | 'rest_base' => $taxonomy->rest_base, |
| 190 | 191 | ); |
| 191 | 192 | |
| 192 | 193 | $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; |
| … |
… |
class WP_REST_Taxonomies_Controller extends WP_REST_Controller { |
| 285 | 286 | 'context' => array( 'view', 'edit' ), |
| 286 | 287 | 'readonly' => true, |
| 287 | 288 | ), |
| | 289 | 'rest_base' => array( |
| | 290 | 'description' => __( 'REST base route for the resource.' ), |
| | 291 | 'type' => 'array', |
| | 292 | 'context' => array( 'view', 'edit', 'embed' ), |
| | 293 | 'readonly' => true, |
| | 294 | ), |
| 288 | 295 | ), |
| 289 | 296 | ); |
| 290 | 297 | return $this->add_additional_fields_schema( $schema ); |
diff --git a/tests/phpunit/tests/rest-api/rest-post-types-controller.php b/tests/phpunit/tests/rest-api/rest-post-types-controller.php
index 9ae9ead..49c9ebb 100644
|
a
|
b
|
class WP_Test_REST_Post_Types_Controller extends WP_Test_REST_Controller_Testcas |
| 119 | 119 | $response = $this->server->dispatch( $request ); |
| 120 | 120 | $data = $response->get_data(); |
| 121 | 121 | $properties = $data['schema']['properties']; |
| 122 | | $this->assertEquals( 7, count( $properties ) ); |
| | 122 | $this->assertEquals( 8, count( $properties ) ); |
| 123 | 123 | $this->assertArrayHasKey( 'capabilities', $properties ); |
| 124 | 124 | $this->assertArrayHasKey( 'description', $properties ); |
| 125 | 125 | $this->assertArrayHasKey( 'hierarchical', $properties ); |
| … |
… |
class WP_Test_REST_Post_Types_Controller extends WP_Test_REST_Controller_Testcas |
| 127 | 127 | $this->assertArrayHasKey( 'name', $properties ); |
| 128 | 128 | $this->assertArrayHasKey( 'slug', $properties ); |
| 129 | 129 | $this->assertArrayHasKey( 'taxonomies', $properties ); |
| | 130 | $this->assertArrayHasKey( 'rest_base', $properties ); |
| 130 | 131 | } |
| 131 | 132 | |
| 132 | 133 | public function test_get_additional_field_registration() { |
| … |
… |
class WP_Test_REST_Post_Types_Controller extends WP_Test_REST_Controller_Testcas |
| 170 | 171 | $this->assertEquals( $post_type_obj->name, $data['slug'] ); |
| 171 | 172 | $this->assertEquals( $post_type_obj->description, $data['description'] ); |
| 172 | 173 | $this->assertEquals( $post_type_obj->hierarchical, $data['hierarchical'] ); |
| | 174 | $this->assertEquals( $post_type_obj->rest_base, $data['rest_base'] ); |
| 173 | 175 | |
| 174 | 176 | $links = test_rest_expand_compact_links( $links ); |
| 175 | 177 | $this->assertEquals( rest_url( 'wp/v2/types' ), $links['collection'][0]['href'] ); |
diff --git a/tests/phpunit/tests/rest-api/rest-taxonomies-controller.php b/tests/phpunit/tests/rest-api/rest-taxonomies-controller.php
index 7f00598..00aa196 100644
|
a
|
b
|
class WP_Test_REST_Taxonomies_Controller extends WP_Test_REST_Controller_Testcas |
| 45 | 45 | $this->assertEquals( 'Tags', $data['post_tag']['name'] ); |
| 46 | 46 | $this->assertEquals( 'post_tag', $data['post_tag']['slug'] ); |
| 47 | 47 | $this->assertEquals( false, $data['post_tag']['hierarchical'] ); |
| | 48 | $this->assertEquals( 'tags', $data['post_tag']['rest_base'] ); |
| 48 | 49 | } |
| 49 | 50 | |
| 50 | 51 | public function test_get_items_invalid_permission_for_context() { |
| … |
… |
class WP_Test_REST_Taxonomies_Controller extends WP_Test_REST_Controller_Testcas |
| 134 | 135 | $response = $this->server->dispatch( $request ); |
| 135 | 136 | $data = $response->get_data(); |
| 136 | 137 | $properties = $data['schema']['properties']; |
| 137 | | $this->assertEquals( 8, count( $properties ) ); |
| | 138 | $this->assertEquals( 9, count( $properties ) ); |
| 138 | 139 | $this->assertArrayHasKey( 'capabilities', $properties ); |
| 139 | 140 | $this->assertArrayHasKey( 'description', $properties ); |
| 140 | 141 | $this->assertArrayHasKey( 'hierarchical', $properties ); |
| … |
… |
class WP_Test_REST_Taxonomies_Controller extends WP_Test_REST_Controller_Testcas |
| 143 | 144 | $this->assertArrayHasKey( 'slug', $properties ); |
| 144 | 145 | $this->assertArrayHasKey( 'show_cloud', $properties ); |
| 145 | 146 | $this->assertArrayHasKey( 'types', $properties ); |
| | 147 | $this->assertArrayHasKey( 'rest_base', $properties ); |
| 146 | 148 | } |
| 147 | 149 | |
| 148 | 150 | public function tearDown() { |
| … |
… |
class WP_Test_REST_Taxonomies_Controller extends WP_Test_REST_Controller_Testcas |
| 168 | 170 | $this->assertEquals( $tax_obj->name, $data['slug'] ); |
| 169 | 171 | $this->assertEquals( $tax_obj->description, $data['description'] ); |
| 170 | 172 | $this->assertEquals( $tax_obj->hierarchical, $data['hierarchical'] ); |
| | 173 | $this->assertEquals( $tax_obj->rest_base, $data['rest_base'] ); |
| 171 | 174 | $this->assertEquals( rest_url( 'wp/v2/taxonomies' ), $links['collection'][0]['href'] ); |
| 172 | 175 | $this->assertArrayHasKey( 'https://api.w.org/items', $links ); |
| 173 | 176 | if ( 'edit' === $context ) { |