当前位置: 首页>>代码示例>>PHP>>正文


PHP WP_Admin_Bar::add_menu方法代码示例

本文整理汇总了PHP中WP_Admin_Bar::add_menu方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Admin_Bar::add_menu方法的具体用法?PHP WP_Admin_Bar::add_menu怎么用?PHP WP_Admin_Bar::add_menu使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WP_Admin_Bar的用法示例。


在下文中一共展示了WP_Admin_Bar::add_menu方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: build_adminbar_menu

 /**
  * Build the admin bar menu
  *
  * @param WP_Admin_Bar $wp_admin_bar
  */
 public function build_adminbar_menu($wp_admin_bar)
 {
     $wp_admin_bar->add_menu(array('id' => 'customer-area', 'title' => __('WP Customer Area', 'cuar'), 'href' => admin_url('admin.php?page=wpca')));
     $wp_admin_bar->add_menu(array('parent' => 'customer-area', 'id' => 'wpca-frontoffice', 'title' => __('Your private area', 'cuar'), 'href' => '#'));
     $submenus = array($this->get_frontoffice_menu_items(), $this->get_private_types_menu_items(), $this->get_users_menu_items(), $this->get_tools_menu_items());
     foreach ($submenus as $submenu_items) {
         foreach ($submenu_items as $item) {
             if (isset($item['capability']) && !current_user_can($item['capability'])) {
                 continue;
             }
             $main_id = sanitize_title($item['slug']);
             $wp_admin_bar->add_menu(array('parent' => isset($item['parent']) ? $item['parent'] : 'customer-area', 'id' => $main_id, 'title' => $item['title'], 'href' => isset($item['href']) ? $item['href'] : '#'));
             if (!isset($item['children'])) {
                 continue;
             }
             foreach ($item['children'] as $subitem) {
                 if (isset($subitem['capability']) && !current_user_can($subitem['capability'])) {
                     continue;
                 }
                 $sub_id = sanitize_title($subitem['slug']);
                 $wp_admin_bar->add_menu(array('parent' => isset($subitem['parent']) ? $subitem['parent'] : $main_id, 'id' => $sub_id, 'title' => $subitem['title'], 'href' => isset($subitem['href']) ? $subitem['href'] : '#'));
             }
         }
     }
     if (current_user_can('manage_options')) {
         $wp_admin_bar->add_menu(array('parent' => 'customer-area', 'id' => 'customer-area-addons', 'title' => __('Add-ons', 'cuar'), 'href' => admin_url('admin.php?page=wpca&tab=addons')));
     }
 }
开发者ID:Darkers54,项目名称:eLEGO,代码行数:33,代码来源:admin-menu-helper.class.php

示例2: 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')]))]);
 }
开发者ID:fritzdenim,项目名称:pangMoves,代码行数:34,代码来源:class-gd-system-plugin-admin-menu.php

示例3: 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'));
 }
开发者ID:L0k1slnk,项目名称:weddly,代码行数:9,代码来源:Html.php

示例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')));
 }
开发者ID:A5hleyRich,项目名称:wp-background-processing-example,代码行数:14,代码来源:example-plugin.php

示例5: 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'));
 }
开发者ID:jeanpage,项目名称:ca_learn,代码行数:10,代码来源:Html.php

示例6: 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 . '&amp;id=' . $blog->userblog_id)));
             }
         }
     }
 }
开发者ID:pmatheus,项目名称:participacao-sitebase,代码行数:17,代码来源:admin.php

示例7: 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'));
}
开发者ID:efueger,项目名称:wordlift-plugin,代码行数:16,代码来源:wordlift_admin_bar.php

示例8: adminBarMenu

 /**
  * Filter WordPress admin bar.
  *
  * @since 150422 Rewrite.
  *
  * @attaches-to `admin_bar_menu` hook.
  *
  * @param $wp_admin_bar \WP_Admin_Bar
  */
 public function adminBarMenu(\WP_Admin_Bar &$wp_admin_bar)
 {
     if (!$this->adminBarShowing()) {
         return;
         // Nothing to do.
     }
     if ($this->adminBarShowing('cache_wipe')) {
         $wp_admin_bar->add_menu(['parent' => 'top-secondary', 'id' => GLOBAL_NS . '-wipe', 'title' => __('Wipe', 'comet-cache'), 'href' => '#', 'meta' => ['title' => __('Wipe Cache (Start Fresh). Clears the cache for all sites in this network at once!', 'comet-cache'), 'class' => '-wipe', 'tabindex' => -1]]);
     }
     if ($this->adminBarShowing('cache_clear')) {
         $wp_admin_bar->add_menu(['parent' => 'top-secondary', 'id' => GLOBAL_NS . '-clear', 'title' => __('Clear Cache', 'comet-cache'), 'href' => '#', 'meta' => ['title' => is_multisite() && current_user_can($this->network_cap) ? __('Clear Cache (Start Fresh). Affects the current site only.', 'comet-cache') : '', 'class' => '-clear', 'tabindex' => -1]]);
     }
 }
开发者ID:arobbins,项目名称:sblog,代码行数:22,代码来源:AdminBarUtils.php

示例9: admin_bar_menu

 /**
  * Add clear cache button to admin bar menu.
  *
  * @param \WP_Admin_Bar $wp_admin_bar
  */
 public function admin_bar_menu(\WP_Admin_Bar $wp_admin_bar)
 {
     $url = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     $url = parse_url($url, PHP_URL_HOST) . parse_url($url, PHP_URL_PATH);
     $color = $this->store->exists($this->generate_hash($url)) ? 'green' : 'red';
     $count = $this->store->count();
     $url = $url . '?';
     // Generate main title html.
     $title = sprintf('<span style="%s%s">%s</span> %s', 'height: 18px;width: 18px;border-radius: 50%;background: #ccc;display: inline-block;vertical-align: middle;margin-right: 7px;position: relative;bottom: 2px;color: #fff;text-align: center;vertical-align: middle;line-height: 19px;', 'background: ' . $color . ';', $count, 'Cachetop');
     // Add site cache menu.
     $wp_admin_bar->add_menu(['id' => 'cachetop', 'title' => $title, 'href' => $url . 'cachetop=flush']);
     // Add flush cache menu.
     $wp_admin_bar->add_menu(['id' => 'cachetop-flush', 'parent' => 'cachetop', 'title' => __('Flush cache', 'cachetop'), 'href' => $url . 'cachetop=flush']);
     // Add flush all caches menu.
     $wp_admin_bar->add_menu(['id' => 'cachetop-flush-all', 'parent' => 'cachetop', 'title' => __('Flush all caches', 'cachetop'), 'href' => $url . 'cachetop=flush-all']);
 }
开发者ID:isotopsweden,项目名称:wp-cachetop,代码行数:21,代码来源:class-cachetop.php

示例10: admin_bar_mode_switch

 /**
  * Mode/Context switch for ERP
  *
  * @param WP_Admin_Bar $wp_admin_bar The admin bar object
  */
 public function admin_bar_mode_switch($wp_admin_bar)
 {
     // bail if current user doesnt have cap
     if (!current_user_can('manage_options')) {
         return;
     }
     $modules = wperp()->modules->get_modules();
     $current_mode = wperp()->modules->get_current_module();
     // ERP Mode
     $title = __('Switch ERP Mode', 'wp-erp');
     $icon = '<span class="ab-icon dashicons-randomize"></span>';
     $text = sprintf('%s: %s', __('ERP Mode', 'wp-erp'), $current_mode['title']);
     $wp_admin_bar->add_menu(array('id' => 'erp-mode-switch', 'title' => $icon . $text, 'href' => '#', 'position' => 0, 'meta' => array('title' => $title)));
     foreach ($modules as $key => $module) {
         $wp_admin_bar->add_menu(array('id' => 'erp-mode-' . $key, 'parent' => 'erp-mode-switch', 'title' => $module['title'], 'href' => wp_nonce_url(add_query_arg('erp-mode', $key), 'erp_mode_nonce', 'erp_mode_nonce')));
     }
 }
开发者ID:nizamuddin,项目名称:wp-erp,代码行数:22,代码来源:class-menu.php

示例11: 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)));
 }
开发者ID:humanmade,项目名称:vip-mu-plugins-public,代码行数:21,代码来源:livepress-admin-bar-status-menu.php

示例12: 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')));
}
开发者ID:trepmal,项目名称:my-sites-search,代码行数:15,代码来源:my-sites-search.php

示例13: admin_menu

 /**
  * Add a "Flush Cache" button the admin menu
  * @param WP_Admin_Bar $admin_bar
  * @return void
  */
 public function admin_menu($admin_bar)
 {
     global $gd_system_config;
     $config = $gd_system_config->get_config();
     // Only show to admin users
     if (is_user_logged_in() && current_user_can('activate_plugins')) {
         // Flush cache
         $admin_bar->add_menu(array('parent' => false, 'id' => 'gd-system-flush-cache', 'title' => __('Flush Cache', 'gd_system'), 'href' => esc_url(add_query_arg(array('GD_COMMAND' => 'FLUSH_CACHE', 'GD_NONCE' => wp_create_nonce('GD_FLUSH_CACHE')))), 'meta' => array()));
         // Gateway / control panel
         // Untestable ... can't reset a constant
         // @codeCoverageIgnoreStart
         $label = __('GoDaddy Settings', 'gd_system');
         if (1 !== intval(GD_RESELLER)) {
             $label = __('Account Settings', 'gd_system');
         }
         // @codeCoverageIgnoreEnd
         $admin_bar->add_menu(array('parent' => false, 'id' => 'gd-system-control-panel', 'title' => $label, 'href' => str_replace('%pl_id%', defined('GD_RESELLER') ? GD_RESELLER : '', $config['gateway_url']), 'meta' => array()));
     }
 }
开发者ID:fernflores0463,项目名称:RandolphTimesWeb,代码行数:24,代码来源:class-gd-system-plugin-admin-menu.php

示例14: add_items

 /**
  * Add items to admin bar
  *
  * @param \WP_Admin_Bar $wp_admin_bar
  */
 public function add_items(&$wp_admin_bar)
 {
     // get Notifications
     $notifications = wp_notification_center()->service('admin_notice_handler')->get_notices();
     // Add top menu
     $wp_admin_bar->add_menu(array('id' => 'wp-notification-center', 'parent' => 'top-secondary', 'title' => sprintf(__('Notifications %s', 'wp-notification-center'), '<span class="wpnc-count">' . count($notifications) . '</span>'), 'href' => false));
     // loop
     if (count($notifications) > 0) {
         $i = 0;
         /** @var Notification $notification */
         foreach ($notifications as $notification) {
             $item_classes = implode(' ', array_map(function ($type) {
                 return 'wpnc-' . $type;
             }, $notification->get_types()));
             $wp_admin_bar->add_menu(array('id' => 'wp-notification-center-item-' . $i, 'parent' => 'wp-notification-center', 'title' => $notification->get_message(), 'href' => false, 'meta' => array('class' => $item_classes)));
             $i++;
         }
     }
 }
开发者ID:GoWP,项目名称:wp-notification-center,代码行数:24,代码来源:AdminBar.php

示例15: _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')));
}
开发者ID:felixarntz,项目名称:global-admin,代码行数:30,代码来源:admin-bar.php


注:本文中的WP_Admin_Bar::add_menu方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。