diff --git a/wp-includes/comment-functions.php b/wp-includes/comment-functions.php index adaed8ac02..ea707ea069 100644 --- a/wp-includes/comment-functions.php +++ b/wp-includes/comment-functions.php @@ -89,45 +89,47 @@ function comments_popup_script($width=400, $height=400, $file='') { } function comments_popup_link($zero='No Comments', $one='1 Comment', $more='% Comments', $CSSclass='', $none='Comments Off') { - global $id, $wpcommentspopupfile, $wpcommentsjavascript, $post, $wpdb; - global $comment_count_cache; - + global $id, $wpcommentspopupfile, $wpcommentsjavascript, $post, $wpdb; + global $comment_count_cache; + if (! is_single() && ! is_page()) { - if ( !isset($comment_count_cache[$id])) - $comment_count_cache[$id] = $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved = '1';"); - - $number = $comment_count_cache[$id]; - - if (0 == $number && 'closed' == $post->comment_status && 'closed' == $post->ping_status) { - echo $none; - return; - } else { - if (!empty($post->post_password)) { // if there's a password - if ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) { // and it doesn't match the cookie - echo('Enter your password to view comments'); - return; - } - } - echo ''; - comments_number($zero, $one, $more, $number); - echo ''; - } + if ( !isset($comment_count_cache[$id]) ) + $comment_count_cache[$id] = $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved = '1';"); + + $number = $comment_count_cache[$id]; + + if (0 == $number && 'closed' == $post->comment_status && 'closed' == $post->ping_status) { + echo $none; + return; + } else { + if (!empty($post->post_password)) { // if there's a password + if ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) { // and it doesn't match the cookie + echo('Enter your password to view comments'); + return; + } + } + echo ''; + comments_number($zero, $one, $more, $number); + echo ''; + } } }