Skip to content
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

Introduce amp_render_scripts() to print AMP component scripts and nothing else #1227

Merged
merged 1 commit into from
Jun 26, 2018

Conversation

westonruter
Copy link
Member

This adds the same script printing logic which runs with theme support to also run for the legacy templates. This prevents scripts from being printed at wp_print_scripts action.

Fixes #1225.
Previously #1097, #1101.

@westonruter westonruter added this to the v0.7.2 milestone Jun 26, 2018
Copy link
Contributor

@kienstra kienstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

Hi @westonruter,
This looks good, and it should help to prevent the invalid script printing in wp_print_scripts, like in the support topics you mentioned.

@@ -1049,7 +1050,7 @@ public function test_prepare_response() {
$this->assertContains( '<meta charset="' . get_bloginfo( 'charset' ) . '">', $sanitized_html );
$this->assertContains( '<meta name="viewport" content="width=device-width,minimum-scale=1">', $sanitized_html );
$this->assertContains( '<style amp-boilerplate>', $sanitized_html );
$this->assertContains( '<style amp-custom>body { background: black; }', $sanitized_html );
$this->assertRegExp( '#<style amp-custom>.*?body\s*{\s*background:\s*black;?\s*}.*?</style>#s', $sanitized_html );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice use of $this->assertRegExp().

* @param array $scripts Script handles mapped to URLs or true.
* @return string HTML for scripts tags that have not yet been done.
*/
function amp_render_scripts( $scripts ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's nice how this is decomposed into amp_render_scripts(), to allow using it for Legacy Templating and theme support.

@westonruter westonruter merged commit bf0b450 into 0.7 Jun 26, 2018
@westonruter westonruter deleted the fix/classic-template-print-scripts-action branch June 26, 2018 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants