Wordpress Plugin: the Conditional “Digg This” Badge

Please note: This mod is currently outdated. It has not been updated for use with Wordpress 2.5 and several people have reported errors with it. I have not had the time to work on it lately, so it may be outdated for some time (or forever). If anyone would like to fix it and/or take over control of the project, let me know. It is open source, after all, you’re all free to edit and play around with it…

The Conditional Digg Badge Wordpress Plugin automatically displays the “Digg This” badge on posts that already have a level of popularity with Digg.

Why, you ask? It’s been suggested by some that showing a Digg badge with a vote of “1″ may be discouraging to your users. It would probably be better not to show the Digg badge at all than to tell your users, “This article really isn’t popular.”

This plug-in makes use of the Digg API to solve that problem. When an article is loaded, the plug-in checks with the Digg API to see how many diggs your article has. If your article has a certain amount of diggs (10 by default), the Digg badge appears. Otherwise, the Digg badge does not.

Download the Source Code

You can download the source code for the Conditional Digg Badge here. When you unpack the .tar.gz file, you should have four files:

  • wp-digg-conditional.php - This is the base plug-in file. It hooks into Wordpress, inserts the required .js files, and inserts some javascript to make the plug-in work.
  • check-digg-stats.php - This script processes the AJAX requests, sending information to the Digg API server and finding out how popular your article is.
  • wp-digg-conditional.js - This is the .js script that creates the AJAX requests, handles the responses, and edits the page as appropriate.
  • prototype.js - This is an AJAX framework. I didn’t make it, but the plug-in uses it.

Download the source code: Wordpress Plugin: Conditional Digg This Badge, Version 1.0

Installing Conditional “Digg This” Badge

That’s pretty simple. Upload to your /wp-content/plugins directory. Unpack. Activate. Forget about it.

The tar.gz is organized into a directory already. Make sure the files are in the “wp-conditional-digg” directory - or else the path to the .js files and the .php script will be wrong. By default, the plug-in will display a “Digg This” badge for any article that already has 10 diggs.

How It Works… for the Curious

If you’ve read this far, you probably want to know how this plug-in works. Head over to the Documentation page for a thorough description of how the plug-in operates and what each file accomplishes.

Or, you can download the source code and jump right in. It’s not too long, and it’s fairly well commented - assuming you know a bit about php, js, and the Wordpress API.

Please Leave Comments with Bugs!

This is a functioning plug-in, but I can’t guarantee it will work perfectly. If you encounter any problems, please leave a comment below so that I can look at it when I have time.

If you have any suggestions for improving the plug-in, leave that as well.

At the moment, I’m aware of one annoying problem. The Digg API server can take a while to respond - so it may take 10 seconds or so for your badge to appear. I’m looking into adding a cache’ing system that only checks the API server every 10 minutes or so.


Bookmark and Share:
These icons link to social bookmarking sites where readers can share and discover new web pages.

  • Digg
  • Furl
  • del.icio.us
  • StumbleUpon
  • MisterWong
  • DZone
  • Technorati

14 Comments to “Wordpress Plugin: the Conditional “Digg This” Badge”

  1. Takuya Misawa said this on

    My blog rarely get dugg, so there’s probably no use for my blog unfortunately. However, I love the concept and how it displays.

    Can the same thing done for StumbleUpon?

  2. Walkere said this on

    StumbleUpon doesn’t have a pre-built badge like that. What are you looking to display?

    If you just want a link to Stumble the page, there are plenty of plug-ins that do that. It looks like you already have a plug-in that posts a Stumbleupon link at the bottom.

    If you wanted to insert a big Stumbleupon link at the beginning of the article, that would be a piece of cake.

    Or, if you wanted to display the # of reviews your page has (and only show that if your page has X reviews), that would be possible. I worked out a script to check how many reviews a page has, so I would just need to build a badge like Digg has to display the # of reviews.

    Anyhow, let me know exactly what you’re looking for and I might be able to work it out this week.

  3. Chicago Plumber said this on

    Interesting. There are some good ideass presented here. I need to do spend some time reading more about these topics.

  4. Henry said this on

    Hi! You got a very nice site. I just bookmarked it.

  5. Max said this on

    Hi - just wanted to say good design and blog - cu!

  6. Dan (future gadgets blog) said this on

    I like your blog theme. I want to use it on my blog.
    Can you please tell me from where I can download these theme?

    Many thanks

    ——————————————————————————–
    Dan owner of the future gadgets blog future gadgets and inventions

  7. internullo said this on

    For me it’s very slow. From the moment i open a post and till the moment the badge shows up, it takes about 30s to 1 minute.

    Can i edit something to make it faster? Like a timer or something?

  8. Walkere said this on

    I’ve noticed that problem, too. There’s no timer built in to it, so there’s nothing in the plugin code that should be holding up the works.

    I have a feeling it has to do with the response time from Digg’s API server, and I’m not sure if there’s anything that can be done to optimize that.

    The best thing I can come up with is to put a kind of cacheing system into it, so that you don’t have to wait for the Digg API server every time a page loads. That should be done in the next week or so, hopefully.

  9. Aravind said this on

    Awesome idea. Cheers from India.
    As one above told, I started professional blogging for 2-3 weeks and i’m still in the beginning stages. So, to be realistic, i cant expect a Digg soon..
    But, this Plugin in awesome and nicely worked out.

    And i want to say you this (abt Stumbleupon)
    I too will be grateful to you for a plugin that shows the number of “Thumbs Up” for a site on stumbleupon.
    I will surely blog that in my blog too…

    Many Thanks from a 16-year young teenager.
    Take Care

  10. Lazy Man and Money said this on

    Excellent stuff, but as mentioned, it’s too slow to be practical. I’d like to see an Ajax/Javascript version. I found one for Delicious, but can’t seem to get it to work for Digg.

  11. Steve said this on

    Is it me, or does the plug-in not with wp-2.5? any thoughts/plans?

    /s

  12. Walkere said this on

    @Lazy Man. The current implementation does use Ajax. The problem isn’t necessarily the script, it’s the response time from Digg’s server. The plan was to build in a caching system with the WP database, but I haven’t got around to it yet.

    @Steve, I haven’t upgraded to WP 2.5, so I wasn’t aware that it was incompatible. I should be upgrading my sites soon, so I’ll probably work out an update. Not sure of an ETA… but soon.

  13. yosonic said this on

    phew I thought it was just me… I am setting up a few new blog sites… wish I hadn’t gone with 2.5 now!

    Ah well… waiting patiently

    Thanks for your effort though, anyone who offers up free stuff is a legend.

  14. tanicos said this on

    it doesn’t work on 2.5..it shows an error message and a help link which tells me to go to their site and check the latest format..

Leave a Reply