Topic on User talk:TiltedCerebellum/Flow

Place GoogleAdsense in the sidebar

2
Weejan91 (talkcontribs)

Hi Tilted Cerebellum,

I've seen that you've managed to manually place a Google AdSense ad into the footer of a MW page by using this code:

$wgHooks['SkinAfterContent'][] = function(&$data, $skin) {
	    $data = '<div class="gas-bottom">';
	    $data .= '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>';
		$data .= '<ins class="adsbygoogle gas-bottom-first"
            style="display:table; width:728px; height:90px; margin:1em auto; clear:both;"
            data-ad-client="ca-pub-XXXXXXXXXXXXXXXX"
            data-ad-slot="XXXXXXXXXX"></ins>';
		$data .= '<script>
        (adsbygoogle = window.adsbygoogle || []).push({});
        </script>';
		$data .= '</div>';
        return true;
};
## -- Adsense footer end -- ##

It works fine, thanks for that! Could you edit the code so I can use it in the sidebar also? I'm sitting for hours and am not able to manage this :-/ Thanks a lot!!!

TiltedCerebellum (talkcontribs)

Sorry, we ended up editing our skin to add that bit to the sidebar as hooks were always funky (we use a non-standard, non-MediaWiki skin). The drawback there is each time the skin is updated, we need to put the code back. It's definitely not ideal, but it works since most of the extensions have gone defunct.

Reply to "Place GoogleAdsense in the sidebar"