Changeset 6726 for trunk/wp-includes/comment.php
- Timestamp:
- 02/05/2008 06:47:27 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/comment.php
r6668 r6726 245 245 } 246 246 247 $totals = (array) $wpdb->get_results(" 248 SELECT comment_approved, COUNT( * ) AS total 249 FROM {$wpdb->comments} 250 {$where} 251 GROUP BY comment_approved 247 $totals = (array) $wpdb->get_results(" 248 SELECT comment_approved, COUNT( * ) AS total 249 FROM {$wpdb->comments} 250 {$where} 251 GROUP BY comment_approved 252 252 ", ARRAY_A); 253 253 254 $comment_count = array( 255 "approved" => 0, 254 $comment_count = array( 255 "approved" => 0, 256 256 "awaiting_moderation" => 0, 257 257 "spam" => 0, 258 258 "total_comments" => 0 259 ); 260 261 foreach ( $totals as $row ) { 262 switch ( $row['comment_approved'] ) { 263 case 'spam': 264 $comment_count['spam'] = $row['total']; 259 ); 260 261 foreach ( $totals as $row ) { 262 switch ( $row['comment_approved'] ) { 263 case 'spam': 264 $comment_count['spam'] = $row['total']; 265 265 $comment_count["total_comments"] += $row['total']; 266 break; 267 case 1: 268 $comment_count['approved'] = $row['total']; 266 break; 267 case 1: 268 $comment_count['approved'] = $row['total']; 269 269 $comment_count['total_comments'] += $row['total']; 270 break; 270 break; 271 271 case 0: 272 272 $comment_count['awaiting_moderation'] = $row['total']; … … 789 789 function wp_defer_comment_counting($defer=null) { 790 790 static $_defer = false; 791 791 792 792 if ( is_bool($defer) ) { 793 793 $_defer = $defer; … … 796 796 wp_update_comment_count( null, true ); 797 797 } 798 798 799 799 return $_defer; 800 800 } … … 820 820 function wp_update_comment_count($post_id, $do_deferred=false) { 821 821 static $_deferred = array(); 822 822 823 823 if ( $do_deferred ) { 824 824 $_deferred = array_unique($_deferred); … … 828 828 } 829 829 } 830 830 831 831 if ( wp_defer_comment_counting() ) { 832 832 $_deferred[] = $post_id; … … 836 836 return wp_update_comment_count_now($post_id); 837 837 } 838 838 839 839 } 840 840 … … 848 848 * 849 849 * @param int $post_id Post ID 850 * @return bool False on '0' $post_id or if post with ID does not exist. True on success. 850 * @return bool False on '0' $post_id or if post with ID does not exist. True on success. 851 851 */ 852 852 function wp_update_comment_count_now($post_id) {
Note: See TracChangeset
for help on using the changeset viewer.