topical media & game development

talk show tell print

professional-search-16-Digg-Plugins-digg-button.php / php



  <?php 
  /* 
  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(ch, CURLOPT_URL, digg_link);  
      curl_setopt(ch, CURLOPT_RETURNTRANSFER, 1);          
      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= echo urlencode(digg_link)?>' height='82' width='55' frameborder='0' scrolling='no'></iframe><?php 
      } 
  } 
  ?>


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.