Sep 16

How To Get Dugg More: Digg for WordPress Plugin

Posted by Jaimie Sirovich on Sep. 16th, 2006. 42 comments — voice your opinion.

NEED A GREAT WEB SITE? NEED IT TO BE SEARCH-ENGINE-FRIENDLY?

SEO Egghead is a web development firm dedicated to creating custom, search engine optimized web site applications. We specialize in eCommerce and content management web sites that not only render information beautifully to the human, but also satisfy the "third browser" — the search engine. To us, search engines are people too. Click here to talk to us. We'd love to help!
X

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

?>

Tell an amigo:
  • Sphinn
  • Digg
  • Reddit
  • del.icio.us
  • StumbleUpon
  • Facebook



Related posts:
Reddit for WordPress Plugin This is a terribly simple but useful WordPress plugin that...
A (not so simple) method to add rel="nofollow" to links I wrote this script so that I can run it...
Stop Hackers With Our WordPress Firewall Plugin v1.2 Getting hacked is a total bummer, right? Right. But...
DiggBait 101: 8 Ways to Help You Get to Digg's Front Page 1. Make People Read Your Boring Crap with a Persuasive...
Using Proper Grammar Programmatically: Part I One of the things that irks me most about programmers...




"42 Wise Comments Banged Out Somewhere On The Internet ..."


SEM Basics

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

mike

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

mike

And what would it do for http://www.sosecret.com

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

-

Where do you put the digg URL?

Muhammad Saleem

Where do I need to put this?

Karl

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.

Eli Horne

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.

lXciD

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

Jonathan Zencovich

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/

Randy

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

Tim

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

Rub3X

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.

Ken

The DiggThis Wordpress Plugin exists for almost a year now.

Here is the Original Digg This Wordpress Plugin

wayne sutton

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

Thanks

Wayne

lXciD

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

tvfree

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.

tvfree

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.

Jaimie Sirovich

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.

tvfree

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.

Jaimie Sirovich

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.

Keith

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

Nickolas

I need to get digged

tonto

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

Anonymous confessions

reepher

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?

soufulow`

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

Angelina ------

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

Martin

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

Jeff

Did everything you said on my seo blog:

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

zanzibar

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.

WintheLog :: Digg Wordpress plugin :: September :: 2006

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

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

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

Stuck in My Crosshairs 9.18.06 at Cory Holt’s Weblog

[...] 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. [...]

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

[...] 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. [...]

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

[...] 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): [...]

SEMBasics » Tools for Digg.com

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

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

[...] 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. [...]

Cornwall SEO » 62 posts on how to squeeze the juice from digg

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

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

[...] 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 [...]

Digg

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

The Ultimate List on Digg Marketing

[...] 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 [...]

SEO Consultant Esoos Bobnar - SEO Consulting Services

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

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



Care To Bang On The Keys ... ?

BECOME AN EGGHEAD. SUBSCRIBE TO OUR RSS FEED!

Learn to be as nerdy as we are by never missing our latest blog entries. Receive great tips, tricks, and ideas on improving your web site every day! Subscribe via our RSS Feed or use the chicklets in the sidebar.