Return to Snippet

Revision: 1124
at September 12, 2006 20:41 by jonhenshaw


Initial Code
<?

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

function reddit_this($reddit_style = 3)
{
    global $id;
    $ref = $_SERVER['HTTP_REFERER'];
    $reddit_link = get_post_meta($id, 'REDDIT_CLASS_reddit_link', true);
    
    if ($reddit_link == '' && preg_match('#reddit.com#i', $ref)) { 
        add_post_meta($id, 'REDDIT_CLASS_reddit_link', $ref);
        $reddit_link = $ref;
    }

    if ($reddit_link) {
        ?><script>reddit_url='<?php the_permalink() ?>'</script><script language="javascript" src="http://reddit.com/button.js?t=<?=$reddit_style?>"></script><?
    }
    
}

?>

Initial URL
http://www.seoegghead.com/blog/seo/reddit-for-wordpress-plugin-p111.html

Initial Description
This is a terribly simple but useful WordPress plugin that puts an interactive counter-style Reddit interface on your blog — but only when someone has already bookmarked the URL.  It looks rather lame when everything isn't bookmarked, but the JavaScript interface with the arrows is a definate enhancement over a simple icon.  So why not show it only when applicable?  I'll narcissistically bookmark this post to demonstrate.  Just call the function "reddit_this()" and specify one of the styles enumerated here (http://reddit.com/buttons).  Enjoy!

Initial Title
Reddit for WordPress Plugin

Initial Tags


Initial Language
PHP