Applying the Hover Intent javascript to chill out the admin bar

This has been bothering me for some time now, and I saw Ryan Imel tweet something while I was out a few days back. So I favored it and finally got to download his plugin.

After downloading plugin I noticed some of the scripts were not loading properly, so I quickly rewrote his plugin into a small class.

Super awesome!! That always bothered me. I don’t know why I didn’t think of this first.

You had some issues with it loading the proper files. So I quickly rewrote it for my own use, have a look and see if you’d like to apply the changes before you push to SVN.

My version – you still need his files

add_action( 'plugins_loaded', 'admin_bar_hover_activate' );

function admin_bar_hover_activate() {
	$hover = new Admin_Bar_Hover_Intent();

if ( !class_exists( 'Admin_Bar_Hover_Intent' ) ) {
    class Admin_Bar_Hover_Intent {
		const version	= '0.1';
		function Admin_Bar_Hover_Intent() {
		function __construct() {
			add_action( 'wp_print_scripts', array( __CLASS__ , 'enqueue_scripts' ) );
			add_action( 'init', array( __CLASS__ , 'enqueue_style' ) );
		function enqueue_scripts() {
			if ( is_admin_bar_showing() ) {
				wp_enqueue_script( 'jquery' );
				wp_enqueue_script( 'hoverintent', esc_url( plugins_url( 'hoverintent.min.js', __FILE__ ) ), array( 'jquery' ), '1.0', true );
				wp_enqueue_script( 'rwi-adminbar-scripts', esc_url( plugins_url( 'rwi-adminbar-scripts.js', __FILE__ ) ), array( 'jquery' ), Admin_Bar_Hover_Intent::version, true );
		function enqueue_style() {
			if ( is_admin_bar_showing() )
				wp_enqueue_style( 'rwi-adminbar', esc_url( plugins_url( 'rwi-adminbar.css', __FILE__ ) ), null, Admin_Bar_Hover_Intent::version, 'screen' );

Just replace the text inside rwi-adminbar-hoverintent.php with the above code.