Feeds: Comments on attachments display in the site-wide comments RSS feed.
Individual attachment pages already have their own RSS comment feed, and would be expected to be included in the site-wide comments RSS feed. Props jbrinley. Fixes #15610 git-svn-id: https://develop.svn.wordpress.org/trunk@36138 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
93e3093a0a
commit
21a4585cd1
|
@ -3193,7 +3193,7 @@ class WP_Query {
|
||||||
$cgroupby = "$wpdb->comments.comment_id";
|
$cgroupby = "$wpdb->comments.comment_id";
|
||||||
} else { // Other non singular e.g. front
|
} else { // Other non singular e.g. front
|
||||||
$cjoin = "JOIN $wpdb->posts ON ( $wpdb->comments.comment_post_ID = $wpdb->posts.ID )";
|
$cjoin = "JOIN $wpdb->posts ON ( $wpdb->comments.comment_post_ID = $wpdb->posts.ID )";
|
||||||
$cwhere = "WHERE post_status = 'publish' AND comment_approved = '1'";
|
$cwhere = "WHERE ( post_status = 'publish' OR ( post_status = 'inherit' && post_type = 'attachment' ) ) AND comment_approved = '1'";
|
||||||
$cgroupby = '';
|
$cgroupby = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,13 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||||
$this->assertQueryTrue('is_feed', 'is_single', 'is_singular', 'is_comment_feed');
|
$this->assertQueryTrue('is_feed', 'is_single', 'is_singular', 'is_comment_feed');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function test_attachment_comments_feed() {
|
||||||
|
$attachment_id = self::factory()->post->create( array( 'post_type' => 'attachment' ) );
|
||||||
|
self::factory()->comment->create_post_comments( $attachment_id, 2 );
|
||||||
|
$this->go_to( get_post_comments_feed_link( $attachment_id ) );
|
||||||
|
$this->assertQueryTrue( 'is_feed', 'is_attachment', 'is_single', 'is_singular', 'is_comment_feed' );
|
||||||
|
}
|
||||||
|
|
||||||
function test_page() {
|
function test_page() {
|
||||||
$page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'about' ) );
|
$page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'about' ) );
|
||||||
$this->go_to( get_permalink( $page_id ) );
|
$this->go_to( get_permalink( $page_id ) );
|
||||||
|
|
|
@ -703,4 +703,19 @@ class Tests_Query_Results extends WP_UnitTestCase {
|
||||||
$result2 = $this->q->query( array( 'title' => 'Tacos', 'fields' => 'ids' ) );
|
$result2 = $this->q->query( array( 'title' => 'Tacos', 'fields' => 'ids' ) );
|
||||||
$this->assertCount( 0, $result2 );
|
$this->assertCount( 0, $result2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ticket 15610
|
||||||
|
*/
|
||||||
|
public function test_main_comments_feed_includes_attachment_comments() {
|
||||||
|
$attachment_id = self::factory()->post->create( array( 'post_type' => 'attachment' ) );
|
||||||
|
$comment_id = self::factory()->comment->create( array( 'comment_post_ID' => $attachment_id, 'comment_approved' => '1' ) );
|
||||||
|
|
||||||
|
$this->q->query( array( 'withcomments' => 1, 'feed' => 'feed' ) );
|
||||||
|
|
||||||
|
$this->assertTrue( $this->q->have_comments() );
|
||||||
|
|
||||||
|
$feed_comment = $this->q->next_comment();
|
||||||
|
$this->assertEquals( $comment_id, $feed_comment->comment_ID );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue