<?php | |
/** | |
* | |
* Mobile theme switcher code - pulled from Mobile theme switch | |
* Original URI: http://wordpress.org/extend/plugins/mobile-theme-switcher/ | |
* Original Author: Jonas Vorwerk, http://www.jonasvorwerk.com/ | |
* | |
* | |
* Bypass this check in any browser by using http://myurl/?mobile=on or http://myurl/?mobile=off This is locally being stored using a cookie. | |
* | |
* param $themes - set to genesis (parent theme) | |
* param $style - set to child theme directory name (child theme) | |
* | |
*/ | |
if( is_admin() ) | |
return; | |
session_start(); | |
if( !isset( $_SESSION['mobilethemeswitch'] ) ) | |
$_SESSION['mobilethemeswitch'] = ''; | |
if( isset( $_GET['mobile'] ) && $_GET['mobile'] == "off"){ | |
$_SESSION['mobilethemeswitch'] = "off"; | |
} else if( isset( $_GET['mobile'] ) && $_GET['mobile'] == "on"){ | |
$_SESSION['mobilethemeswitch'] = "on"; | |
} | |
//mobile browsers - this list can be expanded as needed | |
$iphone = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone"); | |
$ipod = strpos($_SERVER['HTTP_USER_AGENT'],"iPod"); | |
$android = strpos($_SERVER['HTTP_USER_AGENT'],"Android"); | |
$palmpre = strpos($_SERVER['HTTP_USER_AGENT'],"webOS"); | |
$berry = strpos($_SERVER['HTTP_USER_AGENT'],"BlackBerry"); | |
$iemobile = ( strpos($_SERVER['HTTP_USER_AGENT'],"iemobile") || strpos($_SERVER['HTTP_USER_AGENT'],"IEMobile") ); | |
if ( ((($iphone || $android || $palmpre || $ipod || $berry !== FALSE || $iemobile) === true) || $_SESSION['mobilethemeswitch'] == "on") && $_SESSION['mobilethemeswitch'] != "off" ) { | |
add_filter('stylesheet', 'getThemeStyle'); | |
add_filter('template', 'getTemplateStyle'); | |
} | |
function getTemplateStyle(){ | |
$themes = 'genesis'; | |
return $themes; | |
} | |
function getThemeStyle(){ | |
$style = 'dcsi-mobile'; | |
return $style; | |
} |
This file contains 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