MediaWiki extensions manual
OOjs UI icon advanced-invert.svg
Release status: stable
Implementation Skin , MyWiki , Hook
Description Ads banners defined in LocalSettings.php
Author(s) WikiMANNia (WikiForMentalk)
Latest version 2.0.3 (2022-02-16)
MediaWiki 1.23-1.36
PHP 5.6+
License GNU General Public License 2.0 or later
Example http://at.wikimannia.org
  • $wgWimaAdvertising
  • $wgWimaAdvertisingAnonOnly
  • $wgBannerTopCode
  • $wgBannerTopStyle
  • $wgBannerTopType
  • $wgBannerBottomCode
  • $wgBannerBottomStyle
  • $wgBannerBottomType
  • $wgSidebarAd1Code
  • $wgSidebarAd1Type
  • $wgSidebarAd2Code
  • $wgSidebarAd2Type

Check usage and version matrix.

The WimaAdvertising extension offers four additional advertising blocks to the Cologne Blue , Modern , MonoBook , and Vector skin. The banners are placed in the top and bottom of the wiki and two of them in the sidebar .


One ad block is located at the top of the "MediaWiki:Sitenotice", a second one below the article text in front of the category bar and two more ad blocks in the sidebar. By entering * AD1 and * AD2 in the MediaWiki:Sidebar, these can be placed individually. If Sitenotice is defined, the TopBanner will be displayed randomly alternating with the Sitenotice message.


  • Download and place the file(s) in a directory called WimaAdvertising in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php :
    wfLoadExtension( 'WimaAdvertising' );
  •   Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Configuration optionsEdit

Enable advertising. Default is false.

$wgWimaAdvertising = true;

Disable advertising for logged-in users. Default is false.

$wgWimaAdvertisingAnonOnly = true;


  • Set the type of the banner
    • Possible values: 'advertising', 'eventnote', 'hint'
    • Default value: 'advertising'
$wgBannerTopType = "eventnote";
$wgBannerBottomType = "eventnote";
$wgSidebarAd1Type = "advertising";
$wgSidebarAd2Type = "hint";
The labels above the advertising blocks will be translated into: de, en, es, fr, it, nl, pt, ru


$wgBannerTopCode = '<a title="Uhren-Wiki" href="https://www.uhren-wiki.net"><img src="https://wikimannia.org/skins/werbung/Werbung - Oben.jpg" width="728" height="92" alt="Werbung" /></a>';
$wgBannerBottomCode = '
Your banner code here.
$wgSidebarAd1Code = '<a title="Schwarzbuch Wikipedia" href="https://de.wikimannia.org/Schwarzbuch_Wikipedia"><img src="https://wikimannia.org/werbung/images/130px-Schwarzbuch_Wikipedia.jpg" alt="Schwarzbuch_Wikipedia.jpg" /></a> <p><b>Schwarzbuch Wikipedia</b></p><p class="small">Mobbing, Diffamierung und Falschinformation in der Online-Enzyklopädie, und was jetzt dagegen getan werden muss.</p><p>Im Februar 2020 im <i>Zeitgeist-Verlag</i> erschienen.</p>';
$wgSidebarAd2Code = 'Your banner code here.';

You can also do Google AdSense:

$wgSidebarAd2Code = '<script type="text/javascript"><!--
google_ad_client = "pub-9471398824076666";
/* ID 007 */
google_ad_slot = "3512091103";
google_ad_width = 145;
google_ad_height = 260;
google_language = "en";
google_encoding = "utf8";
// -->
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">


  • Set the CSS style specifications for the banner.
$wgBannerTopStyle = 'text-align:center;border:1px solid blue;';
$wgBannerBottomStyle = 'text-align:center;border:1px dotted red;';

Google AdsenseEdit

Version 2 with Google AdSense functionality is available for testing. Just like the Google AdSense extension, but on four possible advertising units. Version 1 is stable now, version 2 is in testing process.

Enable advertising. Default is false.

$wgWimaGoogleAdSense = true;

Disable advertising for logged-in users. Default is false.

$wgWimaGoogleAdSenseAnonOnly = true;

Mandatory parametersEdit

// Replace this with your own publisher ID (google_ad_client / data-ad-client)
$wgWimaGoogleAdSenseClient = 'none'; // Client ID for your AdSense script (example: ca-pub-1234546403419693)

(You can get your publisher ID and ad unit ID from the "Get code" page: Get and copy the ad code.)

Ad unitsEdit

Define up to four ad units:

$wgWimaGoogleAdSense_AD1= [ 'slotid 1', 145, 260 ];
$wgWimaGoogleAdSense_AD2= [ 'slotid 2', 145, 260 ];
$wgWimaGoogleAdSense_Top= [ 'slotid 3', 145, 260 ];
$wgWimaGoogleAdSense_Bottom = [ 'slotid 4', 145, 260 ];

Replace the first value with your AdSense ad unit ID (google_ad_slot / data-ad-slot) for each ad unit. The Slot ID for your AdSense script is for example 1234580893.

Also specify the width and the height of the AdSense unit, specified in your AdSense account (google_ad_width / data-ad-width, google_ad_height / data-ad-height).

Optional parametersEdit

Add any of the optional settings below – if your settings deviate from the defaults:

// This can be anything you like. Default is 'none'.
$wgWimaGoogleAdSenseID = 'none';

// Source URL of the AdSense script. No need to change - it can't deviate from the defaults.
$wgWimaGoogleAdSenseSrc = '//pagead2.googlesyndication.com/pagead/show_ads.js';

// Text coding. Default is 'utf8'.
$wgWimaGoogleAdSenseEncoding = "utf8";

// Advertising language. Default is $wgLanguageCode.
$wgWimaGoogleAdSenseLanguage = "en";


Skin VectorEdit

Skin Vector in revision 1.35 and 1.36 needs a hack to make the extension work for the ads in the sidebar.

In file includes/VectorTemplate.php change line 450 (REL1_35), respectively in file includes/SkinVector.php change line 337 (REL1_36):

	$props['class'] = trim( "$class $extraClasses[$type]" );


	$props['class'] = trim( "$extraClasses[$type]" );

Skin MonoBookEdit

For the Skin MonoBook, the ad at the bottom might look better if the hook is moved to the end of the content area.

In file includes/MonoBookTemplate.php change lines 85-91:

			'<!-- end content -->' .
	$html .= $this->deprecatedHookHack( 'MonoBookAfterContent' );
	$html .= $this->getIfExists( 'dataAfterContent' ) . $this->getClear();
	$html .= Html::closeElement( 'div' );


			'<!-- end content -->' .
			$this->getClear() .
			$this->getIfExists( 'dataAfterContent' ) .
	$html .= Html::closeElement( 'div' );

See alsoEdit

  • PCR GUI Inserts did something similar since REL 1.23, but not as sophisticated.
  • Google AdSense does the same, but only for one banner. And it does not allow custom banners.


  • This extension works from REL1_23 and has been tested up to MediaWiki version 1.36.3.
  • In REL1_37, the SkinBuildSidebar hook no longer allows images and HTML code to be placed in the sidebar.
    A solution for this circumstance is not yet known.