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...
DiggBait 101: 8 Ways to Help You Get to Digg's Front Page 1. Make People Read Your Boring Crap with a Persuasive...
Checking for Dead Links Automatically This neat little class can return the HTTP status code...
WP HTML Taint Check <? /*Plugin Name: HTMLTaintCheckPlugin URI: http://www.seoegghead.com/Description: Checks for suspicious links in posts. MAKE SURE TO REPLACE YOUR EMAIL ADDRESS IN...
Updated PagerFix Plugin Code For WP 2.1 I upgraded to WordPress 2.1 today, and one of my...