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 1 commit into from Jun 26, 2018


None yet
2 participants
Copy link

commented Jun 26, 2018

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

@westonruter westonruter requested a review from kienstra Jun 26, 2018

Copy link

left a comment


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 );

This comment has been minimized.

Copy link

kienstra Jun 26, 2018


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 ) {

This comment has been minimized.

Copy link

kienstra Jun 26, 2018


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

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
continuous-integration/travis-ci/push The Travis CI build passed

@westonruter westonruter deleted the fix/classic-template-print-scripts-action branch Jun 26, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.