The admin-bar.js file###Where is responsible for setting upHover Intent attached to the menus in WordPress core?
The following 2 files go about attaching hoverIntent functionality onas click handlers for the admin bar hereand menu respectively.
Admin Bar
The admin-bar.js file sets up Hover Intent on the top bar here on line 13 of admin-bar.js.
Admin Menu
The common.js file sets up Hover Intent on the side bar menu on line 185 of common.js.
###How to remove HoverIntent from both the bar and menu
WordPress loads a bunch of JS and the hoverintent scripts on Line 13document ready, it attaches a hoverintent handler to the bar and menu at that point, so if we're going to rebind the click handlers we need to make sure we do after WordPress has done it's JS business.
The easiest way to ensure that happens is to fire an enqueue in the admin and set the admin-bar and common scripts as dependancies, this ensures our script is included after WordPress has included the two scripts in question.
###Enqueue in admin head setting required dependancies
Attach a callback to admin_head
and fire an enqueue with 2 dependancies.
add_action( 'admin_head', 'disable_HoverIntent_on_AdminMenu' );
function $disable_HoverIntent_on_AdminMenu('#wpadminbar') {
wp_enqueue_script( 'disable-adminhoverintent-', get_bloginfo( 'stylesheet_directory' ).removeClass'/disableadminhi.js', array('nojq' 'admin-bar', 'common' ) );
}
###Create the custom Javascript file
Create a file in your theme's folder and name it to match the file in the above enqueue, in my example i've used the name disableadminhi.js
, but you're welcome to adjust that and/or repoint the enqueue to somewhere else if you don't want to place it in the theme's folder.
Javascript for disableadminhi.js
jQuery(document).removeClassready('nojs'function($){
$('#wpadminbar').find('li.menupop').hoverIntenthover( function(){
over: function$(ethis){.toggleClass('hover');
});
// Bring menu into $scope(this)defined by common.addClass('hover'js in wordpress);
var menu;
} // Copy of the function from common.js, just without hoverIntent
$('li.wp-has-submenu', menu).hover(
out: function(e){
var b, h, o, f, m = $(this).removeClassfind('hover''.wp-submenu');, menutop, wintop, maxtop;
},
if ( !$(document.body).hasClass('folded') && timeout:$(this).hasClass('wp-menu-open') 180,)
sensitivity: 7, return;
interval: 100 menutop = $(this).offset().top;
} wintop = $(window).scrollTop();
We can of course load up some of our own JS after the admin menu script is included and over-ride the hover functionality, like so..
maxtop = menutop - wintop - 30; // Hookmax into= make the footer,top andof hookthe insub latealmost touch admin bar
add_action
b = menutop + m.height() 'admin_footer',+ 'disable_HoverIntent_on_AdminMenu',1; 99999// Bottom offset of the menu
h = $('#wpwrap').height(); // Height of the entire page
o = 60 + b - h;
function disable_HoverIntent_on_AdminMenu f = $(window).height() {+ wintop - 15; // The fold
? if ( f < (b - o) )
o = b - f;
if ( o > maxtop )
<script type="text/javascript"> o = maxtop;
jQuery if (document o > 1 )
m.ready(functioncss($){'marginTop':'-'+o+'px'});
$ else if ('#wpadminbar') m.findcss('li.menupop''marginTop').bind('hover',function( ){
$ m.css(this{'marginTop':''});
m.toggleClassaddClass('hover''sub-open');
},
function();{
} $(this).find('.wp-submenu').removeClass('sub-open');
</script> }
<?php);
});
That so far just covers the admin bar, i'm going to move on and see if i can track down where it's set for the admin menu on the left to, i'll update this answer once i've figured that, i'm also going to wrap this stuff into an enqueue and i'll update my answer as appropriate once i've got the details figured out..###Enjoy faster navigation!
Answer pending update - watch this space Hope that helps.. :)