Version Description
- fixed: change the order of the UserAgent detection
- updated: update default UserAgent
- added: add HTTP/1.1 Vary header
Download this release
Release Info
Developer | thingsym |
Plugin | Multi Device Switcher |
Version | 1.1.1 |
Comparing to | |
See all releases |
Code changes from version 1.1.0 to 1.1.1
- multi-device-switcher.php +38 -23
- readme.md +6 -2
- readme.txt +8 -4
multi-device-switcher.php
CHANGED
@@ -3,7 +3,7 @@
|
|
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 and custom).
|
6 |
-
Version: 1.1.
|
7 |
Author: thingsym
|
8 |
Author URI: http://www.thingslabo.com/
|
9 |
License: GPL2
|
@@ -34,26 +34,27 @@ class Multi_Device_Switcher {
|
|
34 |
$userAgent = $this->get_options_userAgent();
|
35 |
$this->device = '';
|
36 |
|
37 |
-
|
38 |
-
$
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
$this->device = 'mobile';
|
45 |
-
}
|
46 |
-
elseif ( $userAgent['game'] && preg_match( '/' . implode( '|', $userAgent['game'] ) . '/i', $_SERVER['HTTP_USER_AGENT']) ) {
|
47 |
-
$this->device = 'game';
|
48 |
}
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
|
|
|
|
|
|
|
|
|
|
57 |
}
|
58 |
}
|
59 |
|
@@ -179,6 +180,20 @@ class Multi_Device_Switcher {
|
|
179 |
if ( ! is_admin() )
|
180 |
$multi_device_switcher = new Multi_Device_Switcher();
|
181 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
182 |
/**
|
183 |
* Properly enqueue scripts for our multi_device_switcher options page.
|
184 |
*
|
@@ -290,10 +305,10 @@ function multi_device_switcher_get_default_options() {
|
|
290 |
'theme_tablet' => 'None',
|
291 |
'theme_mobile' => 'None',
|
292 |
'theme_game' => 'None',
|
293 |
-
'userAgent_smart' => 'iPhone, iPod, Android, dream, CUPCAKE, Windows Phone, webOS, BlackBerry8707, BlackBerry9000, BlackBerry9300, BlackBerry9500, BlackBerry9530, BlackBerry9520, BlackBerry9550, BlackBerry9700,
|
294 |
-
'userAgent_tablet' => 'iPad',
|
295 |
'userAgent_mobile' => 'DoCoMo, SoftBank, J-PHONE, Vodafone, KDDI, UP.Browser, WILLCOM, emobile, DDIPOCKET, Windows CE, BlackBerry, Symbian, PalmOS, Huawei, IAC, Nokia',
|
296 |
-
'userAgent_game' => 'PlayStation Portable, PlayStation Vita, PSP, PS2, PLAYSTATION 3, Nitro, Nintendo 3DS, Nintendo Wii',
|
297 |
);
|
298 |
|
299 |
return $default_theme_options;
|
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 and custom).
|
6 |
+
Version: 1.1.1
|
7 |
Author: thingsym
|
8 |
Author URI: http://www.thingslabo.com/
|
9 |
License: GPL2
|
34 |
$userAgent = $this->get_options_userAgent();
|
35 |
$this->device = '';
|
36 |
|
37 |
+
foreach ( array_reverse($userAgent) as $key => $val ) {
|
38 |
+
if ( ! preg_match( "/^custom_switcher_/", $key ) )
|
39 |
+
continue;
|
40 |
+
if ($userAgent[$key] && preg_match( '/' . implode( '|', $userAgent[$key] ) . '/i', $_SERVER['HTTP_USER_AGENT']) ) {
|
41 |
+
$this->device = $key;
|
42 |
+
break;
|
43 |
+
}
|
|
|
|
|
|
|
|
|
44 |
}
|
45 |
+
|
46 |
+
if (! $this->device) {
|
47 |
+
if ( $userAgent['game'] && preg_match( '/' . implode( '|', $userAgent['game'] ) . '/i', $_SERVER['HTTP_USER_AGENT']) ) {
|
48 |
+
$this->device = 'game';
|
49 |
+
}
|
50 |
+
elseif ( $userAgent['tablet'] && preg_match( '/' . implode( '|', $userAgent['tablet'] ) . '/i', $_SERVER['HTTP_USER_AGENT']) ) {
|
51 |
+
$this->device = 'tablet';
|
52 |
+
}
|
53 |
+
elseif ( $userAgent['smart'] && preg_match( '/' . implode( '|', $userAgent['smart'] ) . '/i', $_SERVER['HTTP_USER_AGENT']) ) {
|
54 |
+
$this->device = 'smart';
|
55 |
+
}
|
56 |
+
elseif ( $userAgent['mobile'] && preg_match( '/' . implode( '|', $userAgent['mobile'] ) . '/i', $_SERVER['HTTP_USER_AGENT']) ) {
|
57 |
+
$this->device = 'mobile';
|
58 |
}
|
59 |
}
|
60 |
|
180 |
if ( ! is_admin() )
|
181 |
$multi_device_switcher = new Multi_Device_Switcher();
|
182 |
|
183 |
+
/**
|
184 |
+
* Add HTTP/1.1 Vary header.
|
185 |
+
*
|
186 |
+
* @since 1.1.1
|
187 |
+
*
|
188 |
+
*/
|
189 |
+
function multi_device_switcher_add_header_vary( $headers ) {
|
190 |
+
if ( ! is_admin() ) {
|
191 |
+
$headers['Vary'] = 'User-Agent';
|
192 |
+
return $headers;
|
193 |
+
}
|
194 |
+
}
|
195 |
+
add_filter( 'wp_headers', 'multi_device_switcher_add_header_vary' );
|
196 |
+
|
197 |
/**
|
198 |
* Properly enqueue scripts for our multi_device_switcher options page.
|
199 |
*
|
305 |
'theme_tablet' => 'None',
|
306 |
'theme_mobile' => 'None',
|
307 |
'theme_game' => 'None',
|
308 |
+
'userAgent_smart' => 'iPhone, iPod, Android, dream, CUPCAKE, Windows Phone, webOS, BB10, BlackBerry8707, BlackBerry9000, BlackBerry9300, BlackBerry9500, BlackBerry9530, BlackBerry9520, BlackBerry9550, BlackBerry9700, BlackBerry 93, BlackBerry 97, BlackBerry 99, BlackBerry 98',
|
309 |
+
'userAgent_tablet' => 'iPad, Kindle, Sony Tablet, Nexus 7',
|
310 |
'userAgent_mobile' => 'DoCoMo, SoftBank, J-PHONE, Vodafone, KDDI, UP.Browser, WILLCOM, emobile, DDIPOCKET, Windows CE, BlackBerry, Symbian, PalmOS, Huawei, IAC, Nokia',
|
311 |
+
'userAgent_game' => 'PlayStation Portable, PlayStation Vita, PSP, PS2, PLAYSTATION 3, Nitro, Nintendo 3DS, Nintendo Wii, Xbox',
|
312 |
);
|
313 |
|
314 |
return $default_theme_options;
|
readme.md
CHANGED
@@ -1,8 +1,8 @@
|
|
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 and custom).
|
4 |
-
This plugin detects if your site is being viewed by UserAgent and switches to selected theme.
|
5 |
-
The Custom Switcher can add
|
6 |
|
7 |
## How do I use it?
|
8 |
|
@@ -23,6 +23,10 @@ The Custom Switcher can add to every device.
|
|
23 |
|
24 |
## Changelog
|
25 |
|
|
|
|
|
|
|
|
|
26 |
* Version 1.1.0
|
27 |
* new features: Custom Switcher
|
28 |
* Version 1.0.4
|
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 and custom).
|
4 |
+
This plugin detects if your site is being viewed by UserAgent, and switches to selected theme.
|
5 |
+
The Custom Switcher can add every device.
|
6 |
|
7 |
## How do I use it?
|
8 |
|
23 |
|
24 |
## Changelog
|
25 |
|
26 |
+
* Version 1.1.1
|
27 |
+
* fixed: change the order of the UserAgent detection
|
28 |
+
* updated: update default UserAgent
|
29 |
+
* added: add HTTP/1.1 Vary header
|
30 |
* Version 1.1.0
|
31 |
* new features: Custom Switcher
|
32 |
* Version 1.0.4
|
readme.txt
CHANGED
@@ -5,8 +5,8 @@ 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.4.
|
9 |
-
Stable tag: 1.1.
|
10 |
License: GPL2 or later
|
11 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
|
@@ -15,8 +15,8 @@ This WordPress plugin allows you to set a separate theme for device (Smart Phone
|
|
15 |
== Description ==
|
16 |
|
17 |
This WordPress plugin allows you to set a separate theme for device (Smart Phone, Tablet PC, Mobile Phone, Game and custom).
|
18 |
-
This plugin detects if your site is being viewed by UserAgent and switches to selected theme.
|
19 |
-
The Custom Switcher can add
|
20 |
|
21 |
== Screenshots ==
|
22 |
|
@@ -42,6 +42,10 @@ The Custom Switcher can add to every device.
|
|
42 |
|
43 |
== Changelog ==
|
44 |
|
|
|
|
|
|
|
|
|
45 |
= 1.1.0 =
|
46 |
* new features: Custom Switcher
|
47 |
= 1.0.4 =
|
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.4.2
|
9 |
+
Stable tag: 1.1.1
|
10 |
License: GPL2 or later
|
11 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
|
15 |
== Description ==
|
16 |
|
17 |
This WordPress plugin allows you to set a separate theme for device (Smart Phone, Tablet PC, Mobile Phone, Game and custom).
|
18 |
+
This plugin detects if your site is being viewed by UserAgent, and switches to selected theme.
|
19 |
+
The Custom Switcher can add every device.
|
20 |
|
21 |
== Screenshots ==
|
22 |
|
42 |
|
43 |
== Changelog ==
|
44 |
|
45 |
+
= 1.1.1 =
|
46 |
+
* fixed: change the order of the UserAgent detection
|
47 |
+
* updated: update default UserAgent
|
48 |
+
* added: add HTTP/1.1 Vary header
|
49 |
= 1.1.0 =
|
50 |
* new features: Custom Switcher
|
51 |
= 1.0.4 =
|