I would like to know how to get the list of scripts enqueued in wordpress via wp_enqueue_script. I have done some research and checked the wp core itself but the closest I can get is something like:
add_options_page('Wp Sysinfo', 'Wp Sysinfo', 'manage_options', 'wp-sysinfo', 'sysinfo_page');
function sysinfo_page(){
global $wp_scripts;
print_r($wp_scripts->queue);
}
However it only show scripts in the admin pages not the front end.
FYI: Im building a plugin to display system information in wordpress. This is to provide plugin/theme authors useful info to troubleshoot problems reported by users.
In short, I need a way to get all scripts and styles enqueued in both admin and frontend, and view them within a custom admin page.
There is a dedicated Wordpress action hook for styles as well as scripts. These hooks will be triggered after every script or style is enqueued:
function inspect_scripts() {
global $wp_scripts;
print_r($wp_scripts->queue);
}
add_action( 'wp_print_scripts', 'inspect_scripts' );
function inspect_styles() {
global $wp_styles;
print_r($wp_styles->queue);
}
add_action( 'wp_print_styles', 'inspect_styles' );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With