Hiding the search form in the 3.1 Admin Bar

I love the new admin bar in WordPress 3.1, but the search box just isn’t needed for Eastman thanks to a combination of things. For the Eastman site, we are not using the built-in WordPress search in the usual way. We are also not directing all searches through Google, so having search.php just completely redirect doesn’t. We also already have a site search box in the header, anyway, so it’s kind of redundant (even if it’s just web editors who are seeing the admin bar search).

I looked into the rendering code for the admin bar and didn’t see a hook to manipulate the search box like there are for other menu items. This seems rather unfortunate to me and I may ask the question on wp-hackers later on tonight to see if I’m missing something, but I figured I could probably use CSS to hide it for now. I mean, it’s not like ESM web editors are going to use Firebug and resurrect the form (and I’d have to admit that I’d be really impressed if any of them could do it), and it’s not like the search itself is nonfunctional, it just doesn’t quite behave the way you think it might when searching the entire site. Now, because I want to create a consistent experience, I want to be sure that the search box doesn’t show even if the rare network site uses a different theme, so I figured I’d make a simple plugin and network activate it. So, here goes the plugin:

<?php
/*
Plugin Name: Hide Admin Bar Search
Plugin URI: http://www.helenhousandi.com/wordpress
Description: Uses CSS to hide the search box in the admin bar. Helpful if you don't use the built-in WordPress search like usual.
Version: 1.0
Author: Helen Hou-Sandi
Author URI: http://www.helenhousandi.com
*/

if ( !function_exists('hide_admin_bar_search') ) {
	function hide_admin_bar_search () { ?>
		<style type="text/css">
		#wpadminbar #adminbarsearch {
		display: none;
		}
		</style>
		<?php
	}
	add_action('admin_head', 'hide_admin_bar_search');
	add_action('wp_head', 'hide_admin_bar_search');
}

What we are using the built-in search for: the News Room (a category) and Faculty (a custom post type). The one for Faculty does something pretty cool – to be written about more at another time.

Hiding the search form in the 3.1 Admin Bar

2 thoughts on “Hiding the search form in the 3.1 Admin Bar

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s