Extension:ShoutWiki Ads

ShoutWiki Ads extension displays Google AdSense ads on skins without requiring a wiki system administrator to manually modify any skin files, thus making upgrades smoother. It supports a wide array of skins, see below for a full list.

The extension will not display ads
 * when ads are disabled
 * on the login page (Special:UserLogin)
 * on namespaces where ads are not enabled
 * for users in the  user group
 * if the wiki is in a language that is not supported by Google AdSense

Additionally, the ad HTML is always given the  class to hide the ads in printable view. Note that sadly, as of MediaWiki 1.39, support for this CSS class is a skin-specific feature and some skins do not unfortunately implement it properly; most do, though.

Despite the name, this extension isn't very ShoutWiki-specific and can be used on any MediaWiki installation (running a sufficiently up-to-date version of MediaWiki).

History
The reason why this extension was written was that in the past, each skin (at ShoutWiki) that should have ads needed to implement its own ad loader, which was not very easy to maintain, as it meant lots and lots of code duplication. To solve the problem, we stashed all the ad-related code into one class, and we'd just hook on the different hooks in different skins to display the ads.

All the functions in the ShoutWikiAds class are public and static, so it's very easy to use the class.

Parameters
The extension has only one configuration variable,. It should look something like this:

If the  key is set to , the extension will do nothing.

The  key should be set to your AdSense provider number (just the number, not the "pub-" part!).

Supported skins

 * Aurora (ShoutWiki)
 * (ShoutWiki)
 * Quartz (ShoutWiki)
 * (original version only, Vector 2022/New Vector is untested)
 * (ShoutWiki)
 * Quartz (ShoutWiki)
 * (original version only, Vector 2022/New Vector is untested)
 * (ShoutWiki)
 * Quartz (ShoutWiki)
 * (original version only, Vector 2022/New Vector is untested)
 * Quartz (ShoutWiki)
 * (original version only, Vector 2022/New Vector is untested)
 * (original version only, Vector 2022/New Vector is untested)
 * (original version only, Vector 2022/New Vector is untested)

Note on leaderboard ads
Save for a handful of explicitly blacklisted skins (Dusk and DuskToDawn, which have a very narrow content area; Monaco and Truglass, which do support the leaderboard ad but the implementation is non-standard), almost all skins support the  ad type even if they aren't explicitly listed above as supported. This is because for most skins, the leaderboard ad is implemented via a SiteNoticeAfter hook handler, and this hook should run in pretty much all skins.

To test it out, set  in LocalSettings.php. For example, for the DeskMessMirrored skin:

This would then enable the leaderboard ad slot in the DeskMessMirrored skin, which you can then verify by simply loading a page with the aforementioned skin.

Customizing ad colors
When in the non-responsive mode (i.e.  is set to  ), certain MediaWiki: namespace messages can be used to customize the colors of displayed ads. The naming of these interface messages follows the convention. For example,  could be used to customize the ad background color for wide skyscraper ads in the Metrolook skin (this corresponds to the AdSense JS variable.

For each ad slot, the following JS variables can be customized via the aforementioned messages:
 * border color ( JS variable)
 * background color ( JS variable)
 * link color ( JS variable) (TODO: how does this differ from   below? I have no idea...)
 * text color ( JS variable)
 * URL color ( JS variable) (TODO: how does this differ from   above? I have no idea...)