Saturday, 22 April 2017

How to Customize the WordPress ToolBar — SitePoint

This article is part of a series created in partnership with SiteGround. Thank you for supporting the partners who make SitePoint possible. I have a love/hate affair with the dark grey toolbar introduced in WordPress 3.3. (It was previously named the Admin Bar in WordPress 3.1 and that name stuck for many — including the API authors!). Looking at the positives, the toolbar provides a consistent set of quick links when you’re viewing the administration panels or the live website. That said, it can cause problems when creating themes or confuse site editors who think everyone can see it.
Fortunately, it’s easy to change the toolbar. We’re going to achieve it using a custom WordPress plugin, but you could also consider adding identical code to your theme’s functions.php file.
The WordPress Admin Bar API
The WP_Admin_Bar class provides the following methods:
add_node() — creates a new menu item (or child menu item) on the toolbar
remove_node() — remove a menu item from the toolbar
add_group() — allows toolbar items to be grouped into distinct sections
get_node() — returns a Toolbar object with the properties of a single toolbar item.


No comments:

Post a Comment