Make WordPress Core

Changeset 2685


Ignore:
Timestamp:
07/02/2005 11:35:36 PM (20 years ago)
Author:
matt
Message:

Indentation and correct response link when no comments, fixes #1408

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/comment-functions.php

    r2575 r2685  
    9090
    9191function comments_popup_link($zero='No Comments', $one='1 Comment', $more='% Comments', $CSSclass='', $none='Comments Off') {
    92     global $id, $wpcommentspopupfile, $wpcommentsjavascript, $post, $wpdb;
    93     global $comment_count_cache;
    94 
     92    global $id, $wpcommentspopupfile, $wpcommentsjavascript, $post, $wpdb;
     93    global $comment_count_cache;
     94   
    9595    if (! is_single() && ! is_page()) {
    96     if ( !isset($comment_count_cache[$id]))
    97             $comment_count_cache[$id] = $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved = '1';");
    98 
    99         $number = $comment_count_cache[$id];
    100 
    101     if (0 == $number && 'closed' == $post->comment_status && 'closed' == $post->ping_status) {
    102         echo $none;
    103         return;
    104     } else {
    105         if (!empty($post->post_password)) { // if there's a password
    106             if ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) {  // and it doesn't match the cookie
    107                 echo('Enter your password to view comments');
    108                 return;
    109             }
    110         }
    111         echo '<a href="';
    112         if ($wpcommentsjavascript) {
    113                     if ( empty($wpcommentspopupfile) )
    114                         $home = get_settings('home');
    115                     else
    116                         $home = get_settings('siteurl');
    117                     echo $home . '/' . $wpcommentspopupfile.'?comments_popup='.$id;
    118                     echo '" onclick="wpopen(this.href); return false"';
    119         } else {
    120             // if comments_popup_script() is not in the template, display simple comment link
    121             comments_link();
    122             echo '"';
    123         }
    124         if (!empty($CSSclass)) {
    125             echo ' class="'.$CSSclass.'"';
    126         }
    127         echo '>';
    128         comments_number($zero, $one, $more, $number);
    129         echo '</a>';
    130     }
     96    if ( !isset($comment_count_cache[$id]) )
     97        $comment_count_cache[$id] = $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved = '1';");
     98   
     99    $number = $comment_count_cache[$id];
     100   
     101    if (0 == $number && 'closed' == $post->comment_status && 'closed' == $post->ping_status) {
     102        echo $none;
     103        return;
     104    } else {
     105        if (!empty($post->post_password)) { // if there's a password
     106            if ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) {  // and it doesn't match the cookie
     107                echo('Enter your password to view comments');
     108                return;
     109            }
     110        }
     111        echo '<a href="';
     112        if ($wpcommentsjavascript) {
     113            if ( empty($wpcommentspopupfile) )
     114                $home = get_settings('home');
     115            else
     116                $home = get_settings('siteurl');
     117            echo $home . '/' . $wpcommentspopupfile.'?comments_popup='.$id;
     118            echo '" onclick="wpopen(this.href); return false"';
     119        } else { // if comments_popup_script() is not in the template, display simple comment link
     120            if ( 0 == $number )
     121                echo get_permalink() . '#respond';
     122            else
     123                comments_link();
     124            echo '"';
     125        }
     126        if (!empty($CSSclass)) {
     127            echo ' class="'.$CSSclass.'"';
     128        }
     129        echo '>';
     130        comments_number($zero, $one, $more, $number);
     131        echo '</a>';
     132    }
    131133    }
    132134}
Note: See TracChangeset for help on using the changeset viewer.