Ticket #2485: 2485.diff
File 2485.diff, 9.5 KB (added by , 17 years ago) |
---|
-
wp-includes/feed-atom-comments.php
31 31 $i++; 32 32 } 33 33 34 if (is_single() || is_page()) { 35 $comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_author_email, 36 comment_author_url, comment_date, comment_date_gmt, comment_content, comment_post_ID, 37 $wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments 38 LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE comment_post_ID = '" . get_the_ID() . "' 39 AND $wpdb->comments.comment_approved = '1' AND $wpdb->posts.post_status = 'publish' 40 AND post_date_gmt < '" . gmdate("Y-m-d H:i:59") . "' 41 ORDER BY comment_date_gmt ASC" ); 42 } else { // if no post id passed in, we'll just use the last posts_per_rss comments. 43 $comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_author_email, 44 comment_author_url, comment_date, comment_date_gmt, comment_content, comment_post_ID, 45 $wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments 46 LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE $wpdb->posts.post_status = 'publish' 47 AND $wpdb->comments.comment_approved = '1' AND post_date_gmt < '" . gmdate("Y-m-d H:i:s") . "' 48 ORDER BY comment_date_gmt DESC LIMIT " . get_option('posts_per_rss') ); 49 } 50 51 if ($comments) { 52 foreach ($comments as $comment) { 34 if ($wp_query->comments) { 35 foreach ($wp_query->comments as $comment) { 53 36 $GLOBALS['comment'] =& $comment; 37 38 $comment_post = get_post($comment_post_ID); 54 39 get_post_custom($comment->comment_post_ID); 55 40 ?> 56 41 <entry> … … 75 60 <updated><?php echo mysql2date('D, d M Y H:i:s +0000', get_comment_time('Y-m-d H:i:s', true), false); ?></updated> 76 61 <published><?php echo mysql2date('D, d M Y H:i:s +0000', get_comment_time('Y-m-d H:i:s', true), false); ?></published> 77 62 78 <?php if (!empty($comment ->post_password) && $_COOKIE['wp-postpass'] != $comment->post_password) { ?>63 <?php if (!empty($comment_post->post_password) && $_COOKIE['wp-postpass'] != $comment_post->post_password) { ?> 79 64 <content type="html" xml:base="<?php comment_link(); ?>"><![CDATA[<?php echo get_the_password_form(); ?>]]></content> 80 65 <?php } else { ?> 81 66 <content type="html" xml:base="<?php comment_link(); ?>"><![CDATA[<?php comment_text(); ?>]]></content> -
wp-includes/feed-rss2-comments.php
13 13 while (have_posts()) : the_post(); 14 14 if ($i < 1) { 15 15 $i++; 16 } 16 17 ?> 17 18 <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> 18 19 <link><?php (is_single()) ? permalink_single_rss() : bloginfo_rss("url") ?></link> … … 21 22 <generator>http://wordpress.org/?v=<?php echo $wp_version ?></generator> 22 23 23 24 <?php 24 if (is_single() || is_page()) { 25 $comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_author_email, 26 comment_author_url, comment_date, comment_date_gmt, comment_content, comment_post_ID, 27 $wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments 28 LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE comment_post_ID = '" . get_the_ID() . "' 29 AND $wpdb->comments.comment_approved = '1' AND $wpdb->posts.post_status = 'publish' 30 AND post_date_gmt < '" . gmdate("Y-m-d H:i:59") . "' 31 ORDER BY comment_date_gmt ASC" ); 32 } else { // if no post id passed in, we'll just ue the last 10 comments. 33 $comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_author_email, 34 comment_author_url, comment_date, comment_date_gmt, comment_content, comment_post_ID, 35 $wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments 36 LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE $wpdb->posts.post_status = 'publish' 37 AND $wpdb->comments.comment_approved = '1' AND post_date_gmt < '" . gmdate("Y-m-d H:i:s") . "' 38 ORDER BY comment_date_gmt DESC LIMIT " . get_option('posts_per_rss') ); 39 } 40 // this line is WordPress' motor, do not delete it. 41 if ($comments) { 42 foreach ($comments as $comment) { 25 if ($wp_query->comments) { 26 foreach ($wp_query->comments as $comment) { 43 27 $GLOBALS['comment'] =& $comment; 44 // Some plugins may need to know the metadata45 // associated with this comment's post:28 29 $comment_post = get_post($comment->comment_post_ID); 46 30 get_post_custom($comment->comment_post_ID); 47 31 ?> 48 32 <item> … … 59 43 <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_comment_time('Y-m-d H:i:s', true), false); ?></pubDate> 60 44 <guid><?php comment_link() ?></guid> 61 45 <?php 62 if (!empty($comment ->post_password) && $_COOKIE['wp-postpass'] != $comment->post_password) {46 if (!empty($comment_post->post_password) && $_COOKIE['wp-postpass'] != $comment_post->post_password) { 63 47 ?> 64 48 <description><?php _e('Protected Comments: Please enter your password to view comments.'); ?></description> 65 49 <content:encoded><![CDATA[<?php echo get_the_password_form() ?>]]></content:encoded> … … 80 64 endwhile; endif; 81 65 ?> 82 66 </channel> 83 </rss> 67 </rss> 68 No newline at end of file -
wp-includes/feed.php
10 10 echo get_bloginfo_rss($show); 11 11 } 12 12 13 function get_wp_title_rss($sep = '»') { 14 $title = wp_title($sep, false); 15 $title = apply_filters('get_wp_title_rss', $title); 16 return $title; 17 } 13 18 14 19 function get_the_title_rss() { 15 20 $title = get_the_title(); -
wp-includes/query.php
265 265 var $current_post = -1; 266 266 var $in_the_loop = false; 267 267 var $post; 268 269 var $comments; 268 270 269 271 var $found_posts = 0; 270 272 var $max_num_pages = 0; … … 282 284 var $is_category = false; 283 285 var $is_search = false; 284 286 var $is_feed = false; 287 var $is_comment_feed = false; 285 288 var $is_trackback = false; 286 289 var $is_home = false; 287 290 var $is_404 = false; … … 305 308 $this->is_category = false; 306 309 $this->is_search = false; 307 310 $this->is_feed = false; 311 $this->is_comment_feed = false; 308 312 $this->is_trackback = false; 309 313 $this->is_home = false; 310 314 $this->is_404 = false; … … 512 516 if ('' != $qv['feed']) { 513 517 $this->is_feed = true; 514 518 } 519 520 if ($this->is_feed && (!empty($qv['withcomments']) || $this->is_single || $this->is_page)) { 521 $this->is_comment_feed = true; 522 } 515 523 516 524 if ('' != $qv['tb']) { 517 525 $this->is_trackback = true; … … 966 974 $limits = 'LIMIT ' . $pgstrt . $q['posts_per_page']; 967 975 } 968 976 } 977 978 // Comments feeds 979 if ($this->is_comment_feed && (($this->is_archive || $this->is_search) || (!$this->is_single && !$this->is_page))) { 980 if ($this->is_archive || $this->is_search) { 981 $cjoin = "LEFT JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) $join "; 982 $cwhere = "WHERE comment_approved = '1' $where"; 983 $cgroupby = "GROUP BY $wpdb->comments.comment_id"; 984 } elseif (!$this->is_single && !$this->is_page) { 985 $cjoin = "LEFT JOIN $wpdb->posts ON ( $wpdb->comments.comment_post_ID = $wpdb->posts.ID )"; 986 $cwhere = "WHERE post_status = 'publish' AND comment_approved = '1'"; 987 $cgroupby = ''; 988 } 989 990 $cjoin = apply_filters('comment_feed_join', $cjoin); 991 $cwhere = apply_filters('comment_feed_where', $cwhere); 992 $cgroupby = apply_filters('comment_feed_groupby', $cgroupby); 993 994 $this->comments = $wpdb->get_results("SELECT $distinct $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere $cgroupby ORDER BY comment_date_gmt DESC LIMIT " . get_settings('posts_per_rss')); 995 996 $post_ids = array(); 997 998 foreach ($this->comments as $comment) { 999 $post_ids[] = (int) $comment->comment_post_ID; 1000 } 1001 1002 $post_ids = join(',', $post_ids); 1003 $join = ''; 1004 $where = "AND $wpdb->posts.ID IN ($post_ids) "; 1005 } 969 1006 970 1007 // Apply post-paging filters on where and join. Only plugins that 971 1008 // manipulate paging queries should use these hooks. … … 986 1023 $this->request = apply_filters('posts_request', $request); 987 1024 988 1025 $this->posts = $wpdb->get_results($this->request); 1026 1027 if ($this->is_comment_feed && ($this->is_single || $this->is_page)) { 1028 $cjoin = apply_filters('comment_feed_join', ''); 1029 $cwhere = apply_filters('comment_feed_where', "WHERE comment_post_ID = {$this->posts[0]->ID} AND comment_approved = '1'"); 1030 $comments_request = "SELECT $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere ORDER BY comment_date_gmt DESC LIMIT " . get_settings('posts_per_rss'); 1031 $this->comments = $wpdb->get_results($comments_request); 1032 } 1033 989 1034 if ( !empty($limits) ) { 990 1035 $found_posts_query = apply_filters( 'found_posts_query', 'SELECT FOUND_ROWS()' ); 991 1036 $this->found_posts = $wpdb->get_var( $found_posts_query ); 992 1037 $this->found_posts = apply_filters( 'found_posts', $this->found_posts ); 993 1038 $this->max_num_pages = ceil($this->found_posts / $q['posts_per_page']); 994 1039 } 1040 995 1041 // Check post status to determine if post should be displayed. 996 1042 if ( !empty($this->posts) && ($this->is_single || $this->is_page) ) { 997 1043 $status = get_post_status($this->posts[0]);