Multi Device Switcher - Version 1.6.2

Version Description

  • add prefix into hook tag, change tag name from add_header_vary to multi_device_switcher_add_header_vary
  • for php5.3, change called function via hook from anonymous function to public function
Download this release

Release Info

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

Code changes from version 1.6.1 to 1.6.2

Files changed (4) hide show
  1. README.md +3 -0
  2. multi-device-switcher.php +23 -16
  3. pc-switcher-widget.php +1 -1
  4. readme.txt +5 -1
README.md CHANGED
@@ -396,6 +396,9 @@ Small patches and bug reports can be submitted a issue tracker in Github. Forkin
396
 
397
  ## Changelog
398
 
 
 
 
399
  * Version 1.6.1
400
  * add test cases
401
  * add add_header_vary filter
396
 
397
  ## Changelog
398
 
399
+ * Version 1.6.2
400
+ * add prefix into hook tag, change tag name from add_header_vary to multi_device_switcher_add_header_vary
401
+ * for php5.3, change called function via hook from anonymous function to public function
402
  * Version 1.6.1
403
  * add test cases
404
  * add add_header_vary filter
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.6.1
7
  * Author: thingsym
8
  * Author URI: http://www.thingslabo.com/
9
  * License: GPL2
@@ -83,16 +83,11 @@ class Multi_Device_Switcher {
83
 
84
  public function switch_theme() {
85
  if ( isset( $_COOKIE[ $this->cookie_name_disable_switcher ] ) ) {
86
- add_action( 'wp_headers', function () {
87
- setcookie( $this->cookie_name_disable_switcher, null, time() - 3600, '/', '', is_ssl(), false );
88
- } );
89
  }
90
 
91
  if ( $this->is_disable_switcher() ) {
92
- add_action( 'wp_headers', function () {
93
- setcookie( $this->cookie_name_multi_device_switcher, null, time() - 3600, '/', '', is_ssl(), false );
94
- setcookie( $this->cookie_name_disable_switcher, 1, null, '/', '', is_ssl(), false );
95
- } );
96
  return;
97
  }
98
 
@@ -130,15 +125,10 @@ class Multi_Device_Switcher {
130
  add_filter( 'stylesheet', array( $this, 'get_stylesheet' ) );
131
  add_filter( 'template', array( $this, 'get_template' ) );
132
  add_action( 'wp_footer', array( $this, 'add_pc_switcher' ) );
133
-
134
- add_action( 'wp_headers', function () {
135
- setcookie( $this->cookie_name_multi_device_switcher, preg_replace( '/^custom_switcher_/', '', $this->device ), null, '/', '', is_ssl(), false );
136
- } );
137
  }
138
  else {
139
- add_action( 'wp_headers', function () {
140
- setcookie( $this->cookie_name_multi_device_switcher, null, time() - 3600, '/', '', is_ssl(), false );
141
- } );
142
  }
143
 
144
  if ( isset( $_COOKIE[ $this->cookie_name_pc_switcher ] ) ) {
@@ -251,6 +241,23 @@ class Multi_Device_Switcher {
251
  return;
252
  }
253
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
254
  public function session() {
255
  if ( isset( $_GET['pc-switcher'] ) ) {
256
  setcookie( $this->cookie_name_pc_switcher, $_GET['pc-switcher'] ? 1 : '', null, '/', '', is_ssl(), false );
@@ -362,7 +369,7 @@ class Multi_Device_Switcher {
362
  *
363
  */
364
  public function add_header_vary( $headers ) {
365
- $headers['Vary'] = apply_filters( 'add_header_vary', 'User-Agent' );
366
  return $headers;
367
  }
368
 
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.6.2
7
  * Author: thingsym
8
  * Author URI: http://www.thingslabo.com/
9
  * License: GPL2
83
 
84
  public function switch_theme() {
85
  if ( isset( $_COOKIE[ $this->cookie_name_disable_switcher ] ) ) {
86
+ add_action( 'wp_headers', array( $this, 'set_cookie_rest_disable_switcher' ));
 
 
87
  }
88
 
89
  if ( $this->is_disable_switcher() ) {
90
+ add_action( 'wp_headers', array( $this, 'set_cookie_enable_disable_switcher' ));
 
 
 
91
  return;
92
  }
93
 
125
  add_filter( 'stylesheet', array( $this, 'get_stylesheet' ) );
126
  add_filter( 'template', array( $this, 'get_template' ) );
127
  add_action( 'wp_footer', array( $this, 'add_pc_switcher' ) );
128
+ add_action( 'wp_headers', array( $this, 'set_cookie_switch_theme' ));
 
 
 
129
  }
130
  else {
131
+ add_action( 'wp_headers', array( $this, 'set_cookie_normal_theme' ));
 
 
132
  }
133
 
134
  if ( isset( $_COOKIE[ $this->cookie_name_pc_switcher ] ) ) {
241
  return;
242
  }
243
 
244
+ public function set_cookie_rest_disable_switcher() {
245
+ setcookie( $this->cookie_name_disable_switcher, null, time() - 3600, '/', '', is_ssl(), false );
246
+ }
247
+
248
+ public function set_cookie_enable_disable_switcher() {
249
+ setcookie( $this->cookie_name_multi_device_switcher, null, time() - 3600, '/', '', is_ssl(), false );
250
+ setcookie( $this->cookie_name_disable_switcher, 1, null, '/', '', is_ssl(), false );
251
+ }
252
+
253
+ public function set_cookie_switch_theme() {
254
+ setcookie( $this->cookie_name_multi_device_switcher, preg_replace( '/^custom_switcher_/', '', $this->device ), null, '/', '', is_ssl(), false );
255
+ }
256
+
257
+ public function set_cookie_normal_theme() {
258
+ setcookie( $this->cookie_name_multi_device_switcher, null, time() - 3600, '/', '', is_ssl(), false );
259
+ }
260
+
261
  public function session() {
262
  if ( isset( $_GET['pc-switcher'] ) ) {
263
  setcookie( $this->cookie_name_pc_switcher, $_GET['pc-switcher'] ? 1 : '', null, '/', '', is_ssl(), false );
369
  *
370
  */
371
  public function add_header_vary( $headers ) {
372
+ $headers['Vary'] = apply_filters( 'multi_device_switcher_add_header_vary', 'User-Agent' );
373
  return $headers;
374
  }
375
 
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.6.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.6.2
7
  * Author: thingsym
8
  * Author URI: http://www.thingslabo.com/
9
  * License: GPL2
readme.txt CHANGED
@@ -7,7 +7,7 @@ Tags: switcher, theme, ipad, iphone, android, tablet, mobile, game
7
  Requires at least: 3.7
8
  Requires PHP: 5.4
9
  Tested up to: 4.9
10
- Stable tag: 1.6.1
11
  License: GPL2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
@@ -356,6 +356,10 @@ For more information about the Multi Device Switcher Command, see `wp help multi
356
 
357
  == Changelog ==
358
 
 
 
 
 
359
  = 1.6.1 =
360
  * add test cases
361
  * add add_header_vary filter
7
  Requires at least: 3.7
8
  Requires PHP: 5.4
9
  Tested up to: 4.9
10
+ Stable tag: 1.6.2
11
  License: GPL2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
356
 
357
  == Changelog ==
358
 
359
+ = 1.6.2 =
360
+ * add prefix into hook tag, change tag name from add_header_vary to multi_device_switcher_add_header_vary
361
+ * for php5.3, change called function via hook from anonymous function to public function
362
+
363
  = 1.6.1 =
364
  * add test cases
365
  * add add_header_vary filter