wp_admin_bar_search_menu() - WordPress 函数参考中文文档

返回介绍

wp_admin_bar_search_menu()

发布于 2017-09-11 字数1908 浏览 880 评论 0

wp_admin_bar_search_menu( WP_Admin_Bar $wp_admin_bar )

Add search form.


描述


参数

$wp_admin_bar

(WP_Admin_Bar)
(Required)


源代码

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_menu( array(
		'parent' => 'top-secondary',
		'id'     => 'search',
		'title'  => $form,
		'meta'   => array(
			'class'    => 'admin-bar-search',
			'tabindex' => -1,
		)
	) );
}

更新日志

Version 描述
3.3.0 Introduced.

相关函数

Uses

  • wp-includes/l10n.php:
    __()
  • wp-includes/formatting.php:
    esc_url()
  • wp-includes/load.php:
    is_admin()
  • wp-includes/link-template.php:
    home_url()
  • wp-includes/class-wp-admin-bar.php:
    WP_Admin_Bar::add_menu()

User Contributed Notes

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!