Multi Device Switcher - Version 1.4.1

Version Description

  • edited: edit readme
  • new features: is_disable_switcher() function
  • new features: is_pc_switcher() function
  • fixed: fix redirect url and pc-switcher url
Download this release

Release Info

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

Code changes from version 1.4.0 to 1.4.1

Files changed (4) hide show
  1. multi-device-switcher.php +51 -8
  2. pc-switcher-widget.php +1 -1
  3. readme.md +76 -6
  4. readme.txt +77 -8
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.0
7
  Author: thingsym
8
  Author URI: http://www.thingslabo.com/
9
  License: GPL2
@@ -38,7 +38,8 @@ class Multi_Device_Switcher {
38
  setcookie( 'disable-switcher', null, time() - 3600, '/' );
39
  }
40
 
41
- if ( $this->get_disable() ) {
 
42
  setcookie( 'disable-switcher', 1, null, '/' );
43
  return;
44
  }
@@ -203,7 +204,7 @@ class Multi_Device_Switcher {
203
 
204
  unset( $_GET['pc-switcher'] );
205
  if ( ! empty( $_GET ) ) {
206
- $uri = $uri . '?' . http_build_query( $_GET );
207
  }
208
 
209
  wp_redirect( esc_url( $uri ) );
@@ -224,14 +225,16 @@ class Multi_Device_Switcher {
224
  wp_enqueue_style( 'pc-switcher-options', plugins_url() . '/multi-device-switcher/pc-switcher.css', false, '2013-03-20' );
225
  }
226
 
 
 
227
  if ( isset( $_COOKIE['pc-switcher'] ) ) {
228
- $uri = get_home_url() . add_query_arg( 'pc-switcher', 0 );
229
  ?>
230
  <div class="pc-switcher"><a href="<?php echo esc_url( $uri ); ?>"><?php _e( 'Mobile', 'multi-device-switcher' ); ?></a><span class="active"><?php _e( 'PC', 'multi-device-switcher' ); ?></span></div>
231
  <?php
232
  }
233
  else {
234
- $uri = get_home_url() . add_query_arg( 'pc-switcher', 1 );
235
  ?>
236
  <div class="pc-switcher"><span class="active"><?php _e( 'Mobile', 'multi-device-switcher' ); ?></span><a href="<?php echo esc_url( $uri ); ?>"><?php _e( 'PC', 'multi-device-switcher' ); ?></a></div>
237
  <?php
@@ -250,7 +253,11 @@ class Multi_Device_Switcher {
250
  return (boolean) 0;
251
  }
252
 
253
- public function get_disable( $disable = 0 ) {
 
 
 
 
254
  $options = multi_device_switcher_get_options();
255
  $disable_path = preg_split( '/\R/', $options['disable_path'], -1, PREG_SPLIT_NO_EMPTY );
256
 
@@ -299,7 +306,9 @@ add_filter( 'wp_headers', 'multi_device_switcher_add_header_vary' );
299
  */
300
  function multi_device_switcher_add_pc_switcher() {
301
  global $multi_device_switcher;
302
- $multi_device_switcher->add_pc_switcher( 1 );
 
 
303
  }
304
 
305
  /**
@@ -312,7 +321,41 @@ if ( ! function_exists( 'is_multi_device' ) ) :
312
 
313
  function is_multi_device( $device = '' ) {
314
  global $multi_device_switcher;
315
- return $multi_device_switcher->is_multi_device( $device );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
316
  }
317
  endif;
318
 
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
38
  setcookie( 'disable-switcher', null, time() - 3600, '/' );
39
  }
40
 
41
+ if ( $this->is_disable_switcher() ) {
42
+ setcookie( 'multi-device-switcher', null, time() - 3600, '/' );
43
  setcookie( 'disable-switcher', 1, null, '/' );
44
  return;
45
  }
204
 
205
  unset( $_GET['pc-switcher'] );
206
  if ( ! empty( $_GET ) ) {
207
+ $uri .= '?' . http_build_query( $_GET );
208
  }
209
 
210
  wp_redirect( esc_url( $uri ) );
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 );
232
  ?>
233
  <div class="pc-switcher"><a href="<?php echo esc_url( $uri ); ?>"><?php _e( 'Mobile', 'multi-device-switcher' ); ?></a><span class="active"><?php _e( 'PC', 'multi-device-switcher' ); ?></span></div>
234
  <?php
235
  }
236
  else {
237
+ $uri .= add_query_arg( 'pc-switcher', 1 );
238
  ?>
239
  <div class="pc-switcher"><span class="active"><?php _e( 'Mobile', 'multi-device-switcher' ); ?></span><a href="<?php echo esc_url( $uri ); ?>"><?php _e( 'PC', 'multi-device-switcher' ); ?></a></div>
240
  <?php
253
  return (boolean) 0;
254
  }
255
 
256
+ public function is_pc_switcher() {
257
+ return isset( $_COOKIE['pc-switcher'] );
258
+ }
259
+
260
+ public function is_disable_switcher( $disable = 0 ) {
261
  $options = multi_device_switcher_get_options();
262
  $disable_path = preg_split( '/\R/', $options['disable_path'], -1, PREG_SPLIT_NO_EMPTY );
263
 
306
  */
307
  function multi_device_switcher_add_pc_switcher() {
308
  global $multi_device_switcher;
309
+ if ( is_object( $multi_device_switcher ) ) {
310
+ $multi_device_switcher->add_pc_switcher( 1 );
311
+ }
312
  }
313
 
314
  /**
321
 
322
  function is_multi_device( $device = '' ) {
323
  global $multi_device_switcher;
324
+ if ( is_object( $multi_device_switcher ) ) {
325
+ return $multi_device_switcher->is_multi_device( $device );
326
+ }
327
+ }
328
+ endif;
329
+
330
+ /**
331
+ * Return the state of PC Switcher.
332
+ *
333
+ * @since 1.4.1
334
+ *
335
+ */
336
+ if ( ! function_exists( 'is_pc_switcher' ) ) :
337
+
338
+ function is_pc_switcher() {
339
+ global $multi_device_switcher;
340
+ if ( is_object( $multi_device_switcher ) ) {
341
+ return $multi_device_switcher->is_pc_switcher();
342
+ }
343
+ }
344
+ endif;
345
+
346
+ /**
347
+ * Return the state of disabled.
348
+ *
349
+ * @since 1.4.1
350
+ *
351
+ */
352
+ if ( ! function_exists( 'is_disable_switcher' ) ) :
353
+
354
+ function is_disable_switcher() {
355
+ global $multi_device_switcher;
356
+ if ( is_object( $multi_device_switcher ) ) {
357
+ return $multi_device_switcher->is_disable_switcher();
358
+ }
359
  }
360
  endif;
361
 
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.0
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.1
7
  Author: thingsym
8
  Author URI: http://www.thingslabo.com/
9
  License: GPL2
readme.md CHANGED
@@ -92,7 +92,7 @@ The **Disable Switcher** disable the switching of the theme by a particular URL.
92
  2. Enter the path to the line by line where you want to disable by Disable Switcher option. Check the checkbox 'Enable Regex', if you want to use a regular expression.
93
  3. Have fun!
94
 
95
- ### Examples
96
 
97
  ```
98
  /sample-page
@@ -115,13 +115,13 @@ The **Disable Switcher** disable the switching of the theme by a particular URL.
115
 
116
  Multi Device Switcher set the Cookie that holds the state of the switch. You can get the Cookie and detect the device by JavaScript.
117
 
118
- ### Cookie
119
 
120
  * `multi-device-switcher` The name of the device is switched (value: null | device name)
121
  * `disable-switcher` State of disabled (value: null | 1)
122
  * `pc-switcher` State of the PC Switcher when switched (value: null | 1)
123
 
124
- ### Examples
125
 
126
  ```
127
  <script src="http://DOMEIN/PATH/TO/jquery.cookie.js"></script>
@@ -133,7 +133,7 @@ Multi Device Switcher set the Cookie that holds the state of the switch. You can
133
  } else if ( $.cookie( 'multi-device-switcher' ) == 'tablet' ) {
134
  /* tablet specific stuff here */
135
  } else {
136
- /* pc or other stuff here */
137
  }
138
  });
139
  })(jQuery);
@@ -150,7 +150,7 @@ Multi Device Switcher set the Cookie that holds the state of the switch. You can
150
  <?php is_multi_device('smart'); ?>
151
  ```
152
 
153
- ### Examples
154
 
155
  ```
156
  <?php
@@ -160,7 +160,7 @@ if ( function_exists( 'is_multi_device' ) ) {
160
  } elseif ( is_multi_device('tablet') ) {
161
  /* Display and echo tablet specific stuff here */
162
  } else {
163
- /* Display and echo pc or other stuff here */
164
  }
165
  }
166
  ?>
@@ -182,6 +182,71 @@ if ( function_exists( 'is_multi_device' ) ) {
182
 
183
  (boolean) Return boolean whether a particular device.
184
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
  ## Multi Device Switcher Command
186
 
187
  The **Multi Device Switcher Command** is command-line tool.
@@ -298,6 +363,11 @@ You can send your own language pack to author.
298
 
299
  ## Changelog
300
 
 
 
 
 
 
301
  * Version 1.4.0
302
  * edited: edit readme
303
  * added: add cookies 'multi-device-switcher', 'disable-switcher'
92
  2. Enter the path to the line by line where you want to disable by Disable Switcher option. Check the checkbox 'Enable Regex', if you want to use a regular expression.
93
  3. Have fun!
94
 
95
+ ### Example
96
 
97
  ```
98
  /sample-page
115
 
116
  Multi Device Switcher set the Cookie that holds the state of the switch. You can get the Cookie and detect the device by JavaScript.
117
 
118
+ ### Cookies
119
 
120
  * `multi-device-switcher` The name of the device is switched (value: null | device name)
121
  * `disable-switcher` State of disabled (value: null | 1)
122
  * `pc-switcher` State of the PC Switcher when switched (value: null | 1)
123
 
124
+ ### Example
125
 
126
  ```
127
  <script src="http://DOMEIN/PATH/TO/jquery.cookie.js"></script>
133
  } else if ( $.cookie( 'multi-device-switcher' ) == 'tablet' ) {
134
  /* tablet specific stuff here */
135
  } else {
136
+ /* pc or other specific stuff here */
137
  }
138
  });
139
  })(jQuery);
150
  <?php is_multi_device('smart'); ?>
151
  ```
152
 
153
+ ### Example
154
 
155
  ```
156
  <?php
160
  } elseif ( is_multi_device('tablet') ) {
161
  /* Display and echo tablet specific stuff here */
162
  } else {
163
+ /* Display and echo pc or other specific stuff here */
164
  }
165
  }
166
  ?>
182
 
183
  (boolean) Return boolean whether a particular device.
184
 
185
+ ## is_pc_switcher() function
186
+
187
+ **is_pc_switcher()** function is a boolean function, meaning it returns either TRUE or FALSE. Return the the state of PC Switcher by the Multi_Device_Switcher class. Return true if the theme has switched by the PC Switcher.
188
+
189
+ ### Usage
190
+
191
+ ```
192
+ <?php is_pc_switcher(); ?>
193
+ ```
194
+
195
+ ### Example
196
+
197
+ ```
198
+ <?php
199
+ if ( function_exists( 'is_pc_switcher' ) ) {
200
+ if ( is_pc_switcher() ) {
201
+ /* Theme switched by the PC Switcher. Display and echo specific stuff here */
202
+ } else {
203
+ /* Display and echo specific stuff here */
204
+ }
205
+ }
206
+ ?>
207
+ ```
208
+
209
+ ### Parameters
210
+
211
+ None
212
+
213
+ ### Return Values
214
+
215
+ (boolean) Return the state of PC Switcher.
216
+
217
+
218
+ ## is_disable_switcher() function
219
+
220
+ **is_disable_switcher()** function is a boolean function, meaning it returns either TRUE or FALSE. Return the state of disabled by the Multi_Device_Switcher class.
221
+
222
+ ### Usage
223
+
224
+ ```
225
+ <?php is_disable_switcher(); ?>
226
+ ```
227
+
228
+ ### Example
229
+
230
+ ```
231
+ <?php
232
+ if ( function_exists( 'is_disable_switcher' ) ) {
233
+ if ( is_disable_switcher() ) {
234
+ /* Disabled. Display and echo specific stuff here */
235
+ } else {
236
+ /* Display and echo specific stuff here */
237
+ }
238
+ }
239
+ ?>
240
+ ```
241
+
242
+ ### Parameters
243
+
244
+ None
245
+
246
+ ### Return Values
247
+
248
+ (boolean) Return the state of disabled.
249
+
250
  ## Multi Device Switcher Command
251
 
252
  The **Multi Device Switcher Command** is command-line tool.
363
 
364
  ## Changelog
365
 
366
+ * Version 1.4.1
367
+ * edited: edit readme
368
+ * new features: is_disable_switcher() function
369
+ * new features: is_pc_switcher() function
370
+ * fixed: fix redirect url and pc-switcher url
371
  * Version 1.4.0
372
  * edited: edit readme
373
  * added: add cookies 'multi-device-switcher', 'disable-switcher'
readme.txt CHANGED
@@ -6,7 +6,7 @@ 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.0
10
  License: GPL2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
@@ -140,14 +140,14 @@ The **Disable Switcher** disable the switching of the theme by a particular URL.
140
  2. Enter the path to the line by line where you want to disable by Disable Switcher option. Check the checkbox 'Enable Regex', if you want to use a regular expression.
141
  3. Have fun!
142
 
143
- = Examples =
144
 
145
  `
146
  /sample-page
147
  /2015/01/hello-world
148
  `
149
 
150
- ##### Regex mode (in the case of regular expression)
151
 
152
  `
153
  \/sample\-
@@ -162,13 +162,13 @@ The **Disable Switcher** disable the switching of the theme by a particular URL.
162
 
163
  Multi Device Switcher set the Cookie that holds the state of the switch. You can get the Cookie and detect the device by JavaScript.
164
 
165
- = Cookie =
166
 
167
  * `multi-device-switcher` The name of the device is switched (value: null | device name)
168
  * `disable-switcher` State of disabled (value: null | 1)
169
  * `pc-switcher` State of the PC Switcher when switched (value: null | 1)
170
 
171
- = Examples =
172
 
173
  `
174
  <script src="http://DOMEIN/PATH/TO/jquery.cookie.js"></script>
@@ -180,7 +180,7 @@ Multi Device Switcher set the Cookie that holds the state of the switch. You can
180
  } else if ( $.cookie( 'multi-device-switcher' ) == 'tablet' ) {
181
  /* tablet specific stuff here */
182
  } else {
183
- /* pc or other stuff here */
184
  }
185
  });
186
  })(jQuery);
@@ -197,7 +197,7 @@ Multi Device Switcher set the Cookie that holds the state of the switch. You can
197
  <?php is_multi_device('smart'); ?>
198
  `
199
 
200
- = Examples =
201
 
202
  `
203
  <?php
@@ -207,7 +207,7 @@ if ( function_exists( 'is_multi_device' ) ) {
207
  } elseif ( is_multi_device('tablet') ) {
208
  /* Display and echo tablet specific stuff here */
209
  } else {
210
- /* Display and echo pc or other stuff here */
211
  }
212
  }
213
  ?>
@@ -229,6 +229,70 @@ if ( function_exists( 'is_multi_device' ) ) {
229
 
230
  (boolean) Return boolean whether a particular device.
231
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
232
  = Multi Device Switcher Command =
233
 
234
  The **Multi Device Switcher Command** is command-line tool.
@@ -270,6 +334,11 @@ For more information about the Multi Device Switcher Command, see `wp help multi
270
 
271
  == Changelog ==
272
 
 
 
 
 
 
273
  = 1.4.0 =
274
  * edited: edit readme
275
  * added: add cookies 'multi-device-switcher', 'disable-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
 
140
  2. Enter the path to the line by line where you want to disable by Disable Switcher option. Check the checkbox 'Enable Regex', if you want to use a regular expression.
141
  3. Have fun!
142
 
143
+ = Example =
144
 
145
  `
146
  /sample-page
147
  /2015/01/hello-world
148
  `
149
 
150
+ = Regex mode (in the case of regular expression) =
151
 
152
  `
153
  \/sample\-
162
 
163
  Multi Device Switcher set the Cookie that holds the state of the switch. You can get the Cookie and detect the device by JavaScript.
164
 
165
+ = Cookies =
166
 
167
  * `multi-device-switcher` The name of the device is switched (value: null | device name)
168
  * `disable-switcher` State of disabled (value: null | 1)
169
  * `pc-switcher` State of the PC Switcher when switched (value: null | 1)
170
 
171
+ = Example =
172
 
173
  `
174
  <script src="http://DOMEIN/PATH/TO/jquery.cookie.js"></script>
180
  } else if ( $.cookie( 'multi-device-switcher' ) == 'tablet' ) {
181
  /* tablet specific stuff here */
182
  } else {
183
+ /* pc or other specific stuff here */
184
  }
185
  });
186
  })(jQuery);
197
  <?php is_multi_device('smart'); ?>
198
  `
199
 
200
+ = Example =
201
 
202
  `
203
  <?php
207
  } elseif ( is_multi_device('tablet') ) {
208
  /* Display and echo tablet specific stuff here */
209
  } else {
210
+ /* Display and echo pc or other specific stuff here */
211
  }
212
  }
213
  ?>
229
 
230
  (boolean) Return boolean whether a particular device.
231
 
232
+ = is_pc_switcher() function =
233
+
234
+ **is_pc_switcher()** function is a boolean function, meaning it returns either TRUE or FALSE. Return the the state of PC Switcher by the Multi_Device_Switcher class. Return true if the theme has switched by the PC Switcher.
235
+
236
+ = Usage =
237
+
238
+ `
239
+ <?php is_pc_switcher(); ?>
240
+ `
241
+
242
+ = Example =
243
+
244
+ `
245
+ <?php
246
+ if ( function_exists( 'is_pc_switcher' ) ) {
247
+ if ( is_pc_switcher() ) {
248
+ /* Theme switched by the PC Switcher. Display and echo specific stuff here */
249
+ } else {
250
+ /* Display and echo specific stuff here */
251
+ }
252
+ }
253
+ ?>
254
+ `
255
+
256
+ = Parameters =
257
+
258
+ None
259
+
260
+ = Return Values =
261
+
262
+ (boolean) Return the state of PC Switcher.
263
+
264
+ = is_disable_switcher() function =
265
+
266
+ **is_disable_switcher()** function is a boolean function, meaning it returns either TRUE or FALSE. Return the state of disabled by the Multi_Device_Switcher class.
267
+
268
+ = Usage =
269
+
270
+ `
271
+ <?php is_disable_switcher(); ?>
272
+ `
273
+
274
+ = Example =
275
+
276
+ `
277
+ <?php
278
+ if ( function_exists( 'is_disable_switcher' ) ) {
279
+ if ( is_disable_switcher() ) {
280
+ /* Disabled. Display and echo specific stuff here */
281
+ } else {
282
+ /* Display and echo specific stuff here */
283
+ }
284
+ }
285
+ ?>
286
+ `
287
+
288
+ = Parameters =
289
+
290
+ None
291
+
292
+ = Return Values =
293
+
294
+ (boolean) Return the state of disabled.
295
+
296
  = Multi Device Switcher Command =
297
 
298
  The **Multi Device Switcher Command** is command-line tool.
334
 
335
  == Changelog ==
336
 
337
+ = 1.4.1 =
338
+ * edited: edit readme
339
+ * new features: is_disable_switcher() function
340
+ * new features: is_pc_switcher() function
341
+ * fixed: fix redirect url and pc-switcher url
342
  = 1.4.0 =
343
  * edited: edit readme
344
  * added: add cookies 'multi-device-switcher', 'disable-switcher'