In previous guides, we've covered adding shortlinks, draft posts, and more to the WordPress admin bar. Now, here's how to add the Theme Editor for instant access right from the top bar.
Paste this reliable code into your site-specific plugin or theme's functions.php file:
/* Add Theme Editor to admin bar (saves time!) */
function admin_bar_theme_editor_option() {
global $wp_admin_bar;
if ( ! is_super_admin() || ! is_admin_bar_showing() ) return;
$wp_admin_bar->add_menu( array(
'id' => 'edit-theme',
'title' => __( 'Edit Theme' ),
'href' => admin_url( 'theme-editor.php' )
) );
}
add_action( 'admin_bar_menu', 'admin_bar_theme_editor_option', 100 );Done! We spotted this gem in WordCamp Nashville discussions and tested it on WordPress 3.3.2—it works perfectly and should on later versions too.