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 7b27f60dec..1bf551f2af 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 @@ -1758,7 +1758,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 0a13d81586..b36972b5d3 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'] );