Skip to content

Commit

Permalink
Merge pull request #5450 from ampproject/fix/5449-invalid-timestamp-p…
Browse files Browse the repository at this point in the history
…review-post

Use current timestamp if post does not have a date
  • Loading branch information
westonruter authored Oct 1, 2020
2 parents 5902120 + db11338 commit 5f42cde
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions includes/templates/class-amp-post-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,13 @@ private function build_post_data() {
* @return int Post publish UTC timestamp.
*/
private function build_post_publish_timestamp() {
$format = 'U';
$timestamp = (int) get_post_time( $format, true, $this->post, true );
$format = 'U';

if ( empty( $this->post->post_date_gmt ) || '0000-00-00 00:00:00' === $this->post->post_date_gmt ) {
$timestamp = time();
} else {
$timestamp = (int) get_post_time( $format, true, $this->post, true );
}

/** This filter is documented in wp-includes/general-template.php. */
$filtered_timestamp = apply_filters( 'get_the_date', $timestamp, $format, $this->post );
Expand Down

0 comments on commit 5f42cde

Please sign in to comment.