[wp-hackers] Recommended way for plugins to add admin bar menus

Frank Bueltge frank at bueltge.de
Thu Dec 2 21:51:18 UTC 2010


now on my notebook.
I think this works, an example:

function wp_codex_search_form() {
global $wp_admin_bar, $wpdb;

if ( !is_super_admin() || !is_admin_bar_showing() )
return;
 $codex_search = '<form target="_blank" method="get" action="
http://wordpress.org/search/do-search.php" style="margin:2px 0 0;">
 <input type="text" onblur="this.value=(this.value==\'\') ? \'Search the
Codex\' : this.value;" onfocus="this.value=(this.value==\'Search the
Codex\') ? \'\' : this.value;" maxlength="100" value="Search the Codex"
name="search" class="adminbar-input">
 <button type="submit" class="adminbar-button">
<span>Go</span>
 </button>
</form>';
 /* Add the main siteadmin menu item */
$wp_admin_bar->add_menu( array( 'id' => 'codex_search', 'title' => 'Search
Codex', 'href' => FALSE ) );
 $wp_admin_bar->add_menu( array( 'parent' => 'codex_search', 'title' =>
$codex_search, 'href' => FALSE ) );
}
add_action( 'admin_bar_menu', 'wp_codex_search_form', 1000 );

Best regards
Frank

On Thu, Dec 2, 2010 at 10:39 PM, John Blackbourn
<johnbillion+wp at gmail.com<johnbillion%2Bwp at gmail.com>
> wrote:

> What's the recommended way for plugins to add menus to the new admin bar in
> 3.1?
>
> Is there a nice wrapper function like the administration menus, or
> should plugins just use the add_menu() method of the global
> $wp_admin_bar object?
>
> John
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list