Multi Device Switcher - Version 1.4.2

Version Description

  • edited: edit readme
  • new features: Display Switcher Shortcode
  • updated: update default UserAgent
  • fixed: fix pc-switcher ssl url
Download this release

Release Info

Developer thingsym
Plugin Icon wp plugin Multi Device Switcher
Version 1.4.2
Comparing to
See all releases

Code changes from version 1.4.1 to 1.4.2

Files changed (4) hide show
  1. multi-device-switcher.php +24 -4
  2. pc-switcher-widget.php +1 -1
  3. readme.md +45 -3
  4. readme.txt +44 -2
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.4.1
7
  Author: thingsym
8
  Author URI: http://www.thingslabo.com/
9
  License: GPL2
@@ -32,6 +32,9 @@ Domain Path: /languages/
32
  class Multi_Device_Switcher {
33
 
34
  public function __construct() {
 
 
 
35
  $this->device = '';
36
 
37
  if ( isset( $_COOKIE['disable-switcher'] ) ) {
@@ -225,7 +228,8 @@ class Multi_Device_Switcher {
225
  wp_enqueue_style( 'pc-switcher-options', plugins_url() . '/multi-device-switcher/pc-switcher.css', false, '2013-03-20' );
226
  }
227
 
228
- $uri = is_ssl() ? "https://" : "http://" . $_SERVER["HTTP_HOST"];
 
229
 
230
  if ( isset( $_COOKIE['pc-switcher'] ) ) {
231
  $uri .= add_query_arg( 'pc-switcher', 0 );
@@ -278,6 +282,22 @@ class Multi_Device_Switcher {
278
 
279
  return (boolean) $disable;
280
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
281
  }
282
 
283
  if ( ! is_admin() ) {
@@ -497,8 +517,8 @@ function multi_device_switcher_get_default_options() {
497
  'theme_tablet' => 'None',
498
  'theme_mobile' => 'None',
499
  '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',
502
  'userAgent_mobile' => 'DoCoMo, SoftBank, J-PHONE, Vodafone, KDDI, UP.Browser, WILLCOM, emobile, DDIPOCKET, Windows CE, BlackBerry, Symbian, PalmOS, Huawei, IAC, Nokia',
503
  'userAgent_game' => 'PlayStation Portable, PlayStation Vita, PSP, PS2, PLAYSTATION 3, PlayStation 4, Nitro, Nintendo 3DS, Nintendo Wii, Nintendo WiiU, Xbox',
504
  'disable_path' => '',
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.4.2
7
  Author: thingsym
8
  Author URI: http://www.thingslabo.com/
9
  License: GPL2
32
  class Multi_Device_Switcher {
33
 
34
  public function __construct() {
35
+ add_shortcode( 'multi', array( &$this, 'shortcode_display_switcher' ) );
36
+
37
+
38
  $this->device = '';
39
 
40
  if ( isset( $_COOKIE['disable-switcher'] ) ) {
228
  wp_enqueue_style( 'pc-switcher-options', plugins_url() . '/multi-device-switcher/pc-switcher.css', false, '2013-03-20' );
229
  }
230
 
231
+ $uri = is_ssl() ? 'https://' : 'http://';
232
+ $uri .= $_SERVER['HTTP_HOST'];
233
 
234
  if ( isset( $_COOKIE['pc-switcher'] ) ) {
235
  $uri .= add_query_arg( 'pc-switcher', 0 );
282
 
283
  return (boolean) $disable;
284
  }
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
+
301
  }
302
 
303
  if ( ! is_admin() ) {
517
  'theme_tablet' => 'None',
518
  'theme_mobile' => 'None',
519
  'theme_game' => 'None',
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',
522
  'userAgent_mobile' => 'DoCoMo, SoftBank, J-PHONE, Vodafone, KDDI, UP.Browser, WILLCOM, emobile, DDIPOCKET, Windows CE, BlackBerry, Symbian, PalmOS, Huawei, IAC, Nokia',
523
  'userAgent_game' => 'PlayStation Portable, PlayStation Vita, PSP, PS2, PLAYSTATION 3, PlayStation 4, Nitro, Nintendo 3DS, Nintendo Wii, Nintendo WiiU, Xbox',
524
  'disable_path' => '',
pc-switcher-widget.php CHANGED
@@ -3,7 +3,7 @@
3
  Widget Name: PC Switcher Widget
4
  Plugin URI: https://github.com/thingsym/multi-device-switcher
5
  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
7
  Author: thingsym
8
  Author URI: http://www.thingslabo.com/
9
  License: GPL2
3
  Widget Name: PC Switcher Widget
4
  Plugin URI: https://github.com/thingsym/multi-device-switcher
5
  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.2
7
  Author: thingsym
8
  Author URI: http://www.thingslabo.com/
9
  License: GPL2
readme.md CHANGED
@@ -8,6 +8,7 @@ This plugin detects if your site is being viewed by UserAgent, and switches to s
8
  - Set a separate theme for device (Smart Phone, Tablet PC, Mobile Phone, Game), switches to selected theme.
9
  - Add every device by the **Custom Switcher**.
10
  - Add links 'Mobile' or 'PC' in the theme by the **PC Switcher**, switch to the default theme.
 
11
  - Disable the switching of the theme by a particular URL by the **Disable Switcher**.
12
  - Can be using is_multi_device() function that detect of the device.
13
  - **Multi Device Switcher Command** command-line tool (required WP-CLI)
@@ -84,6 +85,43 @@ You can design the PC Switcher in the Style Sheet.
84
  <div class="pc-switcher"><a href="http://DOMEIN/PATH/TO/?pc-switcher=0">Mobile</a><span class="active">PC</span></div>
85
  ```
86
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  ## How to use the Disable Switcher
88
 
89
  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
285
  get status of settings
286
 
287
  wp multi-device status
288
-
289
  Active Theme: Twenty Fifteen | twentyfifteen
290
  +--------------------------+-----------------+----------------+-------------------------------------------------------------------------+
291
  | Device | Theme | Slug | UserAgent |
@@ -330,7 +368,7 @@ turn on default CSS
330
 
331
  ## Contributing
332
 
333
- ### Patches and Bug Fixes
334
 
335
  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.
336
 
@@ -363,6 +401,11 @@ You can send your own language pack to author.
363
 
364
  ## Changelog
365
 
 
 
 
 
 
366
  * Version 1.4.1
367
  * edited: edit readme
368
  * new features: is_disable_switcher() function
@@ -427,4 +470,3 @@ You can send your own language pack to author.
427
 
428
  * 1.1.2
429
  * Requires at least version 3.4 of the Wordpress
430
-
8
  - Set a separate theme for device (Smart Phone, Tablet PC, Mobile Phone, Game), switches to selected theme.
9
  - Add every device by the **Custom Switcher**.
10
  - 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.
12
  - Disable the switching of the theme by a particular URL by the **Disable Switcher**.
13
  - Can be using is_multi_device() function that detect of the device.
14
  - **Multi Device Switcher Command** command-line tool (required WP-CLI)
85
  <div class="pc-switcher"><a href="http://DOMEIN/PATH/TO/?pc-switcher=0">Mobile</a><span class="active">PC</span></div>
86
  ```
87
 
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
+
125
  ## How to use the Disable Switcher
126
 
127
  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.
323
  get status of settings
324
 
325
  wp multi-device status
326
+
327
  Active Theme: Twenty Fifteen | twentyfifteen
328
  +--------------------------+-----------------+----------------+-------------------------------------------------------------------------+
329
  | Device | Theme | Slug | UserAgent |
368
 
369
  ## Contributing
370
 
371
+ ### Patches and Bug Fixes
372
 
373
  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.
374
 
401
 
402
  ## Changelog
403
 
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
409
  * Version 1.4.1
410
  * edited: edit readme
411
  * new features: is_disable_switcher() function
470
 
471
  * 1.1.2
472
  * Requires at least version 3.4 of the Wordpress
 
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.4
8
- Tested up to: 4.1
9
- Stable tag: 1.4.1
10
  License: GPL2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
@@ -24,6 +24,7 @@ The Custom Switcher can add every device.
24
  * Set a separate theme for device (Smart Phone, Tablet PC, Mobile Phone, Game), switches to selected theme.
25
  * Add every device by the **Custom Switcher**.
26
  * Add links 'Mobile' or 'PC' in the theme by the **PC Switcher**, switch to the default theme.
 
27
  * Disable the switching of the theme for each url by the **Disable Switcher**.
28
  * Can be using **is_multi_device()** function that detect of the device.
29
  * **Multi Device Switcher Command** command-line tool (required WP-CLI)
@@ -131,6 +132,42 @@ You can design the PC Switcher in the Style Sheet.
131
  <div class="pc-switcher"><a href="http://DOMEIN/PATH/TO/?pc-switcher=0">Mobile</a><span class="active">PC</span></div>
132
  `
133
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
 
135
  = How to use the Disable Switcher =
136
 
@@ -334,6 +371,11 @@ For more information about the Multi Device Switcher Command, see `wp help multi
334
 
335
  == Changelog ==
336
 
 
 
 
 
 
337
  = 1.4.1 =
338
  * edited: edit readme
339
  * new features: is_disable_switcher() function
5
  Link: https://github.com/thingsym/multi-device-switcher
6
  Tags: switcher, theme, ipad, iphone, android, tablet, mobile, game
7
  Requires at least: 3.4
8
+ Tested up to: 4.2
9
+ Stable tag: 1.4.2
10
  License: GPL2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
24
  * Set a separate theme for device (Smart Phone, Tablet PC, Mobile Phone, Game), switches to selected theme.
25
  * Add every device by the **Custom Switcher**.
26
  * 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.
28
  * Disable the switching of the theme for each url by the **Disable Switcher**.
29
  * Can be using **is_multi_device()** function that detect of the device.
30
  * **Multi Device Switcher Command** command-line tool (required WP-CLI)
132
  <div class="pc-switcher"><a href="http://DOMEIN/PATH/TO/?pc-switcher=0">Mobile</a><span class="active">PC</span></div>
133
  `
134
 
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
+ `
171
 
172
  = How to use the Disable Switcher =
173
 
371
 
372
  == Changelog ==
373
 
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
379
  = 1.4.1 =
380
  * edited: edit readme
381
  * new features: is_disable_switcher() function