Add buttons/links to admin menu bar (multi site too)

Mods and Stuff for WordPress
Post Reply
User avatar
syntax
Site Admin
Posts: 54
Joined: Tue Jan 06, 2009 9:25 pm

Add buttons/links to admin menu bar (multi site too)

Post by syntax » Wed Dec 17, 2014 5:43 pm

This example add a link on the menu bar to the posts page and also to a plugin I use (CMS Tree View) for pages

Code: Select all

/* add menu items */
function add_to_admin_menu() {
	global $wp_admin_bar;
		if ( !is_user_logged_in() ) { return; }
		if ( !is_admin_bar_showing() ) { return; }
	if ( function_exists('is_multisite') && is_multisite() && is_network_admin() ) {
		/* links here would be on the network admin side */
	}else{
		$wp_admin_bar->add_menu( array(
			'id' => 'posts-link',
			'title' =>'<div class="ab-item dashicons-before dashicons-admin-post"> Posts</div>',
			'href' => admin_url( 'edit.php' ) )
		);
		$wp_admin_bar->add_menu( array(
			'id' => 'pages-link',
			'title' => '<div class="ab-item dashicons-before dashicons-admin-page"> Pages</div>',
			//'href' => admin_url( 'edit.php?post_type=page' ) )
			'href' => admin_url( 'edit.php?post_type=page&page=cms-tpv-page-page' ) )
		);
	}
}
add_action( 'admin_bar_menu', 'add_to_admin_menu', 50 );

Post Reply