WordPress.org

Make WordPress Core

Changeset 40080


Ignore:
Timestamp:
02/19/2017 04:31:12 AM (4 years ago)
Author:
rachelbaker
Message:

REST API: Include the status property in view context responses from the Posts endpoints.

Previously the status for a Post (or other post_types) was only exposed under the edit context, which doesn't really make much sense considering we support querying by post status without authentication. Originally introduced in v2.0 beta 1: https://github.com/WP-API/WP-API/commit/69f617d749e4f165b9e31c1c042eec45ade3e41f without any explanation in the commit message.

Props dhanendran, jnylen0, rachelbaker.
Fixes #39466.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php

    r39967 r40080  
    17681768                    'type'        => 'string',
    17691769                    'enum'        => array_keys( get_post_stati( array( 'internal' => false ) ) ),
    1770                     'context'     => array( 'edit' ),
     1770                    'context'     => array( 'view', 'edit' ),
    17711771                ),
    17721772                'type'            => array(
  • trunk/tests/phpunit/includes/testcase-rest-post-type-controller.php

    r39556 r40080  
    135135        }
    136136
     137        $this->assertEquals( $post->post_status, $data['status'] );
    137138        $this->assertEquals( $post->guid, $data['guid']['rendered'] );
    138139
    139140        if ( 'edit' === $context ) {
    140141            $this->assertEquals( $post->guid, $data['guid']['raw'] );
    141             $this->assertEquals( $post->post_status, $data['status'] );
    142142
    143143            if ( '0000-00-00 00:00:00' === $post->post_date_gmt ) {
  • trunk/tests/qunit/fixtures/wp-api-generated.js

    r40066 r40080  
    33853385        "modified_gmt": "2017-02-14T00:00:00",
    33863386        "slug": "restapi-client-fixture-post",
     3387        "status": "publish",
    33873388        "type": "post",
    33883389        "link": "http://example.org/?p=3",
     
    34753476    "modified_gmt": "2017-02-14T00:00:00",
    34763477    "slug": "restapi-client-fixture-post",
     3478    "status": "publish",
    34773479    "type": "post",
    34783480    "link": "http://example.org/?p=3",
     
    35533555        "modified_gmt": "2017-02-14T00:00:00",
    35543556        "slug": "restapi-client-fixture-page",
     3557        "status": "publish",
    35553558        "type": "page",
    35563559        "link": "http://example.org/?page_id=5",
     
    36273630    "modified_gmt": "2017-02-14T00:00:00",
    36283631    "slug": "restapi-client-fixture-page",
     3632    "status": "publish",
    36293633    "type": "page",
    36303634    "link": "http://example.org/?page_id=5",
     
    37013705        "modified_gmt": "2017-02-14T00:00:00",
    37023706        "slug": "restapi-client-fixture-attachment",
     3707        "status": "inherit",
    37033708        "type": "attachment",
    37043709        "link": "http://example.org/?attachment_id=7",
     
    37593764    "modified_gmt": "2017-02-14T00:00:00",
    37603765    "slug": "restapi-client-fixture-attachment",
     3766    "status": "inherit",
    37613767    "type": "attachment",
    37623768    "link": "http://example.org/?attachment_id=7",
Note: See TracChangeset for help on using the changeset viewer.