Created
July 21, 2017 16:22
-
-
Save tzkmx/06430ab15a7b29782b083653692dd2d3 to your computer and use it in GitHub Desktop.
Force footer registration of scripts for lazyload when assetsminify plugin present
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** After registering scripts, A3 Lazy Load plugin fires action | |
* we use to fix registration, adding data to load it | |
* in footer, because assetsminify mangles the order of files */ | |
add_action('after_a3_lazy_load_xt_script', function() { | |
$plugins = get_option('active_plugins'); | |
if( in_array('assetsminify/plugin.php', $plugins) ) { | |
$scripts = wp_scripts(); | |
foreach($scripts->registered as $handle => $dep) { | |
if( false !== strpos( $handle, 'lazyloadxt' ) ) { | |
$scripts->add_data($handle, 'group', 1); | |
} | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment