Hacking Brian’s Threaded Comments Plugin

Whenever it comes to using nested or threaded comments, there is no plugin as popular as Brian’s Threaded Comments. But it has several flaws and bugs which have not yet been fixed and many bloggers are desperate to find solutions for their problems which are not easily available. People are asking for support via Brian’s Forums but it seems that brian is too busy to attend to the forums.

So here I am trying to sort out the most common issues which people face with this plugin.

Note: The following fixes are only for versions 1.5.9 and above versions of Brian’s Threaded Comments. Don’t ask me if the problem exists in versions below 1.5.9 and fixes for them.

Issue Number 1 – Using Tab key
Versions Affected: 1.5.9 – 1.5.11 Was Fixed in 1.5.12 version.

Most of you will not even detect this issue if you are not totally dependent on your keyboard. But as they say, bug is a bug. If you use tab key to move from field to field while filling the comment form, after reaching the comment textarea, it skips the Submit button and tab button will again take you back to Comment name field.

Issue Number 1 Fix

It has a very simple fix which can be done via 2 ways:

  1. For those who have version 1.5.9 and don’t want to update: Find this line in your comments.php (supplied with plugin and not your theme’s comment.php)
    [javascript]<input onclick="if(typeof(onAddComment) == ‘function’) { onAddComment(); } else { alert(‘ERROR:
    It looks like the website administrator hasn’t activated the Brians Threaded Comments plugin from the plugin page’); };" name="addcommentbutton" type="button" id="addcommentbutton" value="Add comment" />[/javascript]
    Just add tabindex=”5” at end of this line so it will become
    [javascript]<input onclick="if(typeof(onAddComment) == ‘function’) { onAddComment(); } else { alert(‘ERROR:
    It looks like the website administrator hasn’t activated the Brians Threaded Comments plugin from the plugin page’); };" name="addcommentbutton" type="button" id="addcommentbutton" value="Add comment" tabindex="5" />[/javascript]
    Thanks to RJ Matthis and Ryan for the fix.
  2. Secondly is to update your plugin to 1.5.12 version.(Backup everything before updating)

Issue Number 2 – Using Cancel Button
Versions Affected: 1.5.9 – 1.5.12

Whenever you press Cancel button on the submit form of comment, it does not do what it is expected to do. It is a rather irritating behavior. It can be fixed by using the following simple fix.

Issue Number 2 Fix

Open briansthreadedcomments.php file and find this code
[javascript light=”true”]var content = document.getElementById(”content”);[/javascript]
And change it to
[javascript light=”true”]var content = document.getElementById(”content-main”);[/javascript]
Thanks to JohnChow for reporting the fix.

Issue Number 3 – Admin Login/Logout Missing
Versions affected: 1.5.9 – 1.5.12

Problem is simple but yet unfixed. Actually when you are logged in to your WordPress Admin panel, even then the comment form does not recognize you as the blog author or administrator and shows the complete form. Reason for this problem is because the complete code to detect author is missing from the plugin.

Issue Number 3 Fix

Fix was founded by me.
Find the following line in your comments.php(that came with the plugin and not your theme’s comments.php)
[html]Click here to cancel "reply".
</a></small>
</div>[/html]
And add after this the following line
[php] <?php if ( $user_ID ) : ?>
<p>Logged in as <a href="<?php echo get_option(‘siteurl’); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo get_option(‘siteurl’); ?>/wp-login.php?action=logout" title="Log out of this account">Logout »</a></p>
<?php else : ?>[/php]
Now find this line:
[php]<input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="28" tabindex="3" />
</div>[/php]
And after this line insert:
[php light=”true”]<?php endiff; ?>[/php]
Now Brian’s plugin will recognize you as a blog author.

Issue Number 4 – Two Subscribe to Comments Checkboxes display
Versions affected: 1.5.9 – 1.5.12

Problem is not serious but still it looks odd as two subscribe to comments boxes display. Fix is dependent on plugin you are using to notify people of new comments. BTW I found the fix for this problem too.

Issue Number 4 Fix

If you are using Subscribe to Comments plugin from here then use the following fix:
In the Plugin’s Control panel, Change the Not Subscribed Text from
Notify me of followup comments via e-mail
To

<small>Notify me of followup comments via e-mail</small>

Do this for next 2 customised lines…i.e. enclose them also in <small> tags.
And now open your modified comments.php file and find the code:

<input type=”checkbox” name=”subscribe” id=”subscribe” value=”subscribe” />
<small>Subscribe to comments via email</small>

And replace it by

<?php show_subscription_checkbox(); ?>

This will solve the problem of two checkboxes in brian’s threaded comments plugin.

If you are using any other Subscribe to comments plugin apart from mentioned above, follow the fix here. Open the modified comments.php file and find these lines of code:

<?php if(function_exists(‘comment_subscription_status’)) { ?>
<div>
<input type=”checkbox” name=”subscribe” id=”subscribe” value=”subscribe” />
<small>Subscribe to comments via email</small>
</div>
<?php } ?>

Now Delete this code, since it will not work with your plugin.

Issue Number 5 – Moderate Comments Text Missing
Versions affected: 1.5.9 – 1.5.12

I am yet to find a fix for this problem. If anyone of you have found its fix, reply to this post. Help your mates who are using brian’s threaded comments plugin even now.
Till Then A Temporary fix which I would like to suggest you is:
Open modified comments.php of theme and find this line:

You may use <?php echo allowed_tags();?> in your comment.

And add before it:

<strong>Comments are moderated before being shown up. So if your comment does not show up, please don’t resubmit. We have received your comment and will approve/disapprove as required.</strong><br />

This will notify commentors that they don’t need to resubmit as comments are being moderated.

Part 1 of post is completed. This contained all possible fixes to brian’s threaded comments plugin. Next part of this post will contain some cool features which can be added to this plugin.