diff --git a/src/wp-includes/feed-atom.php b/src/wp-includes/feed-atom.php index 9c7fbda7fc..a4a62f74b9 100644 --- a/src/wp-includes/feed-atom.php +++ b/src/wp-includes/feed-atom.php @@ -78,10 +78,13 @@ do_action( 'rss_tag_pre', 'atom' ); * @since 2.0.0 */ do_action( 'atom_entry' ); + + if ( get_comments_number() || comments_open() ) : ?> + diff --git a/src/wp-includes/feed-rss2.php b/src/wp-includes/feed-rss2.php index 69a3035d13..42ff4ea991 100644 --- a/src/wp-includes/feed-rss2.php +++ b/src/wp-includes/feed-rss2.php @@ -83,7 +83,9 @@ do_action( 'rss_tag_pre', 'rss2' ); <?php the_title_rss() ?> + + ]]> @@ -100,8 +102,10 @@ do_action( 'rss_tag_pre', 'rss2' ); ]]> + + channel -> item elements - $items = xml_find($xml, 'rss', 'channel', 'item'); - $posts = get_posts('numberposts='.$this->post_count); + $items = xml_find( $xml, 'rss', 'channel', 'item' ); // check each of the items against the known post data foreach ( $items as $key => $item ) { @@ -178,4 +177,36 @@ class Tests_Feed_RSS2 extends WP_UnitTestCase { $this->assertEquals( html_entity_decode( get_post_comments_feed_link( $post->ID) ), $comment_rss[0]['content'] ); } } + + /** + * @ticket 9134 + */ + function test_items_comments_closed() { + add_filter( 'comments_open', '__return_false' ); + + $this->go_to( '/?feed=rss2' ); + $feed = $this->do_rss2(); + $xml = xml_to_array($feed); + + // get all the rss -> channel -> item elements + $items = xml_find( $xml, 'rss', 'channel', 'item' ); + + // check each of the items against the known post data + foreach ( $items as $key => $item ) { + // Get post for comparison + $guid = xml_find( $items[$key]['child'], 'guid' ); + preg_match( '/\?p=(\d+)/', $guid[0]['content'], $matches ); + $post = get_post( $matches[1] ); + + // comment link + $comments_link = xml_find( $items[ $key ]['child'], 'comments' ); + $this->assertEmpty( $comments_link ); + + // comment rss + $comment_rss = xml_find( $items[ $key ]['child'], 'wfw:commentRss' ); + $this->assertEmpty( $comment_rss ); + } + + remove_filter( 'comments_open', '__return_false' ); + } }