Forked from omurphy27/echo-enqueued-styles-scripts-wordpress.php
Created
November 11, 2021 13:11
-
-
Save EmSixTeen/13dfa1fc1dc0da20a2d478aab5900fca to your computer and use it in GitHub Desktop.
Wordpress - Print Out All Enqueued Scripts And Styles On A Page
This file contains hidden or 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 | |
// add the below to your functions file | |
// then visit the page that you want to see | |
// the enqueued scripts and stylesheets for | |
function se_inspect_styles() { | |
global $wp_styles; | |
echo "<h2>Enqueued CSS Stylesheets</h2><ul>"; | |
foreach( $wp_styles->queue as $handle ) : | |
echo "<li>" . $handle . "</li>"; | |
endforeach; | |
echo "</ul>"; | |
} | |
add_action( 'wp_print_styles', 'se_inspect_styles' ); | |
function se_inspect_scripts() { | |
global $wp_scripts; | |
echo "<h2>Enqueued JS Scripts</h2><ul>"; | |
foreach( $wp_scripts->queue as $handle ) : | |
echo "<li>" . $handle . "</li>"; | |
endforeach; | |
echo "</ul>"; | |
} | |
add_action( 'wp_print_scripts', 'se_inspect_scripts' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment