本文整理汇总了PHP中WP_Admin_Bar类的典型用法代码示例。如果您正苦于以下问题:PHP WP_Admin_Bar类的具体用法?PHP WP_Admin_Bar怎么用?PHP WP_Admin_Bar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WP_Admin_Bar类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: siteorigin_panels_lite_admin_bar_menu
/**
* Add the Edit Home Page item to the admin bar.
*
* @param WP_Admin_Bar $admin_bar
* @return WP_Admin_Bar
*/
function siteorigin_panels_lite_admin_bar_menu($admin_bar)
{
if (is_front_page() && current_user_can('edit_theme_options') && !is_page()) {
$admin_bar->add_node(array('id' => 'edit-home-page', 'title' => __('Edit Home Page', 'clearly'), 'href' => admin_url('themes.php?page=so_panels_home_page')));
}
return $admin_bar;
}
示例2: admin_bar_ip
/**
* @param WP_Admin_Bar $wp_admin_bar
*/
function admin_bar_ip($wp_admin_bar)
{
if (!current_user_can('manage_options')) {
return;
}
$wp_admin_bar->add_node(['id' => 'wp-ip', 'title' => sprintf(__('Currently located at <b>%s</b>'), $_SERVER['SERVER_ADDR']), 'parent' => 'top-secondary']);
}
示例3: admin_bar_menu
/**
* Add a "Flush Cache" button the admin menu
* @param WP_Admin_Bar $admin_bar
* @return void
*/
public function admin_bar_menu($admin_bar)
{
global $gd_system_config;
$config = $gd_system_config->get_config();
$gateway_url = isset($config['gateway_url']) ? $config['gateway_url'] : '';
// Only show to admin users
if (!current_user_can('activate_plugins')) {
return;
}
switch (true) {
case gd_is_mt():
$top_menu_label = __('Media Temple', 'gd_system');
$top_menu_icon_class = 'media-temple';
break;
case gd_is_reseller():
$top_menu_label = __('Managed WordPress', 'gd_system');
$top_menu_icon_class = 'admin-generic';
break;
default:
$top_menu_label = __('GoDaddy', 'gd_system');
$top_menu_icon_class = 'godaddy-alt';
break;
}
$admin_bar->add_menu(['id' => static::ADMIN_MENU_SLUG, 'title' => sprintf('<span class="ab-icon dashicons dashicons-%s"></span><span class="ab-label">%s</span>', $top_menu_icon_class, $top_menu_label)]);
// Settings menu
$admin_bar->add_menu(['parent' => static::ADMIN_MENU_SLUG, 'id' => static::ADMIN_MENU_SLUG . '-control-panel', 'title' => sprintf('%s<span class="dashicons dashicons-external"></span>', __('Account Settings', 'gd_system')), 'href' => str_replace('%pl_id%', defined('GD_RESELLER') ? GD_RESELLER : '', $gateway_url), 'meta' => array('target' => '_blank')]);
// Flush cache menu
$admin_bar->add_menu(['parent' => static::ADMIN_MENU_SLUG, 'id' => static::ADMIN_MENU_SLUG . '-flush-cache', 'title' => __('Flush Cache', 'gd_system'), 'href' => esc_url(add_query_arg(['GD_COMMAND' => 'FLUSH_CACHE', 'GD_NONCE' => wp_create_nonce('GD_FLUSH_CACHE')]))]);
}
示例4: admin_bar
/**
* Admin bar
*
* @param WP_Admin_Bar $wp_admin_bar
*/
public function admin_bar($wp_admin_bar)
{
if (!current_user_can('manage_options')) {
return;
}
$wp_admin_bar->add_menu(array('id' => 'example-plugin', 'title' => __('Process', 'example-plugin'), 'href' => '#'));
$wp_admin_bar->add_menu(array('parent' => 'example-plugin', 'id' => 'example-plugin-single', 'title' => __('Single User', 'example-plugin'), 'href' => wp_nonce_url(admin_url('?process=single'), 'process')));
$wp_admin_bar->add_menu(array('parent' => 'example-plugin', 'id' => 'example-plugin-all', 'title' => __('All Users', 'example-plugin'), 'href' => wp_nonce_url(admin_url('?process=all'), 'process')));
}
示例5: array
/**
* Add status menu to the admin bar.
*
* Ideally, each status comes with an action to take. The action requires
* permission. Also ideally, this just hooks into a LivePress status API.
*
* @author tddewey
*
* @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar object.
*
* @return void
*/
function admin_bar_menu($wp_admin_bar)
{
if (!current_user_can('manage_options') || !is_admin()) {
return;
}
$class = 'livepress-status-menu';
$status = self::get_status();
$wp_admin_bar->add_menu(array('id' => 'livepress-status', 'title' => '<span class="ab-icon"></span><span class="ab-label">' . esc_html__('LivePress', 'livepress') . '</span>', 'href' => '', 'sticky' => true, 'meta' => array('title' => 'connected' == $status ? esc_html__('LivePress connected.', 'livepress') : esc_html__('LivePress connection error.', 'livepress'), 'class' => $class . ' ' . $status)));
}
示例6: mss_admin_bar_menu
/**
* Add search field menu item
*
* @param WP_Admin_Bar $wp_admin_bar
* @return void
*/
function mss_admin_bar_menu($wp_admin_bar)
{
$total_users_sites = count($wp_admin_bar->user->blogs);
$show_if_gt = apply_filters('mms_show_search_minimum_sites', 10);
if (!is_user_logged_in() || $total_users_sites < $show_if_gt) {
return;
}
$wp_admin_bar->add_menu(array('parent' => 'my-sites-list', 'id' => 'my-sites-search', 'title' => sprintf('<label for="my-sites-search-text">%s</label><input type="text" id="my-sites-search-text" placeholder="%s" />', esc_html__('Filter My Sites', 'mss'), esc_attr__('Search Sites', 'mss')), 'meta' => array('class' => 'hide-if-no-js')));
}
示例7: replace_site_name
/**
* Replaces the current site's name with the site's alternative language title, if not empty.
*
* @param WP_Admin_Bar $wp_admin_bar
*
* @return WP_Admin_Bar
*/
public function replace_site_name(WP_Admin_Bar $wp_admin_bar)
{
$title = $this->get_title();
if (!$title) {
return $wp_admin_bar;
}
$wp_admin_bar->add_node(array('id' => 'site-name', 'title' => $title));
return $wp_admin_bar;
}
示例8: action_admin_bar_menu
public function action_admin_bar_menu(WP_Admin_Bar $wp_admin_bar)
{
if (!$this->user_can_view()) {
return;
}
$title = __('Query Monitor', 'query-monitor');
$wp_admin_bar->add_menu(array('id' => 'query-monitor', 'title' => esc_html($title), 'href' => '#qm-overview', 'meta' => array('classname' => 'hide-if-js')));
$wp_admin_bar->add_menu(array('parent' => 'query-monitor', 'id' => 'query-monitor-placeholder', 'title' => esc_html($title), 'href' => '#qm-overview'));
}
示例9: action_admin_bar_menu
public function action_admin_bar_menu(WP_Admin_Bar $wp_admin_bar)
{
if (!$this->qm->user_can_view()) {
return;
}
$class = implode(' ', array('hide-if-js', QM_Util::wpv()));
$title = __('Query Monitor', 'query-monitor');
$wp_admin_bar->add_menu(array('id' => 'query-monitor', 'title' => $title, 'href' => '#qm-overview', 'meta' => array('classname' => $class)));
$wp_admin_bar->add_menu(array('parent' => 'query-monitor', 'id' => 'query-monitor-placeholder', 'title' => $title, 'href' => '#qm-overview'));
}
示例10: test_merging_existing_meta_values
/**
* @ticket 21117
*/
function test_merging_existing_meta_values()
{
$admin_bar = new WP_Admin_Bar();
$admin_bar->add_node(array('id' => 'test-node', 'meta' => array('class' => 'test-class')));
$node = $admin_bar->get_node('test-node');
$this->assertEquals(array('class' => 'test-class'), $node->meta);
$admin_bar->add_node(array('id' => 'test-node', 'meta' => array('some-meta' => 'value')));
$node = $admin_bar->get_node('test-node');
$this->assertEquals(array('class' => 'test-class', 'some-meta' => 'value'), $node->meta);
}
示例11: test_merging_existing_meta_values
/**
* @ticket 21117
*/
function test_merging_existing_meta_values()
{
wp_set_current_user(self::$editor_id);
$admin_bar = new WP_Admin_Bar();
$admin_bar->add_node(array('id' => 'test-node', 'meta' => array('class' => 'test-class')));
$node1 = $admin_bar->get_node('test-node');
$this->assertEquals(array('class' => 'test-class'), $node1->meta);
$admin_bar->add_node(array('id' => 'test-node', 'meta' => array('some-meta' => 'value')));
$node2 = $admin_bar->get_node('test-node');
$this->assertEquals(array('class' => 'test-class', 'some-meta' => 'value'), $node2->meta);
}
示例12: admin_bar_menu
/**
* @hook
*
* @priority 999
*/
public function admin_bar_menu(\WP_Admin_Bar $wp_admin_bar)
{
if (empty($this->nodes)) {
return;
}
foreach ($this->nodes as $id => $args) {
if (call_user_func($args['display_cb'])) {
$wp_admin_bar->add_node($args);
}
}
}
示例13: test_merging_existing_meta_values
/**
* @ticket 21117
*/
function test_merging_existing_meta_values()
{
wp_set_current_user($this->factory->user->create(array('role' => 'editor')));
$admin_bar = new WP_Admin_Bar();
$admin_bar->add_node(array('id' => 'test-node', 'meta' => array('class' => 'test-class')));
$node = $admin_bar->get_node('test-node');
$this->assertEquals(array('class' => 'test-class'), $node->meta);
$admin_bar->add_node(array('id' => 'test-node', 'meta' => array('some-meta' => 'value')));
$node = $admin_bar->get_node('test-node');
$this->assertEquals(array('class' => 'test-class', 'some-meta' => 'value'), $node->meta);
}
示例14: wl_admin_bar
/**
* Adds WordLift to the Admin bar.
* @param WP_Admin_Bar $wp_admin_bar The existing admin bar.
*/
function wl_admin_bar($wp_admin_bar)
{
if (!is_super_admin() || !is_admin_bar_showing()) {
return;
}
$defaults = array('href' => false, 'parent' => false, 'id' => 'wordlift', 'title' => '');
$wp_admin_bar->add_menu($defaults);
// Add a link to the WordLift settings page.
$wp_admin_bar->add_menu(array('parent' => 'wordlift', 'id' => 'wordlift-settings', 'title' => 'Settings', 'href' => get_admin_url(null, 'admin.php?page=wl_configuration_admin_menu')));
// Add a link to the WordLift web site.
$wp_admin_bar->add_menu(array('parent' => 'wordlift', 'id' => 'wordlift-about', 'title' => 'About WordLift', 'href' => 'http://wordlift.it'));
}
示例15: admin_network_menu_bar
/**
* Adds 'Duplicate' entry to network admin-bar
* @since 0.2.0
* @param WP_Admin_Bar $wp_admin_bar
*/
public static function admin_network_menu_bar($wp_admin_bar)
{
if (current_user_can('manage_sites')) {
$wp_admin_bar->add_menu(array('parent' => 'network-admin', 'id' => 'network-admin-duplicate', 'title' => MUCD_NETWORK_MENU_DUPLICATION, 'href' => network_admin_url('sites.php?page=' . MUCD_SLUG_NETWORK_ACTION)));
foreach ((array) $wp_admin_bar->user->blogs as $blog) {
if (MUCD_Functions::is_duplicable($blog->userblog_id)) {
$menu_id = 'blog-' . $blog->userblog_id;
$wp_admin_bar->add_menu(array('parent' => $menu_id, 'id' => $menu_id . '-duplicate', 'title' => MUCD_NETWORK_MENU_DUPLICATE, 'href' => network_admin_url('sites.php?page=' . MUCD_SLUG_NETWORK_ACTION . '&id=' . $blog->userblog_id)));
}
}
}
}