wp_admin_bar_search_menu() WordPress Function
The wp_admin_bar_search_menu() function allows you to add a search form to the WordPress admin bar. This can be useful if you want to search your site while you are logged in as an administrator.
wp_admin_bar_search_menu( WP_Admin_Bar $wp_admin_bar ) #
Adds search form.
Parameters
- $wp_admin_bar
(WP_Admin_Bar)(Required)The WP_Admin_Bar instance.
Source
File: wp-includes/admin-bar.php
function 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 .= '<label for="adminbar-search" class="screen-reader-text">' . __( 'Search' ) . '</label>'; $form .= '<input type="submit" class="adminbar-button" value="' . __( 'Search' ) . '" />'; $form .= '</form>'; $wp_admin_bar->add_node( array( 'parent' => 'top-secondary', 'id' => 'search', 'title' => $form, 'meta' => array( 'class' => 'admin-bar-search', 'tabindex' => -1, ), ) ); }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
3.3.0 | Introduced. |