From 278eb70bbfc9bf3741d76730812f439857144fb2 Mon Sep 17 00:00:00 2001 From: Nick Ivanter Date: Mon, 27 Jul 2015 15:51:47 +0300 Subject: [PATCH] Pick up those scripts that were registered after the head scripts were already printed Some plugins register/enqueue scripts (for the footer) after the head scripts have already been printed. Previously, they were ignored by AssetsMinify. This change fixes it. --- src/AssetsMinify/Init.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/AssetsMinify/Init.php b/src/AssetsMinify/Init.php index 9a5c7c2..dbc37bb 100644 --- a/src/AssetsMinify/Init.php +++ b/src/AssetsMinify/Init.php @@ -39,12 +39,14 @@ public function __construct() { //Detects all js and css added to WordPress and removes their inclusion if( get_option('am_compress_styles', 1) ) add_action( 'wp_print_styles', array( $this->css, 'extract' ) ); - if( get_option('am_compress_scripts', 1) ) + if( get_option('am_compress_scripts', 1) ) { add_action( 'wp_print_scripts', array( $this->js, 'extract' ) ); + add_action( 'wp_print_footer_scripts', array( $this->js, 'extract' ), 5 ); + } //Inclusion of scripts in and before add_action( 'wp_head', array( $this, 'header' ) ); - add_action( 'wp_footer', array( $this, 'footer' ) ); + add_action( 'wp_print_footer_scripts', array( $this, 'footer' ), 6 ); } /** @@ -77,4 +79,4 @@ public function footer() { if ( $this->cache->isUpdated() ) Log::getInstance()->dumpStorage(); } -} \ No newline at end of file +}