How to Customize the WordPress admin bar?

In WordPress 3.3 version there is a handy admin bar that provides quick access to some Admin features for logged in users.
There are several ways to do customize it by creating functions. Here I will show, how you can customize the admin bar the way you want.

WorPress adds a black menu bar (Admin Bar or Toolbar) at the top of the screen when user is logged in.
This menu bar is also visible even when you are at the front end of the site and provide you a quick links of pages quickly.

WordPress allows us to customize the this bar and it’s possible to add new links (menu items) in that bar or remove or change the existing ones. Using admin_bar_menu or wp_before_admin_bar_render hook we can customize the Admin Bar.
wordpress-admin-bar-vivacity
Removing the WordPress Logo from the admin toolbar

function remove_wp_logo() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('wp-logo');
}

add_action( 'wp_before_admin_bar_render', 'remove_wp_logo' );

Disabling the add new content menu from toolbar

function disable_new_content() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('new-content');
}
add_action( 'wp_before_admin_bar_render', 'disable_new_content' );

Adding a new top level menu and two sub menus using admin_bar_menu hook

function custom_admin_bar()
{
global $wp_admin_bar;
//Top menu
$wp_admin_bar->add_menu( array(
'id' => 'my_custom-menu',
'title' => 'Top Menu',
'href' => false
) );
//Sub Menu 1
$wp_admin_bar->add_menu( array(
'id' => 'custom_menu',
'title' => __( 'Google Search' ),
'href' => 'http://google.com/',
'meta'  => array( target => '_blank' ) )
);

// Sub menu 2 to open one of my plugins page
$wp_admin_bar->add_menu( array(
'id' => 'my_plugin-page',
'parent' => 'my_custom-menu',
'title' => 'Settings',
'href' => admin_url('/wp-admin/options-general.php'),
) );
// Sub menu 3 to open facebook link in new window
$wp_admin_bar->add_menu( array(
'id' => 'facebook-page',
'parent' => 'my_custom-menu',
'title' => 'Facebook',
'href' => 'http://facebook.com',
'meta' => array( 'target'=>'_blank' )
) );
}
add_action( 'admin_bar_menu', 'custom_admin_bar' );

Removing the Profile menu from the admin toolbar

function custom_admin_bar_remove() {
global $wp_admin_bar;

/* Remove their stuff */
$wp_admin_bar->remove_menu('my-blogs');
$wp_admin_bar->remove_menu('my-account-with-avatar');
$wp_admin_bar->remove_menu('appearance');
}

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

admin-bar-vivacity
Here are some menu item IDs for top menu links that can be used to customizing the admin bar menu items:

wp-logo: WordPress logo
my-account: Links to your account. The ID depends upon if you have avatar enabled or not.
site-name: Site name with other dashboard items
my-sites : My Sites menu, if you have more than one site
get-shortlink : Shortlink to a page/post
edit : Post/Page/Category/Tag edit link
new-content : Add New menu
comments : Comments link
updates : Updates link
search: Search box

Advertisements

How to customize your WordPress dashboard

There are many ways to customize the WordPress Dashboard.

In default WordPress Installation WP Dashboard have a brief view of the main sections of your site in terms of meta boxes, they also provide granular & graphical data on everything from recent comments & plugin updates to incoming links as well as WordPress latest news.

There are many of dashboard widgets and plugins available in the WordPress Plugin Directory that you can use to transform your Dashboard into nice customized dashboard with your own text/images and links, or even disable it completely.

The details of new plugins, WordPress News & Blog Updates , all these sections are added using the wp_dashboard_setup() hook and we can used it to remove them. You can use below code in your theme`s functions.php file to get rid of them.

Removing Default Widgets from Dashboard

// REMOVE META BOXES FROM WORDPRESS DASHBOARD FOR ALL USERS

// disable default dashboard widgets
function remove_dashboard_widgets() {

	global $wp_meta_boxes;

	unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
	unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);
	unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);
	unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_recent_drafts']);
	unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
	unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);
	unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
	unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);

}
add_action('wp_dashboard_setup', 'remove_dashboard_widgets');

Or you can use this WordPress API functions to do the same

// disable default dashboard widgets
function disable_default_dashboard_widgets() {

	remove_meta_box('dashboard_right_now', 'dashboard', 'core');
	remove_meta_box('dashboard_recent_comments', 'dashboard', 'core');
	remove_meta_box('dashboard_incoming_links', 'dashboard', 'core');
	remove_meta_box('dashboard_plugins', 'dashboard', 'core');

	remove_meta_box('dashboard_quick_press', 'dashboard', 'core');
	remove_meta_box('dashboard_recent_drafts', 'dashboard', 'core');
	remove_meta_box('dashboard_primary', 'dashboard', 'core');
	remove_meta_box('dashboard_secondary', 'dashboard', 'core');
}
add_action('admin_menu', 'disable_default_dashboard_widgets');

wp-dashboard

Create your own Dashboard widget

Here the first function include the content of the custom widget. The second function shows the output of the first function into a widget and lastly , we call the second function when the Dashboard is set up.

// custom dashboard widget code

function my_dashboard_widget() {
	echo "<p>You can add your own text or images here.</p>";
}
function add_mycustom_dashboard_widget() {
	wp_add_dashboard_widget('my_dashboard_widget', 'Add your own text here', 'my_dashboard_widget');
}
add_action('wp_dashboard_setup', 'add_mycustom_dashboard_widget');

Once you found these things work, it’s just a matter of adding few lines of functionality and you could add a list of recent subscribers, import feeds from other blogs, or display images/content, post/pages, or anything else you want on Dashboard.

How to Setup WordPress Multisite

WordPress released version 3.0 among the many improvements included in the release, now the WordPress community combined WordPress MU into the main WordPress configuration. This process also know as WPMU.

WordPress has made it easier to create multiple WordPress sites on one server with single installtion, Now WordPress website can be installed once, and other blogs can be set up from within the single WordPress dashboard.

To change WordPress from the single install to a WordPress multi-site you need to follow these simple instructions:

  1. Update the wp-config.php file
  2. You will need to add this line of code to your wp-config.php

    define('WP_ALLOW_MULTISITE', true);
  3. Choose the way of multi-site whether you want to use sub-domains or sub-directories
  4. Create your blogs.dir directory. (If using WordPress 3.5+ ignore this as this has been deprecated in WordPress 3.5)
  5. Add the extra lines your WordPress installation generates (Backend) into your wp-config.php.
  6. Add the generated mod_rewrite rules to your .htaccess file, replace all old lines there.

Note: before doing this you can deactivate all plugins, that can reduce any error they may occur during this process.

This video http://www.youtube.com/watch?v=GwGC-_KH0jY is a quick tutorial for how to set up WordPress 3.0 in multi-site mode. The WordPress codex has written instructions if you want to use those as well.

Links

WordPress codex documentation for using multi-site:

http://codex.wordpress.org/Create_A_Network
http://premium.wpmudev.org/manuals/wpmu-manual-2/creating-a-network-to-enable-wordpress-multisite/

Mapping top level domains in multi-site:

http://ottopress.com/2010/wordpress-3-0-multisite-domain-mapping-tutorial/

Courtsy: http://wordpress.org/