Changeset 7775 for trunk/wp-admin/includes/comment.php
- Timestamp:
- 04/22/2008 09:26:01 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/wp-admin/includes/comment.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
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.