Posted by on the 17th of January, 2013 at 10:57 pm under 컴퓨터.  This post has no comments.

모바일 테마를 테마를 추가하면서 브라우저에 맞게 자동으로 테마를 바꿀 수 있도록 Any mobile theme switcher를 썼다. 그런데 이 플러그인이 다른건 다 좋은데 안드로이드 폰과 태블릿을 구분하지 않는다. 안드로이드면 무조건 설정한 테마를 보여준다.

안드로이드 폰과 태블릿을 구분할 수 있는지 찾아봤다. stackoverflow에서 원하는 결과를 찾았다. (link) 폰에는 태블릿과 달리 Mobile이라는 문자열이 들어간다. 단, 허니컴 이전 태블릿은 똑같이 Mobile이 들어간다. 그런데 뭐 허니컴 이전 태블릿은 태블릿이라 하기 뭐하니까 상관 없다.

Any mobile theme switcher에 android 문자열을 찾아서 tablet 관련 코드를 추가했다. 일단은 잘 동작한다. 수정사항을 제작자 게시판에 올맀는데 봤을려나? …


diff --git a/user/blog/wp-content/plugins/any-mobile-theme-switcher/any-mobile-theme-switcher.php b/user/blog/wp-content/plugins/any-mobile-theme-switcher/any-mobile-theme-switcher.php
index 5cde7ca..dd22df7 100644
--- a/user/blog/wp-content/plugins/any-mobile-theme-switcher/any-mobile-theme-switcher.php
+++ b/user/blog/wp-content/plugins/any-mobile-theme-switcher/any-mobile-theme-switcher.php
@@ -33,8 +33,16 @@ $accept           = $_SERVER['HTTP_ACCEPT']; // get the content accept value - t
break; // break out and skip the rest if we've had a match on the iphone or ipod

case (preg_match('/android/i',$user_agent));  // we find android in the user agent
-      $mobile_browser = get_option('android_theme'); // mobile browser is either true or false depending on the setting of android when calling the function
-      $status = 'Android';
+      if (preg_match('/mobile/i',$user_agent))
+      {
+        $mobile_browser = get_option('android_theme'); // mobile browser is either true or false depending on the setting of android when calling the function
+        $status = 'Android';
+      }
+      else
+      {
+        $mobile_browser = get_option('android_tablet_theme'); // mobile browser is either true or false depending on the setting of android when calling the function
+        $status = 'AndroidTablet';
+      }
break; // break out and skip the rest if we've had a match on android

case (preg_match('/opera mini/i',$user_agent)); // we find opera mini in the user agent
diff --git a/user/blog/wp-content/plugins/any-mobile-theme-switcher/plugin_interface.php b/user/blog/wp-content/plugins/any-mobile-theme-switcher/plugin_interface.php
index 1dbdd80..2a336fd 100644
--- a/user/blog/wp-content/plugins/any-mobile-theme-switcher/plugin_interface.php
+++ b/user/blog/wp-content/plugins/any-mobile-theme-switcher/plugin_interface.php
@@ -11,6 +11,7 @@ function register_mysettings_theme() {
register_setting('am-settings-group', 'iphone_theme');
register_setting('am-settings-group', 'ipad_theme');
register_setting('am-settings-group', 'android_theme');
+    register_setting('am-settings-group', 'android_tablet_theme');
register_setting('am-settings-group', 'blackberry_theme');
register_setting('am-settings-group', 'windows_theme');
register_setting('am-settings-group', 'opera_theme');
@@ -26,6 +27,7 @@ function am_settings_page() {
$iphoneTheme         = get_option('iphone_theme');
$ipadTheme            = get_option('ipad_theme');
$androidTheme        = get_option('android_theme');
+    $androidTabletTheme        = get_option('android_tablet_theme');
$blackberryTheme    = get_option('blackberry_theme');
$windowsTheme        = get_option('windows_theme');
$operaTheme            = get_option('opera_theme');
@@ -132,6 +134,24 @@ function am_settings_page() {
</tr>


+        <tr valign="top">
+        <th scope="row">Android Tablet Theme</th>
+        <td>
+            <select name="android_tablet_theme">
+     <?php
+      foreach ($themeNames as $themeName) {
+          if (($androidTabletTheme == $themeName) || (($androidTabletTheme == '') && ($themeName == $defaultTheme))) {
+              echo '<option value="' . $themeName . '" selected="selected">' . htmlspecialchars($themeName) . '</option>';
+          } else {
+              echo'<option value="' . $themeName . '">' . htmlspecialchars($themeName) . '</option>';
+          }
+      }
+     ?>
+            </select>
+        </td>
+        </tr>
+
+
<tr valign="top">
<th scope="row">Blackberry Theme</th>
<td>



* Required

The URI to TrackBack this entry is:
https://bmp.pe.kr/blog/index.php/2013/01/17/any-mobile-theme-switcher%ec%97%90-android-tablet-%ec%a7%80%ec%9b%90-%ec%b6%94%ea%b0%80/trackback/