- Timestamp:
- 02/24/2017 06:14:21 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
r40101 r40108 1392 1392 1393 1393 if ( ! empty( $schema['properties']['date_gmt'] ) ) { 1394 $data['date_gmt'] = $this->prepare_date_response( $post->post_date_gmt ); 1394 // For drafts, `post_date_gmt` may not be set, indicating that the 1395 // date of the draft should be updated each time it is saved (see 1396 // #38883). In this case, shim the value based on the `post_date` 1397 // field with the site's timezone offset applied. 1398 if ( '0000-00-00 00:00:00' === $post->post_date_gmt ) { 1399 $post_date_gmt = date( 'Y-m-d H:i:s', strtotime( $post->post_date ) - ( get_option( 'gmt_offset' ) * 3600 ) ); 1400 } else { 1401 $post_date_gmt = $post->post_date_gmt; 1402 } 1403 $data['date_gmt'] = $this->prepare_date_response( $post_date_gmt ); 1395 1404 } 1396 1405 … … 1408 1417 1409 1418 if ( ! empty( $schema['properties']['modified_gmt'] ) ) { 1410 $data['modified_gmt'] = $this->prepare_date_response( $post->post_modified_gmt ); 1419 // For drafts, `post_modified_gmt` may not be set (see 1420 // `post_date_gmt` comments above). In this case, shim the value 1421 // based on the `post_modified` field with the site's timezone 1422 // offset applied. 1423 if ( '0000-00-00 00:00:00' === $post->post_modified_gmt ) { 1424 $post_modified_gmt = date( 'Y-m-d H:i:s', strtotime( $post->post_modified ) - ( get_option( 'gmt_offset' ) * 3600 ) ); 1425 } else { 1426 $post_modified_gmt = $post->post_modified_gmt; 1427 } 1428 $data['modified_gmt'] = $this->prepare_date_response( $post_modified_gmt ); 1411 1429 } 1412 1430
Note: See TracChangeset
for help on using the changeset viewer.