WordPress.org

Make WordPress Core


Ignore:
Timestamp:
02/21/2017 06:17:32 PM (2 years ago)
Author:
jnylen0
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.

Fixes #39256.

File:
1 edited

Legend:

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

    r40080 r40101  
    10051005            if ( ! empty( $date_data ) ) {
    10061006                list( $prepared_post->post_date, $prepared_post->post_date_gmt ) = $date_data;
     1007                $prepared_post->edit_date = true;
    10071008            }
    10081009        } elseif ( ! empty( $schema['properties']['date_gmt'] ) && ! empty( $request['date_gmt'] ) ) {
     
    10111012            if ( ! empty( $date_data ) ) {
    10121013                list( $prepared_post->post_date, $prepared_post->post_date_gmt ) = $date_data;
     1014                $prepared_post->edit_date = true;
    10131015            }
    10141016        }
Note: See TracChangeset for help on using the changeset viewer.