diff --git a/b2-include/b2template.functions.php b/b2-include/b2template.functions.php index 56d6e567ab..ca73cfbe32 100644 --- a/b2-include/b2template.functions.php +++ b/b2-include/b2template.functions.php @@ -912,24 +912,30 @@ function comments_popup_script($width=400, $height=400, $file='b2commentspopup.p echo $javascript; } -function comments_popup_link($zero='No Comments', $one='1 Comment', $more='% Comments', $CSSclass='') { - global $id, $b2commentspopupfile, $b2commentsjavascript; +function comments_popup_link($zero='No Comments', $one='1 Comment', $more='% Comments', $CSSclass='', $none='Comments Off') { + global $id, $b2commentspopupfile, $b2commentsjavascript, $post, $wpdb, $tablecomments; global $querystring_start, $querystring_equal, $querystring_separator, $siteurl; - echo "get_var("SELECT COUNT(*) FROM $tablecomments WHERE comment_post_ID = $id"); + if (0 == $number && 'closed' == $post->comment_status) { + echo $none; + return; } else { - // if comments_popup_script() is not in the template, display simple comment link - comments_link(); - echo '"'; + echo "'; + comments_number($zero, $one, $more); + echo ''; } - if (!empty($CSSclass)) { - echo ' class="'.$CSSclass.'"'; - } - echo '>'; - comments_number($zero, $one, $more); - echo ''; } function comment_ID() {