Changeset 40115 for branches/4.7/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
- Timestamp:
- 02/24/2017 10:02:48 PM (8 years ago)
- 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
r40114 r40115 1386 1386 1387 1387 if ( ! empty( $schema['properties']['date_gmt'] ) ) { 1388 $data['date_gmt'] = $this->prepare_date_response( $post->post_date_gmt ); 1388 // For drafts, `post_date_gmt` may not be set, indicating that the 1389 // date of the draft should be updated each time it is saved (see 1390 // #38883). In this case, shim the value based on the `post_date` 1391 // field with the site's timezone offset applied. 1392 if ( '0000-00-00 00:00:00' === $post->post_date_gmt ) { 1393 $post_date_gmt = date( 'Y-m-d H:i:s', strtotime( $post->post_date ) - ( get_option( 'gmt_offset' ) * 3600 ) ); 1394 } else { 1395 $post_date_gmt = $post->post_date_gmt; 1396 } 1397 $data['date_gmt'] = $this->prepare_date_response( $post_date_gmt ); 1389 1398 } 1390 1399 … … 1402 1411 1403 1412 if ( ! empty( $schema['properties']['modified_gmt'] ) ) { 1404 $data['modified_gmt'] = $this->prepare_date_response( $post->post_modified_gmt ); 1413 // For drafts, `post_modified_gmt` may not be set (see 1414 // `post_date_gmt` comments above). In this case, shim the value 1415 // based on the `post_modified` field with the site's timezone 1416 // offset applied. 1417 if ( '0000-00-00 00:00:00' === $post->post_modified_gmt ) { 1418 $post_modified_gmt = date( 'Y-m-d H:i:s', strtotime( $post->post_modified ) - ( get_option( 'gmt_offset' ) * 3600 ) ); 1419 } else { 1420 $post_modified_gmt = $post->post_modified_gmt; 1421 } 1422 $data['modified_gmt'] = $this->prepare_date_response( $post_modified_gmt ); 1405 1423 } 1406 1424
Note: See TracChangeset
for help on using the changeset viewer.