Skip to content
wp-skills
Register
tools/wordpress-admin-bar-generator

WordPress Admin Bar Generator

Add your own nodes to the WordPress toolbar and remove the ones you do not want: parents that really exist, only the meta keys WP_Admin_Bar reads, and removals on a hook that runs after core has added them.

Where these sit among core's own nodes: 10 is the logo, 30 the site name, 70 the + New menu, 200 the right-hand group.

Logged-out visitors never see the toolbar at all, wherever this is set.

The toolbar itself checks nothing — a subscriber sees it on the front end — so a node linking into wp-admin needs its own check.

Remove core nodes

Removed on wp_before_admin_bar_render, which runs after core has added them — a removal on admin_bar_menu at the default priority runs first and does nothing.

Nodes1
  • #1

    The visible label.

    Unique. Rendered as id="wp-admin-bar-…" and used as a parent by other nodes.

    Blank makes it a plain label rather than a link.

    meta['title'] — the title attribute on the link, not the visible label.

    Added to the node's <li>.

snippet.php
<?php
/**
 * Admin bar (toolbar) nodes
 *
 * Generated by wp-skills.com
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Adds nodes to the toolbar.
 *
 * The callback is handed WP_Admin_Bar by reference, which is why it takes an
 * argument rather than reaching for the $wp_admin_bar global.
 *
 * Priority 10 decides where these sit among core's own nodes rather than
 * whether they appear: core registers its own at 0 (my account), 10 (logo), 30
 * (site name), 70 (+ New), 80 (edit) and 200 (the right-hand group), and a
 * node added later lands after them inside the same parent.
 */
function wp_skills_admin_bar_nodes( $wp_admin_bar ) {
	$wp_admin_bar->add_node(
		array(
			'id'     => 'wp-skills-shortcut',
			'title'  => __( 'My Shortcut', 'text-domain' ),
		)
	);
}
add_action( 'admin_bar_menu', 'wp_skills_admin_bar_nodes', 10 );