We need to be able to be able to fetch an array of all stylesheets/scripts loaded by the wp_head/wp_footer functions both using PHP from the functions.php file in the WordPress theme. Is there a way to do this? My reason for doing this is we have a custom PHP script for minifying and combining them that our client would like to continue to use that's built right into the WordPress theme itself (without any need for plugins).
1
votes
1 Answers
1
votes
using this two filters you can get all loaded js/css files.
add_filter( 'style_loader_src', 'vc_remove_wp_ver_css_js', 9999 );
add_filter( 'script_loader_src', 'vc_remove_wp_ver_css_js', 9999 );
function vc_remove_wp_ver_css_js( $src ) {
return $src;
}
in that function you get the url of css/js files. i hope this hooks is useful for you.
i find this code from here