Skip to content

Instantly share code, notes, and snippets.

@Nerdies24
Created February 18, 2021 17:24
Show Gist options
  • Save Nerdies24/ad332d6e36e9f9b8d7c6e1e0aa25ecf3 to your computer and use it in GitHub Desktop.
Save Nerdies24/ad332d6e36e9f9b8d7c6e1e0aa25ecf3 to your computer and use it in GitHub Desktop.
Zeige alle Scripte und Styles für angemeldete Admins

Zeige alle WordPress Scripte und WordPress Styles für angemeldete Admins

Der Code gehört in die functions.php

  • grün sind Scripte
  • blau sind Styles
//Zeige alle Scripte für eingeloggte Admins
function nerdies_print_scripts_styles() {
    if( !is_admin() && is_user_logged_in() && current_user_can( 'manage_options' )) {
        // Print Scripts
        global $wp_scripts;
        foreach( $wp_scripts->queue as $handle ) :
           echo '<div style="margin: 5px 3%; color: white; background-color: #46B450; border: 1px solid #eee; padding: 20px;">Script <br />';
           echo "Handle: " . $handle . '<br />';
           echo "URL: " . $wp_scripts->registered[$handle]->src;
           echo '</div>';
        endforeach;
     
//Zeige alle Styles für eingeloggte Admins
        global $wp_styles;
        foreach( $wp_styles->queue as $handle ) :
           echo '<div style="margin: 5px 3%; border: 1px solid #eee; padding: 20px; color: white; background-color: #0073AA;">Style <br />';
           echo "Handle: " . $handle . '<br />';
           echo "URL: " . $wp_styles->registered[$handle]->src;
           echo '</div>';
        endforeach;
    }
}
add_action( 'wp_print_scripts', 'nerdies_print_scripts_styles', 101 );

Image

Dieser Gist gehört zur Facebook Gruppe: https://www.facebook.com/groups/deinwordpressprojekt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment