WordPress.org

Make WordPress Core


Ignore:
Timestamp:
12/29/2016 05:27:37 PM (4 years ago)
Author:
rachelbaker
Message:

REST API: Add the supports property to the Post Type response object.

Includes a new supports property in the response object and schema for the /types endpoints for users with the edit_posts capability for the given post type. The supports property returns an object of the features the given post type *supports*.

Props timmydcrawford, tyxla.
Fixes #39033.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-post-types-controller.php

    r39191 r39647  
    120120        $data = $response->get_data();
    121121        $properties = $data['schema']['properties'];
    122         $this->assertEquals( 8, count( $properties ) );
     122        $this->assertEquals( 9, count( $properties ) );
    123123        $this->assertArrayHasKey( 'capabilities', $properties );
    124124        $this->assertArrayHasKey( 'description', $properties );
     
    127127        $this->assertArrayHasKey( 'name', $properties );
    128128        $this->assertArrayHasKey( 'slug', $properties );
     129        $this->assertArrayHasKey( 'supports', $properties );
    129130        $this->assertArrayHasKey( 'taxonomies', $properties );
    130131        $this->assertArrayHasKey( 'rest_base', $properties );
     
    180181            $this->assertEquals( $post_type_obj->cap, $data['capabilities'] );
    181182            $this->assertEquals( $post_type_obj->labels, $data['labels'] );
     183            $this->assertEquals( get_all_post_type_supports( $post_type_obj->name ), $data['supports'] );
    182184        } else {
    183185            $this->assertFalse( isset( $data['capabilities'] ) );
    184186            $this->assertFalse( isset( $data['labels'] ) );
     187            $this->assertFalse( isset( $data['supports'] ) );
    185188        }
    186189    }
Note: See TracChangeset for help on using the changeset viewer.