Always show admin bar

I like the admin bar that we are adding in the soon to be released WordPress 3.1 so much that I wanted it to always show on my site.  This way you get an easy to use search box on every page even when logged out.

I wrote a quick plugin file which I dropped into the wp-content/mu-plugins folder on this site. Here is the code I used in case you want to do the same:


<?php
function pjw_login_adminbar( $wp_admin_bar) {
 if ( !is_user_logged_in() )
 $wp_admin_bar->add_menu( array( 'title' => __( 'Log In' ), 'href' => wp_login_url() ) );
}
add_action( 'admin_bar_menu', 'pjw_login_adminbar' );
add_filter( 'show_admin_bar', '__return_true' , 1000 );

As you can see to make it even more useful I’ve added a Log In link so I can use it to log in to the site.

As with anything else to do with the Admin bar this code requires WordPress 3.1 to work.



d
go to dashboard
l
go to login
h
show/hide help
e
edit post/page
r
comment on post/page
m
go to moderate comments
esc
cancel