<?php
//Plugin Name: New Admin Bar Search
add_action( 'template_redirect', function() {
remove_action( 'admin_bar_menu', 'wp_admin_bar_search_menu', 4 );
add_action( 'admin_bar_menu', 'nabs_wp_admin_bar_search_menu', 4 );
} );
/**
* Add search form.
*
* @since 3.3.0
*
* @param WP_Admin_Bar $wp_admin_bar
*/
function nabs_wp_admin_bar_search_menu( $wp_admin_bar ) {
if ( is_admin() )
return;
$form = '<form action="' . esc_url( home_url( '/' ) ) . '" method="get" id="adminbarsearch">';
$form .= '<input class="adminbar-input" name="s" id="adminbar-search" type="text" value="" maxlength="150" />';
$form .= '<input type="submit" class="adminbar-button" value="' . __('New Search') . '"/>';
$form .= '</form>';
$wp_admin_bar->add_menu( array(
'parent' => 'top-secondary',
'id' => 'search',
'title' => $form,
'meta' => array(
'class' => 'admin-bar-search',
'tabindex' => -1,
)
) );
}