Google rolled out their +1 button today.

So I added it here. You’ll find it below all the posts. Try it out. Here’s the simple-stupid Google Plugin I wrote to do it. While you can just edit your theme, I like making these sort of things into plugins. That way, I can turn them off at will, and I know exactly where to go to change them without having to dive into my theme code. Also, if I change themes, the code still works on the new theme.

   <?php 

   /* 

   Plugin Name: Otto's Google +1 Button

   Description: Add a +1 button after the content.

   Author: Otto

   Version: 999

   */

   add_filter('the_content', 'google_plusone');

   function google_plusone($content) {

       $content = $content.'

‘;    return $content;    }    add_action (‘wp_enqueue_scripts’,’google_plusone_script’);    function google_plusone_script() {    wp_enqueue_script(‘google-plusone’, ‘https://apis.google.com/js/plusone.js’, array(), null);    }

I wrapped the button in a div so that I could style it. In my particular case, I’m floating it right and giving it a margin, same as the Twitter and Facebook plugins. One day, I’ll make all these little Google plugins more generic and configurable, and roll them into a Simple Google Connect plugin. One thing I don’t like is that the +1 button only works for people who are logged into a Gmail account. Sorry Google Apps users, you’re out of luck. Complain to Google until they fix it.

If you want to add more parameters to the Google Plugin and reconfigure it, you can find out about the available parameters here: http://code.google.com/apis/+1button/#configuration

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Welcome to Wbcom Designs!  - Get 10% off on all plugins & themes
Coupon : HELLO10