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)

    <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” />

    Just add tabindex=”5” at end of this line so it will become

    <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″ />

    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

var content = document.getElementById(”content”);

And change it to

var content = document.getElementById(”content-main”);

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)

Click here to cancel “reply”.
</a></small>
</div>

And add after this the following line

<?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 : ?>

Now find this line:

<input type=”text” name=”url” id=”url” value=”<?php echo $comment_author_url; ?>” size=”28″ tabindex=”3″ />
</div>

And after this line insert:

<?php endiff; ?>

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.

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

Related posts

11 Comment(s)

  1. On Nov 26, 2007, Bobs said:

    Thank you for the mention and linkback!

    [Reply]

  2. On Nov 29, 2007, Web tools said:

    oops, this all sound too geek to me.
    I am happy with my Brian’s thread, as it is.

    [Reply]

  3. On Jan 31, 2008, Dhruva Sagar said:

    Hi there, thanks for these fixes you have listed above. But can you visit my blog and check what’s going wrong? The plugin isn’t working properly. I am unable to click on comment author’s links, or the edit comments link or even the expand/collapse link.

    If i execute the collapseThread(..) function manually say through the address bar, the comments are collapsing and expanding but I am not able to click somehow…any help would be appreciated.

    [Reply]

  4. On Jan 31, 2008, Dhruva Sagar said:

    I have been able to sort a lot of things out…things are much better now, though the collaped box is not quite what I would’ve like…lets see perhaps I will be able to get that straight too within a couple of days.

    Thanks a lot for your help again.

    [Reply]

  5. On Feb 6, 2008, JTPratt's Blogging Mistakes said:

    when I try to fix issue #3 in my comments.php I get an parse error on line 259 and have to revert to my previous version.

    any ideas?

    [Reply]

  6. On Feb 12, 2008, Steve said:

    @JTPratt

    It’s most likely because his has an extra ‘f’ in it and should be .

    If I remember correctly, I got that same error.

    [Reply]

  7. On Feb 12, 2008, Steve said:

    Sorry forgot to put the code tags around.

    Anyways his last php tag should be endif; not endiff;

    [Reply]

  8. On Feb 27, 2008, amrayu said:

    So I’ve managed to fix most of the bugs in the version that I downloaded. But… Issue Number 2 – Using Cancel Button, isn’t fixed.
    I don’t get an annoying white box like what’s described. Instead, if a user clicks the cancel button, it takes the user to the top of the page and the comment box is completely gone. Clicking on a “reply to this comment” will result in a pop-up that says: “Error: Threaded comments can’t find the ‘addcomment’ div. THis is probably because you have changed the comments.php file. Make sure there is a tag around the form that has the id ‘addcomment’.
    A temp fix is to refresh the page entirely. That’s when the comment box shows up normally.
    Does anyone have an idea why this is happening?
    Thanks.

    [Reply]

  9. On Feb 27, 2008, amrayu said:

    Nevermind. I just found an easier solution here:
    http://www.learncpp.com/wordpr.....dcomments/

    [Reply]

  10. On Apr 26, 2008, Katie said:

    Thanks for working these out. I’m very new to WordPress (and CSS), though, and I don’t quite understand where the “small” tags need to go. Wherever I place them, I get a fatal error. Can you be more specific?

    [Reply]

  11. On Jun 26, 2008, Steve Scheer, Denver CO said:

    There are so many issues like this to work out when having a blog that sometimes I think it is easier to hire someone for the technical parts like this.

    [Reply]

3 Trackback(s)

  1. Fixing Brian's Threaded Comments Plugin | WordPress Web 2.0 Spot-Er on Mar 3, 2008
  2. Brian Meidell’s Blog » Brian’s Threaded Comments 1.5.17 on Mar 24, 2008
  3. Threading Comments now easier on Apr 13, 2008

Post a Comment

:D :) ^_^ :( :o 8) ;-( :lol: xD :wink: :evil: :p :whistle: :woot: :sleep: =] :sick: :straight: :ninja: :love: :kiss: :angel: :bandit: :alien: