Consolidate get_pending_comments_num() queries. see #6770

git-svn-id: http://svn.automattic.com/wordpress/trunk@7775 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan
2008-04-22 21:26:01 +00:00
parent bf40169710
commit 444391eaff
2 changed files with 31 additions and 4 deletions

View File

@@ -22,6 +22,14 @@
if ( have_posts() ) {
$bgcolor = '';
add_filter('the_title','wp_specialchars');
// Create array of post IDs.
$post_ids = array();
foreach ( $wp_query->posts as $a_post )
$post_ids[] = $a_post->ID;
$comment_pending_count = get_pending_comments_num($post_ids);
while (have_posts()) : the_post();
$class = 'alternate' == $class ? '' : 'alternate';
global $current_user;
@@ -113,7 +121,7 @@ foreach($posts_columns as $column_name=>$column_display_name) {
?>
<td class="num"><div class="post-com-count-wrapper">
<?php
$left = get_pending_comments_num( $post->ID );
$left = isset($comment_pending_count) ? $comment_pending_count[$post->ID] : 0;
$pending_phrase = sprintf( __('%s pending'), number_format( $left ) );
if ( $left )
echo '<strong>';