Changeset 12715 for trunk/wp-admin/includes/comment.php
- Timestamp:
- 01/12/2010 10:38:26 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/wp-admin/includes/comment.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/comment.php
r12595 r12715 110 110 $single = false; 111 111 if ( !is_array($post_id) ) { 112 $post_id = (array) $post_id;112 $post_id_array = (array) $post_id; 113 113 $single = true; 114 } else { 115 $post_id_array = $post_id; 114 116 } 115 $post_id = array_map('intval', $post_id);116 $post_id = "'" . implode("', '", $post_id) . "'";117 $post_id_array = array_map('intval', $post_id_array); 118 $post_id_in = "'" . implode("', '", $post_id_array) . "'"; 117 119 118 $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);120 $pending = $wpdb->get_results( "SELECT comment_post_ID, COUNT(comment_ID) as num_comments FROM $wpdb->comments WHERE comment_post_ID IN ( $post_id_in ) AND comment_approved = '0' GROUP BY comment_post_ID", ARRAY_A ); 119 121 120 if ( empty($pending) ) 121 return 0; 122 if ( $single ) { 123 if ( empty($pending) ) 124 return 0; 125 else 126 return absint($pending[0]['num_comments']); 127 } 128 129 $pending_keyed = array(); 130 131 // Default to zero pending for all posts in request 132 foreach ( $post_id_array as $id ) 133 $pending_keyed[$id] = 0; 122 134 123 if ( $single ) 124 return $pending[0][1]; 125 126 $pending_keyed = array(); 127 foreach ( $pending as $pend ) 128 $pending_keyed[$pend[0]] = $pend[1]; 135 if ( !empty($pending) ) 136 foreach ( $pending as $pend ) 137 $pending_keyed[$pend['comment_post_ID']] = absint($pend['num_comments']); 129 138 130 139 return $pending_keyed;
Note: See TracChangeset
for help on using the changeset viewer.