Google Plus one (+1) on WordPress Theme

Short URL: http://nznet.info/gBXWSo

Here’s one for the web developers of the world.
Google plus one went live today, so I chucked together a couple of simple functions, to include in your WordPress functions.php theme file.

 

function ne_addGooglePLusOneHeader() {
    echo "<script type=\"text/javascript\" src=\"http://apis.google.com/js/plusone.js\"></script>\n";
}    

add_action('wp_head', 'ne_addGooglePLusOneHeader');

function ne_show_googleplusone_button {
    // display Google plus one (+1) at the bottom of the_content()
    global $wp_query;

    //set the size of the button: small, medium, standard, tall
    // (more info here: http://code.google.com/apis/+1button/#script-parameters)
    $size = "medium";

    $postUrl = get_permalink($wp_query->post->ID);
    $plusOneButton = "<g:plusone size=\"$size\" count=\"true\" href=\"$postUrl\"></g:plusone>\n";
    return $content.$plusOneButton;

}

add_filter('the_content', 'ne_show_googleplusone_button');

Paul Willard is the owner of this website, and main contributor. Paul has been involved in internet related technologies since 1994 when the internet went commercial in New Zealand. Paul Willard is a Director at Net Enterprises Ltd, a web development and system administration company in Hamilton, New Zealand. Paul is also frequently involved in business events and get togethers in the region.

http://twitter.com/terminalpaul http://www.facebook.com/TerminalAddict     Get connected with .

Leave a Reply