Reply
A new Threaded Wordpress Comments Plugin
Old 04-29-2008, 09:59 PM A new Threaded Wordpress Comments Plugin
jamestl2's Avatar
Hey.....

Posts: 1,576
Name: James, if you couldn't tell from my username
I've been working on trying to code this sort of feature into my blog all day for the past few days, and with the plugins I've tried (Brian's Threaded Comments, Ajax, etc.), I've been getting errors everywhere, no current theme CSS, etc. It's been really frustrating . (and the WP.org forums haven't been much help either )

Basically what I wanted to do was have a system similar to what those plugins offer, but..... I want:
  • Just the ability to indent a few levels, replying to the above comment (It'd be nice if the form could move too, like with the BTC plugin)
  • To use my theme's current comment stylesheet (I already like the way my comment styles and colors look)
  • And I do NOT want a new comments.php page. (which is what all those WP plugins seem to come with)
I was thinking about just taking the code from each of the files Brian's TC plugin offers, and just making one whole php page plugin out of it, but I'd have no idea what to move to where.

Here's Brian's Threaded Comments' Plugin's code:
PHP Code:
<?php
/*
Plugin Name: Brian's Threaded Comments
Plugin URI: http://meidell.dk/threadedcomments/
Version: 1.5.18
Description: This gives you threaded comments and a "wandering" comment form.
Author: Brian Meidell
Author URI: http://meidell.dk/

Changelog:
   version 1.5:     Released for WP1.5
   version 1.5.1:    Added error message for missing form field
   version 1.5.2:    Fixed stupid bug from last release    
   version 1.5.3:    Much more comprehensive error messages to help with diagnosis of problems.
                  Added login patch from Salil Deshpande.
                  Added auto-integration with subscribe-to-comments.
   version 1.5.4:    A fix to Salil Deshpandes patch - proper login required code, thanks to Salil again.
                  Renamed maybe_add_column to prevent conflicts with other plugins.
   version 1.5.5:    Added an options panel called "Threaded Comments" for the few settings
   version 1.5.6:    Changed comment_reply_ID form field to use comment_form hook instead, making it 
                  compatible with other plugins using this hook. Thanks to Martey of www.marteydodoo.com for pointing this out.
   version 1.5.7: Included bugfix from Zhou Qingbo
   version 1.5.8:    Fixed php opening tags to be verbose, as suggested by Michael Carrino
   version 1.5.9:    Changed plugin to use only existing database columns, and added migration code from older versions
   version 1.5.10: Changed nesting levels setting so it correctly reflects the nesting level (it was one off)
   version 1.5.11: Fixed taborder. Thanks to RJ Matthis (http://blog.reformatthis.com) / Ryan J Parker (http://www.ryanjparker.net)
   version 1.5.12: Fixed missing php opening tag
   version 1.5.15: Fixed closed/open comments bug and deploy script
   version 1.5.16: Big thanks to NSpeaks - Fixed issues mentioned in this post: http://nspeaks.com/149/hacking-brian’s-threaded-comments-plugin/
   version 1.5.17: Fixes from this article implemented: http://www.howtospoter.com/web-20/wordpress/fixing-brians-threaded-comments-plugin - thanks to Alex Sysoef
   version 1.5.18: Added gravatar support for wp2.5 and myavatars, thanks to Alex Sysoef
*/

 
/**
 * Images
 */
$images = array();
$images['subscribed.png'] = "iVBORw0KGgoAAAANSUhEUgAAABUAAAAICAMAAAAhgUThAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAAGUExURai0vvP8+20m9Z0AAAACdFJOU/8A5bcwSgAAAE5JREFUeNpiYAQBBhBGAgABxAARZYBgRigPIIBgchAI1cgAEEBwFWDlUNMYAAIIWS3cIAaAAEIyFy7OyAAQQAxIbkDYBhBAcCaKywACDAAgyABfpZamZwAAAABJRU5ErkJggg==";
$images['subthread.png'] = "iVBORw0KGgoAAAANSUhEUgAAAA0AAAANCAYAAAEF7NTqAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAACmSURBVHjaYvz//z8DCAAEEBMDFAAEECNMBCCA4CIAAQQXgQGAAGJiQAMAAYSiAiCAGIEYzgMIIBSlAAGEogwggBignP/oGCQOEEAYNiADgADCKwkQQBiOhQGAAGIByzIyosgCFTMCBBBOHQABhFMHQADh1AEQQDh1AAQQTh0AAYRTAh8ACCBEzKBZhY8PEEBMDGQAgAAiSxNAAJGlCSCAyAoIgAADAEniPAbcSIg9AAAAAElFTkSuQmCC";
$images['subthread-open.png'] = "iVBORw0KGgoAAAANSUhEUgAAAA0AAAANCAYAAAEF7NTqAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAACoSURBVHjaYvz//z8DCAAEEBMDFAAEECNMBCCA4CIAAQQXgQGAAGJiQAMAAYSiAiCAQOg/VOA/QAChKAUIIBRlAAHEAFOCjkHiAAGEYQMyAAggvJIAAYThFBgACCAWsCwj4380dzICBBBOHQABhFMHQADh1AEQQDh1AAQQTh0AAYRTAh8ACCBEzKBZhWE6kjxAADExkAEAAogsTQABRJYmgAAiKyAAAgwA3YE+/1F5tWAAAAAASUVORK5CYII=";
$images['spacer.png'] = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQI12NgYGBgAAAABQABXvMqOgAAAABJRU5ErkJggg==";

if(isset(
$_GET['image']))
{
    
header("content-type: image/png");
    print 
base64_decode($images[$_GET['image']]);
    exit;
}

function 
btc_options_page()
{
    global 
$wpdb;
?>
 
<div class="wrap"> 
<?php 
    $col 
$wpdb->get_col("DESCRIBE {$wpdb->comments} comment_reply_ID");
    
$col count$col );
?>
  <?php if( $col && !get_option("btc_migrated") ) { ?>
  <h2><?php _e('Upgrade Threading'); ?></h2>
  <form name="form2" method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
    <table width="100%" cellspacing="2" cellpadding="5" class="editform"> 
      <tr valign="top"> 
        <th width="33%" scope="row"><?php _e('Migrate Threading'?></th> 
        <td>
    <?php if( isset($_REQUEST['btc_upgrade']) ) { 
         
$wpdb->query("UPDATE {$wpdb->comments} SET comment_parent=comment_reply_ID WHERE comment_parent = 0");
        
update_option("btc_migrated");
    
?>
           Done migrating comments.
    <?php } else { ?>
      <input type="submit" name="btc_upgrade" value="Migrate now" />
    <br />
    Migrate threading from older version of Brians Threaded Comments plugin. 
    <?php
    
?>
    </td> 
      </tr> 
      </table>
  </form>
  <?php ?>
  <h2><?php _e('Brians Threaded Comments Options'?></h2> 
  <form name="form1" method="post" action="options.php"> 
    <input type="hidden" name="action" value="update" /> <input type="hidden" name="page_options" value="btc_nestinglevels,btc_shrinkby,btc_customtarget,btc_separate_trackbacks" /> 
    <table width="100%" cellspacing="2" cellpadding="5" class="editform"> 
      <tr valign="top"> 
        <th width="33%" scope="row"><?php _e('Max Nesting Levels:'?></th> 
        <td><input name="btc_nestinglevels" type="text" id="btc_nestinglevels" value="<?php form_option('btc_nestinglevels'); ?>" size="5" /></td> 
      </tr> 
      <tr valign="top"> 
        <th scope="row"><?php _e('Shrink Font By %:'?></th> 
        <td><input name="btc_shrinkby" type="text" id="btc_shrinkby" value="<?php form_option('btc_shrinkby'); ?>" size="5" />
        <br />
<?php _e('Enables shrinking the font by n percent per nesting level. Recommended is 0%-2%.'?></td> 
      </tr> 
      <tr valign="top"> 
        <th width="33%" scope="row"><?php _e('Custom Comments Target:'?></th> 
        <td><input name="btc_customtarget" type="text" id="btc_customtarget" value="<?php form_option('btc_customtarget'); ?>" size="40" />
    <br /> 
<?php _e('If you have renamed your wp-comments-post.php file to prevent comment spam, set the filename here (relative to the site root).'?></td> 
      </tr> 
      <tr valign="top"> 
        <th width="33%" scope="row"><?php _e('Separate Trackbacks:'?></th> 
          <td><input name="btc_separate_trackbacks" type="checkbox" id="btc_separate_trackbacks" <?php checked('1'get_settings('btc_separate_trackbacks')); ?> value="1" size="40" />
      </tr> 
</table>

    </fieldset> 
    <p class="submit">
      <input type="submit" name="Submit" value="<?php _e('Update Options'?> &raquo;" />
    </p>
  </form> 
</div> 
<?php 
    
include("admin-footer.php");
    exit;
}
    
/**
 * Settings   
 */
 
$shrinkby get_option("btc_shrinkby");      //    Each level of nesting makes the font size 2% smaller
 
$btc_cutoff_level get_option("btc_nestinglevels")-1;         //     At what level of nesting should we flatten the tree

function bnc_altertable()
{
    global 
$tablecomments;
    if(
get_option("btc_shrinkby") == false)
        
add_option("btc_shrinkby"0"Shrink percentage per nesting level for Brians Threaded Comments");
    if(
get_option("btc_nestinglevels") == false)
        
add_option("btc_nestinglevels"3"Max numver of nesting levels for Brians Threaded Comments");
    if(
get_option("btc_customtarget") == false)
        
add_option("btc_customtarget""wp-comments-post.php""Custom post target script name for Brians Threaded Comments");
    if(
get_option("btc_separate_trackbacks") === false)
        
add_option("btc_separate_trackbacks"'1'"Separate trackbacks form comments for Brians Threaded Comments");
}

function 
briansthreadedcomments() {
global 
$shrinkby;
if (!(
$withcomments) && ($single)) return;

// You can safely delete the single line below if your threaded comments are up and running
    
bnc_altertable();
    
?>
<script language="javascript" type="text/javascript">
<!--
        function collapseThread( theId ) {
            var comment = document.getElementById(theId);
            if(!comment)
            {
                alert("ERROR:\nThe document structure is different\nfrom what Threaded Comments expects.\nYou are missing the element '"+theId+"'");
                return;
            }
            var theBody = findBody(comment);
            if(comment.className.indexOf("collapsed") > -1) {
                comment.className = comment.className.replace(" collapsed", "");;
            } else {
                comment.className += " collapsed";
            }
        }

        function expandThread( theId ) {
            var comment = document.getElementById(theId);
            if(!comment)
            {
                alert("ERROR:\nThe document structure is different\nfrom what Threaded Comments expects.\nYou are missing the element '"+theId+"'");
                return;
            }
            var theBody = findBody(comment);
            if(comment.className.indexOf("collapsed") > -1) {
                comment.className = comment.className.replace(" collapsed", "");;
            } 
        }
        
        function findBody(el)
        {
            var divs = el.getElementsByTagName("div");
            var ret;
            for(var i = 0; i < divs.length; ++i) {
                if(divs.item(i).className.indexOf("body") > -1)
                    return divs.item(i);
            }
            return false;
        }
    
        function onAddComment() {
            //checkDocumentIntegrity();
            var el = document.getElementById("commentform");
            // Future release: Check if form is filled correctly and mark the form fields.
            el.submit();
        }
        
        function moveAddCommentBelow(theId, threadId, collapse)
        {
            expandThread( theId );
            var addComment = document.getElementById("addcomment");
            if(!addComment)
            {
                  alert("ERROR:\nThreaded Comments can't find the 'addcomment' div.\nThis is probably because you have changed\nthe comments.php file.\nMake sure there is a tag around the form\nthat has the id 'addcomment'"); 
                return
            }
            var comment = document.getElementById(theId);
            if(collapse)
            {
                for(var i = 0; i < comment.childNodes.length; ++i) {
                    var c = comment.childNodes.item(i);
                    if(typeof(c.className) == "string" && c.className.indexOf("collapsed")<0) {
                        c.className += " collapsed";
                    }
                }
            }
            addComment.parentNode.removeChild(addComment);

            comment.appendChild(addComment);
            if(comment.className.indexOf("alt")>-1) {
                addComment.className = addComment.className.replace(" alt", "");                    
            } else {
                addComment.className += " alt";
            }
                var replyId = document.getElementById("comment_reply_ID");
            if(replyId == null)
            {
                alert("Brians Threaded Comments Error:\nThere is no hidden form field called\n'comment_reply_ID'. This is probably because you\nchanged the comments.php file and forgot\nto include the field. Please take a look\nat the original comments.php and copy the\nform field over.");
            }
            replyId.value = threadId;
            var reRootElement = document.getElementById("reroot");
            if(reRootElement == null)
            {
                alert("Brians Threaded Comments Error:\nThere is no anchor tag called 'reroot' where\nthe comment form starts.\nPlease compare your comments.php to the original\ncomments.php and copy the reroot anchor tag over.");
            }
            reRootElement.style.display = "block";
            var aTags = comment.getElementsByTagName("A");
            var anc = aTags.item(0).id;
            //document.location.href = "#"+anc;
            document.getElementById("comment").focus();
        }

        function checkDocumentIntegrity()
        {
            str = "";
            
            str += checkElement("reroot","div tag");
            str += checkElement("addcomment", "div tag");
            str += checkElement("comment_reply_ID", "hidden form field");
            str += checkElement("content", "div tag");
            str += checkElement("comment", "textfield");
            str += checkElement("addcommentanchor", "anchor tag");
            
            if(str != "")
            {
                str = "Brian's Threaded Comments are missing some of the elements that are required for it to function correctly.\nThis is probably the because you have changed the original comments.php that was included with the plugin.\n\nThese are the errors:\n" + str;
                str += "\nYou should compare your comments.php with the original comments.php and make sure the required elements have not been removed.";

                alert(str);
            }
        }
               
        function checkElement(theId, elDesc)
        {
            var el = document.getElementById(theId);
            if(!el)
            {
                if(elDesc == null)
                    elDesc = "element";
                return "- The "+elDesc+" with the ID '" +theId + "' is missing\n"; 
            }
            else 
                return "";
        }
        
        function reRoot()
        {
            var addComment = document.getElementById("addcomment");            
            var reRootElement = document.getElementById("reroot");
            reRootElement.style.display = "none";
            var content = document.getElementById("content-main");
            if( !content )
                content = document.getElementById("content");
            if( content )
            {
                addComment.parentNode.removeChild(addComment);
                content.appendChild(addComment);
            }
            addComment.className = addComment.className.replace(" alt", "");
            document.location.href = "#addcommentanchor";
            document.getElementById("comment").focus();                
            document.getElementById("comment_reply_ID").value = "0";
        }            
        
        function changeCommentSize(d)
        {
            var el = document.getElementById("comment");
            var height = parseInt(el.style.height);
            if(!height && el.offsetHeight)
                height = el.offsetHeight;
            height += d;
            if(height < 20) 
                height = 20;
            el.style.height = height+"px";
        }        
-->
</script>
<style type="text/css">
.comment 
{
    position:                 relative;
    margin:                    3px;
    margin-top:                6px;
/*    border:                 1px solid #666; */
    padding:                4px 4px 4px 8px;
<?php if($shrinkby 0) { ?>
    font-size:                <?php echo (100-$shrinkby); ?>%;
<?php ?>
    background-color:        #fff;
}

.odd
{
    background-color: #f8f8f8;
}

.comment div {
    position:                 relative;
}

.comment .comment img
{
    margin:                 0px;
}

.comment .collapseicon 
{
    width:                     13px;
    height:                 13px;
    overflow:                hidden;
    background-image:         url(<?php echo get_settings('siteurl'); ?>/wp-content/plugins/briansthreadedcomments.php?image=subthread-open.png);
}

.collapsed .collapseicon 
{
    background-image:         url(<?php echo get_settings('siteurl'); ?>/wp-content/plugins/briansthreadedcomments.php?image=subthread.png);
}


.comment .reply {
    text-align:             right;
    font-size:                 80%;
    padding:                 0px 6px 6px 0px;
}

.comment
{
    border:     1px solid #ddd;
    margin-top:             10px;
}

input#subscribe
{
    width: auto;
}

.comment .body .content
{
    padding:                0px 3px 0px 3px;
    /*width:                     100%;    */
    overflow:                 auto; 
}

.comment .title abbr
{
    border: none;
}

.collapsed .body, .collapsed .comment
{
    display:                none;
}
 
#commentform textarea {
    width: 97%;
}

<?php if( btc_has_avatars() ) { ?>
.btc_gravatar {
    float: right;
    margin: 3px 3px 4px 4px;
}
<? ?>
</style>
<?php
}

function 
btc_has_avatars()
{

    if( 
function_exists('get_avatar')) 
        return 
true;
    else if(
function_exists('MyAvatars'))
        return 
true;
    return 
false;
}

function 
btc_avatar()
{

    if( 
function_exists('get_avatar')) 
    {
        echo 
get_avatar(get_comment_author_email(), '64'); 
        return;
    }
    else if(
function_exists('MyAvatars')) 
    { 
        
MyAvatars();
        return;
    }
}

function 
btc_add_reply_id($id)
{
    global 
$tablecomments$wpdb;    
    
$reply_id mysql_escape_string($_REQUEST['comment_reply_ID']);
    
$q $wpdb->query("UPDATE $tablecomments SET comment_parent='$reply_id' WHERE comment_ID='$id'");
}

function 
btc_add_options()
{
    
add_options_page("Threaded Comments""Threaded Comments"7__FILE__'btc_options_page');
    
}

function 
btc_add_reply_id_formfield()
{
    print 
"<input type='hidden' id='comment_reply_ID' name='comment_reply_ID' value='0' />";
}

add_action('wp_head','briansthreadedcomments');
add_action('comment_post','btc_add_reply_id');
add_action('admin_menu''btc_add_options');
add_action('comment_form''btc_add_reply_id_formfield');
?>
__________________
Read this if you are new. | PageRank only applies to Web PAGES.

Conspiracy-Forums - THE Place to discuss Conspiracies

jamestl2 is offline
Reply With Quote
View Public Profile Visit jamestl2's homepage!
 
Sponsored Links (We share ad revenue):
 
Old 04-29-2008, 10:00 PM Re: A new Threaded Wordpress Comments Plugin
jamestl2's Avatar
Hey.....

Posts: 1,576
Name: James, if you couldn't tell from my username
(I had to write this extra post because there were too many characters with all that plugin code)

And here's the extra comments.php page it provided:

PHP Code:
<?php

/**
 * This is a modified version of wp-commments that comes with the Brian's Threaded Comments plugin.
 * Version: See briansthreadedcomments.php
 * Author: Brian Meidell
 * Author URI: http://meidell.dk/
 */ 

if ('wp-comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
    die (
'Please do not load this page directly. Thanks!');

include(
ABSPATH WPINC "/version.php");

$is_new = (isset($wp_version) && $wp_version '1.2');

if ((
$is_new) or ($withcomments) or ($single)) {
        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
?>
<p><?php _e("Enter your password to view comments."); ?><p>
<?php
                
return;
            }
        }

         
$comment_author = (isset($_COOKIE['comment_author_'.$cookiehash])) ? trim($_COOKIE['comment_author_'.$cookiehash]) : '';
        
$comment_author_email = (isset($_COOKIE['comment_author_email_'.$cookiehash])) ? trim($_COOKIE['comment_author_email_'.$cookiehash]) : '';
         
$comment_author_url = (isset($_COOKIE['comment_author_url_'.$cookiehash])) ? trim($_COOKIE['comment_author_url_'.$cookiehash]) : '';

        if(!
$tablecomments && $wpdb->comments// this makes it work in both 1.2 and 1.3
            
$tablecomments $wpdb->comments;
            
$comments $wpdb->get_results("SELECT * FROM $tablecomments WHERE comment_post_ID = '$id' AND comment_approved = '1' ORDER BY comment_date");
?>

<!-- You can start editing here. -->

<p><?php comments_rss_link(__('<abbr title="Really Simple Syndication">RSS</abbr> feed')); ?> 
<?php if ('open' == $post->ping_status) { ?>
| <a href="<?php trackback_url()?>">Trackback <acronym title=\"Uniform Resource Identifier\">URI</acronym></a>
<?php ?>
</p>

<?php
$GLOBALS
['threaded_comments'] = array();

function 
write_comment(&$c$deepest_id = -1) {
    global 
$btc_cutoff_level$post;
    
$threaded_comments $GLOBALS['threaded_comments'];
    
$odd = ($GLOBALS['__writeCommentDepth']%2" odd" "");
?>
            <div  id="div-comment-<?php echo $c->comment_ID ?>" class='comment<?php echo $odd?>'>
<?php    if (btc_has_avatars()) {   // Gravatar support ?>
<div class='btc_gravatar gravatar'>
    <?php btc_avatar(); ?>
   <div style="clear: both;"></div>
</div>
<?php // End Gravatar support ?>
                <a name='comment-<?php echo $c->comment_ID ?>' id='comment-<?php echo $c->comment_ID ?>'></a>
                <div class="title">
                    <img class="collapseicon" src="<?php echo get_settings('siteurl'); ?>/wp-content/plugins/briansthreadedcomments.php?image=spacer.png" onclick='collapseThread("div-comment-<?php echo $c->comment_ID ?>")' />
                    <cite><?php comment_type(); ?> <?php _e('by'); ?> <?php comment_author_link() ?><a href="#comment-<?php echo $c->comment_ID ?>"></a></cite> 
                    <?php 
                        
if(function_exists('comment_subscription_status')) { 
                            if (
comment_subscription_status()) { 
                                echo 
"<img alt='Subscribed to comments via email' src='".get_settings('siteurl') ."/wp-content/plugins/briansthreadedcomments.php?image=subscribed.png' />"
                            } 
                        }
                    
?>
                    <?php edit_comment_link(__("Edit This"), ' |'); ?>                
                </div>
                <div class='body'>
                    <div class='meta'>
                        <?php echo $c->comment_date ?> <?php echo $c->comment_time ?>                        
                    </div>                    
                    <div class='content'>
                        <?php comment_text() ?><?php 
                        
if(preg_match('|<Pingback />|'$c->comment_content)) {
                            echo 
"<small>Read the rest at ";
                            echo 
comment_author_link();
                            echo 
"</small>";
                        }
                        
?>
                    </div>
<?php if($GLOBALS['__writeCommentDepth'] < $btc_cutoff_level) { ?>
                    <div class='reply'>
                        <?php if( $post->comment_status == 'open' ) { ?>
                        <?php global $user_ID; if ( get_option("comment_registration") && !$user_ID ) echo '<a href="'.
                        
get_option('siteurl') . 
                        
'/wp-login.php?redirect_to=' get_permalink() .
                        
'">Log in to Reply</a>'; else { ?> 
                        <a href='#' onclick='moveAddCommentBelow("div-comment-<?php echo $c->comment_ID ?>", <?php echo $c->comment_ID ?>, true); return false;'>Reply to this comment</a>
                        <?php ?>
                        <?php ?>
                    </div>
<?php } else if($GLOBALS['__writeCommentDepth'] == $btc_cutoff_level) { 
?>
                <small>(Comments wont nest below this level)</small>
<?php ?>
                </div>
<?php
        
if($threaded_comments[$c->comment_ID]) {
            
$id $c->comment_ID;
            foreach(
$threaded_comments[$id] as $c) {
                
$GLOBALS['__writeCommentDepth']++;
                if(
$GLOBALS['__writeCommentDepth'] == $btc_cutoff_level)
                    
write_comment($c$c->comment_ID);
                else
                    
write_comment($c$deepest_id);
                
$GLOBALS['__writeCommentDepth']--;
            }
        }
?>
<?php 
if($GLOBALS['__writeCommentDepth'] == $btc_cutoff_level ) { ?>

<?php if( $post->comment_status == 'open' ) { ?>
                    <div class='reply'>
                        <?php global $user_ID; if ( get_option("comment_registration") && !$user_ID ) echo '<a href="'.
                        
get_option('siteurl') . 
                        
'/wp-login.php?redirect_to=' get_permalink() .
                        
'">Log in to Reply</a>'; else { ?> 
                        <a href='#' onclick='moveAddCommentBelow("div-comment-<?php echo $deepest_id ?>", <?php echo $deepest_id ?>, false); return false;'>Reply here</a>
                        <?php ?>
                    </div>
    <?php ?>
<?php 
?>                    

            </div>
            <!-- This has to be here because of Internet Explorers plethora of layout bugs -->
            <div style="height: 1px; overflow: hidden;">&nbsp;</div>
<?php
    
}// end function
?>
<h2 id="comments"><?php comments_number(__("Comments"), __("1 Comment"), __("% Comments")); ?> 
<?php if ('open' == $post->comment_status) { ?>
<a href="#postcomment" title="<?php _e("Leave a comment"); ?>">&raquo;</a>
<?php ?>
</h2>
<div class="#commentlist">
<?php if ( $comments ) : 
    foreach(
$comments as $c)
    {
        
$GLOBALS['threaded_comments'][$c->comment_parent][] = $c;
    }
    
$GLOBALS['__writeCommentDepth'] = 0;
    if( 
is_array($GLOBALS['threaded_comments'][0]) ) {
        foreach(
$