Last active
November 28, 2018 00:15
-
-
Save DmitriyRF/ca7b4c74143bfb02cd97e5628a70a753 to your computer and use it in GitHub Desktop.
Work with WordPress enqueue register dependencies / print
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 | |
// wp_head start after wp_enqueue_scripts hook | |
add_action('wp_head', 'get_enqueue_process_list'); | |
function get_enqueue_process_list() | |
{ | |
print_r( formaspace_print_scripts_styles() ); | |
} | |
function formaspace_print_scripts_styles() | |
{ | |
$result = []; | |
$result['scripts'] = []; | |
$result['styles'] = []; | |
// Print all loaded Scripts | |
global $wp_scripts; | |
// wp_scripts->registered as $script show ALL reqisterd wordpress scripts | |
foreach ($wp_scripts->queue as $script): | |
$result['scripts'][] = $wp_scripts->registered[$script]->src . "<br>"; | |
$result['scripts'][] = $wp_scripts->registered[$script]->deps . "<br>"; | |
$result['scripts'][] = $wp_scripts->registered[$script]->handle . "<br>"; | |
endforeach; | |
// Print all loaded Styles (CSS) | |
global $wp_styles; | |
foreach ($wp_styles->queue as $style): | |
$result['styles'][] = $wp_styles->registered[$style]->handle . "<br>"; | |
$result['styles'][] = $wp_styles->registered[$style]->deps . "<br>"; | |
$result['styles'][] = $wp_styles->registered[$style]->src . "<br>"; | |
endforeach; | |
return $result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment