Changeset 46977 for branches/5.3/src/wp-includes/feed.php
- Timestamp:
- 12/17/2019 08:52:44 PM (6 years ago)
- Location:
- branches/5.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.3
- Property svn:mergeinfo changed
/trunk merged: 46973-46974
- Property svn:mergeinfo changed
-
branches/5.3/src/wp-includes/feed.php
r46774 r46977 650 650 651 651 /** 652 * Get the timestampof the most recently modified post from WP_Query.653 * 654 * If viewing a comment feed, the time stampof the most recently modified652 * Get the UTC time of the most recently modified post from WP_Query. 653 * 654 * If viewing a comment feed, the time of the most recently modified 655 655 * comment will be returned. 656 656 * … … 659 659 * @since 5.2.0 660 660 * 661 * @param string $format Format of the timestamp to return, passed to mysql2date. 662 * 663 * @return string The timestamp. 661 * @param string $format Date format string to return the time in. 662 * @return string|false The time in requested format, or false on failure. 664 663 */ 665 664 function get_feed_build_date( $format ) { 666 665 global $wp_query; 667 666 668 if ( empty( $wp_query ) || ! $wp_query->have_posts() ) { 669 // Fallback to last time any post was modified or published. 670 return get_lastpostmodified( 'GMT' ); 671 } 672 673 // Extract the post modified times from the posts. 674 $modified_times = wp_list_pluck( $wp_query->posts, 'post_modified_gmt' ); 675 676 // If this is a comment feed, check those objects too. 677 if ( $wp_query->is_comment_feed() && $wp_query->comment_count ) { 678 // Extract the comment modified times from the comments. 679 $comment_times = wp_list_pluck( $wp_query->comments, 'comment_date_gmt' ); 680 681 // Add the comment times to the post times for comparison. 682 $modified_times = array_merge( $modified_times, $comment_times ); 683 } 684 685 // Determine the maximum modified time. 686 $datetime = date_create_immutable_from_format( 687 'Y-m-d H:i:s', 688 max( $modified_times ), 689 new DateTimeZone( 'UTC' ) 690 ); 691 692 $max_modified_time = $datetime->format( $format ); 667 $datetime = false; 668 $max_modified_time = false; 669 $utc = new DateTimeZone( 'UTC' ); 670 671 if ( ! empty( $wp_query ) && $wp_query->have_posts() ) { 672 // Extract the post modified times from the posts. 673 $modified_times = wp_list_pluck( $wp_query->posts, 'post_modified_gmt' ); 674 675 // If this is a comment feed, check those objects too. 676 if ( $wp_query->is_comment_feed() && $wp_query->comment_count ) { 677 // Extract the comment modified times from the comments. 678 $comment_times = wp_list_pluck( $wp_query->comments, 'comment_date_gmt' ); 679 680 // Add the comment times to the post times for comparison. 681 $modified_times = array_merge( $modified_times, $comment_times ); 682 } 683 684 // Determine the maximum modified time. 685 $datetime = date_create_immutable_from_format( 'Y-m-d H:i:s', max( $modified_times ), $utc ); 686 } 687 688 if ( false === $datetime ) { 689 // Fall back to last time any post was modified or published. 690 $datetime = date_create_immutable_from_format( 'Y-m-d H:i:s', get_lastpostmodified( 'GMT' ), $utc ); 691 } 692 693 if ( false !== $datetime ) { 694 $max_modified_time = $datetime->format( $format ); 695 } 693 696 694 697 /** … … 697 700 * @since 5.2.0 698 701 * 699 * @param string $max_modified_time Date the last post or comment was modified in the query. 700 * @param string $format The date format requested in get_feed_build_date. 702 * @param string|false $max_modified_time Date the last post or comment was modified in the query, in UTC. 703 * False on failure. 704 * @param string $format The date format requested in get_feed_build_date(). 701 705 */ 702 706 return apply_filters( 'get_feed_build_date', $max_modified_time, $format );
Note: See TracChangeset
for help on using the changeset viewer.