ivan79
5/22/2015 - 8:00 AM

From http://luke-danielson.com/2014/07/09/browser-detection-in-wordpress/ Añadir las clases al mobile

function user_client_detection_body_class($classes) {
	global $is_lynx, $is_gecko, $is_IE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone;
	
	if($is_lynx)        $classes[] = 'lynx';
	else if($is_gecko)   $classes[] = 'gecko';
	else if($is_opera)   $classes[] = 'opera';
	else if($is_NS4)     $classes[] = 'ns4';
	else if($is_safari)  $classes[] = 'safari';
	else if($is_chrome)  $classes[] = 'chrome';
	else if($is_IE)      $classes[] = 'ie';
	else                $classes[] = 'unknown';

	if($is_IE && 
	   preg_match('/MSIE ([0-9]+)([a-zA-Z0-9.]+)/', $_SERVER['HTTP_USER_AGENT'], $browser_version))
	{
		$classes[] = 'ie'.$browser_version[1];
	}
	
	if(wp_is_mobile()) $classes[] = 'mobile';

	if($is_iphone) $classes[] = 'iphone';
	else if(strpos($_SERVER['HTTP_USER_AGENT'], 'iPad') !== false) $classes[] = 'ipad';
	else if(strpos($_SERVER['HTTP_USER_AGENT'], 'Android') !== false) $classes[] = 'android';
	else if(strpos($_SERVER['HTTP_USER_AGENT'], 'Kindle') !== false) $classes[] = 'kindle';
	else if(strpos($_SERVER['HTTP_USER_AGENT'], 'BlackBerry') !== false) $classes[] = 'blackberry';
	else if(strpos($_SERVER['HTTP_USER_AGENT'], 'Opera Mini') !== false) $classes[] = 'opera-mini';
	else if(strpos($_SERVER['HTTP_USER_AGENT'], 'Opera Mobi') !== false) $classes[] = 'opera-mobi';
	
	if ( stristr( $_SERVER['HTTP_USER_AGENT'],'mac') ) $classes[] = 'osx';
	else if ( stristr( $_SERVER['HTTP_USER_AGENT'],'linux') ) $classes[] = 'linux';
	else if ( stristr( $_SERVER['HTTP_USER_AGENT'],'windows') ) $classes[] = 'windows';


	return $classes;
}

add_filter('body_class','user_client_detection_body_class');