Archive for the ‘php’ Category

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