Extensions Google Adsense
From Triangle Wiki
IntroductionAdSense is a simple extension which allows you to put AdSense ads in your MediaWiki articles. The Google Ads at the top of this page are generated through this extension. If instead you wish to change the skin to display ads in the left column and the footer on every page (at least the ones permissable by the AdSense Terms & Conditions), see this page [1]. UsagePlease use the code below to place into your WikiPedia articles. <center> <adsense> google_ad_client = 'pub-4390370568784157'; google_ad_width = 728; google_ad_height = 90; google_ad_format = '728x90_as'; google_ad_type = 'text_image'; google_ad_channel = '3267063621'; google_color_border = 'FFFFFF'; google_color_bg = 'FFFFFF'; google_color_link = '3D81EE'; google_color_text = '000000'; google_color_url = '3D81EE'; </adsense> </center> For securing your code against anonymous changes, create a template for the adsense content, or for each type of add you want to create. Call these Template:728x90_as or some naming strategy so you know the type of add you are including into your article. Each template should then be protected so that only SysOps can edit and move the templates. Then include your template in any article by using the wiki markup {{728x90_as}} Installation
GoogleAdsense.php Source code
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* GoogleAdsense WikiMedia extension
*
* Firstly create a file called GoogleAdsense.php and place
* this in the extensions directory - copy all this code to
* that file. To activate the extension, include it from your
* LocalSettings.php with:
* require_once 'extensions/GoogleAdsense.php';
*
* PHP versions 5
*
* LICENSE: This source file is subject to version 3.0 of the
* PHP license that is available through the world-wide-web at
* the following URI: http://www.php.net/license/3_0.txt.
* If you did not receive a copy of the PHP License and are
* unable to obtain it through the web, please send a note to
* license@php.net so we can mail you a copy immediately.
*
* @category Wiki
* @package googleAdsense
* @author Ian Warner
* @copyright 2006 Triangle Solutions Ltd
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version SVN: $Id: $
* @link http://www.triangle-solutions.com/
*
* <code>
* <adsense>
* google_ad_client = 'pub-4390370568784157';
* google_ad_width = 728;
* google_ad_height = 90;
* google_ad_format = '728x90_as';
* google_ad_type = 'text_image';
* google_ad_channel = '3267063621';
* google_color_border = 'FFFFFF';
* google_color_bg = 'FFFFFF';
* google_color_link = '3D81EE';
* google_color_text = '000000';
* google_color_url = '3D81EE';
* </adsense>
* </code>
*/
/*
* @todo Document
*/
$wgExtensionFunctions[] = 'wfGoogleAdsense';
/*
* Extension credits
*/
$wgExtensionCredits['parserhook'][] = array(
'name' => 'GoogleAdsense',
'description' =>
'Enables the use of Google Adsense adverts within articles.',
'url' =>
'http://wiki.triangle-solutions.com/index.php/Extensions',
'author' => 'Triangle Solutions Ltd',
'version' => '1.0.1');
/**
* @todo Document
*/
function wfGoogleAdsense()
{
global $wgParser;
// registers the <adsense> extension with the WikiText parser
$wgParser->setHook('adsense', 'renderGoogleAdsense');
}
/**
* @todo Document
*/
function renderGoogleAdsense($input, $argv)
{
$output = '<script type="text/javascript">/* <![CDATA[ */';
$output .= $input;
$output .= '/* ]]> */</script>';
$output .= '<script type="text/javascript"';
$output .= 'src="http://pagead2.googlesyndication.com/">';
$output .= 'pagead/show_ads.js">';
$output .= '</script>';
return $output;
}
?>
External Links |
|

