Skip to content

Instantly share code, notes, and snippets.

@georgestephanis
Created October 19, 2018 21:12
Show Gist options
  • Save georgestephanis/02b9285b8cd096435899f083abeeeed2 to your computer and use it in GitHub Desktop.
Save georgestephanis/02b9285b8cd096435899f083abeeeed2 to your computer and use it in GitHub Desktop.
<?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 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment