Skip to content

AMP Compatibility Plugin to replace Adsense ads

Notifications You must be signed in to change notification settings

rtCamp/amp-ad-compat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

AMP AD Compatibility Plugin

A WordPress Plugin replaces Ad unit codes and covert them into amp-ad.

Notes

  • The plugin replace <ins class="adsbygoogle"> code with amp-ad.
  • The plugin removes the script for ads since it's no longer needed.
  • Plugin do not place ad code into your site, it just replaces existing codes with amp-ad on AMP endpoint.

Usages Scenario

  • Your theme have settings to add Ad unit code in different areas of theme like header or footer.
  • You are using a plugin which places Ad unit codes but it won't work on AMP.

What this plugin do?

Ad unit code on non-AMP pages.

<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-1234567890123456"
data-ad-slot="1234567890"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

Converted into ad-unit on AMP page.

<amp-ad width="728" height="90" type="adsense" data-ad-client="ca-pub-1234567890123456" data-ad-slot="1234567890" class="adsbygoogle">
</amp-ad>

Plugin Structure

.
├── sanitizers
│   ├── class-sanitizer.php
└── amp-ad-compat.php

Sanitizers

The plugin uses amp_content_sanitizers filter to add custom sanitizers.

Need a feature in plugin?

Feel free to create a issue and will add more examples.

About

AMP Compatibility Plugin to replace Adsense ads

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages