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.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s