Make WordPress Core


Ignore:
Timestamp:
09/23/2019 05:39:36 PM (5 years ago)
Author:
kadamwhite
Message:

REST API: Introduce date_floating property on status endpoint response objects.

Expose a date_floating property on all status objects to permit clients (including the block editor) to make correct decisions about date handling for posts of varying status.

Props mnelson4, earnjam, kadamwhite, jnylen0, nerrad, pento.
See #39953.

File:
1 edited

Legend:

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

    r45811 r46252  
    233233        if ( in_array( 'slug', $fields, true ) ) {
    234234            $data['slug'] = $status->name;
     235        }
     236
     237        if ( in_array( 'date_floating', $fields, true ) ) {
     238            $data['date_floating'] = $status->date_floating;
    235239        }
    236240
     
    278282            'type'       => 'object',
    279283            'properties' => array(
    280                 'name'         => array(
     284                'name'          => array(
    281285                    'description' => __( 'The title for the status.' ),
    282286                    'type'        => 'string',
     
    284288                    'readonly'    => true,
    285289                ),
    286                 'private'      => array(
     290                'private'       => array(
    287291                    'description' => __( 'Whether posts with this status should be private.' ),
    288292                    'type'        => 'boolean',
     
    290294                    'readonly'    => true,
    291295                ),
    292                 'protected'    => array(
     296                'protected'     => array(
    293297                    'description' => __( 'Whether posts with this status should be protected.' ),
    294298                    'type'        => 'boolean',
     
    296300                    'readonly'    => true,
    297301                ),
    298                 'public'       => array(
     302                'public'        => array(
    299303                    'description' => __( 'Whether posts of this status should be shown in the front end of the site.' ),
    300304                    'type'        => 'boolean',
     
    302306                    'readonly'    => true,
    303307                ),
    304                 'queryable'    => array(
     308                'queryable'     => array(
    305309                    'description' => __( 'Whether posts with this status should be publicly-queryable.' ),
    306310                    'type'        => 'boolean',
     
    308312                    'readonly'    => true,
    309313                ),
    310                 'show_in_list' => array(
     314                'show_in_list'  => array(
    311315                    'description' => __( 'Whether to include posts in the edit listing for their post type.' ),
    312316                    'type'        => 'boolean',
     
    314318                    'readonly'    => true,
    315319                ),
    316                 'slug'         => array(
     320                'slug'          => array(
    317321                    'description' => __( 'An alphanumeric identifier for the status.' ),
    318322                    'type'        => 'string',
    319323                    'context'     => array( 'embed', 'view', 'edit' ),
     324                    'readonly'    => true,
     325                ),
     326                'date_floating' => array(
     327                    'description' => __( 'Whether posts of this status may have floating published dates.' ),
     328                    'type'        => 'boolean',
     329                    'context'     => array( 'view', 'edit' ),
    320330                    'readonly'    => true,
    321331                ),
Note: See TracChangeset for help on using the changeset viewer.