Skip to content

Instantly share code, notes, and snippets.

@westonruter
Created April 17, 2019 05:21
Show Gist options
  • Save westonruter/99d365ca3127796c6f05fe4084081aac to your computer and use it in GitHub Desktop.
Save westonruter/99d365ca3127796c6f05fe4084081aac to your computer and use it in GitHub Desktop.
<?php
/**
* Plugin Name: Try AMP CTA
*/
add_filter(
'the_content',
function ( $content ) {
if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) {
$content = '<p>CTA!</p>' . $content;
}
return $content;
},
1000
);
add_action(
'wp_footer',
function() {
if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) {
?>
<amp-user-notification
layout="nodisplay"
id="amp-user-notification1"
data-dismiss-href="https://foo.com/api/dismissed">
This site uses cookies to personalize content.
<a href="">Learn more.</a>
<button on="tap:amp-user-notification1.dismiss">I accept</button>
</amp-user-notification>
<?php
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment