Skip to content

Instantly share code, notes, and snippets.

@asha23
Created June 21, 2018 14:07
Show Gist options
  • Save asha23/d2924483ab966bd4e345a32357fcc6b5 to your computer and use it in GitHub Desktop.
Save asha23/d2924483ab966bd4e345a32357fcc6b5 to your computer and use it in GitHub Desktop.
WordPress plugin to show the script and style handles that are currently enqueued.
<?php
/**
* The plugin bootstrap file.
*
* This file is read by WordPress to generate the plugin information in the plugin
* admin area. This file also includes all of the dependencies used by the plugin,
* registers the activation and deactivation functions, and defines a function
* that starts the plugin.
*
* @see http://ashwhiting.com
* @since 1.0.0
*
* @wordpress-plugin
* Plugin Name: Show script and style handles
* Plugin URI: http://ashwhiting.com
* Description: Simply shows all enqueued scripts and styles.
* Version: 1.0.0
* Author: Ash Whiting
* Author URI: http://ashwhiting.com
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: script-style-handles
* Domain Path: /languages
*/
if (!defined('WPINC')) {
die;
}
define('PLUGIN_NAME_VERSION', '1.0.0');
global $enqueued_scripts;
global $enqueued_styles;
add_action('wp_print_scripts', 'cyb_list_scripts');
function cyb_list_scripts()
{
global $wp_scripts;
global $enqueued_scripts;
$enqueued_scripts = array();
echo '<h1>Scripts</h1>';
foreach ($wp_scripts->queue as $handle) {
echo '<p>'.$handle.'</p>';
}
}
add_action('wp_print_styles', 'cyb_list_styles');
function cyb_list_styles()
{
global $wp_styles;
global $enqueued_styles;
$enqueued_styles = array();
echo '<h1>Styles</h1>';
foreach ($wp_styles->queue as $handle) {
echo '<p>'.$handle.'</p>';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment