I’ve seen techniques on how to remove specific Admin Bar items, but how do we do with those extra menus added by plugins/themes?
How to remove all Admin Bar items?
Related Q&A’s
I’ve seen techniques on how to remove specific Admin Bar items, but how do we do with those extra menus added by plugins/themes?
How to remove all Admin Bar items?
Related Q&A’s
You must be logged in to post a comment.
I’m solving this getting all nodes from the Admin Bar, iterating through them and removing all that doesn’t have a
parent
.An exception is made to the User Actions menu (“Howdy, user_name”), which needs an extra checking.
This produces the following Admin Bar:
The only remnant is the Debug Bar plugin, which is added with a priority of
1000
.The problem is that if we hook with a priority higher than
200
, we cannot add items to thetop-secondary
node. And that’s a mystery for me…But ok, that’s a developer item and shouldn’t be an issue. And all 4 extra items added by plugins were removed.
For completeness, an example of what to add after we clean up the Admin Bar. The following goes after
// end Clean
:This will produce a different Admin Bar if viewing the admin or the site.