WordPress.org

Make WordPress Core


Ignore:
Timestamp:
02/24/2017 09:58:07 PM (3 years ago)
Author:
SergeyBiryukov
Message:

REST API: Fix multiple issues with setting dates of posts and comments.

This commit modifies the rest_get_date_with_gmt function to correctly parse local and UTC timestamps with or without timezone information.

It also ensures that the REST API can edit the dates of draft posts by setting the edit_date flag to wp_update_post.

Overall this commit ensures that post and comment dates can be set and updated as expected.

Props jnylen0.
Merges [40101] to the 4.7 branch.
Fixes #39256.

Location:
branches/4.7
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.7

  • branches/4.7/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php

    r40081 r40114  
    10001000            if ( ! empty( $date_data ) ) {
    10011001                list( $prepared_post->post_date, $prepared_post->post_date_gmt ) = $date_data;
     1002                $prepared_post->edit_date = true;
    10021003            }
    10031004        } elseif ( ! empty( $schema['properties']['date_gmt'] ) && ! empty( $request['date_gmt'] ) ) {
     
    10061007            if ( ! empty( $date_data ) ) {
    10071008                list( $prepared_post->post_date, $prepared_post->post_date_gmt ) = $date_data;
     1009                $prepared_post->edit_date = true;
    10081010            }
    10091011        }
Note: See TracChangeset for help on using the changeset viewer.