Version Description
- Initial release.
Download this release
Release Info
Developer | thingsym |
Plugin | Multi Device Switcher |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- languages/multi-device-switcher-ja.mo +0 -0
- languages/multi-device-switcher-ja.po +54 -0
- languages/multi-device-switcher.pot +53 -0
- multi-device-switcher.css +5 -0
- multi-device-switcher.js +11 -0
- multi-device-switcher.php +517 -0
- readme.md +19 -0
- readme.txt +36 -0
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
languages/multi-device-switcher-ja.mo
ADDED
Binary file
|
languages/multi-device-switcher-ja.po
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
msgid ""
|
2 |
+
msgstr ""
|
3 |
+
"Project-Id-Version: Multi Device Switcher\n"
|
4 |
+
"Report-Msgid-Bugs-To: \n"
|
5 |
+
"POT-Creation-Date: 2012-01-17 22:01+0900\n"
|
6 |
+
"PO-Revision-Date: 2012-01-28 18:19+0900\n"
|
7 |
+
"Last-Translator: Yousuke Mizuno <thingsym@gmail.com>\n"
|
8 |
+
"Language-Team: \n"
|
9 |
+
"MIME-Version: 1.0\n"
|
10 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
+
"Content-Transfer-Encoding: 8bit\n"
|
12 |
+
|
13 |
+
msgid "Multi Device Switcher"
|
14 |
+
msgstr "マルチデバイス"
|
15 |
+
|
16 |
+
msgid "Theme"
|
17 |
+
msgstr "テーマ"
|
18 |
+
|
19 |
+
msgid "UserAgent"
|
20 |
+
msgstr "ユーザーエージェント"
|
21 |
+
|
22 |
+
msgid "Smart Phone Theme"
|
23 |
+
msgstr "スマートフォン用テーマ"
|
24 |
+
|
25 |
+
msgid "Tablet PC Theme"
|
26 |
+
msgstr "タブレット端末用テーマ"
|
27 |
+
|
28 |
+
msgid "Mobile Phone Theme"
|
29 |
+
msgstr "携帯モバイル端末用テーマ"
|
30 |
+
|
31 |
+
msgid "Game Platforms Theme"
|
32 |
+
msgstr "ゲームプラットフォーム用テーマ"
|
33 |
+
|
34 |
+
msgid "Smart Phone"
|
35 |
+
msgstr "スマートフォン"
|
36 |
+
|
37 |
+
msgid "Tablet PC"
|
38 |
+
msgstr "タブレット端末"
|
39 |
+
|
40 |
+
msgid "Mobile Phone"
|
41 |
+
msgstr "携帯モバイル端末"
|
42 |
+
|
43 |
+
msgid "Game Platforms"
|
44 |
+
msgstr "ゲームプラットフォーム"
|
45 |
+
|
46 |
+
msgid "Reset Settings to Default UserAgent"
|
47 |
+
msgstr "ユーザーエージェントをデフォルトにもどす"
|
48 |
+
|
49 |
+
msgid "Donationware"
|
50 |
+
msgstr "ドネーションウェア (寄付)"
|
51 |
+
|
52 |
+
msgid "If you like this plugin, please donate to support development and maintenance."
|
53 |
+
msgstr "よろしければ、開発とメンテナンスのために寄付していただければうれしいです。"
|
54 |
+
|
languages/multi-device-switcher.pot
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
msgid ""
|
2 |
+
msgstr ""
|
3 |
+
"Project-Id-Version: Multi Device Switcher\n"
|
4 |
+
"Report-Msgid-Bugs-To: \n"
|
5 |
+
"POT-Creation-Date: 2012-01-17 22:01+0900\n"
|
6 |
+
"PO-Revision-Date: 2012-01-17 19:19+0900\n"
|
7 |
+
"Last-Translator: \n"
|
8 |
+
"Language-Team: \n"
|
9 |
+
"MIME-Version: 1.0\n"
|
10 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
+
"Content-Transfer-Encoding: 8bit\n"
|
12 |
+
|
13 |
+
msgid "Multi Device Switcher"
|
14 |
+
msgstr ""
|
15 |
+
|
16 |
+
msgid "Theme"
|
17 |
+
msgstr ""
|
18 |
+
|
19 |
+
msgid "UserAgent"
|
20 |
+
msgstr ""
|
21 |
+
|
22 |
+
msgid "Smart Phone Theme"
|
23 |
+
msgstr ""
|
24 |
+
|
25 |
+
msgid "Tablet PC Theme"
|
26 |
+
msgstr ""
|
27 |
+
|
28 |
+
msgid "Mobile Phone Theme"
|
29 |
+
msgstr ""
|
30 |
+
|
31 |
+
msgid "Game Platforms Theme"
|
32 |
+
msgstr ""
|
33 |
+
|
34 |
+
msgid "Smart Phone"
|
35 |
+
msgstr ""
|
36 |
+
|
37 |
+
msgid "Tablet PC"
|
38 |
+
msgstr ""
|
39 |
+
|
40 |
+
msgid "Mobile Phone"
|
41 |
+
msgstr ""
|
42 |
+
|
43 |
+
msgid "Game Platforms"
|
44 |
+
msgstr ""
|
45 |
+
|
46 |
+
msgid "Reset Settings to Default UserAgent"
|
47 |
+
msgstr ""
|
48 |
+
|
49 |
+
msgid "Donationware"
|
50 |
+
msgstr ""
|
51 |
+
|
52 |
+
msgid "If you like this plugin, please donate to support development and maintenance."
|
53 |
+
msgstr ""
|
multi-device-switcher.css
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#admin-tabs ul.ui-tabs-nav {border-bottom:1px solid #dfdfdf; font-size:12px; height:29px; list-style-image:none; list-style-position:outside; list-style-type:none; margin:13px 0 0; overflow:visible; padding:0 0 0 8px;}
|
2 |
+
#admin-tabs ul.ui-tabs-nav li {display:block; float:left; line-height:200%; list-style-image:none; list-style-position:outside; list-style-type:none; margin:0; padding:0; position:relative; text-align:center; white-space:nowrap; width:auto;}
|
3 |
+
#admin-tabs ul.ui-tabs-nav li a {background:transparent none no-repeat scroll 0 50%; border-bottom:1px solid #dfdfdf; display:block; float:left; line-height:28px; padding:1px 13px 0; position:relative; text-decoration:none;}
|
4 |
+
#admin-tabs ul.ui-tabs-nav li.ui-tabs-selected a{-moz-border-radius-topleft:4px; -moz-border-radius-topright:4px;border:1px solid #dfdfdf; border-bottom-color:#fff; color:#333333; font-weight:normal; padding:0 12px;}
|
5 |
+
#admin-tabs ul.ui-tabs-nav a:focus, a:active {outline-color:-moz-use-text-color; outline-style:none; outline-width:medium;}
|
multi-device-switcher.js
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
jQuery(document).ready(function(){
|
2 |
+
if (! jQuery('#admin-tabs').length) return;
|
3 |
+
jQuery('#admin-tabs').prepend('<ul><\/ul>');
|
4 |
+
jQuery('#admin-tabs > fieldset').each(function (i) {
|
5 |
+
id = jQuery(this).attr('id');
|
6 |
+
caption = jQuery(this).find('h3.label').text();
|
7 |
+
jQuery('#admin-tabs > ul').append('<li><a href="#'+id+'"><span>'+caption+'<\/span><\/a><\/li>');
|
8 |
+
});
|
9 |
+
|
10 |
+
jQuery('#admin-tabs').tabs();
|
11 |
+
});
|
multi-device-switcher.php
ADDED
@@ -0,0 +1,517 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: Multi Device Switcher
|
4 |
+
Plugin URI: https://github.com/thingsym/multi-device-switcher
|
5 |
+
Description: This WordPress plugin allows you to set a separate theme for device (Smart Phone, Tablet PC, Mobile Phone, Game).
|
6 |
+
Version: 1.0.0
|
7 |
+
Author: Yousuke Mizuno
|
8 |
+
Author URI: http://www.thingslabo.com/
|
9 |
+
License: GPL2
|
10 |
+
*/
|
11 |
+
|
12 |
+
/*
|
13 |
+
Copyright 2012 thingsym (http://www.thingslabo.com/)
|
14 |
+
|
15 |
+
This program is free software; you can redistribute it and/or modify
|
16 |
+
it under the terms of the GNU General Public License as published by
|
17 |
+
the Free Software Foundation; either version 2 of the License, or
|
18 |
+
(at your option) any later version.
|
19 |
+
|
20 |
+
This program is distributed in the hope that it will be useful,
|
21 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
22 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
23 |
+
GNU General Public License for more details.
|
24 |
+
|
25 |
+
You should have received a copy of the GNU General Public License
|
26 |
+
along with this program; if not, write to the Free Software
|
27 |
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
|
28 |
+
*/
|
29 |
+
|
30 |
+
class Multi_Device_Switcher {
|
31 |
+
|
32 |
+
function Multi_Device_Switcher() {
|
33 |
+
|
34 |
+
$userAgent = $this->get_options_userAgent();
|
35 |
+
|
36 |
+
if ( $userAgent['smart'] && preg_match( '/' . implode( '|', $userAgent['smart'] ) . '/i', $_SERVER['HTTP_USER_AGENT']) ) {
|
37 |
+
$this->device = 'smart';
|
38 |
+
}
|
39 |
+
elseif ( $userAgent['tablet'] && preg_match( '/' . implode( '|', $userAgent['tablet'] ) . '/i', $_SERVER['HTTP_USER_AGENT']) ) {
|
40 |
+
$this->device = 'tablet';
|
41 |
+
}
|
42 |
+
elseif ( $userAgent['mobile'] && preg_match( '/' . implode( '|', $userAgent['mobile'] ) . '/i', $_SERVER['HTTP_USER_AGENT']) ) {
|
43 |
+
$this->device = 'mobile';
|
44 |
+
}
|
45 |
+
elseif ( $userAgent['game'] && preg_match( '/' . implode( '|', $userAgent['game'] ) . '/i', $_SERVER['HTTP_USER_AGENT']) ) {
|
46 |
+
$this->device = 'game';
|
47 |
+
}
|
48 |
+
else {
|
49 |
+
$this->device = '';
|
50 |
+
}
|
51 |
+
|
52 |
+
if ($this->device) {
|
53 |
+
add_filter('stylesheet', array(&$this, 'get_stylesheet'));
|
54 |
+
add_filter('template', array(&$this, 'get_template'));
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
function get_options_userAgent() {
|
59 |
+
$options = get_option('multi_device_switcher_options');
|
60 |
+
$default_options = multi_device_switcher_get_default_options();
|
61 |
+
|
62 |
+
if ( ! isset( $options['userAgent_smart'] ) )
|
63 |
+
$options['userAgent_smart'] = $default_options['userAgent_smart'];
|
64 |
+
if ( ! isset( $options['userAgent_tablet'] ) )
|
65 |
+
$options['userAgent_tablet'] = $default_options['userAgent_tablet'];
|
66 |
+
if ( ! isset( $options['userAgent_mobile'] ) )
|
67 |
+
$options['userAgent_mobile'] = $default_options['userAgent_mobile'];
|
68 |
+
if ( ! isset( $options['userAgent_game'] ) )
|
69 |
+
$options['userAgent_game'] = $default_options['userAgent_game'];
|
70 |
+
|
71 |
+
if ( $options['userAgent_smart'] )
|
72 |
+
$userAgent['smart'] = preg_split( "/,\s*/", $options['userAgent_smart'] );
|
73 |
+
if ( $options['userAgent_tablet'] )
|
74 |
+
$userAgent['tablet'] = preg_split( "/,\s*/", $options['userAgent_tablet'] );
|
75 |
+
if ( $options['userAgent_mobile'] )
|
76 |
+
$userAgent['mobile'] = preg_split( "/,\s*/", $options['userAgent_mobile'] );
|
77 |
+
if ( $options['userAgent_game'] )
|
78 |
+
$userAgent['game'] = preg_split( "/,\s*/", $options['userAgent_game'] );
|
79 |
+
|
80 |
+
return $userAgent;
|
81 |
+
}
|
82 |
+
|
83 |
+
function get_stylesheet($stylesheet = '') {
|
84 |
+
$name = $this->get_device_theme();
|
85 |
+
|
86 |
+
if ( empty($name) )
|
87 |
+
return $stylesheet;
|
88 |
+
|
89 |
+
$theme = get_theme($name);
|
90 |
+
|
91 |
+
if ( empty($theme) )
|
92 |
+
return $stylesheet;
|
93 |
+
|
94 |
+
if ( isset($theme['Status']) && $theme['Status'] != 'publish' )
|
95 |
+
return $stylesheet;
|
96 |
+
|
97 |
+
return $theme['Stylesheet'];
|
98 |
+
}
|
99 |
+
|
100 |
+
function get_template($template = '') {
|
101 |
+
$name = $this->get_device_theme();
|
102 |
+
|
103 |
+
if ( empty($name) )
|
104 |
+
return $template;
|
105 |
+
|
106 |
+
$theme = get_theme($name);
|
107 |
+
|
108 |
+
if ( empty( $theme ) )
|
109 |
+
return $template;
|
110 |
+
|
111 |
+
if ( isset($theme['Status']) && $theme['Status'] != 'publish' )
|
112 |
+
return $template;
|
113 |
+
|
114 |
+
return $theme['Template'];
|
115 |
+
}
|
116 |
+
|
117 |
+
function get_device_theme() {
|
118 |
+
$options = get_option('multi_device_switcher_options');
|
119 |
+
|
120 |
+
if ($this->device == 'smart') {
|
121 |
+
return $options['theme_smartphone'];
|
122 |
+
}
|
123 |
+
elseif ($this->device == 'tablet') {
|
124 |
+
return $options['theme_tablet'];
|
125 |
+
}
|
126 |
+
elseif ($this->device == 'mobile') {
|
127 |
+
return $options['theme_mobile'];
|
128 |
+
}
|
129 |
+
elseif ($this->device == 'game') {
|
130 |
+
return $options['theme_game'];
|
131 |
+
}
|
132 |
+
|
133 |
+
return;
|
134 |
+
}
|
135 |
+
}
|
136 |
+
|
137 |
+
$multi_device_switcher = new Multi_Device_Switcher;
|
138 |
+
|
139 |
+
/**
|
140 |
+
* Register the form setting for our multi_device_switcher array.
|
141 |
+
*
|
142 |
+
* This function is attached to the admin_init action hook.
|
143 |
+
*
|
144 |
+
* This call to register_setting() registers a validation callback, multi_device_switcher_validate(),
|
145 |
+
* which is used when the option is saved, to ensure that our option values are complete, properly
|
146 |
+
* formatted, and safe.
|
147 |
+
*
|
148 |
+
* @since 1.0
|
149 |
+
*/
|
150 |
+
function multi_device_switcher_init() {
|
151 |
+
// If we have no options in the database, let's add them now.
|
152 |
+
if ( false === multi_device_switcher_get_options() )
|
153 |
+
add_option( 'multi_device_switcher_options' );
|
154 |
+
|
155 |
+
load_plugin_textdomain('multi-device-switcher', false, 'multi-device-switcher/languages');
|
156 |
+
|
157 |
+
wp_enqueue_style( 'multi-device-switcher-options', WP_PLUGIN_URL . '/multi-device-switcher/multi-device-switcher.css', false, '2011-08-22' );
|
158 |
+
wp_enqueue_style( 'thickbox', includes_url() . '/js/thickbox/thickbox.css', false, '20090514' );
|
159 |
+
wp_enqueue_script('jquery-ui-tabs');
|
160 |
+
wp_enqueue_script( 'multi-device-switcher-options', WP_PLUGIN_URL . '/multi-device-switcher/multi-device-switcher.js', array( 'jquery' ), '2011-08-22' );
|
161 |
+
|
162 |
+
register_setting(
|
163 |
+
'multi_device_switcher', // Options group, see settings_fields() call in multi_device_switcher_render_page()
|
164 |
+
'multi_device_switcher_options', // Database option, see multi_device_switcher_get_options()
|
165 |
+
'multi_device_switcher_validate' // The sanitization callback, see multi_device_switcher_validate()
|
166 |
+
);
|
167 |
+
}
|
168 |
+
|
169 |
+
add_action( 'admin_init', 'multi_device_switcher_init' );
|
170 |
+
|
171 |
+
/**
|
172 |
+
* Change the capability required to save the 'multi_device_switcher' options group.
|
173 |
+
*
|
174 |
+
* @see multi_device_switcher_init() First parameter to register_setting() is the name of the options group.
|
175 |
+
* @see multi_device_switcher_add_page() The edit_theme_options capability is used for viewing the page.
|
176 |
+
*
|
177 |
+
* By default, the options groups for all registered settings require the manage_options capability.
|
178 |
+
* By default, only administrators have either of these capabilities, but the desire here is
|
179 |
+
* to allow for finer-grained control for roles and users.
|
180 |
+
*
|
181 |
+
* @param string $capability The capability used for the page, which is manage_options by default.
|
182 |
+
* @return string The capability to actually use.
|
183 |
+
*/
|
184 |
+
function multi_device_switcher_page_capability( $capability ) {
|
185 |
+
return 'edit_theme_options';
|
186 |
+
}
|
187 |
+
add_filter( 'option_page_capability_multi_device_switcher', 'multi_device_switcher_page_capability' );
|
188 |
+
|
189 |
+
/**
|
190 |
+
* Add our options page to the admin menu, including some help documentation.
|
191 |
+
*
|
192 |
+
* This function is attached to the admin_menu action hook.
|
193 |
+
*
|
194 |
+
* @since 1.0
|
195 |
+
*/
|
196 |
+
function multi_device_switcher_add_page() {
|
197 |
+
load_plugin_textdomain('multi-device-switcher', false, 'multi-device-switcher/languages');
|
198 |
+
|
199 |
+
$theme_page = add_theme_page(
|
200 |
+
__( 'Multi Device Switcher', 'multi-device-switcher' ), // Name of page
|
201 |
+
__( 'Multi Device Switcher', 'multi-device-switcher' ), // Label in menu
|
202 |
+
'manage_options', // Capability required
|
203 |
+
'multi-device-switcher', // Menu slug, used to uniquely identify the page
|
204 |
+
'multi_device_switcher_render_page' // Function that renders the options page
|
205 |
+
);
|
206 |
+
|
207 |
+
if ( ! $theme_page )
|
208 |
+
return;
|
209 |
+
|
210 |
+
$help = '';
|
211 |
+
|
212 |
+
if ($help)
|
213 |
+
add_contextual_help( $theme_page, $help );
|
214 |
+
}
|
215 |
+
add_action( 'admin_menu', 'multi_device_switcher_add_page' );
|
216 |
+
|
217 |
+
/**
|
218 |
+
* Returns the default options.
|
219 |
+
*
|
220 |
+
* @since 1.0
|
221 |
+
*/
|
222 |
+
function multi_device_switcher_get_default_options() {
|
223 |
+
$default_theme_options = array(
|
224 |
+
'theme_smartphone' => 'None',
|
225 |
+
'theme_tablet' => 'None',
|
226 |
+
'theme_mobile' => 'None',
|
227 |
+
'theme_game' => 'None',
|
228 |
+
'userAgent_smart' => 'iPhone, iPod, Android, dream, CUPCAKE, Windows Phone, webOS, BlackBerry8707, BlackBerry9000, BlackBerry9300, BlackBerry9500, BlackBerry9530, BlackBerry9520, BlackBerry9550, BlackBerry9700, BlackBerry9800',
|
229 |
+
'userAgent_tablet' => 'iPad',
|
230 |
+
'userAgent_mobile' => 'DoCoMo, SoftBank, J-PHONE, Vodafone, KDDI, UP.Browser, WILLCOM, emobile, DDIPOCKET, Windows CE, BlackBerry, Symbian, PalmOS, Huawei, IAC, Nokia',
|
231 |
+
'userAgent_game' => 'PlayStation Portable, PlayStation Vita, PSP, PS2, PLAYSTATION 3, Nitro, Nintendo 3DS, Nintendo Wii',
|
232 |
+
);
|
233 |
+
|
234 |
+
return $default_theme_options;
|
235 |
+
}
|
236 |
+
|
237 |
+
/**
|
238 |
+
* Returns the options array.
|
239 |
+
*
|
240 |
+
* @since 1.0
|
241 |
+
*/
|
242 |
+
function multi_device_switcher_get_options() {
|
243 |
+
$options = get_option( 'multi_device_switcher_options' );
|
244 |
+
$default_options = multi_device_switcher_get_default_options();
|
245 |
+
|
246 |
+
if ( ! isset( $options['theme_smartphone'] ) )
|
247 |
+
$options['theme_smartphone'] = $default_options['theme_smartphone'];
|
248 |
+
if ( ! isset( $options['theme_tablet'] ) )
|
249 |
+
$options['theme_tablet'] = $default_options['theme_tablet'];
|
250 |
+
if ( ! isset( $options['theme_mobile'] ) )
|
251 |
+
$options['theme_mobile'] = $default_options['theme_mobile'];
|
252 |
+
if ( ! isset( $options['theme_game'] ) )
|
253 |
+
$options['theme_game'] = $default_options['theme_game'];
|
254 |
+
|
255 |
+
if ( ! isset( $options['userAgent_smart'] ) )
|
256 |
+
$options['userAgent_smart'] = $default_options['userAgent_smart'];
|
257 |
+
if ( ! isset( $options['userAgent_tablet'] ) )
|
258 |
+
$options['userAgent_tablet'] = $default_options['userAgent_tablet'];
|
259 |
+
if ( ! isset( $options['userAgent_mobile'] ) )
|
260 |
+
$options['userAgent_mobile'] = $default_options['userAgent_mobile'];
|
261 |
+
if ( ! isset( $options['userAgent_game'] ) )
|
262 |
+
$options['userAgent_game'] = $default_options['userAgent_game'];
|
263 |
+
|
264 |
+
return $options;
|
265 |
+
}
|
266 |
+
|
267 |
+
/**
|
268 |
+
* Rendering Options Setting Page.
|
269 |
+
*
|
270 |
+
* @since 1.0
|
271 |
+
*/
|
272 |
+
function multi_device_switcher_render_page() {
|
273 |
+
?>
|
274 |
+
<div class="wrap" style="width: 60%; float: left;">
|
275 |
+
<div id="icon-themes" class="icon32"><br></div>
|
276 |
+
<h2><?php printf( __( 'Multi Device Switcher', 'multi-device-switcher' ), get_current_theme() ); ?></h2>
|
277 |
+
<?php settings_errors(); ?>
|
278 |
+
|
279 |
+
<form method="post" action="options.php">
|
280 |
+
<?php
|
281 |
+
settings_fields( 'multi_device_switcher' );
|
282 |
+
$options = multi_device_switcher_get_options();
|
283 |
+
?>
|
284 |
+
|
285 |
+
<div id="admin-tabs">
|
286 |
+
<fieldset id="Theme" class="options">
|
287 |
+
<h3 class="label"><?php _e( 'Theme', 'multi-device-switcher' ); ?></h3>
|
288 |
+
<table class="form-table">
|
289 |
+
<tr><th scope="row"><?php _e( 'Smart Phone Theme', 'multi-device-switcher' ); ?></th>
|
290 |
+
<td>
|
291 |
+
|
292 |
+
<?php
|
293 |
+
$themes = get_themes();
|
294 |
+
$default_theme = get_current_theme();
|
295 |
+
|
296 |
+
if (count($themes) > 1) {
|
297 |
+
$theme_names = array_keys($themes);
|
298 |
+
natcasesort($theme_names);
|
299 |
+
$html = '<select name="multi_device_switcher_options[theme_smartphone]">';
|
300 |
+
|
301 |
+
if (($options['theme_smartphone'] == 'None') || ($options['theme_smartphone'] == '')) {
|
302 |
+
$html .= '<option value="None" selected="selected">None</option>';
|
303 |
+
}
|
304 |
+
else {
|
305 |
+
$html .= '<option value="None">None</option>';
|
306 |
+
}
|
307 |
+
|
308 |
+
foreach ($theme_names as $theme_name) {
|
309 |
+
if ($options['theme_smartphone'] == $theme_name) {
|
310 |
+
$html .= '<option value="' . $theme_name . '" selected="selected">' . htmlspecialchars($theme_name) . '</option>';
|
311 |
+
}
|
312 |
+
else {
|
313 |
+
$html .= '<option value="' . $theme_name . '">' . htmlspecialchars($theme_name) . '</option>';
|
314 |
+
}
|
315 |
+
}
|
316 |
+
$html .= '</select>';
|
317 |
+
}
|
318 |
+
echo $html;
|
319 |
+
?>
|
320 |
+
</td>
|
321 |
+
</tr>
|
322 |
+
<tr><th scope="row"><?php _e( 'Tablet PC Theme', 'multi-device-switcher' ); ?></th>
|
323 |
+
<td>
|
324 |
+
|
325 |
+
<?php
|
326 |
+
$themes = get_themes();
|
327 |
+
$default_theme = get_current_theme();
|
328 |
+
|
329 |
+
if (count($themes) > 1) {
|
330 |
+
$theme_names = array_keys($themes);
|
331 |
+
natcasesort($theme_names);
|
332 |
+
$html = '<select name="multi_device_switcher_options[theme_tablet]">';
|
333 |
+
|
334 |
+
if (($options['theme_tablet'] == 'None') || ($options['theme_tablet'] == '')) {
|
335 |
+
$html .= '<option value="None" selected="selected">None</option>';
|
336 |
+
}
|
337 |
+
else {
|
338 |
+
$html .= '<option value="None">None</option>';
|
339 |
+
}
|
340 |
+
|
341 |
+
foreach ($theme_names as $theme_name) {
|
342 |
+
if ($options['theme_tablet'] == $theme_name) {
|
343 |
+
$html .= '<option value="' . $theme_name . '" selected="selected">' . htmlspecialchars($theme_name) . '</option>';
|
344 |
+
}
|
345 |
+
else {
|
346 |
+
$html .= '<option value="' . $theme_name . '">' . htmlspecialchars($theme_name) . '</option>';
|
347 |
+
}
|
348 |
+
}
|
349 |
+
$html .= '</select>';
|
350 |
+
}
|
351 |
+
echo $html;
|
352 |
+
?>
|
353 |
+
</td>
|
354 |
+
</tr>
|
355 |
+
<tr><th scope="row"><?php _e( 'Mobile Phone Theme', 'multi-device-switcher' ); ?></th>
|
356 |
+
<td>
|
357 |
+
|
358 |
+
<?php
|
359 |
+
$themes = get_themes();
|
360 |
+
$default_theme = get_current_theme();
|
361 |
+
|
362 |
+
if (count($themes) > 1) {
|
363 |
+
$theme_names = array_keys($themes);
|
364 |
+
natcasesort($theme_names);
|
365 |
+
$html = '<select name="multi_device_switcher_options[theme_mobile]">';
|
366 |
+
|
367 |
+
if (($options['theme_mobile'] == 'None') || ($options['theme_mobile'] == '')) {
|
368 |
+
$html .= '<option value="None" selected="selected">None</option>';
|
369 |
+
}
|
370 |
+
else {
|
371 |
+
$html .= '<option value="None">None</option>';
|
372 |
+
}
|
373 |
+
|
374 |
+
foreach ($theme_names as $theme_name) {
|
375 |
+
if ($options['theme_mobile'] == $theme_name) {
|
376 |
+
$html .= '<option value="' . $theme_name . '" selected="selected">' . htmlspecialchars($theme_name) . '</option>';
|
377 |
+
}
|
378 |
+
else {
|
379 |
+
$html .= '<option value="' . $theme_name . '">' . htmlspecialchars($theme_name) . '</option>';
|
380 |
+
}
|
381 |
+
}
|
382 |
+
$html .= '</select>';
|
383 |
+
}
|
384 |
+
echo $html;
|
385 |
+
?>
|
386 |
+
</td>
|
387 |
+
</tr>
|
388 |
+
<tr><th scope="row"><?php _e( 'Game Platforms Theme', 'multi-device-switcher' ); ?></th>
|
389 |
+
<td>
|
390 |
+
|
391 |
+
<?php
|
392 |
+
$themes = get_themes();
|
393 |
+
$default_theme = get_current_theme();
|
394 |
+
|
395 |
+
if (count($themes) > 1) {
|
396 |
+
$theme_names = array_keys($themes);
|
397 |
+
natcasesort($theme_names);
|
398 |
+
$html = '<select name="multi_device_switcher_options[theme_game]">';
|
399 |
+
|
400 |
+
if (($options['theme_game'] == 'None') || ($options['theme_game'] == '')) {
|
401 |
+
$html .= '<option value="None" selected="selected">None</option>';
|
402 |
+
}
|
403 |
+
else {
|
404 |
+
$html .= '<option value="None">None</option>';
|
405 |
+
}
|
406 |
+
|
407 |
+
foreach ($theme_names as $theme_name) {
|
408 |
+
if ($options['theme_game'] == $theme_name) {
|
409 |
+
$html .= '<option value="' . $theme_name . '" selected="selected">' . htmlspecialchars($theme_name) . '</option>';
|
410 |
+
}
|
411 |
+
else {
|
412 |
+
$html .= '<option value="' . $theme_name . '">' . htmlspecialchars($theme_name) . '</option>';
|
413 |
+
}
|
414 |
+
}
|
415 |
+
$html .= '</select>';
|
416 |
+
}
|
417 |
+
echo $html;
|
418 |
+
?>
|
419 |
+
</td>
|
420 |
+
</tr>
|
421 |
+
</table>
|
422 |
+
</fieldset>
|
423 |
+
|
424 |
+
<fieldset id="UserAgent" class="options">
|
425 |
+
<h3 class="label"><?php _e( 'UserAgent', 'multi-device-switcher' ); ?></h3>
|
426 |
+
<table class="form-table">
|
427 |
+
<tr><th scope="row"><?php _e( 'Smart Phone', 'multi-device-switcher' ); ?></th>
|
428 |
+
<td><textarea name="multi_device_switcher_options[userAgent_smart]" rows="4" cols="42"><?php echo $options['userAgent_smart']; ?></textarea></td>
|
429 |
+
</tr>
|
430 |
+
<tr><th scope="row"><?php _e( 'Tablet PC', 'multi-device-switcher' ); ?></th>
|
431 |
+
<td><textarea name="multi_device_switcher_options[userAgent_tablet]" rows="4" cols="42"><?php echo $options['userAgent_tablet']; ?></textarea></td>
|
432 |
+
</tr>
|
433 |
+
<tr><th scope="row"><?php _e( 'Mobile Phone', 'multi-device-switcher' ); ?></th>
|
434 |
+
<td><textarea name="multi_device_switcher_options[userAgent_mobile]" rows="4" cols="42"><?php echo $options['userAgent_mobile']; ?></textarea></td>
|
435 |
+
</tr>
|
436 |
+
<tr><th scope="row"><?php _e( 'Game Platforms', 'multi-device-switcher' ); ?></th>
|
437 |
+
<td><textarea name="multi_device_switcher_options[userAgent_game]" rows="4" cols="42"><?php echo $options['userAgent_game']; ?></textarea></td>
|
438 |
+
</tr>
|
439 |
+
<tr><th></th>
|
440 |
+
<td><input type="submit" name="multi_device_switcher_options[restore_UserAgent]" value="<?php _e( 'Reset Settings to Default UserAgent', 'multi-device-switcher' ); ?>"></td>
|
441 |
+
</tr>
|
442 |
+
</table>
|
443 |
+
</fieldset>
|
444 |
+
</div>
|
445 |
+
<?php submit_button(); ?>
|
446 |
+
</form>
|
447 |
+
</div>
|
448 |
+
|
449 |
+
<div id="donate" style="width: 36%; float: left; margin: 2em 0;padding: 0.4em;border: 1px solid #ddd;">
|
450 |
+
<h2><?php _e( 'Donationware', 'multi-device-switcher' ); ?></h2>
|
451 |
+
<p><?php _e( 'If you like this plugin, please donate to support development and maintenance.', 'multi-device-switcher' ); ?></p>
|
452 |
+
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
|
453 |
+
<input type="hidden" name="cmd" value="_s-xclick">
|
454 |
+
<input type="hidden" name="hosted_button_id" value="9L53NELFMHTWW">
|
455 |
+
<table>
|
456 |
+
<tr><td><input type="hidden" name="on0" value="Donationware">Donationware</td></tr><tr><td><select name="os0">
|
457 |
+
<option value="1. Donate">1. Donate $3.00 USD</option>
|
458 |
+
<option value="2. Donate">2. Donate $5.00 USD</option>
|
459 |
+
<option value="3. Donate">3. Donate $7.00 USD</option>
|
460 |
+
<option value="4. Donate" selected="selected">4. Donate $10.00 USD</option>
|
461 |
+
<option value="5. Donate">5. Donate $20.00 USD</option>
|
462 |
+
<option value="6. Donate">6. Donate $30.00 USD</option>
|
463 |
+
<option value="7. Donate">7. Donate $40.00 USD</option>
|
464 |
+
<option value="8. Donate">8. Donate $50.00 USD</option>
|
465 |
+
<option value="9. Donate">9. Donate $60.00 USD</option>
|
466 |
+
<option value="10. Donate">10. Donate $70.00 USD</option>
|
467 |
+
</select> </td></tr>
|
468 |
+
</table>
|
469 |
+
<input type="hidden" name="currency_code" value="USD">
|
470 |
+
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
|
471 |
+
<img alt="" border="0" src="https://www.paypalobjects.com/ja_JP/i/scr/pixel.gif" width="1" height="1">
|
472 |
+
</form>
|
473 |
+
</div>
|
474 |
+
|
475 |
+
<?php
|
476 |
+
}
|
477 |
+
|
478 |
+
/**
|
479 |
+
* Sanitize and validate form input. Accepts an array, return a sanitized array.
|
480 |
+
*
|
481 |
+
* @see multi_device_switcher_init()
|
482 |
+
*
|
483 |
+
* @since 1.0
|
484 |
+
*/
|
485 |
+
function multi_device_switcher_validate( $input ) {
|
486 |
+
$output = $default_options = multi_device_switcher_get_default_options();
|
487 |
+
|
488 |
+
if ( isset( $input['theme_smartphone'] ) )
|
489 |
+
$output['theme_smartphone'] = $input['theme_smartphone'];
|
490 |
+
if ( isset( $input['theme_tablet'] ) )
|
491 |
+
$output['theme_tablet'] = $input['theme_tablet'];
|
492 |
+
if ( isset( $input['theme_mobile'] ) )
|
493 |
+
$output['theme_mobile'] = $input['theme_mobile'];
|
494 |
+
if ( isset( $input['theme_game'] ) )
|
495 |
+
$output['theme_game'] = $input['theme_game'];
|
496 |
+
|
497 |
+
if (isset( $input['restore_UserAgent'] )) {
|
498 |
+
$output['userAgent_smart'] = $default_options['userAgent_smart'];
|
499 |
+
$output['userAgent_tablet'] = $default_options['userAgent_tablet'];
|
500 |
+
$output['userAgent_mobile'] = $default_options['userAgent_mobile'];
|
501 |
+
$output['userAgent_game'] = $default_options['userAgent_game'];
|
502 |
+
}
|
503 |
+
else {
|
504 |
+
if ( isset( $input['userAgent_smart'] ) )
|
505 |
+
$output['userAgent_smart'] = $input['userAgent_smart'];
|
506 |
+
if ( isset( $input['userAgent_tablet'] ) )
|
507 |
+
$output['userAgent_tablet'] = $input['userAgent_tablet'];
|
508 |
+
if ( isset( $input['userAgent_mobile'] ) )
|
509 |
+
$output['userAgent_mobile'] = $input['userAgent_mobile'];
|
510 |
+
if ( isset( $input['userAgent_game'] ) )
|
511 |
+
$output['userAgent_game'] = $input['userAgent_game'];
|
512 |
+
}
|
513 |
+
|
514 |
+
return apply_filters( 'multi_device_switcher_validate', $output, $input, $default_options );
|
515 |
+
}
|
516 |
+
|
517 |
+
?>
|
readme.md
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Introducing Multi Device Switcher
|
2 |
+
|
3 |
+
This WordPress plugin allows you to set a separate theme for device (Smart Phone, Tablet PC, Mobile Phone, Game).
|
4 |
+
This plugin detects if your site is being viewed by UserAgent and switches to selected theme.
|
5 |
+
|
6 |
+
## How do I use it?
|
7 |
+
|
8 |
+
1. Unzip files.
|
9 |
+
2. Upload "multi-device-switcher" to the "/wp-content/plugins/" directory.
|
10 |
+
3. Activate the plugin through the 'Plugins' menu in WordPress
|
11 |
+
4. Upload a separate theme to the "/wp-content/themes/" directory.
|
12 |
+
5. Go to the "Multi Device Switcher" options page through the 'Appearance' menu in WordPress.
|
13 |
+
6. Configure settings to your needs. Select Theme by Theme option. Add and fix UserAgent by UserAgent option if necessary.
|
14 |
+
7. Have fun!
|
15 |
+
|
16 |
+
## Changelog
|
17 |
+
|
18 |
+
* Version 1.0.0
|
19 |
+
* Initial release.
|
readme.txt
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Multi Device Switcher ===
|
2 |
+
|
3 |
+
Contributors: Yousuke Mizuno
|
4 |
+
Donate link: http://blog.thingslabo.com/archives/000251.html
|
5 |
+
Link: https://github.com/thingsym/multi-device-switcher
|
6 |
+
Tags: switcher, theme, ipad, iphone, android, tablet, mobile, game
|
7 |
+
Requires at least: 3.2.1
|
8 |
+
Tested up to: 3.3.1
|
9 |
+
Stable tag: 1.0.0
|
10 |
+
|
11 |
+
This WordPress plugin allows you to set a separate theme for device (Smart Phone, Tablet PC, Mobile Phone, Game).
|
12 |
+
|
13 |
+
== Description ==
|
14 |
+
|
15 |
+
This WordPress plugin allows you to set a separate theme for device (Smart Phone, Tablet PC, Mobile Phone, Game).
|
16 |
+
This plugin detects if your site is being viewed by UserAgent and switches to selected theme.
|
17 |
+
|
18 |
+
== Screenshots ==
|
19 |
+
|
20 |
+
1. Theme option
|
21 |
+
2. UserAgent option
|
22 |
+
|
23 |
+
== Installation ==
|
24 |
+
|
25 |
+
1. Unzip files.
|
26 |
+
2. Upload "multi-device-switcher" to the "/wp-content/plugins/" directory.
|
27 |
+
3. Activate the plugin through the 'Plugins' menu in WordPress
|
28 |
+
4. Upload a separate theme to the "/wp-content/themes/" directory.
|
29 |
+
5. Go to the "Multi Device Switcher" options page through the 'Appearance' menu in WordPress.
|
30 |
+
6. Configure settings to your needs. Select Theme by Theme option. Add and fix UserAgent by UserAgent option if necessary.
|
31 |
+
7. Have fun!
|
32 |
+
|
33 |
+
== Changelog ==
|
34 |
+
|
35 |
+
= 1.0.0 =
|
36 |
+
* Initial release.
|
screenshot-1.png
ADDED
Binary file
|
screenshot-2.png
ADDED
Binary file
|