Hacking Disqus

by Scott Jangro on 08 April 2008

If you're new here, please subscribe to my RSS feed. And follow me on twitter. Thanks for visiting!

No video for this post today. It’s just pure geekery that just cannot be made any less geeky or any more interesting by staring at my talking head.

Have I mentioned before that I <3 Disqus? I think maybe I have.

And a big thanks to the disqus guys for adding in a quick feature request I had that allowed me to pull my own disqus comments from every blog into my lifestream here on my homepage.

There are some other features that I’d like to see, and to work that out on my own, I’ve been doing some hacking and tweaking to get Disqus to do exactly what I want in Wordpress. Here’s what I’ve done so far and how you can implement it on your own.

If you do make these changes, keep a few things in mind:

  1. I did this in the beta version of the wordpress plugin.
  2. once they issue an update, these changes will be overwritten and if they haven’t addressed them, will need to be redone. That’s the life of a gangsta.
  3. proceed at your own risk.

Trackbacks

Disqus doesn’t have any support at all for trackbacks. But since Wordpress will still grab and store them in your comment database, you can still display those. Add the following code somewhere in your wp-plugins/disqus/comments.php script. Be sure to edit the one in the plugin dir. I put mine way down at the bottom.

<h3>Trackbacks</h3>
<ol>
<?php foreach ($comments as $comment) : ?>
<?php $comment_type = get_comment_type(); ?>
<?php if($comment_type != 'comment') { ?>
<li><?php comment_author_link() ?></li>
<?php } ?>
<?php endforeach; ?>
</ol>

DoFollow/NoFollow

Disqus posts all links in comments as dofollow links. (sans the rel=”nofollow”). That’s not that bad since Disqus has measures to prevent spammers. But it doesn’t stop the comment monkeys.

So I’ve been playing with a few different ways do put nofollow on some of the spammier comments while taking the opportunity to give dofollow back to the good guys.

Here’s what I did, again to comments.php. The bold code is what I added, I’ve included a little context so you can put it in yourself:

<ul id="dsq-comments">
	<?php foreach ( $disqus_response['posts'] as $comment ) : ?>
	<?php
		//SCJ added check for rel=nofollow
		if ($comment['points'] < 1 || $comment['user']['is_anonymous']) {
			$follow = ' rel="nofollow" ';
		} else {
			$follow = "";
		}
		//SCJ end change
		$profile_url = DISQUS_URL . '/people/' . $comment['user']['profile'] . '/';
	?>

That sets the $follow var which I just slip into the website link here, down about 30 lines from the first change.

<?php if ( $comment['user']['url'] ) : ?>
	<li><a href="<?php echo $comment['user']['url']; ?>"
	target="_blank" <?php echo $follow?>>Website</a></li>
<?php endif ; ?>

Feature Requests for Disqus

While I’m at it, here are some feature requests…

  1. Incorporate real trackback support. I don’t think I care whether you just use Wordpresses trackback support like I did or try to incorporate it into your service. If you think you can do something about the spammers and scrapers, then by all means take it in. Maybe just allow an option to show trackbacks above or below the comments?
  2. Do something with the Dofollow/Nofollow. I’m pretty happy with the rules I set, which is to add in a nofollow for anonymous commenters and for comments that have been voted down. But something more sophisticated could surely be done and would be welcomed here.
  3. I want more notifications on blogs that I comment on. Right now, I think you send me an email if someone replies to one of my comments somewhere. But if there’s a conversation going on in a blog post that I’ve commented on, I want to know about it. Can I opt to get notified of any reply in a blog post that I’ve contributed to?
  4. I want to do more with Disqus, namely allow people who read my blog to START conversations, not just respond to the ones I start. I sent you guys at Disqus an email about this with more details. But I really think you guys are just scratching the surface here.
  5. I’m sure your lunches with Loic have you thinking about video comments, so I won’t waste a wish on that one. ;)

What do you say, does anybody have other wishes? They’re hiring and surely need stuff for that Python hacker to do.

  • Disqus is the top commenting platform in my opinion. Not only is Facebook Connect integration nice but allowing users to also use their Twitter accounts to leave comments is awesome.
  • Disqus now brings us the ability to comment using your Twitter account. You don’t have to give up your actual Twitter credentials since Disqus takes advantage of Twitter’s support
  • can anyone tell me please how can i convert disqus comments into dofollow links, thanks
  • A very important one for me is turning off the default behavior of asking people to log in once the click to submit. It is easy to just add the script in your -head- as follows:

    -script- var disqus_skip_auth = true; -/script-

    I also took out the line from comments.php that includes "blog comments powered by DISQUS" because people keep searching for a phrase and including that in the search. Seconds later, I get spammy comments like mad. Of course I delete the comments and block them, but just removing that seems to help.

    Thanks for the nice clips, Scott. If there are any more nice Disqus hacks anybody can think of, I am delighted to hear of them. :-)

    BTW, I like Disqus, and I have made that clear to Giannii at Disqus. I would say, however, that there are still more improvements to be made. I found the latest release too buggy to use, so I am just working with the old one.
  • not work on new disqus. thank's for your information
  • DISQUS is a great commenting plug-in it is easy to new person as well as DISQUS has measures to prevent spammers..
  • Disqus is great
  • i think disqus is very power,i am using now
  • I think Disqus is going to be the next best thing in commenting. It's great at stopping spam!
  • Cool site, keep up the good work!~The Gman
blog comments powered by Disqus