Changeset 7775
- Timestamp:
- 04/22/2008 09:26:01 PM (18 years ago)
- Location:
- trunk/wp-admin
- Files:
-
- 2 edited
-
edit-post-rows.php (modified) (2 diffs)
-
includes/comment.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/edit-post-rows.php
r7640 r7775 23 23 $bgcolor = ''; 24 24 add_filter('the_title','wp_specialchars'); 25 26 // Create array of post IDs. 27 $post_ids = array(); 28 foreach ( $wp_query->posts as $a_post ) 29 $post_ids[] = $a_post->ID; 30 31 $comment_pending_count = get_pending_comments_num($post_ids); 32 25 33 while (have_posts()) : the_post(); 26 34 $class = 'alternate' == $class ? '' : 'alternate'; … … 114 122 <td class="num"><div class="post-com-count-wrapper"> 115 123 <?php 116 $left = get_pending_comments_num( $post->ID );124 $left = isset($comment_pending_count) ? $comment_pending_count[$post->ID] : 0; 117 125 $pending_phrase = sprintf( __('%s pending'), number_format( $left ) ); 118 126 if ( $left ) -
trunk/wp-admin/includes/comment.php
r7645 r7775 67 67 function get_pending_comments_num( $post_id ) { 68 68 global $wpdb; 69 $post_id = (int) $post_id; 70 $pending = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '0'", $post_id) ); 71 return $pending; 69 70 $single = false; 71 if ( !is_array($post_id) ) { 72 $post_id = (array) $post_id; 73 $single = true; 74 } 75 $post_id = array_map('intval', $post_id); 76 $post_id = "'" . implode("', '", $post_id) . "'"; 77 78 $pending = $wpdb->get_results( "SELECT comment_post_ID, COUNT(comment_ID) as num_comments FROM $wpdb->comments WHERE comment_post_ID IN ( $post_id ) AND comment_approved = '0' GROUP BY comment_post_ID", ARRAY_N ); 79 80 if ( empty($pending) ) 81 return 0; 82 83 if ( $single ) 84 return $pending[0][1]; 85 86 $pending_keyed = array(); 87 foreach ( $pending as $pend ) 88 $pending_keyed[$pend[0]] = $pend[1]; 89 90 return $pending_keyed; 72 91 } 73 92
Note: See TracChangeset
for help on using the changeset viewer.