SEO Egghead by Jaimie Sirovich: A blog about SEO, written for nerds, by a nerd.

Choose a Topic:

» Suggest a topic or buzz to cover; if I write about it, you'll get credit with a link in the post!

Sat
16
Sep '06

How To Get Dugg More: Digg for WordPress Plugin

So I got Dugg -- but I'm convinced this trivial WordPress Plugin is part of what helped me top the Digg charts for so long.  All it does is examine every incoming HTTP_REFERER, and if a Digg URL (of a specific Digg) hits a blog post URL, it assumes that it's a Digg of that post.  Then the plugin automatically stores that URL and inserts the Digg button code.  It's not perfect, but it should mostly work automagically.  Just call the function within your template somewhere.  If you find any bugs, leave a comment.  Here it is:

<?

/*
Plugin Name: Digg
Plugin URI: http://www.seoegghead.com/
Description: Creates an interactive Digg button.
Author: Jaimie Sirovich
Version: 1.0
Author URI: http://www.seoegghead.com/
*/ 

function _scrape_check_digg($digg_link$the_permalink)
{    
    
$ch curl_init(); 
    
curl_setopt($chCURLOPT_URL$digg_link); 
    
curl_setopt($chCURLOPT_RETURNTRANSFER1);         
    
$http_result curl_exec($ch);
    
curl_close($ch);            
    
$_ preg_match('#<h3 id="title"><a href="(.*?)">#is'$http_result$captures);
    return (
$captures[1] == $the_permalink);
}

function digg_this()
{
    global 
$id;
    
$digg_link get_post_meta($id'DIGG_CLASS_digg_link'true);
    
    if (
is_single() && !$digg_link && preg_match('#^http://(www\.)?digg\.com/.+#i'$_SERVER['HTTP_REFERER']) && !preg_match('#^http://(www\.)?digg\.com/(view|users)#i'$_SERVER['HTTP_REFERER']) && _scrape_check_digg($_SERVER['HTTP_REFERER'], get_permalink())) {
        
add_post_meta($id'DIGG_CLASS_digg_link'$_SERVER['HTTP_REFERER']);
        
$digg_link $_SERVER['HTTP_REFERER'];
    }

    if ($digg_link) {
        
?><iframe src='http://digg.com/api/diggthis.php?u=<?=urlencode($digg_link)?>' height='82' width='55' frameborder='0' scrolling='no'></iframe><?
    
}
}

?>

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • digg
  • Furl
  • Reddit
  E-Mail This Post/Page

42 Responses to “How To Get Dugg More: Digg for WordPress Plugin”

  1. SEM Basics Says:

    Hello,

    I don't quite understand how this works or how it helps. Could you explain it for the laymen out there? Thanks.

    All the best,

    Moshe

  2. mike Says:

    So if I wanted to add this to my anonymous confession website www.sosecret.com, where would I put it?

  3. mike Says:

    And what would it do for www.sosecret.com

    This is lame and too easy. Go ahead and delete lol

  4. - Says:

    Where do you put the digg URL?

  5. Muhammad Saleem Says:

    Where do I need to put this?

  6. Karl Says:

    Basically what happens is, if he gets dugg then that button appears on his page. So when people view the page they're being asked to digg it.
    That's how I understand it anyway.

  7. Eli Horne Says:

    that "digg it" button drives me nuts because it doesn't render correctly in safari. yeah, yeah, 3% of the market, but digg has a big mac user following.

    I'm sure it could be corrected easily, yet I never seem to hear anyone complain about it. Makes me not want to click it for some reason.

  8. lXciD Says:

    Hello, I thanks for the plugin. I had just integrate it into my site and wrote a guide on how to do it. You can check it out at http://www.thedarkestsociety.com/2006/09/18/simple-step-by-step-guide-to-install-digg-in-your-wordpress/

    Cheers,
    lXciD

  9. Jonathan Zencovich Says:

    Wow I must admit this is brilliant. It's not perfect however, but brilliant nonetheless. I'll keep on the look out for bugs.

    Keep up the good work!

    --Jon Z | http://jzencovich.blogspot.com/

  10. Randy Says:

    Something's wrong in Safari. The bottom of the button is cropped in Safari. You can only see the top half of "digg it".

  11. Tim Says:

    I get the following error when I try to activate this plugin:

    --
    Warning: Cannot modify header information - headers already sent by (output started at /home/northwes/public_html/blog/wp-content/plugins/Digg.php:29) in /home/northwes/public_html/blog/wp-admin/plugins.php on line 22
    --

  12. Rub3X Says:

    When it detects incoming links to your site from digg it parses the URL to see if you've been submitted to digg. It then inserts that "digg" button on your blog.

  13. Ken Says:

    The DiggThis Wordpress Plugin exists for almost a year now.

    Here is the Original Digg This Wordpress Plugin

  14. wayne sutton Says:

    Hey can you give a more detailed explanation on how to install this?

    Thanks

    Wayne

  15. lXciD Says:

    Hi wayne,
    I posted before in here that I does have a more detail explanation on how to install this on my site. I even have it installed. Check it out at my website.

    http://www.thedarkestsociety.com/2006/09/18/simple-step-by-step-guide-to-install-digg-in-your-wordpress/

    Cheers,
    lXciD

  16. tvfree Says:

    Nice idea in concept, but it fails in execution.

    People can post urls in the digg comments section and so if someone clicks a link coming through a digg comment, your blog would assume that the page the user came from is a digg of your site - when in reality, it could be the competitors site (most likely is if someone is posting your url in the digg comments).

    So in doing this, you've essentially left yourself open to advertising your competitor. Also note the predicament that occurs when two or more diggs have been submitted about an article - you'll end up with more then 2 digg items on your site, and if someone wants to be malicious they can digg your article several times using slight variations of the url - thus making it possible to 'spam' your page with these digg buttons.

    One thing to fix it, is to check the url referrer and ensure that it contains "/design/" or whatever other digg categories there are, that way only if the incoming digg.com referrer has one of those category labels in its url will the digg button be added.

    Very Simple solution.

  17. tvfree Says:

    me again, I tested it out and I was right!

    Check out this section:
    http://www.seoegghead.com/blog/category/cloaking/
    The digg will digg an item about some new tech advance in Apple, essentially I can hijack any page so that instead of digging the actual post the user ends up digging whatever post I selected. It only works if the article/page has not been dugg before, so the main thing is to digg your article first - otherwise you can easily get ppl to vote for your article.

    I strongly recommend making the corrections I mentioned in the last post, and digging it immediately - it's pretty critical when you essentially create an exploit that makes the entire digg system vulnerable.

  18. Jaimie Sirovich Says:

    TVFree,

    You have a point -- and to be honest, they wouldn't need to do it with a comment. They could just create a malicious post in the first place. What I could do is fetch the referer and scrape out the URL it points to to verify.

    I do check if the URL is a category URL. That's why I exclude view|users. Checking for the actual categories would be much more annoying and error-prone.

  19. tvfree Says:

    yes, but if you checked if the url exists it would take up too much cpu time and would slow the load of the page. Even if you only do it once, it would be very easy to set up a script (cron job) that basically sends tons of requests to your article using fake headers, and because your script is checking the existence of each -it would slow your page load. Trust me it's never a good idea to begin parsing items, and also the way I mentioned above would result in the digg article being real. I tested it out with an article on digg currently, and it worked perfectly - the digg article existed in the first place, so even if the script checked it - it would still result positive. The problem is that a script like this can not be done properly because its very easy to exploit the system with referrers, there is no real way to do is securely.

    BUT I'd recommend searching the referrer string for the digg categories, not the users label. Check out "http://www.seoegghead.com/blog/category/cloaking/", I tested it out and I was able to get the article to link to another digg article. Unfortunately for some reason, your blog seemed to change all the articles to this digg link (I didn't intend on doing this, but it's yet another thing to look into - it thereby causes every article to have the same digg link, meaning that a user spam an entire blog very easily).

    The only real solution I see, is to check the incoming referrer variable to see if it contains (instr) any of the following text "/design/", "/gaming/", "/politics/", etc.. If it finds the text in the referrer, and if it finds "digg.com" in the text as well - then it records the referrer url and saves it. Otherwise it shows nothing, or displays an error. If you don't put that in, anybody can easily post links to the article and have it show up. See 'cloaking' section of your site to see it.

  20. Jaimie Sirovich Says:

    I fixed most of these issues. Seriously, though, if someone kept getting digged, I'd expect they'd notice if someone maliciously set up a fake digg. And the malicious user would have to anticipate which post it is that breaks loose in the first place. This will never happen in practice.

    And it would be quickly discovered when/if it did. I think you're overreacting. In any case, I fixed it. Theoretically it opens another pandora's box, but I'm OK with that one.

    The issue with the categories URL is a simple oversight. I'm very green with WP, and I checked that it's not the homepage, not that it is a single-page. Since I rarely look at category pages, I overlooked it. That's fixed.

    The plugin will only work for individual posts now. That makes sense anyway.

  21. WintheLog :: Digg Wordpress plugin :: September :: 2006 Says:

    [...] Permanent Link  |   Del.icio.us  |   Cosmos  |   Digg  |   Slashdot [...]

  22. Simple step by step guide to install Digg in your WordPress at diggaddict.com Says:

    [...] This is a follow up article on “How to Get Dugg More: Digg for WordPress Plugin“. [...]

  23. Keith Says:

    I used to have Digg plugin on some of the posts in my WordPress website too. Not sure if that belongs to you.

  24. Stuck in My Crosshairs 9.18.06 at Cory Holt’s Weblog Says:

    [...] Like getting Dugg? Want to get Dugg more often? Use WordPress? Well then your in luck. Using this pretty nice plugin, you can add a Digg counter just like on the main Digg website to your blog. This counter will display how many Diggs that article has on Digg.com at that time. [...]

  25. SEO Egghead » Blog Archive » DiggBait 101: 8 Ways to Help You Get to Digg’s Front Page Says:

    [...] 8. Leave a Hook for Improvement & Editorials:Leave a hook for others to add value or explain your post.  Sometimes explaining things badly actually helps!  Another blogger will clarify your message and link to you.  I did this with this post and someone took the bait.  If you say everything, they have less of a reason to link to you. [...]

  26. SEO Consultant Esoos Bobnar - SEO Consulting Services Says:

    A Diggable List of Lists on How to Get Dugg on Digg...

    A guide on how to get your site into Digg....

  27. Wordpress Quickies: Stats and Diggs. at Cory Holt’s Weblog Says:

    [...] Funny enough, I came accross this mod on Digg. It’s a plugin that displays the ammount of diggs your story has gotten as well as a Digg link for others to do the same. The block looks just like what you see on the homepage, so users will recognize it right away. It’s extreamly easy to use, just copy the code thats in this article, and save it as a php file and drop it in your template’s folder. Once you have done that, just call up the function using the following line of code (I found that this code was missing from the original article, so I decided to add it): [...]

  28. Nickolas Says:

    I need to get digged

  29. SEMBasics » Tools for Digg.com Says:

    [...] 1) A wordpress plug-in by SEO Egghead [...]

  30. SEO Egghead by Jaimie Sirovich » 3 SEO Enhancements That Won’t Require Ripping Up Your Site Says:

    [...] 1. Streamline Social Bookmarking Functionality.  People = Lazy. Social bookmarking sites allow users to bookmark and tag content with certain attributes.  The aggregate of this information is used both to cite popular content within certain timeframes, as well as over time.  Adding icons and buttons to content facilitates the process of bookmarking and likely increases number of users who bookmark your web site.  I discussed effective ways to do this (with code!) here, here, and here. [...]

  31. tonto Says:

    Why not just have a bookmark menu like on this site?

    Anonymous confessions

  32. reepher Says:

    I think this is a cool idea. Can it be coded in such a way as to catch any incoming url and insert a differnt icon based on the website. Like in the options tab have an admin panel that allows you to select a certain url and the code that should be inserted into the post based on that info?

  33. soufulow` Says:

    Great one, will soon to be added to my blog. i am quite an idiot to php and coding but i think i can make it. have to thanks lXciD for his details step-by-step guides as well!

    just one questions...can i customize the logo of digg it? (or make it smaller to fit in to my blog design?)

  34. Cornwall SEO » 62 posts on how to squeeze the juice from digg Says:

    [...] How To Get Dugg More: Digg for WordPress Plugin [...]

  35. Digg : Search Engine Marketing : Darin Carter Says:

    [...] http://www.seoegghead.com/blog/seo/how-to-get-dugg-digg-for-wordpress-plugin-p113.html [...]

  36. Angelina ------ Says:

    Do we need to put this code into file and upload to our plugins folder ?

  37. timspangler dot com: confessions of a journalism school dissident » Blog Archive » How to: Fix your WordPress ‘Digg This’ plugin Says:

    [...] to php.ini. After a quick search, I found another plugin with similar functionality on SEOEgghead. Their script makes the same requests to Digg as Digg This, but does them more efficiently with [...]

  38. Digg Says:

    [...] http://www.seoegghead.com/blog/seo/ how-to-get-dugg-digg-for-wordpress-plugin-p113.html [...]

  39. Martin Says:

    I plan to use digg with my site www.eruptingmind.com this looks interesting

  40. The Ultimate List on Digg Marketing Says:

    [...] Egghead: How to Get Dugg More: Digg for Wordpress Plugin Although Digg do have their own tools for this now aswell, its great to see what works and [...]

  41. Jeff Says:

    Did everything you said on my seo blog:

    SEO Blog, however, still did not see the digg showing. I am using wordpress 2.2

  42. zanzibar Says:

    It's a nice plugin but i cant get it to work on my wordpress blog. I'll keep trying but i was hoping to get on of those plugins that you upload like a folder on the plugins folder for wordpress.

Leave a Reply