Skip to content

Commit e158110

Browse files
committed
Merge branch 'release-1.4.2'
2 parents 80dd7ae + 9d146f6 commit e158110

File tree

4 files changed

+114
-10
lines changed

4 files changed

+114
-10
lines changed

multi-device-switcher.php

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Plugin Name: Multi Device Switcher
44
Plugin URI: https://github.com/thingsym/multi-device-switcher
55
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.4.1
6+
Version: 1.4.2
77
Author: thingsym
88
Author URI: http://www.thingslabo.com/
99
License: GPL2
@@ -32,6 +32,9 @@
3232
class Multi_Device_Switcher {
3333

3434
public function __construct() {
35+
add_shortcode( 'multi', array( &$this, 'shortcode_display_switcher' ) );
36+
37+
3538
$this->device = '';
3639

3740
if ( isset( $_COOKIE['disable-switcher'] ) ) {
@@ -225,7 +228,8 @@ public function add_pc_switcher( $pc_switcher = 0 ) {
225228
wp_enqueue_style( 'pc-switcher-options', plugins_url() . '/multi-device-switcher/pc-switcher.css', false, '2013-03-20' );
226229
}
227230

228-
$uri = is_ssl() ? "https://" : "http://" . $_SERVER["HTTP_HOST"];
231+
$uri = is_ssl() ? 'https://' : 'http://';
232+
$uri .= $_SERVER['HTTP_HOST'];
229233

230234
if ( isset( $_COOKIE['pc-switcher'] ) ) {
231235
$uri .= add_query_arg( 'pc-switcher', 0 );
@@ -278,6 +282,22 @@ public function is_disable_switcher( $disable = 0 ) {
278282

279283
return (boolean) $disable;
280284
}
285+
286+
public function shortcode_display_switcher( $atts, $content = '' ) {
287+
$atts = shortcode_atts( array(
288+
'device' => '',
289+
), $atts );
290+
291+
if ( empty( $atts['device'] ) && ( $this->is_multi_device( $atts['device'] ) || $this->is_pc_switcher() ) ) {
292+
return $content;
293+
}
294+
elseif ( ! empty( $atts['device'] ) && $this->is_multi_device( $atts['device'] ) && ! $this->is_pc_switcher() ) {
295+
return $content;
296+
}
297+
298+
return '';
299+
}
300+
281301
}
282302

283303
if ( ! is_admin() ) {
@@ -497,8 +517,8 @@ function multi_device_switcher_get_default_options() {
497517
'theme_tablet' => 'None',
498518
'theme_mobile' => 'None',
499519
'theme_game' => 'None',
500-
'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',
501-
'userAgent_tablet' => 'iPad, Kindle, Sony Tablet, Nexus 7',
520+
'userAgent_smart' => 'iPhone, iPod, Android.*Mobile, dream, CUPCAKE, Windows Phone, IEMobile.*Touch, webOS, BB10.*Mobile, BlackBerry.*Mobile, Mobile.*Gecko',
521+
'userAgent_tablet' => 'iPad, Kindle, Silk, Android(?!.*Mobile), Windows.*Touch, PlayBook, Tablet.*Gecko',
502522
'userAgent_mobile' => 'DoCoMo, SoftBank, J-PHONE, Vodafone, KDDI, UP.Browser, WILLCOM, emobile, DDIPOCKET, Windows CE, BlackBerry, Symbian, PalmOS, Huawei, IAC, Nokia',
503523
'userAgent_game' => 'PlayStation Portable, PlayStation Vita, PSP, PS2, PLAYSTATION 3, PlayStation 4, Nitro, Nintendo 3DS, Nintendo Wii, Nintendo WiiU, Xbox',
504524
'disable_path' => '',

pc-switcher-widget.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Widget Name: PC Switcher Widget
44
Plugin URI: https://github.com/thingsym/multi-device-switcher
55
Description: PC Switcher Widget add-on for the Multi Device Switcher. Use this widget to add the PC Switcher to a widget.
6-
Version: 1.4.1
6+
Version: 1.4.2
77
Author: thingsym
88
Author URI: http://www.thingslabo.com/
99
License: GPL2

readme.md

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ This plugin detects if your site is being viewed by UserAgent, and switches to s
88
- Set a separate theme for device (Smart Phone, Tablet PC, Mobile Phone, Game), switches to selected theme.
99
- Add every device by the **Custom Switcher**.
1010
- Add links 'Mobile' or 'PC' in the theme by the **PC Switcher**, switch to the default theme.
11+
- Switch the content of the post or page for each device by the **Display Switcher** Shortcode.
1112
- Disable the switching of the theme by a particular URL by the **Disable Switcher**.
1213
- Can be using is_multi_device() function that detect of the device.
1314
- **Multi Device Switcher Command** command-line tool (required WP-CLI)
@@ -84,6 +85,43 @@ You can design the PC Switcher in the Style Sheet.
8485
<div class="pc-switcher"><a href="http://DOMEIN/PATH/TO/?pc-switcher=0">Mobile</a><span class="active">PC</span></div>
8586
```
8687

88+
## How to use the Display Switcher Shortcode
89+
90+
The **Display Switcher** Shortcode switch the content of the post or page through the detection of the device.
91+
92+
Add the shortcode `[multi]` in a post or page and use the `device` attribute to device name. if the device attribute is empty, detect the desktop PC.
93+
94+
### Attributes
95+
96+
**device**
97+
98+
(string | empty) The name of the device
99+
100+
* smart
101+
* tablet
102+
* mobile
103+
* game
104+
* the name of the Custom Switcher
105+
106+
if empty, detect the desktop PC
107+
108+
### Example Shortcode
109+
110+
```
111+
[multi]pc or other specific stuff here[/multi]
112+
[multi device="smart"]smartphone specific stuff here[/multi]
113+
[multi device="tablet"]tablet specific stuff here[/multi]
114+
[multi device="test"]test Custom Switcher specific stuff here[/multi]
115+
```
116+
117+
For theme or plugin developers. Filters The Display Switcher Shortcode through hooks. In that case, edit theme or plugin files.
118+
119+
```
120+
<?php
121+
echo do_shortcode('[multi device="smart"]smartphone specific stuff here[/multi]');
122+
?>
123+
```
124+
87125
## How to use the Disable Switcher
88126

89127
The **Disable Switcher** disable the switching of the theme by a particular URL. If you match the access the url and a string or a regular expression (Regex mode), disable the switching of the theme. Regex mode is for advanced users.
@@ -285,7 +323,7 @@ For more information about the Multi Device Switcher Command, see `wp help multi
285323
get status of settings
286324

287325
wp multi-device status
288-
326+
289327
Active Theme: Twenty Fifteen | twentyfifteen
290328
+--------------------------+-----------------+----------------+-------------------------------------------------------------------------+
291329
| Device | Theme | Slug | UserAgent |
@@ -330,7 +368,7 @@ turn on default CSS
330368

331369
## Contributing
332370

333-
### Patches and Bug Fixes
371+
### Patches and Bug Fixes
334372

335373
Small patches and bug reports can be submitted a issue tracker in Github. Forking on Github is another good way. You can send a pull request.
336374

@@ -363,6 +401,11 @@ You can send your own language pack to author.
363401

364402
## Changelog
365403

404+
* Version 1.4.2
405+
* edited: edit readme
406+
* new features: Display Switcher Shortcode
407+
* updated: update default UserAgent
408+
* fixed: fix pc-switcher ssl url
366409
* Version 1.4.1
367410
* edited: edit readme
368411
* new features: is_disable_switcher() function
@@ -427,4 +470,3 @@ You can send your own language pack to author.
427470

428471
* 1.1.2
429472
* Requires at least version 3.4 of the Wordpress
430-

readme.txt

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ Donate link: http://blog.thingslabo.com/archives/000251.html
55
Link: https://github.com/thingsym/multi-device-switcher
66
Tags: switcher, theme, ipad, iphone, android, tablet, mobile, game
77
Requires at least: 3.4
8-
Tested up to: 4.1
9-
Stable tag: 1.4.1
8+
Tested up to: 4.2
9+
Stable tag: 1.4.2
1010
License: GPL2 or later
1111
License URI: http://www.gnu.org/licenses/gpl-2.0.html
1212

@@ -24,6 +24,7 @@ The Custom Switcher can add every device.
2424
* Set a separate theme for device (Smart Phone, Tablet PC, Mobile Phone, Game), switches to selected theme.
2525
* Add every device by the **Custom Switcher**.
2626
* Add links 'Mobile' or 'PC' in the theme by the **PC Switcher**, switch to the default theme.
27+
* Switch the content of the post or page for each device by the **Display Switcher** Shortcode.
2728
* Disable the switching of the theme for each url by the **Disable Switcher**.
2829
* Can be using **is_multi_device()** function that detect of the device.
2930
* **Multi Device Switcher Command** command-line tool (required WP-CLI)
@@ -131,6 +132,42 @@ You can design the PC Switcher in the Style Sheet.
131132
<div class="pc-switcher"><a href="http://DOMEIN/PATH/TO/?pc-switcher=0">Mobile</a><span class="active">PC</span></div>
132133
`
133134

135+
= How to use the Display Switcher Shortcode =
136+
137+
The **Display Switcher** Shortcode switch the content of the post or page through the detection of the device.
138+
139+
Add the shortcode `[multi]` in a post or page and use the `device` attribute to device name. if the device attribute is empty, detect the desktop PC.
140+
141+
= Attributes =
142+
143+
**device**
144+
145+
(string | empty) The name of the device
146+
147+
* smart
148+
* tablet
149+
* mobile
150+
* game
151+
* the name of the Custom Switcher
152+
153+
if empty, detect the desktop PC
154+
155+
= Example Shortcode =
156+
157+
`
158+
[multi]pc or other specific stuff here[/multi]
159+
[multi device="smart"]smartphone specific stuff here[/multi]
160+
[multi device="tablet"]tablet specific stuff here[/multi]
161+
[multi device="test"]test Custom Switcher specific stuff here[/multi]
162+
`
163+
164+
For theme or plugin developers. Filters The Display Switcher Shortcode through hooks. In that case, edit theme or plugin files.
165+
166+
`
167+
<?php
168+
echo do_shortcode('[multi device="smart"]smartphone specific stuff here[/multi]');
169+
?>
170+
`
134171

135172
= How to use the Disable Switcher =
136173

@@ -334,6 +371,11 @@ For more information about the Multi Device Switcher Command, see `wp help multi
334371

335372
== Changelog ==
336373

374+
= 1.4.2 =
375+
* edited: edit readme
376+
* new features: Display Switcher Shortcode
377+
* updated: update default UserAgent
378+
* fixed: fix pc-switcher ssl url
337379
= 1.4.1 =
338380
* edited: edit readme
339381
* new features: is_disable_switcher() function

0 commit comments

Comments
 (0)