From 846123a0ee568369403a2a0f91dce5ac69675162 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 25 Apr 2018 21:05:46 -0700 Subject: [PATCH] Ensure only remaining AMP scripts are printed when preparing response --- includes/class-amp-theme-support.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/class-amp-theme-support.php b/includes/class-amp-theme-support.php index d10d93b9910..3d51ad3a7f3 100644 --- a/includes/class-amp-theme-support.php +++ b/includes/class-amp-theme-support.php @@ -1130,7 +1130,8 @@ public static function prepare_response( $response, $args = array() ) { // Print all scripts, some of which may have already been printed and inject into head. ob_start(); - wp_print_scripts( array_keys( $amp_scripts ) ); + remove_all_filters( 'print_scripts_array' ); // Make sure only the script handles we pass in will in fact get printed. + wp_scripts()->do_items( array_keys( $amp_scripts ) ); $script_tags = ob_get_clean(); if ( ! empty( $script_tags ) ) { $response = preg_replace(