Reddit for WordPress Plugin


/ Published in: PHP
Save to your folder(s)

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!


Copy this code and paste it in your HTML
  1. <?
  2.  
  3. /*
  4. Plugin Name: Reddit
  5. Plugin URI: http://www.seoegghead.com/
  6. Description: Creates an interactive Reddit icon.
  7. Author: Jaimie Sirovich
  8. Version: 1.0
  9. Author URI: http://www.seoegghead.com/
  10. */
  11.  
  12. function reddit_this($reddit_style = 3)
  13. {
  14. global $id;
  15. $ref = $_SERVER['HTTP_REFERER'];
  16. $reddit_link = get_post_meta($id, 'REDDIT_CLASS_reddit_link', true);
  17.  
  18. if ($reddit_link == '' && preg_match('#reddit.com#i', $ref)) {
  19. add_post_meta($id, 'REDDIT_CLASS_reddit_link', $ref);
  20. $reddit_link = $ref;
  21. }
  22.  
  23. if ($reddit_link) {
  24. ?><script>reddit_url='<?php the_permalink() ?>'</script><script language="javascript" src="http://reddit.com/button.js?t=<?=$reddit_style?>"></script><?
  25. }
  26.  
  27. }
  28.  
  29. ?>

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.