Skip to content

Instantly share code, notes, and snippets.

@LittleCoding
Last active January 30, 2018 17:00
Show Gist options
  • Save LittleCoding/2004d9fd16fdec4eba199e3052330497 to your computer and use it in GitHub Desktop.
Save LittleCoding/2004d9fd16fdec4eba199e3052330497 to your computer and use it in GitHub Desktop.
Display current template filename in WordPress administration menu bar
<?php
/**
* code to be placed in theme functions.php
* add_filter priority of 200 or greater to display last.
*/
if ( ! function_exists( 'mytheme_admin_bar_menu' ) ) {
function mytheme_admin_bar_menu( $wp_admin_bar ) {
if ( defined( 'WP_DEBUG' ) && WP_DEBUG && ! is_admin() ) {
global $template;
$wp_admin_bar->add_menu( array(
'parent' => false,
'id' => 'template',
'title' => preg_replace( '#^' . $_SERVER['DOCUMENT_ROOT'] .'#', '~', $template ),
'href' => false,
));
}
}
add_filter( 'admin_bar_menu', 'mytheme_admin_bar_menu', 200 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment