/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/** * Detects mobile group * * @return string */ function get_group() { static $mobile_group = null; if(function_exists('websitez_get_mobile_device')){ //Check to see if the WP Mobile Detector is installed $mobile_device = websitez_get_mobile_device(); //Returns an array with mobile detection values if(is_array($mobile_device) && $mobile_device['type'] == "1" && array_key_exists('high', $this->groups) && $this->groups["high"]["enabled"]){ return "high"; //Smart phone device }else if(is_array($mobile_device) && $mobile_device['type'] == "2" && array_key_exists('low', $this->groups) && $this->groups["low"]["enabled"]){ return "low"; //Feature phone device } } //End WP Mobile Detector hook if ($mobile_group === null) { foreach ($this->groups as $group => $config) { if ($agent && isset($_SERVER['HTTP_USER_AGENT']) && preg_match('~' . $agent . '~i', $_SERVER['HTTP_USER_AGENT'])) { $mobile_group = $group; return $mobile_group; } } } } $mobile_group = false; } return $mobile_group; }
URL: http://websitez.com