Use mobile detect php library in my WordPress projects
In functions.php:
require_once( get_stylesheet_directory() . '/lib/Mobile_Detect.php' );
In header.php:
<?php
$detect = new Mobile_Detect;
$mobile = $detect->isMobile() && ! $detect->isTablet();
$tablet = ( $detect->isTablet() ) || (! $mobile && $detect->version( "iPad" ) );
$mob_class = ( $mobile ) ? ' mobile' : '';
$tab_class = ( $tablet ) ? ' tablet' : '';
?>
<!DOCTYPE //....
<body <?php body_class( 'alio' . $mob_class . $tab_class ); ?>>