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.

It’s been a while.


A good decade or so. It wasn’t personal, i didn’t stop existing, i just didn’t have a need to be writing about or code for, WordPress, nor have any need to be part of the whole ecosystem.

WordPress has changed pretty significantly in my absence. What the feck are blocks and why don’t i like em? I’m trying (i’ve not simply enabled the old editor), but it feels like dozens of layers of overly abstract JS libraries(that seems to be the modern thing) for what results in a barely intuitive and sluggish UI all just to allow users to become amateur front end designers with their content.

And yet a decade later registering an admin page results in a dozen extra CSS stylesheets being loaded into the head that aren’t needed (without even mentioning the emoji stuff). There has been some nice work on the backend however, the admin color themes are simple, subtle but work and there’s been some changes to the general admin markup, it’s more light, trim and consistent compared to the 3.x days (WP wasn’t even at v4 last time i was around).

Well, anyway, i’m blowing the dust off my old accounts and getting back into PHP and WP, i have time, little to do and a passion for writing PHP.

I’m feeling a bit behind the time and rusty, the underlying core aside from the block stuff seems to be largely the same, let’s see if this old dog can’t learn some new tricks.