Ticket #2485: 2485.2.diff
File 2485.2.diff, 11.8 KB (added by , 18 years ago) |
---|
-
wp-includes/comment-template.php
289 289 $email_db = $wpdb->escape($comment_author_email); 290 290 $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post->ID' AND ( comment_approved = '1' OR ( comment_author = '$author_db' AND comment_author_email = '$email_db' AND comment_approved = '0' ) ) ORDER BY comment_date"); 291 291 } 292 293 // keep $comments for legacy's sake (remember $table*? ;) ) 294 $comments = $wp_query->comments = apply_filters( 'comments_array', $comments, $post->ID ); 295 $wp_query->comment_count = count($wp_query->comment_count); 292 296 293 $comments = apply_filters( 'comments_array', $comments, $post->ID );294 295 297 define('COMMENTS_TEMPLATE', true); 296 298 $include = apply_filters('comments_template', TEMPLATEPATH . $file ); 297 299 if ( file_exists( $include ) ) -
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
250 250 } 251 251 252 252 /* 253 * Comments loop. 254 */ 255 256 function have_comments() { 257 global $wp_query; 258 259 return $wp_query->have_comments(); 260 } 261 262 function the_comment() { 263 global $wp_query; 264 265 return $wp_query->the_comment(); 266 } 267 268 /* 253 269 * WP_Query 254 270 */ 255 271 … … 265 281 var $current_post = -1; 266 282 var $in_the_loop = false; 267 283 var $post; 284 285 var $comments; 286 var $comments_count = 0; 287 var $current_comment = -1; 288 var $comment; 268 289 269 290 var $found_posts = 0; 270 291 var $max_num_pages = 0; … … 282 303 var $is_category = false; 283 304 var $is_search = false; 284 305 var $is_feed = false; 306 var $is_comment_feed = false; 285 307 var $is_trackback = false; 286 308 var $is_home = false; 287 309 var $is_404 = false; … … 305 327 $this->is_category = false; 306 328 $this->is_search = false; 307 329 $this->is_feed = false; 330 $this->is_comment_feed = false; 308 331 $this->is_trackback = false; 309 332 $this->is_home = false; 310 333 $this->is_404 = false; … … 318 341 319 342 function init () { 320 343 unset($this->posts); 344 unset($this->comments); 321 345 unset($this->query); 322 346 $this->query_vars = array(); 323 347 unset($this->queried_object); … … 512 536 if ('' != $qv['feed']) { 513 537 $this->is_feed = true; 514 538 } 539 540 if ($this->is_feed && (!empty($qv['withcomments']) || $this->is_single || $this->is_page)) { 541 $this->is_comment_feed = true; 542 } 515 543 516 544 if ('' != $qv['tb']) { 517 545 $this->is_trackback = true; … … 966 994 $limits = 'LIMIT ' . $pgstrt . $q['posts_per_page']; 967 995 } 968 996 } 997 998 // Comments feeds 999 if ($this->is_comment_feed && (($this->is_archive || $this->is_search) || (!$this->is_single && !$this->is_page))) { 1000 if ($this->is_archive || $this->is_search) { 1001 $cjoin = "LEFT JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) $join "; 1002 $cwhere = "WHERE comment_approved = '1' $where"; 1003 $cgroupby = "GROUP BY $wpdb->comments.comment_id"; 1004 } elseif (!$this->is_single && !$this->is_page) { 1005 $cjoin = "LEFT JOIN $wpdb->posts ON ( $wpdb->comments.comment_post_ID = $wpdb->posts.ID )"; 1006 $cwhere = "WHERE post_status = 'publish' AND comment_approved = '1'"; 1007 $cgroupby = ''; 1008 } 1009 1010 $cjoin = apply_filters('comment_feed_join', $cjoin); 1011 $cwhere = apply_filters('comment_feed_where', $cwhere); 1012 $cgroupby = apply_filters('comment_feed_groupby', $cgroupby); 1013 1014 $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')); 1015 1016 $post_ids = array(); 1017 1018 foreach ($this->comments as $comment) { 1019 $post_ids[] = (int) $comment->comment_post_ID; 1020 } 1021 1022 $post_ids = join(',', $post_ids); 1023 $join = ''; 1024 $where = "AND $wpdb->posts.ID IN ($post_ids) "; 1025 } 969 1026 970 1027 // Apply post-paging filters on where and join. Only plugins that 971 1028 // manipulate paging queries should use these hooks. … … 986 1043 $this->request = apply_filters('posts_request', $request); 987 1044 988 1045 $this->posts = $wpdb->get_results($this->request); 1046 1047 if ($this->is_comment_feed && ($this->is_single || $this->is_page)) { 1048 $cjoin = apply_filters('comment_feed_join', ''); 1049 $cwhere = apply_filters('comment_feed_where', "WHERE comment_post_ID = {$this->posts[0]->ID} AND comment_approved = '1'"); 1050 $comments_request = "SELECT $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere ORDER BY comment_date_gmt DESC LIMIT " . get_settings('posts_per_rss'); 1051 $this->comments = $wpdb->get_results($comments_request); 1052 } 1053 989 1054 if ( !empty($limits) ) { 990 1055 $found_posts_query = apply_filters( 'found_posts_query', 'SELECT FOUND_ROWS()' ); 991 1056 $this->found_posts = $wpdb->get_var( $found_posts_query ); 992 1057 $this->found_posts = apply_filters( 'found_posts', $this->found_posts ); 993 1058 $this->max_num_pages = ceil($this->found_posts / $q['posts_per_page']); 994 1059 } 1060 995 1061 // Check post status to determine if post should be displayed. 996 1062 if ( !empty($this->posts) && ($this->is_single || $this->is_page) ) { 997 1063 $status = get_post_status($this->posts[0]); … … 1071 1137 $this->post = $this->posts[0]; 1072 1138 } 1073 1139 } 1140 1141 function next_comment() { 1142 $this->current_comment++; 1143 1144 $this->comment = $this->comments[$this->current_comment]; 1145 return $this->comment; 1146 } 1147 1148 function the_comment() { 1149 global $comment; 1150 1151 $comment = $this->next_comment(); 1152 1153 if ($this->current_comment == 0) { 1154 do_action('comment_loop_start'); 1155 } 1156 } 1157 1158 function have_comments() { 1159 if ($this->current_comment + 1 < $this->comment_count) { 1160 return true; 1161 } elseif ($this->current_comment + 1 == $this->comment_count) { 1162 $this->rewind_comments(); 1163 } 1164 1165 return false; 1166 } 1167 1168 function rewind_comments() { 1169 $this->current_comment = -1; 1170 if ($this->comment_count > 0) { 1171 $this->comment = $this->comments[0]; 1172 } 1173 } 1074 1174 1075 1175 function &query($query) { 1076 1176 $this->parse_query($query);