adsense module fix

spaldam
spaldam's picture

Joined: 2004-07-08
Posts: 23
Posted: Mon, 2014-07-14 00:17

I installed the adsense module (http://codex.galleryproject.org/Gallery3:Modules:adsense) on 3.0.9 release, code named Chartres.

I had to tweak the source to get it working:

modules/adsense/helpers/adsense_theme.php:

From:
$google_code = '
<script type="text/javascript">' . $code . '</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>';

return $google_code;
To:
$google_code = '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle" ' . $code . ' ></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
<br><br><br><br>';

return $google_code

Then within The Gallery administration under "Settings -> Adsense" you insert your specific details:

style="display:inline-block;width:###px;height:##px"
data-ad-client="ca-pub-#########"
data-ad-slot="#########"

It still has more blank space between the header text and the ad then I'd like, and I had to put a bunch of extra returns in to make sure it didn't cover up the menu items, but at least it works fairly well.

- spaldam.com