Feeds: improve structure and naming of feed build date helper function.
Simplify overall code structure by passing the required format to the helper function. Clarify functionality by renaming `get_last_build_date` to `get_feed_build_date`. Props pento, spacedmonkey. Fixes #4575. Built from https://develop.svn.wordpress.org/trunk@45247 git-svn-id: http://core.svn.wordpress.org/trunk@45056 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
2d58638ba0
commit
b287642342
|
@ -43,8 +43,7 @@ do_action( 'rss_tag_pre', 'atom-comments' );
|
|||
</title>
|
||||
<subtitle type="text"><?php bloginfo_rss( 'description' ); ?></subtitle>
|
||||
|
||||
<?php $date = get_last_build_date(); ?>
|
||||
<updated><?php echo $date ? mysql2date( 'Y-m-d\TH:i:s\Z', $date, false ) : date( 'Y-m-d\TH:i:s\Z' ); ?></updated>
|
||||
<updated><?php echo get_feed_build_date( 'Y-m-d\TH:i:s\Z' ); ?></updated>
|
||||
|
||||
<?php if ( is_singular() ) { ?>
|
||||
<link rel="alternate" type="<?php bloginfo_rss( 'html_type' ); ?>" href="<?php comments_link_feed(); ?>" />
|
||||
|
|
|
@ -30,8 +30,7 @@ do_action( 'rss_tag_pre', 'atom' );
|
|||
<title type="text"><?php wp_title_rss(); ?></title>
|
||||
<subtitle type="text"><?php bloginfo_rss( 'description' ); ?></subtitle>
|
||||
|
||||
<?php $date = get_last_build_date(); ?>
|
||||
<updated><?php echo $date ? mysql2date( 'Y-m-d\TH:i:s\Z', $date, false ) : date( 'Y-m-d\TH:i:s\Z' ); ?></updated>
|
||||
<updated><?php echo get_feed_build_date( 'Y-m-d\TH:i:s\Z' ); ?></updated>
|
||||
|
||||
<link rel="alternate" type="<?php bloginfo_rss( 'html_type' ); ?>" href="<?php bloginfo_rss( 'url' ); ?>" />
|
||||
<id><?php bloginfo( 'atom_url' ); ?></id>
|
||||
|
|
|
@ -33,12 +33,7 @@ do_action( 'rss_tag_pre', 'rdf' );
|
|||
<title><?php wp_title_rss(); ?></title>
|
||||
<link><?php bloginfo_rss( 'url' ); ?></link>
|
||||
<description><?php bloginfo_rss( 'description' ); ?></description>
|
||||
<dc:date>
|
||||
<?php
|
||||
$date = get_last_build_date();
|
||||
echo $date ? mysql2date( 'Y-m-d\TH:i:s\Z', $date ) : date( 'Y-m-d\TH:i:s\Z' );
|
||||
?>
|
||||
</dc:date>
|
||||
<dc:date><?php echo get_feed_build_date( 'Y-m-d\TH:i:s\Z' ); ?> </dc:date>
|
||||
<sy:updatePeriod>
|
||||
<?php
|
||||
/** This filter is documented in wp-includes/feed-rss2.php */
|
||||
|
|
|
@ -14,12 +14,7 @@ echo '<?xml version="1.0" encoding="' . get_option( 'blog_charset' ) . '"?' . '>
|
|||
<title><?php wp_title_rss(); ?></title>
|
||||
<link><?php bloginfo_rss( 'url' ); ?></link>
|
||||
<description><?php bloginfo_rss( 'description' ); ?></description>
|
||||
<lastBuildDate>
|
||||
<?php
|
||||
$date = get_last_build_date();
|
||||
echo $date ? mysql2date( 'D, d M Y H:i:s +0000', $date ) : date( 'D, d M Y H:i:s +0000' );
|
||||
?>
|
||||
</lastBuildDate>
|
||||
<lastBuildDate><?php echo get_feed_build_date( 'D, d M Y H:i:s +0000' ); ?></lastBuildDate>
|
||||
<docs>http://backend.userland.com/rss092</docs>
|
||||
<language><?php bloginfo_rss( 'language' ); ?></language>
|
||||
|
||||
|
|
|
@ -49,12 +49,7 @@ do_action( 'rss_tag_pre', 'rss2-comments' );
|
|||
<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
|
||||
<link><?php ( is_single() ) ? the_permalink_rss() : bloginfo_rss( 'url' ); ?></link>
|
||||
<description><?php bloginfo_rss( 'description' ); ?></description>
|
||||
<lastBuildDate>
|
||||
<?php
|
||||
$date = get_last_build_date();
|
||||
echo $date ? mysql2date( 'r', $date, false ) : date( 'r' );
|
||||
?>
|
||||
</lastBuildDate>
|
||||
<lastBuildDate><?php echo get_feed_build_date( 'r' ); ?></lastBuildDate>
|
||||
<sy:updatePeriod>
|
||||
<?php
|
||||
/** This filter is documented in wp-includes/feed-rss2.php */
|
||||
|
|
|
@ -42,12 +42,7 @@ do_action( 'rss_tag_pre', 'rss2' );
|
|||
<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
|
||||
<link><?php bloginfo_rss( 'url' ); ?></link>
|
||||
<description><?php bloginfo_rss( 'description' ); ?></description>
|
||||
<lastBuildDate>
|
||||
<?php
|
||||
$date = get_last_build_date();
|
||||
echo $date ? mysql2date( 'r', $date, false ) : date( 'r' );
|
||||
?>
|
||||
</lastBuildDate>
|
||||
<lastBuildDate><?php echo get_feed_build_date( 'r' ); ?></lastBuildDate>
|
||||
<language><?php bloginfo_rss( 'language' ); ?></language>
|
||||
<sy:updatePeriod>
|
||||
<?php
|
||||
|
|
|
@ -638,18 +638,20 @@ function self_link() {
|
|||
}
|
||||
|
||||
/*
|
||||
* Get the timestamp of the most recently modified post from WP_Query.
|
||||
*
|
||||
* If viewing a comment feed, the date of the most recently modified
|
||||
* comment will be returned.
|
||||
*
|
||||
* @global WP_Query $wp_query The global WP_Query object.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @return string The timestamp.
|
||||
*/
|
||||
function get_last_build_date() {
|
||||
* Get the timestamp of the most recently modified post from WP_Query.
|
||||
*
|
||||
* If viewing a comment feed, the timestamp of the most recently modified
|
||||
* comment will be returned.
|
||||
*
|
||||
* @global WP_Query $wp_query The global WP_Query object.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @param string $format Format of the timestamp to return, passed to mysql2date.
|
||||
*
|
||||
* @return string The timestamp.
|
||||
*/
|
||||
function get_feed_build_date( $format ) {
|
||||
global $wp_query;
|
||||
|
||||
if ( empty( $wp_query ) || ! $wp_query->have_posts() ) {
|
||||
|
@ -670,16 +672,24 @@ function get_last_build_date() {
|
|||
}
|
||||
|
||||
// Determine the maximum modified time.
|
||||
$max_modified_time = max( $modified_times );
|
||||
$max_modified_time = max(
|
||||
array_map(
|
||||
function ( $time ) use ( $format ) {
|
||||
return mysql2date( $format, $time, false );
|
||||
},
|
||||
$modified_times
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* Filters the date the last post or comment in the query was modified.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @param string $max_modified_times Date the last post or comment was modified in the query.
|
||||
* @param string $max_modified_time Date the last post or comment was modified in the query.
|
||||
* @param string $format The date format requested in get_feed_build_date.
|
||||
*/
|
||||
return apply_filters( 'get_last_build_date', $max_modified_time );
|
||||
return apply_filters( 'get_feed_build_date', $max_modified_time, $format );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.2-beta3-45246';
|
||||
$wp_version = '5.2-beta3-45247';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue