wp_admin_bar_search_menu

Add search form.

Description

wp_admin_bar_search_menu( (WP_Admin_Bar) $wp_admin_bar ); 

Parameters (1)

0. $wp_admin_bar (WP_Admin_Bar)
The wp admin bar.

Usage

  1. if ( !function_exists( 'wp_admin_bar_search_menu' ) ) { 
  2. require_once ABSPATH . WPINC . '/admin-bar.php'; 
  3.  
  4. // The wp admin bar. 
  5. $wp_admin_bar = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wp_admin_bar_search_menu($wp_admin_bar); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/admin-bar.php  
  1. function wp_admin_bar_search_menu( $wp_admin_bar ) { 
  2. if ( is_admin() ) 
  3. return; 
  4.  
  5. $form = '<form action="' . esc_url( home_url( '/' ) ) . '" method="get" id="adminbarsearch">'; 
  6. $form .= '<input class="adminbar-input" name="s" id="adminbar-search" type="text" value="" maxlength="150" />'; 
  7. $form .= '<label for="adminbar-search" class="screen-reader-text">' . __( 'Search' ) . '</label>'; 
  8. $form .= '<input type="submit" class="adminbar-button" value="' . __('Search') . '"/>'; 
  9. $form .= '</form>'; 
  10.  
  11. $wp_admin_bar->add_menu( array( 
  12. 'parent' => 'top-secondary',  
  13. 'id' => 'search',  
  14. 'title' => $form,  
  15. 'meta' => array( 
  16. 'class' => 'admin-bar-search',  
  17. 'tabindex' => -1,  
  18. ) );