mirror of
git://develop.git.wordpress.org/
synced 2025-02-25 17:13:30 +01:00
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
This commit is contained in:
parent
292a871e44
commit
faa6386ca0
@ -1966,7 +1966,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
||||
$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 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te
|
||||
$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 );
|
||||
|
Loading…
x
Reference in New Issue
Block a user