Make WordPress Core

Changeset 49922


Ignore:
Timestamp:
01/02/2021 11:47:42 PM (13 months ago)
Author:
TimothyBlynJacobs
Message:

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

Previously, all taxonomies were incorrectly exposed as possible values.

Props johnbillion.
Fixes #51940.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php

    r49790 r49922  
    966966                    'description' => __( 'Type attribution for the term.' ),
    967967                    'type'        => 'string',
    968                     'enum'        => array_keys( get_taxonomies() ),
     968                    'enum'        => array( $this->taxonomy ),
    969969                    'context'     => array( 'view', 'embed', 'edit' ),
    970970                    'readonly'    => true,
  • trunk/tests/phpunit/tests/rest-api/rest-categories-controller.php

    r49603 r49922  
    11411141        $this->assertArrayHasKey( 'slug', $properties );
    11421142        $this->assertArrayHasKey( 'taxonomy', $properties );
    1143         $this->assertSame( array_keys( get_taxonomies() ), $properties['taxonomy']['enum'] );
     1143        $this->assertSame( array( 'category' ), $properties['taxonomy']['enum'] );
    11441144    }
    11451145
  • trunk/tests/phpunit/tests/rest-api/rest-tags-controller.php

    r49603 r49922  
    12341234        $this->assertArrayHasKey( 'slug', $properties );
    12351235        $this->assertArrayHasKey( 'taxonomy', $properties );
    1236         $this->assertSame( array_keys( get_taxonomies() ), $properties['taxonomy']['enum'] );
     1236        $this->assertSame( array( 'post_tag' ), $properties['taxonomy']['enum'] );
    12371237    }
    12381238
Note: See TracChangeset for help on using the changeset viewer.