-
Notifications
You must be signed in to change notification settings - Fork 384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Let whitelist sanitizer dictate the required AMP scripts via spec #882
Conversation
* Use spec to determine which script components get enqueued * Use the latest component instead of 0.1 * Reduce duplicated logic by defining get_scripts() method on base sanitizer * Add get_allowed_tag_data method on AMP_Allowed_Tags_Generated to reduce size of array passing. * Define sanitized_tag class variable on sanitizer classes
Include also_requires_tag_warning in AMP_Allowed_Tags_Generated
…now handles discovery
Now the scripts are obtained via the whitelist sanitizer alone, so there is no need for the redundancy of obtaining the component scripts via the individual sanitizers or to duplicate the component lookup via a get_allowed_tag_data method.
@westonruter how about running the embeds through the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work on this, bang on! I am merging this so that @DavidCramer can use it in #871.
This comment may be implemented in another PR if we decide to go with it.
Sweet! |
Excellent point. The embeds don't need to implement |
requires_extension
andalso_requires_tag_warning
from spec inAMP_Allowed_Tags_Generated
so that the required AMP components can be determined for a given tag spec and returned viaAMP_Tag_And_Attribute_Sanitizer::get_scripts()
.latest
versions of AMP component scripts instead of0.1
. (Discussed with @amedina.)get_scripts()
method implementations from all of the sanitizers since all of the scripts now identified by whitelist sanitizer.AMP_Theme_Support::get_amp_component_scripts()
.With the changes here, you can just drop in AMP components to your post content (or to the theme templates w/ theme support) and AMP component scripts will automatically be added for them. For example, try pasting the following into a new post:
Automatically you'll then see these scripts added to the
head
:<script custom-element="amp-video" src="https://cdn.ampproject.org/v0/amp-video-latest.js" async></script>
<script custom-element="amp-gist" src="https://cdn.ampproject.org/v0/amp-gist-latest.js" async></script>
See #875.