Created
April 11, 2013 20:56
-
-
Save timbroder/5367090 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: dts_class_switcher.php | |
=================================================================== | |
--- dts_class_switcher.php (revision 696222) | |
+++ dts_class_switcher.php (working copy) | |
@@ -84,26 +84,37 @@ | |
// DEVICE READING & ALTERNATE THEME OUTPUT | |
// ------------------------------------------------------------------------ | |
public function detect_device_and_set_flag () { | |
- //Include the MobileESP code library for acertaining device user agents | |
- include_once('mdetect.php'); | |
- | |
- //Setup the MobileESP Class | |
- $uagent_info = new uagent_info; | |
- | |
- //Detect if the device is a handheld | |
- if ($uagent_info->DetectTierIphone() || $uagent_info->DetectBlackBerry() || $uagent_info->DetectTierRichCss()) : | |
- $this->device_theme = $this->handheld_theme; | |
- endif ; | |
- | |
- //Detect if the device is a tablets | |
- if ($uagent_info->DetectTierTablet() || $uagent_info->DetectKindle() || $uagent_info->DetectAmazonSilk()) : | |
- $this->device_theme = $this->tablet_theme; | |
- endif ; | |
+ if (!isset($_SERVER['HTTP_X_UA_DEVICE'])) : | |
+ //Include the MobileESP code library for acertaining device user agents | |
+ include_once('mdetect.php'); | |
+ | |
+ //Setup the MobileESP Class | |
+ $uagent_info = new uagent_info; | |
+ | |
+ //Detect if the device is a handheld | |
+ if ($uagent_info->DetectTierIphone() || $uagent_info->DetectBlackBerry() || $uagent_info->DetectTierRichCss()) : | |
+ $this->device_theme = $this->handheld_theme; | |
+ endif ; | |
+ | |
+ //Detect if the device is a tablets | |
+ if ($uagent_info->DetectTierTablet() || $uagent_info->DetectKindle() || $uagent_info->DetectAmazonSilk()) : | |
+ $this->device_theme = $this->tablet_theme; | |
+ endif ; | |
- //Detect if the device is a tablets | |
- if ($uagent_info->DetectBlackBerryLow() || $uagent_info->DetectTierOtherPhones()) : | |
- $this->device_theme = $this->low_support_theme; | |
- endif ; | |
+ //Detect if the device is a tablets | |
+ if ($uagent_info->DetectBlackBerryLow() || $uagent_info->DetectTierOtherPhones()) : | |
+ $this->device_theme = $this->low_support_theme; | |
+ endif ; | |
+ //Support for Varnish Device Detect: https://github.com/varnish/varnish-devicedetect/ | |
+ else : | |
+ if (in_array($_SERVER['HTTP_X_UA_DEVICE'], array('mobile-iphone', 'mobile-android', 'mobile-smartphone', 'mobile-generic'))) : | |
+ $this->device_theme = $this->handheld_theme; | |
+ elseif (in_array($_SERVER['HTTP_X_UA_DEVICE'], array('tablet-ipad', 'tablet-android'))) : | |
+ $this->device_theme = $this->tablet_theme; | |
+ else: | |
+ $this->device_theme = $this->low_support_theme; | |
+ endif; | |
+ endif; | |
}//END member function deliver_theme_to_device | |
public function deliver_alternate_device_theme () { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment