Custom Element Scripts being removed
-
Hi,
After an update to the AMP WP plugin custom element scripts are being stripped.
The code we are using to output the custom element scripts looks like this
add_action( 'amp_post_template_head', 'theme_slug_amp_post_template_head' ); /** * Adds the async script tags with custom element for amp analytics and potentially other scripts. */ function theme_slug_amp_post_template_head() { // phpcs:disable WordPress.WP.EnqueuedResources.NonEnqueuedScript ?> <!-- This is loaded from the theme 1 --> <script async src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js" custom-element="amp-analytics"></script> <script async src="https://cdn.ampproject.org/v0/amp-form-0.1.js" custom-element="amp-form"></script> <?php // phpcs:enable }
I added the HTML comment to verify the hook was still working as expected.
This theme is based on TwentySeventeen. Due to the way it was built, it doesn’t look right using Transitional or Standard modes so it is using Reader mode.
There is a form and an analytics tag output into the AMP page. In some cases the
amp-analytics
script is left but theamp-form
script is always stripped.Things I’ve tried:
– Output an HTML comment to make sure the action is working as expected.
– Change the priority to PHP_MAX_INT
– Search Google and the git repo for any hint about this
- The topic ‘Custom Element Scripts being removed’ is closed to new replies.