Extension:Google +1
From MediaWiki.org
|
Google +1 Release status: beta |
|||
|---|---|---|---|
| Implementation | Tag | ||
| Description | Creates 4 versions of Google +1 button. | ||
| Author(s) | José Miguel López Salvador (jmlopezsalvadorTalk) | ||
| Last version | 1.0.4 (2011-08-13) | ||
| MediaWiki | 1.16 | ||
| License | GNU public License | ||
| Download | Google1.zip (1.0.1) or this page |
||
| Example | WikiCode | ||
|
|||
|
Check usage (experimental) |
|||
Contents |
[edit] What can this extension do?
Allows you to very simply include Google +1 button in 4 different versions.
[edit] Usage
With the tag <google1></google1>
- Version 1: <google1 style="1"></google1> (Small version)
- Version 2: <google1 style="2"></google1> (Medium version)
- Version 3: <google1 style="3"></google1> (Standard version)
- Version 4: <google1 style="4"></google1> (Tall version)
- Version 5: <google1 style="5"></google1> (Small version - Home URL)
- Version 6: <google1 style="6"></google1> (Medium version - Home URL)
- Version 7: <google1 style="7"></google1> (Standard version - Home URL)
- Version 8: <google1 style="8"></google1> (Tall version - Home URL)
Default version = 1 (Small)
[edit] Download instructions
You can download the php file from Google1_zip or copy and paste the code found below and place it in $IP/extensions/Google1/Google1.php. Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.
[edit] Installation
To install this extension, add the following to LocalSettings.php:
require_once("$IP/extensions/Google1/Google1.php"); $google1siteurl = "(your site URL - ex: http://example.com/wiki)";
[edit] Code
<?php /** * Google +1 extension * Allows to insert the +1 button from Google * Installation Instructions: http://www.mediawiki.org/wiki/Extension:Google_+1 * * @file * @package MediaWiki * @subpackage Extensions * @author José Miguel López Salvador * @copyright © 2011 José Miguel López Salvador * @licence GNU General Public Licence 3.0 or later */ $wgExtensionCredits['parserhook'][] = array( 'name' => 'Google +1', 'version' => '1.0.4', 'author' => 'José Miguel López Salvador', 'url' => 'http://www.mediawiki.org/wiki/Extension:Google_+1', 'description' => 'Allows to insert the +1 button from Google' ); $wgExtensionFunctions[] = "google1Extension"; function google1Extension() { global $wgParser; global $versions_google1; global $google1siteurl; $wgParser->setHook( "google1", "renderGoogle1" ); $versions_google1 = array(); $versions_google1[1] = '<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script><g:plusone size="small"></g:plusone>'; $versions_google1[2] = '<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script><g:plusone size="medium"></g:plusone>'; $versions_google1[3] = '<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script><g:plusone></g:plusone>'; $versions_google1[4] = '<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script><g:plusone size="tall"></g:plusone>'; $versions_google1[5] = '<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script><g:plusone size="small" href="' . $google1siteurl . '"></g:plusone>'; $versions_google1[6] = '<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script><g:plusone size="medium" href="' . $google1siteurl . '"></g:plusone>'; $versions_google1[7] = '<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script><g:plusone href="' . $google1siteurl . '"></g:plusone>'; $versions_google1[8] = '<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script><g:plusone size="tall" href="' . $google1siteurl . '"></g:plusone>'; } function renderGoogle1( $input, $argv ) { global $versions_google1; $style= @$argv['style']; if (is_numeric($style)) { $version = $style; if (!$versions_google1[$version]) { $version = 1; } } else { $version = 1; } $form=$versions_google1[$version]; //$output = '<table border=0><tr><td>'.$form.'</td><td valign=center>'.$input.'</td></tr></table>'; $output = $form; return $output; }
