本文整理汇总了PHP中WP_Admin_Bar类的典型用法代码示例。如果您正苦于以下问题:PHP WP_Admin_Bar类的具体用法?PHP WP_Admin_Bar怎么用?PHP WP_Admin_Bar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WP_Admin_Bar类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 . '&id=' . $blog->userblog_id)));
}
}
}
}
开发者ID:pmatheus,项目名称:participacao-sitebase,代码行数:17,代码来源:admin.php
示例16: 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
示例17: 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)
{
/**
* @var WP_Query $wp_query
*/
global $wp_query;
if ($wp_query->is_home() && $wp_query->is_main_query()) {
// Check that we support the home page
if (!current_user_can('edit_theme_options')) {
return $admin_bar;
}
$admin_bar->add_node(array('id' => 'edit-home-page', 'title' => __('Edit Home Page', 'vantage'), 'href' => admin_url('themes.php?page=so_panels_home_page')));
}
return $admin_bar;
}
开发者ID:pradeep-web,项目名称:brandt,代码行数:21,代码来源:panels-lite.php
示例18: 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
示例19: genesis_cpt_archive_settings_link
/**
* Adds a toolbar link to edit the custom post archive settings
*
* @since 2.3.0
*
* @global WP_Admin_Bar $wp_admin_bar
*
* @param WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance.
* @return WP_Admin_Bar Return `$wp_admin_bar` early if in admin, not a CPT archive, not a valid post type,
* or a post type that does not have support for `genesis-cpt-archive-settings`.
*/
function genesis_cpt_archive_settings_link($wp_admin_bar)
{
// Bail if in admin, not a CPT archive, or post_type doesn't have support for genesis-cpt-archive-settings.
if (is_admin() || !is_post_type_archive() || !genesis_has_post_type_archive_support()) {
return $wp_admin_bar;
}
// Get the post type we're viewing.
$post_type = get_post_type();
// Bail if we didn't get a valid post type.
if (!$post_type) {
return $wp_admin_bar;
}
// Add our toolbar link.
$args = array('id' => 'cpt-archive-settings', 'title' => __('Edit Archive Settings', 'genesis'), 'href' => admin_url("edit.php?post_type={$post_type}&page=genesis-cpt-archive-{$post_type}"), 'meta' => array('class' => ''));
$wp_admin_bar->add_node($args);
}
开发者ID:netmagik,项目名称:netmagik,代码行数:27,代码来源:toolbar.php
示例20: 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
注:本文中的WP_Admin_Bar类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论