• Welcome to Tux Reports: Where Penguins Fly. We hope you find the topics varied, interesting, and worthy of your time. Please become a member and join in the discussions.

Admin Bar Changes For Common Network Header

LPH

Flight Director
Flight Instructor
There are many articles on the internet showing people how to modify the WordPress admin bar. Unfortunately, the information is scattered to get this to work on a multisite. Also, the Sign In needed to be on the right side. While not complete, the following version may help you.

This code is a php file sitting in the mu-plugins directory. Name the file anyway you please.

Code:
/* Removes parts of the admin bar */

function trn_admin_bar_remove() {
global $wp_admin_bar;

/* Remove their stuff */
$wp_admin_bar->remove_menu('wp-logo');
$wp_admin_bar->remove_menu('my-sites');
$wp_admin_bar->remove_node('search');
$wp_admin_bar->remove_node('my-account');
}

add_action('wp_before_admin_bar_render', 'trn_admin_bar_remove', 0);


/* Fix the height of the admin bar */

function add_wpadmin_styles() {
echo '<style>#wpadminbar { 
font-size: 14px;
font-family: Arial, sans-serif;
color: #ffffff;
background: rgba(0, 0, 0, 0.8);
min-height: 50px;
line-height: 28px;
left: 0;
min-width: 600px;
position: fixed;
top: 0;
width: 100%;
z-index: 99999;
padding-left: 0px;
padding-top: 15px;
!important;
}</style>';

/* Shift labels to the right */

echo '<style> 
#wpadminbar .quicklinks {
border-left: 1px solid transparent;
float: right;
padding-right: 20px;
}
</style>';


/* Fix for the header themes */

echo '<style> body {
position: relative !important;
top:45px;
}
</style>';
}

add_action('wp_before_admin_bar_render', 'add_wpadmin_styles');

/* 
Alternatives to render the admin bar

admin_bar_menu
wp_head
*/


/* Builds the menu */

function add_trn_admin_bar_link() {
global $wp_admin_bar;

$wp_admin_bar->add_menu( array(
'id' => 'trn_link',
'title' => __( 'Tux Reports Network'),
'href' => __('http://www.tuxreportsnetwork.com')
));

// Add sub menu link "Community"
$wp_admin_bar->add_menu( array(
'parent' => 'trn_link',
'id' => 'trn_community',
'title' => __( 'Community'),
'href' => __('http://www.tuxreportsdebates.com/community')
));



// Add sub menu link "Education"
$wp_admin_bar->add_menu( array(
'parent' => 'trn_link',
'id' => 'trn_education',
'title' => __( 'Education'),
'href' => __('http://www.tuxreportsdebates.com/community'),
'meta' => array(
'class' => 'st_menu_download')
));
$wp_admin_bar->add_menu( array(
'parent' => 'trn_education',
'id' => 'trn_apenviro',
'title' => __( 'AP Environmental Science'),
'href' => __('http://www.apenvironmentalscience.com')
));

$wp_admin_bar->add_menu( array(
'parent' => 'trn_education',
'id' => 'trn_chem',
'title' => __( 'The Chem Book'),
'href' => __('http://www.thechembook.com')
));

$wp_admin_bar->add_menu( array(
'parent' => 'trn_education',
'id' => 'trn_classic',
'title' => __( 'Classic Education'),
'href' => __('http://www.Educlassics.com')
));

$wp_admin_bar->add_menu( array(
'parent' => 'trn_education',
'id' => 'trn_green',
'title' => __( 'Green Enterprise'),
'href' => __('http://www.avgreen.org')
));

$wp_admin_bar->add_menu( array(
'parent' => 'trn_education',
'id' => 'trn_retaining',
'title' => __( 'Retaining Teachers'),
'href' => __('http://www.retainingteachers.com')
));

$wp_admin_bar->add_menu( array(
'parent' => 'trn_education',
'id' => 'trn_secondary',
'title' => __( 'Secondary Classroom'),
'href' => __('http://www.secondaryclassroom.com')
));


// Add sub menu link "Entertainment"
$wp_admin_bar->add_menu( array(
'parent' => 'trn_link',
'id' => 'trn_entertainment',
'title' => __( 'Dogs Times'),
'href' => __('http://www.dogstimes.com')
));


// Add sub menu link "News"
$wp_admin_bar->add_menu( array(
'parent' => 'trn_link',
'id' => 'trn_news',
'title' => __( 'News'),
'href' => __('http://www.tuxreportsnews.com')
));


// Add sub menu link "Politics"
$wp_admin_bar->add_menu( array(
'parent' => 'trn_link',
'id' => 'trn_politics',
'title' => __( 'Politics'),
'href' => __('http://www.insanepolitics.com')
));

// Add sub menu link "Technology"
$wp_admin_bar->add_menu( array(
'parent' => 'trn_link',
'id' => 'trn_technology',
'title' => __( 'Technology'),
'href' => __('http://www.tuxreportstech.com'),
'meta' => array(
'class' => 'st_menu_download')
));
$wp_admin_bar->add_menu( array(
'parent' => 'trn_technology',
'id' => 'trn_amd',
'title' => __( 'AMD Views'),
'href' => __('http://www.amdviews.com')
));

$wp_admin_bar->add_menu( array(
'parent' => 'trn_technology',
'id' => 'trn_android',
'title' => __( 'The Android Buzz'),
'href' => __('http://www.theandroidbuzz.com')
));

$wp_admin_bar->add_menu( array(
'parent' => 'trn_technology',
'id' => 'trn_apple',
'title' => __( 'Apple iPad Buzz'),
'href' => __('http://www.appleipadbuzz.com')
));

$wp_admin_bar->add_menu( array(
'parent' => 'trn_technology',
'id' => 'trn_kindlebuzz',
'title' => __( 'Kindle Buzz'),
'href' => __('http://www.kindlebuzz.com')
));

$wp_admin_bar->add_menu( array(
'parent' => 'trn_technology',
'id' => 'trn_mobile',
'title' => __( 'Mobile Questions'),
'href' => __('http://www.mobilequestions.com')
));

$wp_admin_bar->add_menu( array(
'parent' => 'trn_technology',
'id' => 'trn_notebooks',
'title' => __( 'Notebook Questions'),
'href' => __('http://www.notebookquestions.com')
));

$wp_admin_bar->add_menu( array(
'parent' => 'trn_technology',
'id' => 'trn_tabletpcquestions',
'title' => __( 'Tablet PC Questions'),
'href' => __('http://www.tabletpcquestions.com')
));

$wp_admin_bar->add_menu( array(
'parent' => 'trn_technology',
'id' => 'trn_linux',
'title' => __( 'Tux Reports'),
'href' => __('http://www.tuxreports.com')
));

$wp_admin_bar->add_menu( array(
'parent' => 'trn_technology',
'id' => 'trn_tech_aggregate',
'title' => __( 'Tux Reports Tech'),
'href' => __('http://www.tuxreportstech.com')
));

$wp_admin_bar->add_menu( array(
'parent' => 'trn_technology',
'id' => 'trn_tech_win',
'title' => __( 'What Is New'),
'href' => __('http://www.whatisnew.com')
));


// Add sub menu link "Staff"
$wp_admin_bar->add_menu( array(
'parent' => 'trn_link',
'id' => 'trn_staff',
'title' => __( 'Staff'),
'href' => __('http://www.tuxreportsdebates.com'),
'meta' => array(
'class' => 'st_menu_download')
));
$wp_admin_bar->add_menu( array(
'parent' => 'trn_staff',
'id' => 'trn_layne',
'title' => __( 'Layne P. Heiny'),
'href' => __('http://www.layneheiny.com')
));

$wp_admin_bar->add_menu( array(
'parent' => 'trn_staff',
'id' => 'trn_lora',
'title' => __( 'Lora J. Heiny'),
'href' => __('http://www.loraheiny.com')
));

$wp_admin_bar->add_menu( array(
'parent' => 'trn_staff',
'id' => 'trn_loren',
'title' => __( 'Loren C. Heiny'),
'href' => __('http://www.lorenheiny.com')
));

$wp_admin_bar->add_menu( array(
'parent' => 'trn_staff',
'id' => 'trn_robert',
'title' => __( 'Robert W. Heiny'),
'href' => __('http://www.robertheiny.com')
));


}
add_action('admin_bar_menu', 'add_trn_admin_bar_link', 1);
View the Post on the Blog
 

LPH

Flight Director
Flight Instructor
The "my-account" must be removed in order for the float:right to work properly.
 

LPH

Flight Director
Flight Instructor
Oops. Left out a key component when this was copied. The code below belongs above the first lines of the plugin.

Code:
/* Always show admin bar */
 
add_filter( 'show_admin_bar', '__return_true' , 1000 );

Otherwise the admin bar does not always show across the network. :oops:
 
Top