Ticket #2485: commentfeed.diff
File commentfeed.diff, 8.0 KB (added by , 19 years ago) |
---|
-
wp-includes/default-filters.php
72 72 // RSS filters 73 73 add_filter('the_title_rss', 'strip_tags'); 74 74 add_filter('the_title_rss', 'ent2ncr', 8); 75 add_filter('get_wp_title_rss', 'ent2ncr', 8); 75 76 add_filter('the_content_rss', 'ent2ncr', 8); 76 77 add_filter('the_excerpt_rss', 'convert_chars'); 77 78 add_filter('the_excerpt_rss', 'ent2ncr', 8); -
wp-includes/classes.php
12 12 var $current_post = -1; 13 13 var $in_the_loop = false; 14 14 var $post; 15 var $comments; 15 16 16 17 var $is_single = false; 17 18 var $is_preview = false; … … 26 27 var $is_category = false; 27 28 var $is_search = false; 28 29 var $is_feed = false; 30 var $is_comment_feed = false; 29 31 var $is_trackback = false; 30 32 var $is_home = false; 31 33 var $is_404 = false; … … 46 48 $this->is_category = false; 47 49 $this->is_search = false; 48 50 $this->is_feed = false; 51 $this->is_comment_feed = false; 49 52 $this->is_trackback = false; 50 53 $this->is_home = false; 51 54 $this->is_404 = false; … … 215 218 $this->is_feed = true; 216 219 } 217 220 221 if ($this->is_feed && ( '' != $qv['withcomments'] || $this->is_single || $this->is_page )) { 222 $this->is_comment_feed = true; 223 } 224 218 225 if ('' != $qv['tb']) { 219 226 $this->is_trackback = true; 220 227 } … … 630 637 } 631 638 } 632 639 640 if ( $this->is_comment_feed && ( ( $this->is_archive || $this->is_search ) || ( !$this->is_single && !$this->is_page ) ) ) { // Grab the comments then cache the posts 641 if ( $this->is_archive || $this->is_search ) { 642 $cjoin = "LEFT JOIN $wpdb->posts ON ( $wpdb->comments.comment_post_ID = $wpdb->posts.ID ) $join "; 643 $cwhere = "WHERE comment_approved = '1' $where"; 644 $cgroupby = "GROUP BY $wpdb->comments.comment_id"; 645 } else if ( !$this->is_single && !$this->is_page ) { // main feed 646 $cjoin = "LEFT JOIN $wpdb->posts ON ( $wpdb->comments.comment_post_ID = $wpdb->posts.ID )"; 647 $cwhere = "WHERE post_status = 'publish' AND comment_approved = '1'"; 648 $cgroupby = ''; 649 } 650 $cjoin = apply_filters('comment_feed_join', $cjoin); 651 $cwhere = apply_filters('comment_feed_where', $cwhere); 652 $cgroupby = apply_filters('comment_feed_groupby', $cgroupby); 653 $comments_request = "SELECT $distinct $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere GROUP BY $wpdb->comments.comment_id ORDER BY comment_date_gmt DESC LIMIT " . get_settings('posts_per_rss'); 654 $this->comments = $wpdb->get_results($comments_request); 655 $post_ids = array(); 656 foreach ( $this->comments as $comment ) 657 $post_ids[] = (int) $comment->comment_post_ID; 658 $post_ids = join(',', $post_ids); 659 $join = ''; 660 $where = " AND $wpdb->posts.ID IN ($post_ids) "; 661 } 662 663 633 664 // Apply post-paging filters on where and join. Only plugins that 634 665 // manipulate paging queries should use these hooks. 635 666 $where = apply_filters('posts_where_paged', $where); … … 637 668 $groupby = apply_filters('posts_groupby', $groupby); 638 669 $join = apply_filters('posts_join_paged', $join); 639 670 $orderby = "post_" . $q['orderby']; 640 $orderby = apply_filters('posts_orderby', $orderby); 671 $orderby = apply_filters('posts_orderby', $orderby); 672 641 673 $request = " SELECT $distinct * FROM $wpdb->posts $join WHERE 1=1" . $where . " GROUP BY " . $groupby . " ORDER BY " . $orderby . " $limits"; 642 674 $this->request = apply_filters('posts_request', $request); 643 675 644 676 $this->posts = $wpdb->get_results($this->request); 645 677 678 if ( $this->is_comment_feed && ( $this->is_single || $this->is_page ) ) { // Cache the post then grab its comments 679 $cjoin = apply_filters('comment_feed_join', ''); 680 $cwhere = apply_filters('comment_feed_where', "WHERE comment_post_ID = {$this->posts[0]->ID} AND comment_approved = '1'"); 681 $comments_request = "SELECT $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere ORDER BY comment_date_gmt DESC LIMIT " . get_settings('posts_per_rss'); 682 $this->comments = $wpdb->get_results($comments_request); 683 } 684 646 685 // Check post status to determine if post should be displayed. 647 686 if ($this->is_single || $this->is_page) { 648 687 $status = get_post_status($this->posts[0]); -
wp-includes/feed-functions.php
9 9 echo get_bloginfo_rss($show); 10 10 } 11 11 12 function get_wp_title_rss() { 13 return apply_filters( 'get_wp_title_rss', wp_title( '»', false ) ); 14 } 15 12 16 function get_the_title_rss() { 13 17 $title = get_the_title(); 14 18 $title = apply_filters('the_title', $title); … … 161 165 } 162 166 } 163 167 164 ?> 165 No newline at end of file 168 ?> -
wp-commentsrss2.php
20 20 if ($i < 1) { 21 21 $i++; 22 22 ?> 23 <title><?php if (is_single() || is_page() ) { printf(__('Comments on: %s'), get_the_title_rss()); } else { printf(__('Comments for %s'), get_bloginfo_rss("name")); }?></title>24 <link><?php (is_single() ) ? permalink_single_rss() : bloginfo_rss("url")?></link>25 <description><?php bloginfo_rss("description") ?></description>23 <title><?php printf(__('Comments on: %s'), get_bloginfo_rss('name') . get_wp_title_rss()); ?></title> 24 <link><?php (is_single() || is_page()) ? permalink_single_rss() : bloginfo_rss("url"); // is_archive || is_search need links ?></link> 25 <description><?php bloginfo_rss("description"); // need different description for !main_feed ?></description> 26 26 <pubDate><?php echo gmdate('r'); ?></pubDate> 27 27 <generator>http://wordpress.org/?v=<?php echo $wp_version ?></generator> 28 28 29 29 <?php 30 if (is_single() || is_page()) { 31 $comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_author_email, 32 comment_author_url, comment_date, comment_date_gmt, comment_content, comment_post_ID, 33 $wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments 34 LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE comment_post_ID = '$id' 35 AND $wpdb->comments.comment_approved = '1' AND $wpdb->posts.post_status = 'publish' 36 AND post_date_gmt < '" . gmdate("Y-m-d H:i:59") . "' 37 ORDER BY comment_date_gmt DESC LIMIT " . get_settings('posts_per_rss') ); 38 } else { // if no post id passed in, we'll just ue the last 10 comments. 39 $comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_author_email, 40 comment_author_url, comment_date, comment_date_gmt, comment_content, comment_post_ID, 41 $wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments 42 LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE $wpdb->posts.post_status = 'publish' 43 AND $wpdb->comments.comment_approved = '1' AND post_date_gmt < '" . gmdate("Y-m-d H:i:s") . "' 44 ORDER BY comment_date_gmt DESC LIMIT " . get_settings('posts_per_rss') ); 45 } 46 // this line is WordPress' motor, do not delete it. 47 if ($comments) { 48 foreach ($comments as $comment) { 30 if ($wp_query->comments) { 31 foreach ($wp_query->comments as $comment) { 49 32 // Some plugins may need to know the metadata 50 33 // associated with this comment's post: 34 $comment_post = get_post($comment->comment_post_ID); 51 35 get_post_custom($comment->comment_post_ID); 52 36 ?> 53 37 <item> … … 63 47 <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_comment_time('Y-m-d H:i:s', true), false); ?></pubDate> 64 48 <guid><?php comment_link() ?></guid> 65 49 <?php 66 if (!empty($comment ->post_password) && $_COOKIE['wp-postpass'] != $comment->post_password) {50 if (!empty($comment_post->post_password) && $_COOKIE['wp-postpass'] != $comment_post->post_password) { 67 51 ?> 68 52 <description><?php _e('Protected Comments: Please enter your password to view comments.'); ?></description> 69 53 <content:encoded><![CDATA[<?php echo get_the_password_form() ?>]]></content:encoded>