當前位置: 首頁>>代碼示例>>PHP>>正文


PHP WP_Admin_Bar類代碼示例

本文整理匯總了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;
}
開發者ID:GvarimAZA,項目名稱:website,代碼行數:13,代碼來源:panels-lite.php

示例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']);
}
開發者ID:asmbs,項目名稱:wp-ip,代碼行數:10,代碼來源:wp-ip.php

示例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')]))]);
 }
開發者ID:fritzdenim,項目名稱:pangMoves,代碼行數:34,代碼來源:class-gd-system-plugin-admin-menu.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: 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

示例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')));
}
開發者ID:trepmal,項目名稱:my-sites-search,代碼行數:15,代碼來源:my-sites-search.php

示例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;
 }
開發者ID:luisarn,項目名稱:multilingual-press,代碼行數:16,代碼來源:Mlp_Admin_Bar_Customizer.php

示例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'));
 }
開發者ID:L0k1slnk,項目名稱:weddly,代碼行數:9,代碼來源:Html.php

示例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'));
 }
開發者ID:jeanpage,項目名稱:ca_learn,代碼行數:10,代碼來源:Html.php

示例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);
 }
開發者ID:boonebgorges,項目名稱:wp,代碼行數:13,代碼來源:adminbar.php

示例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);
 }
開發者ID:boonebgorges,項目名稱:develop.wordpress,代碼行數:14,代碼來源:adminbar.php

示例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);
         }
     }
 }
開發者ID:ssnepenthe,項目名稱:metis,代碼行數:16,代碼來源:Toolbar.php

示例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);
 }
開發者ID:plis197715,項目名稱:wordpress-develop,代碼行數:14,代碼來源:adminbar.php

示例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'));
}
開發者ID:efueger,項目名稱:wordlift-plugin,代碼行數:16,代碼來源:wordlift_admin_bar.php

示例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 . '&amp;id=' . $blog->userblog_id)));
             }
         }
     }
 }
開發者ID:pmatheus,項目名稱:participacao-sitebase,代碼行數:17,代碼來源:admin.php


注:本文中的WP_Admin_Bar類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。