本文整理汇总了PHP中WP_Admin_Bar::remove_node方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Admin_Bar::remove_node方法的具体用法?PHP WP_Admin_Bar::remove_node怎么用?PHP WP_Admin_Bar::remove_node使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_Admin_Bar
的用法示例。
在下文中一共展示了WP_Admin_Bar::remove_node方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: siteorigin_panels_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_admin_bar_menu($admin_bar)
{
// Ignore this unless the theme is using the home page feature.
if (!siteorigin_panels_setting('home-page')) {
return $admin_bar;
}
if (!current_user_can('edit_theme_options')) {
return $admin_bar;
}
if (is_home() || is_front_page()) {
if (is_page() && get_post_meta(get_the_ID(), 'panels_data', true) !== '' || !is_page()) {
$admin_bar->add_node(array('id' => 'edit-home-page', 'title' => __('Edit Home Page', 'siteorigin-panels'), 'href' => admin_url('themes.php?page=so_panels_home_page')));
if (is_page()) {
// Remove the standard edit button
$admin_bar->remove_node('edit');
}
}
}
return $admin_bar;
}
示例2: change_admin_bar_menu
/**
* Maybe removes the "W" logo incl. sublinks from the admin menu.
*
* Use the filter hook to change the default to remove the "W" logo and his sublinks
* Hook: multisite_enhancements_remove_wp_admin_bar
*
* @since 0.0.2
* @param WP_Admin_Bar $admin_bar WP_Admin_Bar instance, passed by reference.
*/
public function change_admin_bar_menu($admin_bar)
{
/**
* Use the filter hook to remove or not remove the first part in the admin bar.
*
* @type bool
*/
if (apply_filters('multisite_enhancements_remove_wp_admin_bar', self::$remove_wp_admin_bar)) {
$admin_bar->remove_node('wp-logo');
}
}
示例3: remove_all_non_snapshot_admin_bar_links
/**
* Remove all admin bar nodes that have links and which aren't for snapshots.
*
* @param \WP_Admin_Bar $wp_admin_bar Admin bar.
*/
public function remove_all_non_snapshot_admin_bar_links($wp_admin_bar)
{
if (empty($this->snapshot)) {
return;
}
$snapshot_admin_bar_node_ids = array('customize', 'exit-customize-snapshot', 'inspect-customize-snapshot');
foreach ($wp_admin_bar->get_nodes() as $node) {
if (in_array($node->id, $snapshot_admin_bar_node_ids, true) || '#' === substr($node->href, 0, 1)) {
continue;
}
$parsed_link_url = wp_parse_url($node->href);
$parsed_home_url = wp_parse_url(home_url('/'));
$is_external_link = isset($parsed_link_url['host']) && $parsed_link_url['host'] !== $parsed_home_url['host'] || isset($parsed_link_url['path']) && 0 !== strpos($parsed_link_url['path'], $parsed_home_url['path']) || (!isset($parsed_link_url['query']) || !preg_match('#(^|&)customize_snapshot_uuid=#', $parsed_link_url['query']));
if ($is_external_link) {
$wp_admin_bar->remove_node($node->id);
}
}
}
示例4: siteorigin_panels_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_admin_bar_menu($admin_bar)
{
// Ignore this unless the theme is using the home page feature.
if (!siteorigin_panels_setting('home-page')) {
return $admin_bar;
}
if (is_home() || is_front_page()) {
if (is_page() && get_the_ID() == get_option('siteorigin_panels_home_page_id') || current_user_can('edit_theme_options')) {
$admin_bar->add_node(array('id' => 'edit-home-page', 'title' => __('Edit Home Page', 'siteorigin-panels'), 'href' => admin_url('themes.php?page=so_panels_home_page')));
}
if (is_page() && get_the_ID() == get_option('siteorigin_panels_home_page_id')) {
$admin_bar->remove_node('edit');
}
}
return $admin_bar;
}
示例5: remove_admin_bar_comment_items
/**
* Remove comment entry in Admin Bar.
*
* @access public
* @since 0.0.1
*
* @param WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance, passed by reference.
*
* @return null
*/
public function remove_admin_bar_comment_items($wp_admin_bar)
{
if (!is_admin_bar_showing()) {
return NULL;
}
// Remove comment item in blog list for "My Sites" in Admin Bar.
if (isset($GLOBALS['blog_id'])) {
$wp_admin_bar->remove_node('blog-' . $GLOBALS['blog_id'] . '-c');
}
// Remove entry in admin bar.
$wp_admin_bar->remove_node('comments');
}
示例6: setAdminBarOrder
/**
* Sort admin bar nodes according to a list of IDs.
*
* This method will re-arrange the admin bar to match the key order of the $order array.
* Any nodes that don't have a matching key will be moved to the end of the admin bar.
*
* @param WP_Admin_Bar $adminBar
* @param array $order An array indexed by node ID.
*/
protected function setAdminBarOrder($adminBar, $order)
{
//Unfortunately, WP_Admin_Bar has no "sort" or "move_node" method, and it is not possible
//to add one because the $nodes array is private. So we'll have to do this the hard way.
$nodes = $adminBar->get_nodes();
//1. Remove all nodes.
foreach ($nodes as $wpNode) {
$adminBar->remove_node($wpNode->id);
}
//2. Add them back in the right order.
foreach ($order as $id => $unusedValue) {
if (isset($nodes[$id])) {
//Hidden nodes have been removed by this point.
$wpNode = $nodes[$id];
$adminBar->add_node($wpNode);
unset($nodes[$id]);
}
}
//3. Add back any left-over nodes (theoretically, this should never happen).
if (!empty($nodes)) {
foreach ($nodes as $wpNode) {
$adminBar->add_node($wpNode);
}
}
}