Feeds: <comments> is optional in RSS2, so don't include it when comments aren't present or open. Same for <wfw:commentRss> and <slash:comments>

Adds unit test.

Props swissspidy, realloc, hakre, sivel.
Fixes #9134.


git-svn-id: https://develop.svn.wordpress.org/trunk@35506 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor
2015-11-04 17:46:41 +00:00
parent 00ee9a62d1
commit ee98fd84bb
3 changed files with 40 additions and 2 deletions

View File

@@ -83,7 +83,9 @@ do_action( 'rss_tag_pre', 'rss2' );
<item>
<title><?php the_title_rss() ?></title>
<link><?php the_permalink_rss() ?></link>
<?php if ( get_comments_number() || comments_open() ) : ?>
<comments><?php comments_link_feed(); ?></comments>
<?php endif; ?>
<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate>
<dc:creator><![CDATA[<?php the_author() ?>]]></dc:creator>
<?php the_category_rss('rss2') ?>
@@ -100,8 +102,10 @@ do_action( 'rss_tag_pre', 'rss2' );
<content:encoded><![CDATA[<?php the_excerpt_rss(); ?>]]></content:encoded>
<?php endif; ?>
<?php endif; ?>
<?php if ( get_comments_number() || comments_open() ) : ?>
<wfw:commentRss><?php echo esc_url( get_post_comments_feed_link(null, 'rss2') ); ?></wfw:commentRss>
<slash:comments><?php echo get_comments_number(); ?></slash:comments>
<?php endif; ?>
<?php rss_enclosure(); ?>
<?php
/**