PHP 7: An quick overview

PHP 7.0.0 was released on December 3rd, 2015. The community quickly produced several builds which make it easy to install this new version using your system’s package manager.Now You can download the source code here php-7.0.0
The PHP 7 release brought some much-desired changes and improvements t…

Advertisements

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

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/