I’ve mixed feelings about the WordPress admin bar, but that has to do with how third-party solutions add their options to it (plus, it can be disabled if you’re not a big fan of it).
Recently, I published a small plugin – meant primarily for developers – that allows users to toggle admin notices whenever they are working with WordPress (ideally in their local environment, though it can be installed anywhere WordPress is installed).
The plugin is simple:
- It introduces an item into the WP admin bar,
- When you click on an item, it will toggle any notices or messages that are displayed,
- When you click on it again, it will toggle their visibility.
But there’s a small nuance that I think is worth covering and that has to do with manipulating the WP admin bar styles using client-side code.
WP Admin Bar Styles
This means that we have to be aware of the events that are bound to the item so we can manipulate them. And that’s the point I’m getting at in this post.
Menu items have a blur event attached to them that allow us to trigger so that we can manipulate the WP admin bar styles.
Granted, this doesn’t have to be isolated to client-side functionality, but if you want to manipulate the styles of the menu item when hovering the mouse over the item before loading another page, this is the event you want to use (at least at the time of writing this post).