Looking to add Google's new plusone feature to your site but don't have HTML5 enabled pages? Then keep reading ![]()
<?php
$url = isset($_GET['url']) ? htmlspecialchars($_GET['url']) : "";
$size = isset($_GET['size']) ? htmlspecialchars($_GET['size']) : "tall";
if ($url != "") {
?>
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
html,
body {
margin:0;
padding:0;
width:auto;
overflow:hidden;
}
</style>
<script type="text/javascript" src="http://apis.google.com/js/plusone.js" />
</head>
<body>
<g:plusone size="<?php echo $size; ?>" href="<?php echo $url; ?>"></g:plusone>
</body>
</html>
<?php
}
?>
The best way to use the above code is to drop it into a PHP file called plusone.php and drop it into the root of your site.
The next step is to call this script in your main code to display the button where you want it. The code below shows the basics of what you need to include:
<iframe src="/plusone.php?url={PAGE_URL}&size={BUTTON_TYPE}" marginheight="0" marginwidth="0" frameborder="0" scrolling="no" style="border:0;width:58px;height:70px;"></iframe>
From the URL you will see two tags, {PAGE_URL} and {BUTTON_TYPE}, hopefully replacing these with actual information is easy enough to figure out but in case not, see below for details ![]()
There are four sizes for Google's + button which can be seen in the image below:

Please feel free to let me know you use this code so I can tell if this is actually useful to anyone
There are no comments for this article
Use the links below to view each of the different code snippet categories
Below are the latest code snippets that I have written
If you like this code snippet or use it then please donate something to me so I can continue updating this as well as creating new ones
Copyright © 2010 - Matthew Kellett