diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php index 25e9c9a405..16765a5a5f 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php @@ -1767,7 +1767,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { 'description' => __( 'A named status for the object.' ), 'type' => 'string', 'enum' => array_keys( get_post_stati( array( 'internal' => false ) ) ), - 'context' => array( 'edit' ), + 'context' => array( 'view', 'edit' ), ), 'type' => array( 'description' => __( 'Type of Post for the object.' ), diff --git a/tests/phpunit/includes/testcase-rest-post-type-controller.php b/tests/phpunit/includes/testcase-rest-post-type-controller.php index 49c2ebaf9c..387d359459 100644 --- a/tests/phpunit/includes/testcase-rest-post-type-controller.php +++ b/tests/phpunit/includes/testcase-rest-post-type-controller.php @@ -134,11 +134,11 @@ abstract class WP_Test_REST_Post_Type_Controller_Testcase extends WP_Test_REST_C $this->assertFalse( isset( $data['excerpt'] ) ); } + $this->assertEquals( $post->post_status, $data['status'] ); $this->assertEquals( $post->guid, $data['guid']['rendered'] ); if ( 'edit' === $context ) { $this->assertEquals( $post->guid, $data['guid']['raw'] ); - $this->assertEquals( $post->post_status, $data['status'] ); if ( '0000-00-00 00:00:00' === $post->post_date_gmt ) { $this->assertNull( $data['date_gmt'] ); diff --git a/tests/qunit/fixtures/wp-api-generated.js b/tests/qunit/fixtures/wp-api-generated.js index 2adb53cd8a..a7f253282f 100644 --- a/tests/qunit/fixtures/wp-api-generated.js +++ b/tests/qunit/fixtures/wp-api-generated.js @@ -3384,6 +3384,7 @@ mockedApiResponse.PostsCollection = [ "modified": "2017-02-14T00:00:00", "modified_gmt": "2017-02-14T00:00:00", "slug": "restapi-client-fixture-post", + "status": "publish", "type": "post", "link": "http://example.org/?p=3", "title": { @@ -3474,6 +3475,7 @@ mockedApiResponse.PostModel = { "modified": "2017-02-14T00:00:00", "modified_gmt": "2017-02-14T00:00:00", "slug": "restapi-client-fixture-post", + "status": "publish", "type": "post", "link": "http://example.org/?p=3", "title": { @@ -3552,6 +3554,7 @@ mockedApiResponse.PagesCollection = [ "modified": "2017-02-14T00:00:00", "modified_gmt": "2017-02-14T00:00:00", "slug": "restapi-client-fixture-page", + "status": "publish", "type": "page", "link": "http://example.org/?page_id=5", "title": { @@ -3626,6 +3629,7 @@ mockedApiResponse.PageModel = { "modified": "2017-02-14T00:00:00", "modified_gmt": "2017-02-14T00:00:00", "slug": "restapi-client-fixture-page", + "status": "publish", "type": "page", "link": "http://example.org/?page_id=5", "title": { @@ -3700,6 +3704,7 @@ mockedApiResponse.MediaCollection = [ "modified": "2017-02-14T00:00:00", "modified_gmt": "2017-02-14T00:00:00", "slug": "restapi-client-fixture-attachment", + "status": "inherit", "type": "attachment", "link": "http://example.org/?attachment_id=7", "title": { @@ -3758,6 +3763,7 @@ mockedApiResponse.MediaModel = { "modified": "2017-02-14T00:00:00", "modified_gmt": "2017-02-14T00:00:00", "slug": "restapi-client-fixture-attachment", + "status": "inherit", "type": "attachment", "link": "http://example.org/?attachment_id=7", "title": {