REST API: Only include the controller's own taxonomy in it's schema.

Previously, all taxonomies were incorrectly exposed as possible values.

This commit brings the changes from [49922] to the 5.6 branch.

Props johnbillion, TimothyBlynJacobs.

Fixes #51940.


git-svn-id: https://develop.svn.wordpress.org/branches/5.6@50047 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jake Spurlock 2021-01-28 00:52:01 +00:00
parent 95634ef0f4
commit 3bf49fdece
3 changed files with 3 additions and 3 deletions

View File

@ -965,7 +965,7 @@ class WP_REST_Terms_Controller extends WP_REST_Controller {
'taxonomy' => array(
'description' => __( 'Type attribution for the term.' ),
'type' => 'string',
'enum' => array_keys( get_taxonomies() ),
'enum' => array( $this->taxonomy ),
'context' => array( 'view', 'embed', 'edit' ),
'readonly' => true,
),

View File

@ -1140,7 +1140,7 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas
$this->assertArrayHasKey( 'parent', $properties );
$this->assertArrayHasKey( 'slug', $properties );
$this->assertArrayHasKey( 'taxonomy', $properties );
$this->assertSame( array_keys( get_taxonomies() ), $properties['taxonomy']['enum'] );
$this->assertSame( array( 'category' ), $properties['taxonomy']['enum'] );
}
public function test_get_additional_field_registration() {

View File

@ -1233,7 +1233,7 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase {
$this->assertArrayHasKey( 'name', $properties );
$this->assertArrayHasKey( 'slug', $properties );
$this->assertArrayHasKey( 'taxonomy', $properties );
$this->assertSame( array_keys( get_taxonomies() ), $properties['taxonomy']['enum'] );
$this->assertSame( array( 'post_tag' ), $properties['taxonomy']['enum'] );
}
public function test_get_item_schema_non_hierarchical() {