Created
September 5, 2018 19:42
-
-
Save kienstra/c204c13a0974d949ed741f37f8f9e14f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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