Code Snippet: Disable jQuery Migrate


I like to keep my installs trim and scripts to minimum, i know nothing i run needs the migration tool, so let’s knock that one on the head. If you don’t know what this script does or is for, it’s probably best to leave it be.

	add_action( 'wp_default_scripts', 'on_wp_default_scripts', 2000 );
	public function on_wp_default_scripts( $wp_script_instance ) {
		
		if( !isset( $wp_script_instance->registered['jquery'] ) )
			return;
		
		foreach( $wp_script_instance->registered['jquery']->deps as $k => $script ) {
			
			if( 'jquery-migrate' !== $script ) 
				continue;

			unset( $wp_script_instance->registered['jquery']->deps[$k] );
			break;
		}
	}
Advertisement

Code Snippet: Replace the admin bar logo link


A handful of misclicks on that logo and i’m going to be writing a function to change the link.

add_action( 'wp_before_admin_bar_render', 'change_admin_logo_link' );

function change_admin_logo_link() {
	
	global $wp_admin_bar;
	
	// Get the logo node
	$menu_node = $wp_admin_bar->get_node('wp-logo');

	// Change the link to wp-admin
	$menu_node->href = network_admin_url();

	// Add the modified node back
	$wp_admin_bar->add_node( $menu_node );

	// Clean up
	unset( $menu_node );
}

Now I can avoid seeing that dreadfully designed about page if I misclick the top corner of the screen.