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-posts-controller.php

    r46249 r46252  
    10221022        // Post date.
    10231023        if ( ! empty( $schema['properties']['date'] ) && ! empty( $request['date'] ) ) {
    1024             $date_data = rest_get_date_with_gmt( $request['date'] );
    1025 
    1026             if ( ! empty( $date_data ) ) {
     1024            $current_date = isset( $prepared_post->ID ) ? get_post( $prepared_post->ID )->post_date : false;
     1025            $date_data    = rest_get_date_with_gmt( $request['date'] );
     1026
     1027            if ( ! empty( $date_data ) && $current_date !== $date_data[0] ) {
    10271028                list( $prepared_post->post_date, $prepared_post->post_date_gmt ) = $date_data;
    10281029                $prepared_post->edit_date                                        = true;
    10291030            }
    10301031        } elseif ( ! empty( $schema['properties']['date_gmt'] ) && ! empty( $request['date_gmt'] ) ) {
    1031             $date_data = rest_get_date_with_gmt( $request['date_gmt'], true );
    1032 
    1033             if ( ! empty( $date_data ) ) {
     1032            $current_date = isset( $prepared_post->ID ) ? get_post( $prepared_post->ID )->post_date_gmt : false;
     1033            $date_data    = rest_get_date_with_gmt( $request['date_gmt'], true );
     1034
     1035            if ( ! empty( $date_data ) && $current_date !== $date_data[1] ) {
    10341036                list( $prepared_post->post_date, $prepared_post->post_date_gmt ) = $date_data;
    10351037                $prepared_post->edit_date                                        = true;
Note: See TracChangeset for help on using the changeset viewer.