How to add HTML / Form to an Admin Bar Menu

I just gave this a shot and it seemed to work fine:

function wpse_form_in_admin_bar() {
    global $wp_admin_bar;

    $wp_admin_bar->add_menu( array(
        'id' => 'wpse-form-in-admin-bar',
        'parent' => 'top-secondary',
        'title' => '<form><input type="text" /><input type="submit" /> </form>'
    ) );
}
add_action( 'admin_bar_menu', 'wpse_form_in_admin_bar' );

You’ll have to do some work to gussy it up a bit, but it looks like there is a chance you can do what you want.

Leave a Comment