Here is the code I have added to LocalSettings.php:
wfLoadExtension( 'WimaAdvertising' );
$wmGoogleAdSense = true;
$wmGoogleAdSenseClient = 'ca-pub-xxxxxxxxxxxxxxx';
$wmGoogleAdSense_AD1 = [ '<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-xxxxxxxxxxxxxxx" crossorigin="anonymous"></script>
<ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-xxxxxxxxxxxxxxx"
data-ad-slot="xxxxxxxxxx" data-ad-format="auto" data-full-width-responsive="true">
</ins>
<script>(adsbygoogle = window.adsbygoogle || []).push({});</script>', 145, 260 ];
$wmGoogleAdSenseSrc = '//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-xxxxxxxxxxxxxx';
This has as a result no ad related code do be added anywhere in the HTML source.
I have also tried instead of setting $wmGoogleAdSense_AD1
to use Manual:Hooks/SkinAfterPortlet. Here is the relative code:
$wgHooks['SkinAfterPortlet'][] = function($skin, $portletName, &$html) {$user = $skin->getUser();
if ($portletName === "tb") {
$html = <<< EOT
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-xxxxxxxxxxxxxxxx" crossorigin="anonymous"></script>
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-xxxxxxxxxxxxxxxx"
data-ad-slot="xxxxxxxxxx"
data-ad-format="auto"
data-full-width-responsive="true"></ins>
<script>(adsbygoogle = window.adsbygoogle || []).push({});</script>
EOT;
return true;
}
};
The addition of the hook reserves a space under the "Wiki Tools" section, but again no ads shown. I'm not sure if this has to do with AdSense itself though.
And just a final question. Shouldn't any AdSense code be added by the extension in the <header>
? Now the only code added is the one by the SkinAfterPortlet hook. Shouldn't setting the $wmGoogleAdSenseSrc
variable lead to an addition of related code in the header section?