Skip to content

Instantly share code, notes, and snippets.

@tommcfarlin
Created March 7, 2017 16:17
Show Gist options
  • Save tommcfarlin/a867844aeb9b32efbe3e38b43e19bb52 to your computer and use it in GitHub Desktop.
Save tommcfarlin/a867844aeb9b32efbe3e38b43e19bb52 to your computer and use it in GitHub Desktop.
[WordPress] Manipulating WP Admin Bar Styles with Events
(function( $ ) {
'use strict';
/**
* Hide all of the messages when the option is include and restore the menu items'
* default hover state style.
*/
var hide_menu_notices = function() {
// Setup references to the plugin menu item and all admin notices.
var $admin_button = $( '#wp-admin-bar-toggle-admin-notices a' ),
$messages = $( '.notice, .warning, .error' );
$admin_button.on( 'click', function( evt ) {
evt.preventDefault();
$messages.toggle( 'medium' );
$( this ).trigger( 'blur' );
});
};
$(function() {
hide_admin_notices();
});
})( jQuery );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment