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.
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 );