Archive for May, 2012

function replace_howdy( $wp_admin_bar ) {
    $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;
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() {
add_action( 'admin_init', 'disable_drag_metabox' );

You can hide admin menu items of wordpress using following code.


function remove_menus () {
global $menu;
	$restricted = array(__('Dashboard'), __('Posts'), __('Media'), __('Links'), __('Pages'), __('Appearance'), __('Tools'), __('Users'), __('Settings'), __('Comments'), __('Plugins'));
	end ($menu);
	while (prev($menu)){
		$value = explode(' ',$menu[key($menu)][0]);
		if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);}
add_action('admin_menu', 'remove_menus');

Detect Device using php code

Posted: May 24, 2012 in php
Tags: , , ,

Here we can detect the mobile devices using php code. actually the code is detecting the device usign user agent.

please click here to download mobile detect code .


1. Download mobile detect code from above link.

2.Include and instantiate the class

$detect = new Mobile_Detect();

3.Check for a specific platform:

    // code to run for the Apple iOS platform.
    // code to run for the Google Android platform.

Other case insensitive available methods are isIphone(), isIpad(), isBlackBerry(), isKindle(), isOpera(), etc. For the full list of available methods check the demo.php file or the wiki.

Alternatively, if you are only interested in checking to see if the user is using a mobile device, without caring for specific platform:

if ($detect->isMobile()) {
    // any mobile platform
    // any tablet