morganestes
10/19/2018 - 9:12 PM

screen_id.php

<?php

add_action( 'admin_bar_menu', function( $wp_admin_bar ) {
    $screen = get_current_screen();
    if ( is_a( $screen, 'WP_Screen' ) ) {
        $wp_admin_bar->add_node( [
            'id'    => 'screen_id',
            'title' => sprintf( __( 'Screen ID: <kbd style="font-family: monospace; font-weight: 900;">%s</kbd>' ), esc_html( $screen->id ) ),
        ] );

        foreach ( get_object_vars( $screen ) as $key => $value ) {
            if ( empty( $value ) || ! is_scalar( $value ) ) {
                continue;
            }
            $wp_admin_bar->add_node( [
                'id'     => 'screen_id_' . $key,
                'parent' => 'screen_id',
                'title'  => sprintf( __( '%s: <kbd style="font-family: monospace; font-weight: 900;">%s</kbd>' ), esc_html( $key ), esc_html( $value ) ),
            ] );
        }
    }
}, 999 );