Created
July 2, 2017 19:22
-
-
Save daltonnyx/30230662ae34dbf6c0ac0780057d28eb 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
<?php | |
add_filter('template', 'change_theme'); | |
add_filter('option_template', 'change_theme'); | |
add_filter('option_stylesheet', 'change_theme'); | |
function change_theme() | |
{ | |
require_once("/path/to/Mobile_Detect.php"); | |
$detect = new Mobile_Detect; | |
$deviceType = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') : | |
'computer'); | |
switch($deviceType): | |
case 'computer': $theme = 'default_theme_name'; | |
break; | |
case 'tablet': $theme = 'tablet_theme_name'; | |
break; | |
case 'phone': $theme = 'phone_theme_name'; | |
break; | |
default: $theme = 'default_theme_name'; | |
break; | |
endswitch; | |
return $theme; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment