Skip to content

Instantly share code, notes, and snippets.

@kienstra
Created September 5, 2018 19:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kienstra/c204c13a0974d949ed741f37f8f9e14f to your computer and use it in GitHub Desktop.
Save kienstra/c204c13a0974d949ed741f37f8f9e14f to your computer and use it in GitHub Desktop.
<?php
/**
* Plugin Name: Invalid AMP
* Description: Intentionally outputs invalid AMP.
*/
/**
* Outputs a disallowed <script> for post types of 'page' only.
*/
add_action( 'wp_print_footer_scripts', function() {
if ( 'page' === get_post_type() ) :
?>
<script type="text/javascript">
console.log( 'Invalid AMP' );
</script>
<?php
endif;
} );
/**
* Enqueues scripts and stylesheets to cause AMP validation errros.
*/
add_action( 'wp_enqueue_scripts', function() {
wp_enqueue_script( 'iu-foo-a', 'http://example.com/foo-a' );
wp_enqueue_script( 'iu-foo-b', 'http://example.com/foo-b' );
wp_enqueue_style( 'iu-example-a', 'http://example.com/example-a' );
wp_enqueue_style( 'iu-example-b', 'http://example.com/example-b' );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment