本文整理汇总了PHP中WP_Admin_Bar::add_node方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Admin_Bar::add_node方法的具体用法?PHP WP_Admin_Bar::add_node怎么用?PHP WP_Admin_Bar::add_node使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_Admin_Bar
的用法示例。
在下文中一共展示了WP_Admin_Bar::add_node方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
/**
* @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);
}
示例2: array
/**
* @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);
}
示例3: array
/**
* @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);
}
示例4: 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;
}
示例5: 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']);
}
示例6: 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;
}
示例7: 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);
}
}
}
示例8: 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;
}
示例9: 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);
}
示例10: googleadconsole_add_node
/**
* Add the "Google Ads Console" item to the WordPress admin bar.
*
* @param WP_Admin_Bar $wp_admin_bar A reference to the global $wp_admin_bar object.
*/
function googleadconsole_add_node($wp_admin_bar)
{
// Don't display this in the admin area
if (is_admin()) {
return;
}
$url = googleadconsole_toggle_console_url();
$args = array('id' => 'google-ad-console-toggle', 'title' => esc_html__('Google Ad Console', 'google-ad-console'), 'href' => esc_url($url));
// Active state for the node
if (get_query_var('google_force_console', false)) {
$args['meta'] = array('class' => 'hover');
}
/**
* Filter the arguments used to construct the "Google Ads Console" admin bar node.
*
* @param array $args WP admin bar node arguments.
*/
$args = apply_filters('googleadconsole_before_add_node', $args);
$wp_admin_bar->add_node($args);
}
示例11: 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'));
}
}
}
示例12: vp_admin_bar_warning
function vp_admin_bar_warning(WP_Admin_Bar $adminBar)
{
if (!current_user_can('manage_options')) {
return;
}
// @codingStandardsIgnoreStart
$adminBarText = "<span style=\"color:#FF8800;font-weight:bold\">VersionPress running</span>";
$popoverTitle = "Note";
$popoverText = "<p style='margin-top: 5px;'>You are running <strong>VersionPress " . VersionPress::getVersion() . "</strong> which is an <strong style='font-size: 1.15em;'>Early Access release</strong>. As such, it might not fully support certain workflows, 3<sup>rd</sup> party plugins, hosts etc.<br /><br /><strong>We recommend that you keep a safe backup of the site at all times</strong></p>";
$popoverText .= "<p><a href='http://docs.versionpress.net/en/release-notes' target='_blank'>Learn more about VersionPress releases</a></p>";
$adminBar->add_node(['id' => 'vp-running', 'title' => "<a href='#' class='ab-item' id='vp-warning'>{$adminBarText}</a>\n <script>\n var warning = jQuery('#vp-warning');\n var customPopoverClass = \"versionpress-alpha\"; // used to identify the popover later\n\n warning.webuiPopover({title:\"{$popoverTitle}\", content: \"{$popoverText}\", closeable: true, style: customPopoverClass, width:450});\n </script>", 'parent' => 'top-secondary']);
// @codingStandardsIgnoreEnd
}
示例13: admin_bar_menu
/**
* Render interface and add to the toolbar.
*
* @param \WP_Admin_Bar $wp_admin_bar
*/
public static function admin_bar_menu($wp_admin_bar)
{
if (!apply_filters('laps_can_see', current_user_can('manage_options'))) {
return;
}
global $timestart, $wpdb;
$mustache = new \Mustache_Engine(array('loader' => new \Mustache_Loader_FilesystemLoader(dirname(__DIR__) . '/views'), 'cache' => new Mustache_Cache_FrozenCache(dirname(__DIR__) . '/views/cache')));
if (self::$stopwatch->isStarted('Toolbar')) {
self::$stopwatch->stop('Toolbar');
}
$events = self::$stopwatch->getSectionEvents('__root__');
$start = $timestart * 1000;
$end = microtime(true) * 1000;
$total = $end - $start;
$event_data = array();
$http_data = array();
foreach ($events as $name => $event) {
$offset = round(($event->getOrigin() - $start) / $total * 100, 2);
$duration = $event->getDuration();
$width = round($duration / $total * 100, 2);
$category = $event->getCategory();
if ('http' === $category) {
$http_data[] = compact('name', 'offset', 'duration', 'width', 'category');
continue;
}
$memory = $event->getMemory() / 1024 / 1024;
$event_data[] = compact('name', 'offset', 'duration', 'width', 'category', 'memory');
}
$query_data = array();
$last_query_end = 0;
$last_offset = 0;
$last_duration = 0;
if (defined('SAVEQUERIES') && SAVEQUERIES) {
foreach ($wpdb->queries as $key => $query) {
$query_start = isset(self::$query_starts[$key]) ? self::$query_starts[$key] : $last_query_end;
list($sql, $duration, $trace) = $query;
$sql = trim($sql);
$category = 'query-read';
if (0 === stripos($sql, 'INSERT') || 0 === stripos($sql, 'UPDATE')) {
$category = 'query-write';
}
$duration *= 1000;
$last_query_end = $query_start + $duration;
$offset = round(($query_start - $start) / $total * 100, 2);
// if query is indistinguishably close to previous then stack it
if ($offset === $last_offset) {
$key = count($query_data) - 1;
$query_data[$key]['sql'] .= '<br />' . $sql;
$last_duration += $duration;
$width = round($last_duration / $total * 100, 2);
$query_data[$key]['width'] = $width;
continue;
}
$width = round($duration / $total * 100, 2);
$last_offset = $offset;
$last_duration = $duration;
$query_data[] = compact('sql', 'duration', 'offset', 'width', 'category');
}
}
$html = $mustache->render('laps', array('events' => $event_data, 'queries' => $query_data, 'savequeries' => defined('SAVEQUERIES') && SAVEQUERIES, 'http' => $http_data, 'savehttp' => !empty($http_data)));
$wp_admin_bar->add_node(array('id' => 'laps', 'title' => sprintf('Lap: %ss', round($total / 1000, 3))));
$wp_admin_bar->add_node(array('id' => 'laps_output', 'parent' => 'laps', 'meta' => array('html' => $html)));
}
示例14: callback_admin_bar_menu
/**
* @callback
*
* @param \WP_Admin_Bar $wp_admin_bar
*/
public function callback_admin_bar_menu(WP_Admin_Bar $wp_admin_bar)
{
$wp_admin_bar->add_node(array('id' => 'wskl-root', 'title' => '<span class="ab-icon"></span><span>' . __('다보리', 'wskl') . '</span>', 'parent' => FALSE, 'href' => wskl_get_setting_tab_url(''), 'meta' => array()));
$sub_menus = array(array('parent' => 'wskl-root', 'id' => 'wskl-preview', 'title' => __('일러두기', 'wskl'), 'href' => wskl_get_setting_tab_url('preview')), array('parent' => 'wskl-root', 'id' => 'wskl-authentication', 'title' => __('제품인증', 'wskl'), 'href' => wskl_get_setting_tab_url('authentication')), array('parent' => 'wskl-root', 'id' => 'wskl-checkout-payment-gates', 'title' => __('지불기능', 'wskl'), 'href' => wskl_get_setting_tab_url('checkout-payment-gates')), array('parent' => 'wskl-root', 'id' => 'wskl-essential-features', 'title' => __('핵심기능', 'wskl'), 'href' => wskl_get_setting_tab_url('essential-features')), array('parent' => 'wskl-root', 'id' => 'wskl-convenience-features', 'title' => __('편의기능', 'wskl'), 'href' => wskl_get_setting_tab_url('convenience-features')), array('parent' => 'wskl-root', 'id' => 'wskl-social-login', 'title' => __('소셜기능', 'wskl'), 'href' => wskl_get_setting_tab_url('social-login')), array('parent' => 'wskl-root', 'id' => 'wskl-protection-features', 'title' => __('차단보안기능', 'wskl'), 'href' => wskl_get_setting_tab_url('protection-features')), array('parent' => 'wskl-root', 'id' => 'wskl-marketing', 'title' => __('마케팅자동화기능', 'wskl'), 'href' => wskl_get_setting_tab_url('marketing')));
if (wskl_lab_enabled()) {
$sub_menus[] = array('parent' => 'wskl-root', 'id' => 'wskl-beta-features', 'title' => __('다보리 실험실', 'wskl'), 'href' => wskl_get_setting_tab_url('beta-features'));
}
if (wskl_debug_enabled()) {
$sub_menus[] = array('parent' => 'wskl-root', 'id' => 'wskl-developer', 'title' => __('개발자용 ', 'wskl'), 'href' => wskl_get_setting_tab_url('developer'));
}
if (wskl_is_option_enabled('enable_dabory_members')) {
$sub_menus[] = array('parent' => 'wskl-root', 'id' => 'wskl-dabory-members', 'title' => __('다보리 멤버스 설정', 'wskl'), 'href' => wskl_wp_members_url());
}
if (wskl_is_option_enabled('enable_inactive_accounts')) {
$sub_menus[] = array('parent' => 'wskl-root', 'id' => 'wskl-inactive-accounts', 'title' => __('휴면계정 설정', 'wskl'), 'href' => wskl_wp_members_url('inactive-accounts'));
}
if (wskl_is_option_enabled('enable_dabory_sms')) {
$sub_menus[] = array('parent' => 'wskl-root', 'id' => 'wskl-dabory-sms', 'title' => __('다보리 SMS 설정', 'wskl'), 'href' => wskl_dabory_sms_url());
}
if (wskl_is_option_enabled('enable_config_editor')) {
$sub_menus[] = array('parent' => 'wskl-root', 'id' => 'wskl-config-editor', 'title' => __('WP Config 편집', 'wskl'), 'href' => wskl_wp_config_editor_url());
}
foreach ($sub_menus as $menu) {
$wp_admin_bar->add_menu($menu);
}
}
示例15: siteorigin_settings_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_settings_admin_bar_menu($admin_bar)
{
// Only display this until the theme settings have been saved for the first time
if (get_option(get_template() . '_theme_settings', false) !== false) {
return $admin_bar;
}
if (is_admin()) {
// Skip this on the settings page
$screen = get_current_screen();
if ($screen->base == 'appearance_page_theme_settings_page') {
return $admin_bar;
}
}
if (current_user_can('edit_theme_options') && has_filter('siteorigin_settings_tour_content')) {
$admin_bar->add_node(array('id' => 'theme-settings-tour', 'title' => __('Theme Tour', 'vantage'), 'href' => admin_url('themes.php?page=theme_settings_page#tour')));
}
return $admin_bar;
}