Any Mobile Theme Switcher - Version 0.5

Version Description

  • Requires License Key (Offer your price ($0 - $100) and get the license key from here)
  • Added More Mobile User Agents
  • 3.4 Tested
Download this release

Release Info

Developer dnesscarkey
Plugin Icon 128x128 Any Mobile Theme Switcher
Version 0.5
Comparing to
See all releases

Version 0.5

any-mobile-theme-switcher.php ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Any Mobile Theme Switcher
4
+ Plugin URI: http://dineshkarki.com.np/plugins/any-mobile-theme-switcher
5
+ Description: This plugin allow you to detect all mobile platform and switch the theme. Supports most of the mobile platform including iphone, ipad, ipod, windows mobile, parm os, blackberry, android.
6
+ Author: Dinesh Karki
7
+ Version: 0.5
8
+ Author URI: http://www.dineshkarki.com.np
9
+ */
10
+
11
+ /* Copyright 2012 Dinesh Karki (email : dnesskarki@gmail.com)*/
12
+
13
+ if (!session_id()){
14
+ session_start();
15
+ }
16
+
17
+ $mobile_browser = '';
18
+ $mobileredirect = '';
19
+ $status = '';
20
+ $user_agent = $_SERVER['HTTP_USER_AGENT']; // get the user agent value - this should be cleaned to ensure no nefarious input gets executed
21
+ $accept = $_SERVER['HTTP_ACCEPT']; // get the content accept value - this should be cleaned to ensure no nefarious input gets executed
22
+
23
+ switch(true){ // using a switch against the following statements which could return true is more efficient than the previous method of using if statements
24
+
25
+ case (preg_match('/ipad/i',$user_agent)); // we find the word ipad in the user agent
26
+ $mobile_browser = get_option('ipad_theme'); // mobile browser is either true or false depending on the setting of ipad when calling the function
27
+ $status = 'Apple iPad';
28
+ break; // break out and skip the rest if we've had a match on the ipad // this goes before the iphone to catch it else it would return on the iphone instead
29
+
30
+ case (preg_match('/ipod/i',$user_agent)||preg_match('/iphone/i',$user_agent)); // we find the words iphone or ipod in the user agent
31
+ $mobile_browser = get_option('iphone_theme'); // mobile browser is either true or false depending on the setting of iphone when calling the function
32
+ $status = 'Apple';
33
+ break; // break out and skip the rest if we've had a match on the iphone or ipod
34
+
35
+ case (preg_match('/android/i',$user_agent)); // we find android in the user agent
36
+ $mobile_browser = get_option('android_theme'); // mobile browser is either true or false depending on the setting of android when calling the function
37
+ $status = 'Android';
38
+ break; // break out and skip the rest if we've had a match on android
39
+
40
+ case (preg_match('/opera mini/i',$user_agent)); // we find opera mini in the user agent
41
+ $mobile_browser = get_option('opera_theme'); // mobile browser is either true or false depending on the setting of opera when calling the function
42
+ $status = 'Opera';
43
+ break; // break out and skip the rest if we've had a match on opera
44
+
45
+ case (preg_match('/blackberry/i',$user_agent)); // we find blackberry in the user agent
46
+ $mobile_browser = get_option('blackberry_theme'); // mobile browser is either true or false depending on the setting of blackberry when calling the function
47
+ $status = 'Blackberry';
48
+ break; // break out and skip the rest if we've had a match on blackberry
49
+
50
+ case (preg_match('/(pre\/|palm os|palm|hiptop|avantgo|plucker|xiino|blazer|elaine)/i',$user_agent)); // we find palm os in the user agent - the i at the end makes it case insensitive
51
+ $mobile_browser = get_option('parm_os_theme'); // mobile browser is either true or false depending on the setting of palm when calling the function
52
+ $status = 'Palm';
53
+ break; // break out and skip the rest if we've had a match on palm os
54
+
55
+ case (preg_match('/(iris|3g_t|windows ce|opera mobi|windows ce; smartphone;|windows ce; iemobile)/i',$user_agent)); // we find windows mobile in the user agent - the i at the end makes it case insensitive
56
+ $mobile_browser = get_option('windows_theme'); // mobile browser is either true or false depending on the setting of windows when calling the function
57
+ $status = 'Windows Smartphone';
58
+ break; // break out and skip the rest if we've had a match on windows
59
+
60
+ case (preg_match('/(mini 9.5|vx1000|lge |m800|e860|u940|ux840|compal|wireless| mobi|ahong|lg380|lgku|lgu900|lg210|lg47|lg920|lg840|lg370|sam-r|mg50|s55|g83|t66|vx400|mk99|d615|d763|el370|sl900|mp500|samu3|samu4|vx10|xda_|samu5|samu6|samu7|samu9|a615|b832|m881|s920|n210|s700|c-810|_h797|mob-x|sk16d|848b|mowser|s580|r800|471x|v120|rim8|c500foma:|160x|x160|480x|x640|t503|w839|i250|sprint|w398samr810|m5252|c7100|mt126|x225|s5330|s820|htil-g1|fly v71|s302|-x113|novarra|k610i|-three|8325rc|8352rc|sanyo|vx54|c888|nx250|n120|mtk |c5588|s710|t880|c5005|i;458x|p404i|s210|c5100|teleca|s940|c500|s590|foma|samsu|vx8|vx9|a1000|_mms|myx|a700|gu1100|bc831|e300|ems100|me701|me702m-three|sd588|s800|8325rc|ac831|mw200|brew |d88|htc\/|htc_touch|355x|m50|km100|d736|p-9521|telco|sl74|ktouch|m4u\/|me702|8325rc|kddi|phone|lg |sonyericsson|samsung|240x|x320|vx10|nokia|sony cmd|motorola|up.browser|up.link|mmp|symbian|smartphone|midp|wap|vodafone|o2|pocket|kindle|mobile|psp|treo)/i',$user_agent)); // check if any of the values listed create a match on the user agent - these are some of the most common terms used in agents to identify them as being mobile devices - the i at the end makes it case insensitive
61
+ $mobile_browser = get_option('other_theme'); // set mobile browser to true
62
+ $status = 'Mobile matched on piped preg_match';
63
+ break; // break out and skip the rest if we've preg_match on the user agent returned true
64
+
65
+ case ((strpos($accept,'text/vnd.wap.wml')>0)||(strpos($accept,'application/vnd.wap.xhtml+xml')>0)); // is the device showing signs of support for text/vnd.wap.wml or application/vnd.wap.xhtml+xml
66
+ $mobile_browser = get_option('other_theme'); // set mobile browser to true
67
+ $status = 'Mobile matched on content accept header';
68
+ break; // break out and skip the rest if we've had a match on the content accept headers
69
+
70
+ case (isset($_SERVER['HTTP_X_WAP_PROFILE'])||isset($_SERVER['HTTP_PROFILE'])); // is the device giving us a HTTP_X_WAP_PROFILE or HTTP_PROFILE header - only mobile devices would do this
71
+ $mobile_browser = get_option('other_theme'); // set mobile browser to true
72
+ $status = 'Mobile matched on profile headers being set';
73
+ break; // break out and skip the final step if we've had a return true on the mobile specfic headers
74
+
75
+ case (in_array(strtolower(substr($user_agent,0,4)),array('1207'=>'1207','3gso'=>'3gso','4thp'=>'4thp','501i'=>'501i','502i'=>'502i','503i'=>'503i','504i'=>'504i','505i'=>'505i','506i'=>'506i','6310'=>'6310','6590'=>'6590','770s'=>'770s','802s'=>'802s','a wa'=>'a wa','acer'=>'acer','acs-'=>'acs-','airn'=>'airn','alav'=>'alav','asus'=>'asus','attw'=>'attw','au-m'=>'au-m','aur '=>'aur ','aus '=>'aus ','abac'=>'abac','acoo'=>'acoo','aiko'=>'aiko','alco'=>'alco','alca'=>'alca','amoi'=>'amoi','anex'=>'anex','anny'=>'anny','anyw'=>'anyw','aptu'=>'aptu','arch'=>'arch','argo'=>'argo','bell'=>'bell','bird'=>'bird','bw-n'=>'bw-n','bw-u'=>'bw-u','beck'=>'beck','benq'=>'benq','bilb'=>'bilb','blac'=>'blac','c55/'=>'c55/','cdm-'=>'cdm-','chtm'=>'chtm','capi'=>'capi','cond'=>'cond','craw'=>'craw','dall'=>'dall','dbte'=>'dbte','dc-s'=>'dc-s','dica'=>'dica','ds-d'=>'ds-d','ds12'=>'ds12','dait'=>'dait','devi'=>'devi','dmob'=>'dmob','doco'=>'doco','dopo'=>'dopo','el49'=>'el49','erk0'=>'erk0','esl8'=>'esl8','ez40'=>'ez40','ez60'=>'ez60','ez70'=>'ez70','ezos'=>'ezos','ezze'=>'ezze','elai'=>'elai','emul'=>'emul','eric'=>'eric','ezwa'=>'ezwa','fake'=>'fake','fly-'=>'fly-','fly_'=>'fly_','g-mo'=>'g-mo','g1 u'=>'g1 u','g560'=>'g560','gf-5'=>'gf-5','grun'=>'grun','gene'=>'gene','go.w'=>'go.w','good'=>'good','grad'=>'grad','hcit'=>'hcit','hd-m'=>'hd-m','hd-p'=>'hd-p','hd-t'=>'hd-t','hei-'=>'hei-','hp i'=>'hp i','hpip'=>'hpip','hs-c'=>'hs-c','htc '=>'htc ','htc-'=>'htc-','htca'=>'htca','htcg'=>'htcg','htcp'=>'htcp','htcs'=>'htcs','htct'=>'htct','htc_'=>'htc_','haie'=>'haie','hita'=>'hita','huaw'=>'huaw','hutc'=>'hutc','i-20'=>'i-20','i-go'=>'i-go','i-ma'=>'i-ma','i230'=>'i230','iac'=>'iac','iac-'=>'iac-','iac/'=>'iac/','ig01'=>'ig01','im1k'=>'im1k','inno'=>'inno','iris'=>'iris','jata'=>'jata','java'=>'java','kddi'=>'kddi','kgt'=>'kgt','kgt/'=>'kgt/','kpt '=>'kpt ','kwc-'=>'kwc-','klon'=>'klon','lexi'=>'lexi','lg g'=>'lg g','lg-a'=>'lg-a','lg-b'=>'lg-b','lg-c'=>'lg-c','lg-d'=>'lg-d','lg-f'=>'lg-f','lg-g'=>'lg-g','lg-k'=>'lg-k','lg-l'=>'lg-l','lg-m'=>'lg-m','lg-o'=>'lg-o','lg-p'=>'lg-p','lg-s'=>'lg-s','lg-t'=>'lg-t','lg-u'=>'lg-u','lg-w'=>'lg-w','lg/k'=>'lg/k','lg/l'=>'lg/l','lg/u'=>'lg/u','lg50'=>'lg50','lg54'=>'lg54','lge-'=>'lge-','lge/'=>'lge/','lynx'=>'lynx','leno'=>'leno','m1-w'=>'m1-w','m3ga'=>'m3ga','m50/'=>'m50/','maui'=>'maui','mc01'=>'mc01','mc21'=>'mc21','mcca'=>'mcca','medi'=>'medi','meri'=>'meri','mio8'=>'mio8','mioa'=>'mioa','mo01'=>'mo01','mo02'=>'mo02','mode'=>'mode','modo'=>'modo','mot '=>'mot ','mot-'=>'mot-','mt50'=>'mt50','mtp1'=>'mtp1','mtv '=>'mtv ','mate'=>'mate','maxo'=>'maxo','merc'=>'merc','mits'=>'mits','mobi'=>'mobi','motv'=>'motv','mozz'=>'mozz','n100'=>'n100','n101'=>'n101','n102'=>'n102','n202'=>'n202','n203'=>'n203','n300'=>'n300','n302'=>'n302','n500'=>'n500','n502'=>'n502','n505'=>'n505','n700'=>'n700','n701'=>'n701','n710'=>'n710','nec-'=>'nec-','nem-'=>'nem-','newg'=>'newg','neon'=>'neon','netf'=>'netf','noki'=>'noki','nzph'=>'nzph','o2 x'=>'o2 x','o2-x'=>'o2-x','opwv'=>'opwv','owg1'=>'owg1','opti'=>'opti','oran'=>'oran','p800'=>'p800','pand'=>'pand','pg-1'=>'pg-1','pg-2'=>'pg-2','pg-3'=>'pg-3','pg-6'=>'pg-6','pg-8'=>'pg-8','pg-c'=>'pg-c','pg13'=>'pg13','phil'=>'phil','pn-2'=>'pn-2','pt-g'=>'pt-g','palm'=>'palm','pana'=>'pana','pire'=>'pire','pock'=>'pock','pose'=>'pose','psio'=>'psio','qa-a'=>'qa-a','qc-2'=>'qc-2','qc-3'=>'qc-3','qc-5'=>'qc-5','qc-7'=>'qc-7','qc07'=>'qc07','qc12'=>'qc12','qc21'=>'qc21','qc32'=>'qc32','qc60'=>'qc60','qci-'=>'qci-','qwap'=>'qwap','qtek'=>'qtek','r380'=>'r380','r600'=>'r600','raks'=>'raks','rim9'=>'rim9','rove'=>'rove','s55/'=>'s55/','sage'=>'sage','sams'=>'sams','sc01'=>'sc01','sch-'=>'sch-','scp-'=>'scp-','sdk/'=>'sdk/','se47'=>'se47','sec-'=>'sec-','sec0'=>'sec0','sec1'=>'sec1','semc'=>'semc','sgh-'=>'sgh-','shar'=>'shar','sie-'=>'sie-','sk-0'=>'sk-0','sl45'=>'sl45','slid'=>'slid','smb3'=>'smb3','smt5'=>'smt5','sp01'=>'sp01','sph-'=>'sph-','spv '=>'spv ','spv-'=>'spv-','sy01'=>'sy01','samm'=>'samm','sany'=>'sany','sava'=>'sava','scoo'=>'scoo','send'=>'send','siem'=>'siem','smar'=>'smar','smit'=>'smit','soft'=>'soft','sony'=>'sony','t-mo'=>'t-mo','t218'=>'t218','t250'=>'t250','t600'=>'t600','t610'=>'t610','t618'=>'t618','tcl-'=>'tcl-','tdg-'=>'tdg-','telm'=>'telm','tim-'=>'tim-','ts70'=>'ts70','tsm-'=>'tsm-','tsm3'=>'tsm3','tsm5'=>'tsm5','tx-9'=>'tx-9','tagt'=>'tagt','talk'=>'talk','teli'=>'teli','topl'=>'topl','hiba'=>'hiba','up.b'=>'up.b','upg1'=>'upg1','utst'=>'utst','v400'=>'v400','v750'=>'v750','veri'=>'veri','vk-v'=>'vk-v','vk40'=>'vk40','vk50'=>'vk50','vk52'=>'vk52','vk53'=>'vk53','vm40'=>'vm40','vx98'=>'vx98','virg'=>'virg','vite'=>'vite','voda'=>'voda','vulc'=>'vulc','w3c '=>'w3c ','w3c-'=>'w3c-','wapj'=>'wapj','wapp'=>'wapp','wapu'=>'wapu','wapm'=>'wapm','wig '=>'wig ','wapi'=>'wapi','wapr'=>'wapr','wapv'=>'wapv','wapy'=>'wapy','wapa'=>'wapa','waps'=>'waps','wapt'=>'wapt','winc'=>'winc','winw'=>'winw','wonu'=>'wonu','x700'=>'x700','xda2'=>'xda2','xdag'=>'xdag','yas-'=>'yas-','your'=>'your','zte-'=>'zte-','zeto'=>'zeto','acs-'=>'acs-','alav'=>'alav','alca'=>'alca','amoi'=>'amoi','aste'=>'aste','audi'=>'audi','avan'=>'avan','benq'=>'benq','bird'=>'bird','blac'=>'blac','blaz'=>'blaz','brew'=>'brew','brvw'=>'brvw','bumb'=>'bumb','ccwa'=>'ccwa','cell'=>'cell','cldc'=>'cldc','cmd-'=>'cmd-','dang'=>'dang','doco'=>'doco','eml2'=>'eml2','eric'=>'eric','fetc'=>'fetc','hipt'=>'hipt','http'=>'http','ibro'=>'ibro','idea'=>'idea','ikom'=>'ikom','inno'=>'inno','ipaq'=>'ipaq','jbro'=>'jbro','jemu'=>'jemu','java'=>'java','jigs'=>'jigs','kddi'=>'kddi','keji'=>'keji','kyoc'=>'kyoc','kyok'=>'kyok','leno'=>'leno','lg-c'=>'lg-c','lg-d'=>'lg-d','lg-g'=>'lg-g','lge-'=>'lge-','libw'=>'libw','m-cr'=>'m-cr','maui'=>'maui','maxo'=>'maxo','midp'=>'midp','mits'=>'mits','mmef'=>'mmef','mobi'=>'mobi','mot-'=>'mot-','moto'=>'moto','mwbp'=>'mwbp','mywa'=>'mywa','nec-'=>'nec-','newt'=>'newt','nok6'=>'nok6','noki'=>'noki','o2im'=>'o2im','opwv'=>'opwv','palm'=>'palm','pana'=>'pana','pant'=>'pant','pdxg'=>'pdxg','phil'=>'phil','play'=>'play','pluc'=>'pluc','port'=>'port','prox'=>'prox','qtek'=>'qtek','qwap'=>'qwap','rozo'=>'rozo','sage'=>'sage','sama'=>'sama','sams'=>'sams','sany'=>'sany','sch-'=>'sch-','sec-'=>'sec-','send'=>'send','seri'=>'seri','sgh-'=>'sgh-','shar'=>'shar','sie-'=>'sie-','siem'=>'siem','smal'=>'smal','smar'=>'smar','sony'=>'sony','sph-'=>'sph-','symb'=>'symb','t-mo'=>'t-mo','teli'=>'teli','tim-'=>'tim-','tosh'=>'tosh','treo'=>'treo','tsm-'=>'tsm-','upg1'=>'upg1','upsi'=>'upsi','vk-v'=>'vk-v','voda'=>'voda','vx52'=>'vx52','vx53'=>'vx53','vx60'=>'vx60','vx61'=>'vx61','vx70'=>'vx70','vx80'=>'vx80','vx81'=>'vx81','vx83'=>'vx83','vx85'=>'vx85','wap-'=>'wap-','wapa'=>'wapa','wapi'=>'wapi','wapp'=>'wapp','wapr'=>'wapr','webc'=>'webc','whit'=>'whit','winw'=>'winw','wmlb'=>'wmlb','xda-'=>'xda-',))); // check against a list of trimmed user agents to see if we find a match
76
+ $mobile_browser = get_option('other_theme'); // set mobile browser to true
77
+ $status = 'Mobile matched on in_array';
78
+ break; // break even though it's the last statement in the switch so there's nothing to break away from but it seems better to include it than exclude it
79
+
80
+ } // ends the switch
81
+
82
+ //Force Theme Display request from visitor.
83
+ if ($_GET['am_force_theme_layout']){
84
+ $_SESSION['am_force_theme_layout'] = $_GET['am_force_theme_layout'];
85
+ }
86
+
87
+ if (isset($_SESSION['am_force_theme_layout'])){ //IF USER FORCE FOR THE THEME
88
+ if ($_SESSION['am_force_theme_layout'] == 'mobile'){ // IF FORCED THEME IS MOBILE
89
+ $mobile_browser = get_option('iphone_theme');
90
+ add_filter('stylesheet', 'loadMobileStyle');
91
+ add_filter('template', 'loadMobileTheme');
92
+ $shown_theme = 'mobile';
93
+ }
94
+ } else { // NORMAL THEME [PLUGIN DEFAULT]
95
+ if (!empty($mobile_browser)){
96
+ add_filter('stylesheet', 'loadMobileStyle');
97
+ add_filter('template', 'loadMobileTheme');
98
+ $shown_theme = 'mobile';
99
+ }
100
+ }
101
+
102
+
103
+ function loadMobileStyle(){
104
+ global $mobile_browser;
105
+ $mobileTheme = $mobile_browser;
106
+ $themeList = get_themes();
107
+ foreach ($themeList as $theme) {
108
+ if ($theme['Name'] == $mobileTheme) {
109
+ return $theme['Stylesheet'];
110
+ }
111
+ }
112
+ }
113
+
114
+ function loadMobileTheme(){
115
+ global $mobile_browser;
116
+ $mobileTheme = $mobile_browser;
117
+ $themeList = get_themes();
118
+ foreach ($themeList as $theme) {
119
+ if ($theme['Name'] == $mobileTheme) {
120
+ return $theme['Template'];
121
+ }
122
+ }
123
+ }
124
+
125
+ // Embed Switch Links in Theme Via Shortcode
126
+ // [show_theme_switch_link]
127
+ function show_theme_switch_link_func( $atts ){
128
+ $desktopSwitchLink = get_option('show_switch_link_for_desktop');
129
+ global $shown_theme;
130
+ global $status;
131
+ if ($shown_theme){
132
+ $return = '<a rel="external" data-ajax="false" href="'.get_bloginfo('url').'?am_force_theme_layout=desktop" class="am-switch-btn godesktop">'.get_option('desktop_view_theme_link_text').'</a>';
133
+ } else {
134
+ if ((!empty($status)) || ($desktopSwitchLink == 'yes')){
135
+ $return = '<a href="'.get_bloginfo('url').'?am_force_theme_layout=mobile" class="am-switch-btn gomobile">'.get_option('mobile_view_theme_link_text').'</a>';
136
+ }
137
+ }
138
+ return $return;
139
+ }
140
+ add_shortcode('show_theme_switch_link', 'show_theme_switch_link_func');
141
+
142
+ include('plugin_interface.php');
143
+ ?>
plugin_interface.php ADDED
@@ -0,0 +1,258 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ add_action('admin_menu', 'any_mobile_create_menu');
3
+
4
+ function any_mobile_create_menu() {
5
+ add_options_page('Any Mobile Theme', 'Any Mobile Theme', 'administrator', __FILE__, 'am_settings_page');
6
+ add_action('admin_init', 'register_mysettings_theme');
7
+ }
8
+
9
+
10
+ function register_mysettings_theme() {
11
+ register_setting('am-settings-group', 'iphone_theme');
12
+ register_setting('am-settings-group', 'ipad_theme');
13
+ register_setting('am-settings-group', 'android_theme');
14
+ register_setting('am-settings-group', 'blackberry_theme');
15
+ register_setting('am-settings-group', 'windows_theme');
16
+ register_setting('am-settings-group', 'opera_theme');
17
+ register_setting('am-settings-group', 'parm_os_theme');
18
+ register_setting('am-settings-group', 'other_theme');
19
+ register_setting('am-settings-group', 'mobile_view_theme_link_text');
20
+ register_setting('am-settings-group', 'desktop_view_theme_link_text');
21
+ register_setting('am-settings-group', 'show_switch_link_for_desktop');
22
+ }
23
+
24
+ function am_settings_page() {
25
+
26
+ $iphoneTheme = get_option('iphone_theme');
27
+ $ipadTheme = get_option('ipad_theme');
28
+ $androidTheme = get_option('android_theme');
29
+ $blackberryTheme = get_option('blackberry_theme');
30
+ $windowsTheme = get_option('windows_theme');
31
+ $operaTheme = get_option('opera_theme');
32
+ $palmTheme = get_option('parm_os_theme');
33
+ $otherTheme = get_option('other_theme');
34
+ $mobileThemeText = get_option('mobile_view_theme_link_text');
35
+ $desktopThemeText = get_option('desktop_view_theme_link_text');
36
+ $desktopSwitchLink = get_option('show_switch_link_for_desktop');
37
+
38
+
39
+ if (empty($mobileThemeText)){
40
+ update_option('mobile_view_theme_link_text', 'Switch To Mobile Version');
41
+ $mobileThemeText = get_option('mobile_view_theme_link_text');
42
+ }
43
+
44
+ if (empty($desktopThemeText)){
45
+ update_option('desktop_view_theme_link_text', 'Switch To Desktop Version');
46
+ $desktopThemeText = get_option('desktop_view_theme_link_text');
47
+ }
48
+
49
+ if (empty($desktopSwitchLink)){
50
+ update_option('show_switch_link_for_desktop', 'no');
51
+ $desktopSwitchLink = get_option('show_switch_link_for_desktop');
52
+ }
53
+
54
+ $themeList = get_themes();
55
+ $themeNames = array_keys($themeList);
56
+ $defaultTheme = get_current_theme();
57
+ natcasesort($themeNames);
58
+ ?>
59
+ <div class="wrap">
60
+ <h2>Any Mobile Theme Switcher</h2>
61
+ <style>
62
+ fieldset.license_key { border:1px solid #060; padding:5px;-webkit-border-radius: 5px;border-radius: 5px; padding-bottom:10px;}
63
+ fieldset.license_key legend{ color:#060; font-size:15px; font-weight:bold; padding-left:5px; padding-right:5px;}
64
+ fieldset.license_key input[type=text]{ margin-right:20px;}
65
+ </style>
66
+
67
+ <h3>Select Theme For Devices</h3>
68
+ <form method="post" action="options.php">
69
+ <?php settings_fields( 'am-settings-group' ); ?>
70
+ <table class="form-table">
71
+ <tr valign="top">
72
+ <th scope="row">iPhone/iPod Touch Theme:</th>
73
+ <td>
74
+ <select name="iphone_theme">
75
+ <?php
76
+ foreach ($themeNames as $themeName) {
77
+ if (($iphoneTheme == $themeName) || (($iphoneTheme == '') && ($themeName == $defaultTheme))) {
78
+ echo '<option value="' . $themeName . '" selected="selected">' . htmlspecialchars($themeName) . '</option>';
79
+ } else {
80
+ echo '<option value="' . $themeName . '">' . htmlspecialchars($themeName) . '</option>';
81
+ }
82
+ }
83
+ ?>
84
+ </select>
85
+ </td>
86
+ </tr>
87
+
88
+ <tr valign="top">
89
+ <th scope="row">iPad Theme</th>
90
+ <td>
91
+ <select name="ipad_theme">
92
+ <?php
93
+ foreach ($themeNames as $themeName) {
94
+ if (($ipadTheme == $themeName) || (($ipadTheme == '') && ($themeName == $defaultTheme))) {
95
+ echo '<option value="' . $themeName . '" selected="selected">' . htmlspecialchars($themeName) . '</option>';
96
+ } else {
97
+ echo'<option value="' . $themeName . '">' . htmlspecialchars($themeName) . '</option>';
98
+ }
99
+ }
100
+ ?>
101
+ </select>
102
+ </td>
103
+ </tr>
104
+
105
+ <tr valign="top">
106
+ <th scope="row">Android Theme</th>
107
+ <td>
108
+ <select name="android_theme">
109
+ <?php
110
+ foreach ($themeNames as $themeName) {
111
+ if (($androidTheme == $themeName) || (($androidTheme == '') && ($themeName == $defaultTheme))) {
112
+ echo '<option value="' . $themeName . '" selected="selected">' . htmlspecialchars($themeName) . '</option>';
113
+ } else {
114
+ echo'<option value="' . $themeName . '">' . htmlspecialchars($themeName) . '</option>';
115
+ }
116
+ }
117
+ ?>
118
+ </select>
119
+ </td>
120
+ </tr>
121
+
122
+
123
+ <tr valign="top">
124
+ <th scope="row">Blackberry Theme</th>
125
+ <td>
126
+ <select name="blackberry_theme">
127
+ <?php
128
+ foreach ($themeNames as $themeName) {
129
+ if (($blackberryTheme == $themeName) || (($blackberryTheme == '') && ($themeName == $defaultTheme))) {
130
+ echo '<option value="' . $themeName . '" selected="selected">' . htmlspecialchars($themeName) . '</option>';
131
+ } else {
132
+ echo'<option value="' . $themeName . '">' . htmlspecialchars($themeName) . '</option>';
133
+ }
134
+ }
135
+ ?>
136
+ </select>
137
+ </td>
138
+ </tr>
139
+
140
+
141
+ <tr valign="top">
142
+ <th scope="row">Windows Mobile Theme</th>
143
+ <td>
144
+ <select name="windows_theme">
145
+ <?php
146
+ foreach ($themeNames as $themeName) {
147
+ if (($windowsTheme == $themeName) || (($windowsTheme == '') && ($themeName == $defaultTheme))) {
148
+ echo '<option value="' . $themeName . '" selected="selected">' . htmlspecialchars($themeName) . '</option>';
149
+ } else {
150
+ echo'<option value="' . $themeName . '">' . htmlspecialchars($themeName) . '</option>';
151
+ }
152
+ }
153
+ ?>
154
+ </select>
155
+ </td>
156
+ </tr>
157
+
158
+ <tr valign="top">
159
+ <th scope="row">Opera Mini Theme</th>
160
+ <td>
161
+ <select name="opera_theme">
162
+ <?php
163
+ foreach ($themeNames as $themeName) {
164
+ if (($operaTheme == $themeName) || (($operaTheme == '') && ($themeName == $defaultTheme))) {
165
+ echo '<option value="' . $themeName . '" selected="selected">' . htmlspecialchars($themeName) . '</option>';
166
+ } else {
167
+ echo'<option value="' . $themeName . '">' . htmlspecialchars($themeName) . '</option>';
168
+ }
169
+ }
170
+ ?>
171
+ </select>
172
+ </td>
173
+ </tr>
174
+
175
+ <tr valign="top">
176
+ <th scope="row">Parm Os Theme</th>
177
+ <td>
178
+ <select name="parm_os_theme">
179
+ <?php
180
+ foreach ($themeNames as $themeName) {
181
+ if (($palmTheme == $themeName) || (($palmTheme == '') && ($themeName == $defaultTheme))) {
182
+ echo '<option value="' . $themeName . '" selected="selected">' . htmlspecialchars($themeName) . '</option>';
183
+ } else {
184
+ echo'<option value="' . $themeName . '">' . htmlspecialchars($themeName) . '</option>';
185
+ }
186
+ }
187
+ ?>
188
+ </select>
189
+ </td>
190
+ </tr>
191
+
192
+ <tr valign="top">
193
+ <th scope="row">Other Mobile Device Theme</th>
194
+ <td>
195
+ <select name="other_theme">
196
+ <?php
197
+ foreach ($themeNames as $themeName) {
198
+ if (($otherTheme == $themeName) || (($otherTheme == '') && ($themeName == $defaultTheme))) {
199
+ echo '<option value="' . $themeName . '" selected="selected">' . htmlspecialchars($themeName) . '</option>';
200
+ } else {
201
+ echo'<option value="' . $themeName . '">' . htmlspecialchars($themeName) . '</option>';
202
+ }
203
+ }
204
+ ?>
205
+ </select>
206
+ </td>
207
+ </tr>
208
+
209
+ </table>
210
+
211
+ <br/>
212
+ <h3>Other Settings (Optional)</h3>
213
+ <table class="form-table">
214
+ <tr valign="top">
215
+ <th scope="row">Switch Mobile Theme Link Text</th>
216
+ <td>
217
+ <input name="mobile_view_theme_link_text" style="width:300px;" value="<?php echo $mobileThemeText; ?>" type="text" />
218
+ </td>
219
+ </tr>
220
+
221
+ <tr valign="top">
222
+ <th scope="row">Switch Desktop Theme Link Text</th>
223
+ <td>
224
+ <input name="desktop_view_theme_link_text" style="width:300px;" value="<?php echo $desktopThemeText; ?>" type="text" />
225
+ </td>
226
+ </tr>
227
+
228
+ <tr valign="top">
229
+ <th scope="row">Do you want to show Switch Mobile Theme link even the vistor is viewing from desktop ?</th>
230
+ <td>
231
+ <input name="show_switch_link_for_desktop" type="radio" value="yes" <?php echo $desktopSwitchLink == 'yes'?'checked="checked"':''; ?> /> Yes &nbsp;&nbsp;&nbsp;
232
+ <input name="show_switch_link_for_desktop" type="radio" value="no" <?php echo $desktopSwitchLink == 'no'?'checked="checked"':''; ?> /> No <br/><span class="description">Normally, it is <b>NO</b>. It is usually useless to force the visitor to switch to mobile theme when s/he is in desktop.</span>
233
+ </td>
234
+ </tr>
235
+
236
+ </table>
237
+
238
+ <br/>
239
+ <h3>Read Me Please</h3>
240
+ <p>
241
+ Use the following shortcode <strong>[show_theme_switch_link]</strong> in templates to show the theme switch link.
242
+ <br/>Example: <strong>&lt;?php echo do_shortcode('[show_theme_switch_link]'); ?&gt;</strong>
243
+ <br/><br/>
244
+ You can also add Switch Mobile Theme link to your Menus from Custom Links section under Appearance > Menus.<br />
245
+ Example:<br />
246
+ Url : <strong>http://yoursitename.com/?am_force_theme_layout=desktop</strong> (For Mobile Theme)<br/>
247
+ Url : <strong>http://yoursitename.com/?am_force_theme_layout=mobile</strong> (For Desktop Theme)<br/>
248
+ Label : As you wish :)
249
+ </p>
250
+
251
+
252
+ <p class="submit">
253
+ <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
254
+ </p>
255
+
256
+ </form>
257
+ </div>
258
+ <?php } ?>
readme.txt ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Any Mobile Theme Switcher ===
2
+ Contributors: dnesscarkey
3
+ Tags: mobile theme, switcher, mobile-browser
4
+ Requires at least: 3.0.
5
+ Tested up to: 3.4.1
6
+ Stable tag: 0.5
7
+
8
+ This Plugin detects mobile browser and display the theme as the setting done from admin. Usefull for switch to Mobile Theme.
9
+
10
+ == Description ==
11
+
12
+ Detects all the Mobile Browsers and loads the mobile theme as per your settings done in admin.
13
+
14
+ * Iphone / Ipod
15
+ * Ipad
16
+ * Parm Os
17
+ * Android
18
+ * Windows Mobile
19
+ * Blackberry
20
+ * Opera Mini
21
+ * Others Mobile Browsers
22
+
23
+ You can select a different mobile theme for each mobile browser. You can select different mobile themes for each of the options above.
24
+
25
+ Needs Activation Key from Version 0.5.
26
+ Comes With 30 Days Trial Period.
27
+ Offer your price ($0 to $100) and get the license key from <a href="http://dineshkarki.com.np/license" target="_blank">here</a>
28
+
29
+ Please report any bugs @ http://dineshkarki.com.np/plugins/any-mobile-theme-switcher/report-bugs.
30
+
31
+ Thanks to <a href="http://wework4web.com" target="_blank">wework4web</a> for supporting plugin developement.
32
+
33
+ == Installation ==
34
+
35
+ 1. Upload the plugin any-mobile-theme-switcher files to the `/wp-content/plugins/` directory
36
+ 1. Activate the any-mobile-theme-switcher plugin through the 'Plugins' menu in WordPress.
37
+ 1. Select Themes For Mobile Browsers under under Settings > Any Mobile Theme
38
+
39
+ == Frequently Asked Questions ==
40
+
41
+ = Does it detect all browsers ? =
42
+
43
+ Yes it detect most of the mobile browsers and redirects it to its mobile theme set from admin settings.
44
+
45
+ == Screenshots ==
46
+
47
+ 1. Admin Setting For Mobile Theme selection repective to their platform.
48
+
49
+ == Changelog ==
50
+
51
+ = 0.5 =
52
+ * Requires License Key (Offer your price ($0 - $100) and get the license key from <a href="http://dineshkarki.com.np/license" target="_blank">here</a>)
53
+ * Added More Mobile User Agents
54
+ * 3.4 Tested
55
+
56
+ = 0.4 =
57
+ * Added Child Theme Support
58
+ * Error Fixes
59
+
60
+ = 0.3 =
61
+ * Added Support to get mobile theme / desktop theme switch link from shortcode.
62
+
63
+ = 0.2 =
64
+ * Fixed Links
65
+
66
+ = 0.1 =
67
+ * First Release
screenshot-1.png ADDED
Binary file