本文整理汇总了PHP中WP_Admin_Bar::add_group方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Admin_Bar::add_group方法的具体用法?PHP WP_Admin_Bar::add_group怎么用?PHP WP_Admin_Bar::add_group使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_Admin_Bar
的用法示例。
在下文中一共展示了WP_Admin_Bar::add_group方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: configure
/**
* Configures an admin bar object adding menus, groups and nodes to it.
*
* @param WP_Admin_Bar $wp_admin_bar
*
* @return array An array of menus to add to the admin bar.
*/
public function configure(WP_Admin_Bar $wp_admin_bar)
{
$main = Tribe__Events__Main::instance();
$wp_admin_bar->add_menu(array('id' => 'tribe-events', 'title' => '<span class="ab-icon dashicons-before dashicons-calendar"></span>' . sprintf(__('%s', 'the-events-calendar'), $main->plural_event_label), 'href' => $main->getLink('home')));
$wp_admin_bar->add_group(array('id' => 'tribe-events-group', 'parent' => 'tribe-events'));
$wp_admin_bar->add_group(array('id' => 'tribe-events-add-ons-group', 'parent' => 'tribe-events'));
$wp_admin_bar->add_group(array('id' => 'tribe-events-settings-group', 'parent' => 'tribe-events'));
if (current_user_can('edit_tribe_events')) {
$wp_admin_bar->add_group(array('id' => 'tribe-events-import-group', 'parent' => 'tribe-events-add-ons-group'));
}
$wp_admin_bar->add_menu(array('id' => 'tribe-events-view-calendar', 'title' => esc_html__('View Calendar', 'the-events-calendar'), 'href' => $main->getLink('home'), 'parent' => 'tribe-events-group'));
if (current_user_can('edit_tribe_events')) {
$wp_admin_bar->add_menu(array('id' => 'tribe-events-add-event', 'title' => sprintf(esc_html__('Add %s', 'the-events-calendar'), $main->singular_event_label), 'href' => trailingslashit(get_admin_url()) . 'post-new.php?post_type=' . Tribe__Events__Main::POSTTYPE, 'parent' => 'tribe-events-group'));
}
if (current_user_can('edit_tribe_events')) {
$wp_admin_bar->add_menu(array('id' => 'tribe-events-edit-events', 'title' => sprintf(esc_html__('Edit %s', 'the-events-calendar'), $main->plural_event_label), 'href' => trailingslashit(get_admin_url()) . 'edit.php?post_type=' . Tribe__Events__Main::POSTTYPE, 'parent' => 'tribe-events-group'));
}
if (current_user_can('publish_tribe_events')) {
$import_node = $wp_admin_bar->get_node('tribe-events-import');
if (!is_object($import_node)) {
$wp_admin_bar->add_node(array('id' => 'tribe-events-import', 'title' => esc_html__('Import', 'the-events-calendar'), 'parent' => 'tribe-events-import-group', 'href' => esc_url(add_query_arg(array('post_type' => Tribe__Events__Main::POSTTYPE, 'page' => 'aggregator'), admin_url('edit.php')))));
}
}
if (current_user_can('manage_options')) {
$hide_all_settings = Tribe__Settings_Manager::get_network_option('allSettingsTabsHidden', '0');
if ($hide_all_settings == '0') {
$wp_admin_bar->add_menu(array('id' => 'tribe-events-settings', 'title' => esc_html__('Settings', 'the-events-calendar'), 'href' => Tribe__Settings::instance()->get_url(), 'parent' => 'tribe-events-settings-group'));
}
// Only show help link if it's not blocked in network admin.
$hidden_settings_tabs = Tribe__Settings_Manager::get_network_option('hideSettingsTabs', array());
if (!in_array('help', $hidden_settings_tabs)) {
$href = esc_url(add_query_arg(array('post_type' => Tribe__Events__Main::POSTTYPE, 'page' => 'tribe-help'), admin_url('edit.php')));
$wp_admin_bar->add_menu(array('id' => 'tribe-events-help', 'title' => esc_html__('Help', 'the-events-calendar'), 'href' => $href, 'parent' => 'tribe-events-settings-group'));
}
}
}
示例2: _ga_adjust_admin_bar_my_sites_menu
/**
* Adds links to the Global Administration panel to the Toolbar as necessary.
*
* @since 1.0.0
* @access private
*
* @param WP_Admin_Bar $admin_bar The Toolbar instance.
*/
function _ga_adjust_admin_bar_my_sites_menu($admin_bar)
{
if (!is_user_logged_in() || !current_user_can('manage_global')) {
return;
}
$admin_bar->add_group(array('parent' => 'my-sites', 'id' => 'my-sites-global-admin'));
$admin_bar->add_menu(array('parent' => 'my-sites-global-admin', 'id' => 'global-admin', 'title' => __('Global Admin', 'global-admin'), 'href' => global_admin_url()));
$admin_bar->add_menu(array('parent' => 'global-admin', 'id' => 'global-admin-d', 'title' => __('Dashboard'), 'href' => global_admin_url()));
/**
* Filters whether the Networks item should be shown in the Global Admin menu of the Toolbar.
*
* @private
* @since 1.0.0
*
* @param bool Whether to show the item. Defaults to false.
*/
if (apply_filters('_global_admin_show_admin_bar_networks', false)) {
$admin_bar->add_menu(array('parent' => 'global-admin', 'id' => 'global-admin-n', 'title' => __('Networks', 'global-admin'), 'href' => add_query_arg(array('page' => 'networks'), global_admin_url('admin.php'))));
}
$admin_bar->add_menu(array('parent' => 'global-admin', 'id' => 'global-admin-u', 'title' => __('Users'), 'href' => global_admin_url('users.php')));
$admin_bar->add_menu(array('parent' => 'global-admin', 'id' => 'global-admin-o', 'title' => __('Settings'), 'href' => global_admin_url('settings.php')));
}
示例3: wp_admin_bar_add_secondary_groups
/**
* Add secondary menus.
*
* @since 3.3.0
*
* @param WP_Admin_Bar $wp_admin_bar
*/
function wp_admin_bar_add_secondary_groups($wp_admin_bar)
{
$wp_admin_bar->add_group(array('id' => 'top-secondary', 'meta' => array('class' => 'ab-top-secondary')));
$wp_admin_bar->add_group(array('parent' => 'wp-logo', 'id' => 'wp-logo-external', 'meta' => array('class' => 'ab-sub-secondary')));
}
示例4: replace_menu_bar_my_sites
/**
* Rearrange ordering of Admin bar menu elements for our purposes
*
* @param \WP_Admin_Bar $wp_admin_bar
*/
function replace_menu_bar_my_sites($wp_admin_bar)
{
$wp_admin_bar->remove_menu('my-sites');
// Don't show for logged out users or single site mode.
if (!is_user_logged_in() || !is_multisite()) {
return;
}
// Show only when the user has at least one site, or they're a super admin.
if (count($wp_admin_bar->user->blogs) < 1 && !is_super_admin()) {
return;
}
$wp_admin_bar->add_menu(array('id' => 'my-books', 'title' => __('My Catalog', 'pressbooks'), 'href' => admin_url('index.php?page=pb_catalog')));
$wp_admin_bar->add_node(array('parent' => 'my-books', 'id' => 'add-new-book', 'title' => __('Add A New Book', 'pressbooks'), 'href' => network_home_url('wp-signup.php')));
if (is_super_admin()) {
$wp_admin_bar->add_group(array('parent' => 'my-books', 'id' => 'my-books-super-admin'));
$wp_admin_bar->add_menu(array('parent' => 'my-books-super-admin', 'id' => 'pb-network-admin', 'title' => __('Network Admin', 'pressbooks'), 'href' => network_admin_url()));
$wp_admin_bar->add_menu(array('parent' => 'pb-network-admin', 'id' => 'pb-network-admin-d', 'title' => __('Dashboard', 'pressbooks'), 'href' => network_admin_url()));
$wp_admin_bar->add_menu(array('parent' => 'pb-network-admin', 'id' => 'pb-network-admin-s', 'title' => __('Sites', 'pressbooks'), 'href' => network_admin_url('sites.php')));
$wp_admin_bar->add_menu(array('parent' => 'pb-network-admin', 'id' => 'pb-network-admin-u', 'title' => __('Users', 'pressbooks'), 'href' => network_admin_url('users.php')));
$wp_admin_bar->add_menu(array('parent' => 'pb-network-admin', 'id' => 'pb-network-admin-v', 'title' => __('Visit Network', 'pressbooks'), 'href' => network_home_url()));
}
// Add site links
$wp_admin_bar->add_group(array('parent' => 'my-books', 'id' => 'my-books-list', 'meta' => array('class' => is_super_admin() ? 'ab-sub-secondary' : '')));
foreach ((array) $wp_admin_bar->user->blogs as $blog) {
$blavatar = '<span class="blavatar"/></span>';
$blogname = empty($blog->blogname) ? $blog->domain : $blog->blogname;
$menu_id = 'blog-' . $blog->userblog_id;
$admin_url = get_admin_url($blog->userblog_id);
$wp_admin_bar->add_menu(array('parent' => 'my-books-list', 'id' => $menu_id, 'title' => $blavatar . $blogname, 'href' => $admin_url));
$wp_admin_bar->add_menu(array('parent' => $menu_id, 'id' => $menu_id . '-d', 'title' => __('Dashboard', 'pressbooks'), 'href' => $admin_url));
if (current_user_can_for_blog($blog->userblog_id, 'edit_posts')) {
$wp_admin_bar->remove_menu($menu_id . '-n');
$wp_admin_bar->remove_menu($menu_id . '-c');
}
$wp_admin_bar->add_menu(array('parent' => $menu_id, 'id' => $menu_id . '-v', 'title' => __('Visit Site', 'pressbooks'), 'href' => get_home_url($blog->userblog_id, '/')));
}
}
示例5: wp_toolbar_experiments_ab_admin_menu
/**
* Add admin submenu items to the "Site Name" menu.
*
* @since 4.4.0
*
* @param WP_Admin_Bar $wp_admin_bar
*/
function wp_toolbar_experiments_ab_admin_menu($wp_admin_bar)
{
$wp_admin_bar->add_group(array('parent' => 'site-name', 'id' => 'admin'));
// Post types.
$cpts = (array) get_post_types(array('show_in_admin_bar' => true), 'objects');
if (isset($cpts['post']) && current_user_can($cpts['post']->cap->edit_posts)) {
$menu_icon = '<span class="ab-icon dashicons-admin-post"></span>';
$actions['edit.php'] = array($cpts['post']->labels->name, 'edit-posts', $menu_icon);
}
if (isset($cpts['attachment']) && current_user_can('edit_posts')) {
$menu_icon = '<span class="ab-icon dashicons-admin-media"></span>';
$actions['upload.php'] = array($cpts['attachment']->labels->name, 'edit-media', $menu_icon);
}
if (isset($cpts['page']) && current_user_can($cpts['page']->cap->edit_posts)) {
$menu_icon = '<span class="ab-icon dashicons-admin-page"></span>';
$actions['edit.php?post_type=page'] = array($cpts['page']->labels->name, 'edit-pages', $menu_icon);
}
unset($cpts['post'], $cpts['page'], $cpts['attachment']);
// Add any additional custom post types.
foreach ($cpts as $cpt) {
if (!current_user_can($cpt->cap->edit_posts)) {
continue;
}
if (is_string($cpt->menu_icon)) {
// Special handling for data:image/svg+xml and Dashicons.
if (0 === strpos($cpt->menu_icon, 'dashicons-')) {
$menu_icon = '<span class="ab-icon ' . $cpt->menu_icon . '"></span>';
} elseif (0 === strpos($cpt->menu_icon, 'data:image/svg+xml;base64,')) {
$menu_icon = '<span class="ab-icon"><img src="' . $cpt->menu_icon . '"></span>';
} else {
$menu_icon = '<span class="ab-icon"><img src="' . esc_url($cpt->menu_icon) . '"></span>';
}
} else {
$menu_icon = '<span class="ab-icon dashicons-admin-post"></span>';
}
$key = 'edit.php?post_type=' . $cpt->name;
$actions[$key] = array($cpt->labels->menu_name, 'edit-' . $cpt->name, $menu_icon);
}
if ($actions) {
foreach ($actions as $link => $action) {
list($title, $id, $menu_icon) = $action;
$wp_admin_bar->add_menu(array('parent' => 'admin', 'id' => $id, 'title' => $menu_icon . '<span class="ab-label">' . $title . '</span>', 'href' => admin_url($link)));
}
}
// Comments
if (current_user_can('edit_posts')) {
$awaiting_mod = wp_count_comments();
$awaiting_mod = $awaiting_mod->moderated;
$icon = '<span class="ab-icon dashicons-admin-comments"></span>';
$wp_admin_bar->add_menu(array('parent' => 'admin', 'id' => 'comments', 'title' => $icon . '<span class="ab-label">' . sprintf(__('Comments %s'), "<span class='awaiting-mod count-{$awaiting_mod}'><span class='pending-count'>" . number_format_i18n($awaiting_mod) . "</span></span>") . '</span>', 'href' => admin_url('edit-comments.php')));
}
// Appearance.
if (current_user_can('switch_themes') || current_user_can('edit_theme_options')) {
$icon = '<span class="ab-icon dashicons-admin-appearance"></span>';
$wp_admin_bar->add_menu(array('parent' => 'admin', 'id' => 'themes', 'title' => $icon . '<span class="ab-label">' . __('Appearance') . '</span>', 'href' => admin_url('themes.php')));
}
// Plugins.
if (current_user_can('activate_plugins')) {
if (!is_multisite() && current_user_can('update_plugins')) {
$update_data = wp_get_update_data();
$count = "<span class='update-plugins count-{$update_data['counts']['plugins']}'><span class='plugin-count'>" . number_format_i18n($update_data['counts']['plugins']) . "</span></span>";
} else {
$count = '';
}
$icon = '<span class="ab-icon dashicons-admin-plugins"></span>';
$wp_admin_bar->add_menu(array('parent' => 'admin', 'id' => 'plugins', 'title' => $icon . '<span class="ab-label">' . sprintf(__('Plugins %s'), $count) . '</span>', 'href' => admin_url('plugins.php')));
}
// Users.
if (current_user_can('list_users')) {
$icon = '<span class="ab-icon dashicons-admin-users"></span>';
$wp_admin_bar->add_menu(array('parent' => 'admin', 'id' => 'edit-users', 'title' => $icon . '<span class="ab-label">' . __('Users') . '</span>', 'href' => admin_url('users.php')));
}
// Tools.
if (current_user_can('edit_posts')) {
$icon = '<span class="ab-icon dashicons-admin-tools"></span>';
$wp_admin_bar->add_menu(array('parent' => 'admin', 'id' => 'tools', 'title' => $icon . '<span class="ab-label">' . __('Tools') . '</span>', 'href' => admin_url('tools.php')));
}
// Settings.
if (current_user_can('manage_options')) {
$icon = '<span class="ab-icon dashicons-admin-settings"></span>';
$wp_admin_bar->add_menu(array('parent' => 'admin', 'id' => 'settings', 'title' => $icon . '<span class="ab-label">' . __('Settings') . '</span>', 'href' => admin_url('options.php')));
}
}
示例6: add_admin_bar_alerts_submenu
/**
* Add Admin Bar Alerts Submenu
*
* Adds an 'site_move_monitor_alerts' group to the Site Move Monitor
* admin bar menu. Only alerts should be displayed in this group.
* This group will only show if site move is detected.
*
* Called with priority 0 to show at the top of
* the Site Move Monitor admin bar menu.
*
* @access private
*
* @param WP_Admin_Bar $wp_admin_bar Reference to the admin bar instance.
*/
public function add_admin_bar_alerts_submenu($wp_admin_bar)
{
// If site moved...
if ($this->checker->test_moved()) {
// Add alerts group
$wp_admin_bar->add_group(array('id' => 'site_move_monitor_alerts', 'parent' => 'site_move_monitor', 'meta' => array('class' => 'site-move-monitor-alerts')));
$this->add_admin_bar_alerts($wp_admin_bar);
}
}
示例7: sa_admin_bar
/**
* Creates an Admin Bar Option Offer and submenu for any registered sub-menus ( admin submenu )
*
* @static
* @return void
*/
public static function sa_admin_bar(WP_Admin_Bar $wp_admin_bar)
{
if (!current_user_can('manage_sprout_invoices_options')) {
return;
}
$menu_items = apply_filters('si_admin_bar', array());
$sub_menu_items = apply_filters('si_admin_bar_sub_items', array());
$wp_admin_bar->add_node(array('id' => self::MENU_ID, 'parent' => false, 'title' => '<span class="icon-sproutapps-flat ab-icon"></span>' . self::__('Sprout Invoices'), 'href' => admin_url('admin.php?page=sprout-apps/settings&tab=reporting')));
uasort($menu_items, array(get_class(), 'sort_by_weight'));
foreach ($menu_items as $item) {
$wp_admin_bar->add_node(array('parent' => self::MENU_ID, 'id' => $item['id'], 'title' => self::__($item['title']), 'href' => $item['href']));
}
$wp_admin_bar->add_group(array('parent' => self::MENU_ID, 'id' => self::MENU_ID . '_options', 'meta' => array('class' => 'ab-sub-secondary')));
uasort($sub_menu_items, array(get_class(), 'sort_by_weight'));
foreach ($sub_menu_items as $item) {
$wp_admin_bar->add_node(array('parent' => self::MENU_ID . '_options', 'id' => $item['id'], 'title' => self::__($item['title']), 'href' => $item['href']));
}
}