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


PHP WP_Admin_Bar::get_node方法代码示例

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


在下文中一共展示了WP_Admin_Bar::get_node方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
 }
开发者ID:boonebgorges,项目名称:wp,代码行数:13,代码来源:adminbar.php

示例2: 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);
 }
开发者ID:aaemnnosttv,项目名称:develop.git.wordpress.org,代码行数:14,代码来源:adminbar.php

示例3: 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);
 }
开发者ID:plis197715,项目名称:wordpress-develop,代码行数:14,代码来源:adminbar.php

示例4: 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'));
         }
     }
 }
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:43,代码来源:Default_Configurator.php

示例5: test_add_post_edit_and_exit_links

 /**
  * Test misc admin bar extensions.
  *
  * @covers CustomizeSnapshots\Customize_Snapshot_Manager::add_post_edit_screen_link()
  * @covers CustomizeSnapshots\Customize_Snapshot_Manager::add_snapshot_exit_link()
  * @covers CustomizeSnapshots\Customize_Snapshot_Manager::add_resume_snapshot_link()
  * @covers CustomizeSnapshots\Customize_Snapshot_Manager::remove_all_non_snapshot_admin_bar_links()
  */
 public function test_add_post_edit_and_exit_links()
 {
     global $wp_admin_bar;
     set_current_screen('front');
     require_once ABSPATH . WPINC . '/class-wp-admin-bar.php';
     $this->manager->post_type->save(array('uuid' => self::UUID, 'data' => array('blogname' => array('value' => 'Hello')), 'status' => 'draft'));
     remove_all_actions('admin_bar_menu');
     $manager = new Customize_Snapshot_Manager($this->plugin);
     $manager->init();
     $wp_admin_bar = new \WP_Admin_Bar();
     // WPCS: Override OK.
     $wp_admin_bar->initialize();
     $wp_admin_bar->add_menus();
     do_action_ref_array('admin_bar_menu', array(&$wp_admin_bar));
     $this->assertEmpty($wp_admin_bar->get_node('inspect-customize-snapshot'));
     $this->assertEmpty($wp_admin_bar->get_node('exit-customize-snapshot'));
     $this->assertNotEmpty($wp_admin_bar->get_node('wporg'));
     $this->assertNotEmpty($wp_admin_bar->get_node('resume-customize-snapshot'));
     $this->go_to(home_url('?customize_snapshot_uuid=' . self::UUID));
     $_REQUEST['customize_snapshot_uuid'] = self::UUID;
     remove_all_actions('admin_bar_menu');
     $manager = new Customize_Snapshot_Manager($this->plugin);
     $manager->init();
     $wp_admin_bar = new \WP_Admin_Bar();
     // WPCS: Override OK.
     $wp_admin_bar->initialize();
     $wp_admin_bar->add_menus();
     do_action_ref_array('admin_bar_menu', array(&$wp_admin_bar));
     $this->assertNotEmpty($wp_admin_bar->get_node('inspect-customize-snapshot'));
     $this->assertNotEmpty($wp_admin_bar->get_node('exit-customize-snapshot'));
     $this->assertEmpty($wp_admin_bar->get_node('wporg'));
     $this->assertNotEmpty($wp_admin_bar->get_node('resume-customize-snapshot'));
 }
开发者ID:xwp,项目名称:wp-customize-snapshots,代码行数:41,代码来源:test-class-customize-snapshot-manager.php

示例6: add_edit_button

 /**
  * Add an Edit Index Page button to the admin bar if applicable.
  *
  * @since 1.0.0
  *
  * @param WP_Admin_Bar $wp_admin_bar The admin bar object.
  */
 public static function add_edit_button(\WP_Admin_Bar $wp_admin_bar)
 {
     // Abort if not an archive for the supported post types
     if (!is_post_type_archive()) {
         return;
     }
     // Abort if an edit node already exists
     if ($wp_admin_bar->get_node('edit')) {
         return;
     }
     // Get the page post type object
     $post_type_object = get_post_type_object('page');
     // If an index is found, is editable, and has an edit link, add the edit button.
     if (($index_page = Registry::get_index_page(get_query_var('post_type'))) && current_user_can('edit_post', $index_page) && ($edit_post_link = get_edit_post_link($index_page))) {
         $wp_admin_bar->add_menu(array('id' => 'edit', 'title' => $post_type_object->labels->edit_item, 'href' => $edit_post_link));
     }
 }
开发者ID:dougwollison,项目名称:index-pages,代码行数:24,代码来源:class-indexpages-frontend.php

示例7: replace_customize_link

 /**
  * Replaces the "Customize" link in the Toolbar.
  *
  * @param \WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance.
  */
 public function replace_customize_link($wp_admin_bar)
 {
     if (empty($this->snapshot)) {
         return;
     }
     $customize_node = $wp_admin_bar->get_node('customize');
     if (empty($customize_node)) {
         return;
     }
     // Remove customize_snapshot_uuuid query param from url param to be previewed in Customizer.
     $preview_url_query_params = array();
     $preview_url_parsed = wp_parse_url($customize_node->href);
     parse_str($preview_url_parsed['query'], $preview_url_query_params);
     if (!empty($preview_url_query_params['url'])) {
         $preview_url_query_params['url'] = remove_query_arg(array('customize_snapshot_uuid'), $preview_url_query_params['url']);
         $customize_node->href = preg_replace('/(?<=\\?).*?(?=#|$)/', build_query($preview_url_query_params), $customize_node->href);
     }
     // Add customize_snapshot_uuid param as param to customize.php itself.
     $customize_node->href = add_query_arg(array('customize_snapshot_uuid' => $this->current_snapshot_uuid), $customize_node->href);
     $customize_node->meta['class'] .= ' ab-customize-snapshots-item';
     $wp_admin_bar->add_menu((array) $customize_node);
 }
开发者ID:xwp,项目名称:wp-customize-snapshots,代码行数:27,代码来源:class-customize-snapshot-manager.php


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