Posts Tagged ‘admin’

function replace_howdy( $wp_admin_bar ) {
    $my_account=$wp_admin_bar->get_node('my-account');
    $newtitle = str_replace( 'Howdy,', 'Logged in as', $my_account->title );
    $wp_admin_bar->add_node( array(
        'id' => 'my-account',
        'title' => $newtitle,
    ) );
}
add_filter( 'admin_bar_menu', 'replace_howdy',25 );

To remove any item of the admin bar of your site use following code.

function wps_admin_bar() {
    global $wp_admin_bar;
    $wp_admin_bar->remove_menu('wp-logo');
    $wp_admin_bar->remove_menu('about');
    $wp_admin_bar->remove_menu('wporg');
    $wp_admin_bar->remove_menu('documentation');
    $wp_admin_bar->remove_menu('support-forums');
    $wp_admin_bar->remove_menu('feedback');
    $wp_admin_bar->remove_menu('view-site');
}
add_action( 'wp_before_admin_bar_render', 'wps_admin_bar' );

use following code to show the admin bar only for the admin of your website

 

if (!current_user_can('manage_options')) {
	add_filter('show_admin_bar', '__return_false');
}

To show any warning message or notices in your wordpress admin panel/ dashboard use below code in your theme function.php file

 

function showMessage($message, $errormsg = false)
{
	if ($errormsg) {
		echo '<div id="message">';
	}
	else {
		echo '<div id="message">';
	}
	echo "<p><strong>$message</strong></p></div>";
} 

function showAdminMessages()
{
    showMessage("Working on Theme's function.php, Do not touch it till further notice.", true);
}
add_action('admin_notices', 'showAdminMessages');

If you like to remove the functionality of dragging of metaboxes within the admin area and dashboard  Go to functions.php in your theme folder and add following code.

function disable_drag_metabox() {
    wp_deregister_script('postbox');
}
add_action( 'admin_init', 'disable_drag_metabox' );