If I understood your question correctly1, wrapping the action call inside a Class avoids the menu being displayed in all sites of the network.
1
its only showing when i am in that blog => I understand that you mean: "it is not only showing..."
When i am in blogid:3 or blogid:4, i cant see that menu in blogid:2's list => I understand that you mean: "I can see the menu of blogid:2..."
/*
Plugin Name: The Menu Item
Plugin URI: http://wordpress.stackexchange.com/questions/55724/
Description: Add Menu Items to Admin Bar
Version: 1.0
Author: wordpress.stackexchange
*/
class Brsfl_55724_MenuItem
{
public function __construct()
{
add_action( 'admin_bar_menu', array($this, 'toolbar_link_to_mypage'), 999 );
}
function toolbar_link_to_mypage( $wp_admin_bar )
{
$menu_id = 'my_page';
$args = array(
'id' => $menu_id,
'title' => 'The Menu Item',
'href' => '#',
'meta' => array('class' => 'my-toolbar-page')
);
$args2 = array(
'parent' => $menu_id,
'id' => $menu_id . '-example',
'title' => __( 'Example Menu Item', 'example' ),
'href' => get_admin_url( $blog->userblog_id, 'edit.php?post_type=example' ),
'meta' => array('class' => 'my-toolbar-page')
);
$wp_admin_bar->add_node($args);
$wp_admin_bar->add_node($args2);
}
}
$brsfl_55724_MenuItem = new Brsfl_55724_MenuItem();