Skip to content
Permalink
Browse files

REST API: Include featured_media in embed responses.

Props kadamwhite, jnylen0, westonruter.
Fixes #39805.


git-svn-id: https://develop.svn.wordpress.org/trunk@40602 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information...
rmccue committed May 10, 2017
1 parent 292a871 commit faa6386ca0483dd2f2c54d84b10d91bd632892b8
@@ -1966,7 +1966,7 @@ public function get_item_schema() {
$schema['properties']['featured_media'] = array(
'description' => __( 'The ID of the featured media for the object.' ),
'type' => 'integer',
'context' => array( 'view', 'edit' ),
'context' => array( 'view', 'edit', 'embed' ),
);
break;
@@ -2914,6 +2914,106 @@ public function test_get_item_schema() {
$this->assertArrayHasKey( 'categories', $properties );
}
/**
* @ticket 39805
*/
public function test_get_post_view_context_properties() {
$request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
$request->set_param( 'context', 'view' );
$response = $this->server->dispatch( $request );
$keys = array_keys( $response->get_data() );
sort( $keys );
$expected_keys = array(
'author',
'categories',
'comment_status',
'content',
'date',
'date_gmt',
'excerpt',
'featured_media',
'format',
'guid',
'id',
'link',
'meta',
'modified',
'modified_gmt',
'ping_status',
'slug',
'status',
'sticky',
'tags',
'template',
'title',
'type',
);
$this->assertEquals( $expected_keys, $keys );
}
public function test_get_post_edit_context_properties() {
wp_set_current_user( self::$editor_id );
$request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
$request->set_param( 'context', 'edit' );
$response = $this->server->dispatch( $request );
$keys = array_keys( $response->get_data() );
sort( $keys );
$expected_keys = array(
'author',
'categories',
'comment_status',
'content',
'date',
'date_gmt',
'excerpt',
'featured_media',
'format',
'guid',
'id',
'link',
'meta',
'modified',
'modified_gmt',
'password',
'ping_status',
'slug',
'status',
'sticky',
'tags',
'template',
'title',
'type',
);
$this->assertEquals( $expected_keys, $keys );
}
public function test_get_post_embed_context_properties() {
$request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
$request->set_param( 'context', 'embed' );
$response = $this->server->dispatch( $request );
$keys = array_keys( $response->get_data() );
sort( $keys );
$expected_keys = array(
'author',
'date',
'excerpt',
'featured_media',
'id',
'link',
'slug',
'title',
'type',
);
$this->assertEquals( $expected_keys, $keys );
}
public function test_status_array_enum_args() {
$request = new WP_REST_Request( 'GET', '/wp/v2' );
$response = $this->server->dispatch( $request );

0 comments on commit faa6386

Please sign in to comment.
You can’t perform that action at this time.