Multi Device Switcher - Version 1.1.0

Version Description

  • new features: Custom Switcher
Download this release

Release Info

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

Code changes from version 1.0.4 to 1.1.0

languages/multi-device-switcher-ja.mo CHANGED
Binary file
languages/multi-device-switcher-ja.po CHANGED
@@ -3,7 +3,7 @@ msgstr ""
3
  "Project-Id-Version: Multi Device Switcher\n"
4
  "Report-Msgid-Bugs-To: \n"
5
  "POT-Creation-Date: 2012-01-17 22:01+0900\n"
6
- "PO-Revision-Date: 2012-03-04 15:57+0900\n"
7
  "Last-Translator: thingsym <thingsym@gmail.com>\n"
8
  "Language-Team: \n"
9
  "MIME-Version: 1.0\n"
@@ -31,6 +31,15 @@ msgstr "携帯モバイル端末用テーマ"
31
  msgid "Game Platforms Theme"
32
  msgstr "ゲームプラットフォーム用テーマ"
33
 
 
 
 
 
 
 
 
 
 
34
  msgid "Smart Phone"
35
  msgstr "スマートフォン"
36
 
@@ -46,6 +55,18 @@ msgstr "ゲームプラットフォーム"
46
  msgid "Reset Settings to Default UserAgent"
47
  msgstr "ユーザーエージェントをデフォルトにもどす"
48
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  msgid "Donationware"
50
  msgstr "ドネーションウェア (寄付)"
51
 
3
  "Project-Id-Version: Multi Device Switcher\n"
4
  "Report-Msgid-Bugs-To: \n"
5
  "POT-Creation-Date: 2012-01-17 22:01+0900\n"
6
+ "PO-Revision-Date: 2012-07-17 16:39+0900\n"
7
  "Last-Translator: thingsym <thingsym@gmail.com>\n"
8
  "Language-Team: \n"
9
  "MIME-Version: 1.0\n"
31
  msgid "Game Platforms Theme"
32
  msgstr "ゲームプラットフォーム用テーマ"
33
 
34
+ msgid "Custom Switcher Theme"
35
+ msgstr "Custom Switcher用テーマ"
36
+
37
+ msgid "20 characters max, alphanumeric"
38
+ msgstr "半角英数字 20 文字以内"
39
+
40
+ msgid "Enter Comma-separated values (csv) format."
41
+ msgstr "csv 形式で入力してください。"
42
+
43
  msgid "Smart Phone"
44
  msgstr "スマートフォン"
45
 
55
  msgid "Reset Settings to Default UserAgent"
56
  msgstr "ユーザーエージェントをデフォルトにもどす"
57
 
58
+ msgid "Add Custom Switcher"
59
+ msgstr "Custom Switcher を追加"
60
+
61
+ msgid "Add"
62
+ msgstr "追加"
63
+
64
+ msgid "Delete"
65
+ msgstr "削除"
66
+
67
+ msgid "Are you sure you want to delete %1$s ?"
68
+ msgstr "%1$s を削除してよろしいですか?"
69
+
70
  msgid "Donationware"
71
  msgstr "ドネーションウェア (寄付)"
72
 
languages/multi-device-switcher.pot CHANGED
@@ -3,7 +3,7 @@ msgstr ""
3
  "Project-Id-Version: Multi Device Switcher\n"
4
  "Report-Msgid-Bugs-To: \n"
5
  "POT-Creation-Date: 2012-01-17 22:01+0900\n"
6
- "PO-Revision-Date: 2012-01-17 19:19+0900\n"
7
  "Last-Translator: \n"
8
  "Language-Team: \n"
9
  "MIME-Version: 1.0\n"
@@ -31,6 +31,15 @@ msgstr ""
31
  msgid "Game Platforms Theme"
32
  msgstr ""
33
 
 
 
 
 
 
 
 
 
 
34
  msgid "Smart Phone"
35
  msgstr ""
36
 
@@ -46,6 +55,18 @@ msgstr ""
46
  msgid "Reset Settings to Default UserAgent"
47
  msgstr ""
48
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  msgid "Donationware"
50
  msgstr ""
51
 
3
  "Project-Id-Version: Multi Device Switcher\n"
4
  "Report-Msgid-Bugs-To: \n"
5
  "POT-Creation-Date: 2012-01-17 22:01+0900\n"
6
+ "PO-Revision-Date: 2012-07-11 0:23+0900\n"
7
  "Last-Translator: \n"
8
  "Language-Team: \n"
9
  "MIME-Version: 1.0\n"
31
  msgid "Game Platforms Theme"
32
  msgstr ""
33
 
34
+ msgid "Custom Switcher Theme"
35
+ msgstr ""
36
+
37
+ msgid "20 characters max, alphanumeric"
38
+ msgstr ""
39
+
40
+ msgid "Enter Comma-separated values (csv) format."
41
+ msgstr ""
42
+
43
  msgid "Smart Phone"
44
  msgstr ""
45
 
55
  msgid "Reset Settings to Default UserAgent"
56
  msgstr ""
57
 
58
+ msgid "Add Custom Switcher"
59
+ msgstr ""
60
+
61
+ msgid "Add"
62
+ msgstr ""
63
+
64
+ msgid "Delete"
65
+ msgstr ""
66
+
67
+ msgid "Are you sure you want to delete %1$s ?"
68
+ msgstr ""
69
+
70
  msgid "Donationware"
71
  msgstr ""
72
 
multi-device-switcher.php CHANGED
@@ -2,8 +2,8 @@
2
  /*
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).
6
- Version: 1.0.4
7
  Author: thingsym
8
  Author URI: http://www.thingslabo.com/
9
  License: GPL2
@@ -32,6 +32,7 @@ class Multi_Device_Switcher {
32
  public function __construct() {
33
 
34
  $userAgent = $this->get_options_userAgent();
 
35
 
36
  if ( $userAgent['smart'] && preg_match( '/' . implode( '|', $userAgent['smart'] ) . '/i', $_SERVER['HTTP_USER_AGENT']) ) {
37
  $this->device = 'smart';
@@ -46,7 +47,14 @@ class Multi_Device_Switcher {
46
  $this->device = 'game';
47
  }
48
  else {
49
- $this->device = '';
 
 
 
 
 
 
 
50
  }
51
 
52
  if ($this->device) {
@@ -77,6 +85,16 @@ class Multi_Device_Switcher {
77
  if ( $options['userAgent_game'] )
78
  $userAgent['game'] = preg_split( "/,\s*/", $options['userAgent_game'] );
79
 
 
 
 
 
 
 
 
 
 
 
80
  return $userAgent;
81
  }
82
 
@@ -141,6 +159,18 @@ class Multi_Device_Switcher {
141
  elseif ($this->device == 'game') {
142
  return $options['theme_game'];
143
  }
 
 
 
 
 
 
 
 
 
 
 
 
144
 
145
  return;
146
  }
@@ -453,10 +483,72 @@ function multi_device_switcher_render_page() {
453
  </td>
454
  </tr>
455
  </table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
456
  </fieldset>
457
 
458
  <fieldset id="UserAgent" class="options">
459
  <h3 class="label"><?php _e( 'UserAgent', 'multi-device-switcher' ); ?></h3>
 
 
460
  <table class="form-table">
461
  <tr><th scope="row"><?php _e( 'Smart Phone', 'multi-device-switcher' ); ?></th>
462
  <td><textarea name="multi_device_switcher_options[userAgent_smart]" rows="4" cols="42"><?php echo $options['userAgent_smart']; ?></textarea></td>
@@ -471,8 +563,26 @@ function multi_device_switcher_render_page() {
471
  <td><textarea name="multi_device_switcher_options[userAgent_game]" rows="4" cols="42"><?php echo $options['userAgent_game']; ?></textarea></td>
472
  </tr>
473
  <tr><th></th>
474
- <td><p class="submit"><input type="submit" name="multi_device_switcher_options[restore_UserAgent]" value="<?php _e( 'Reset Settings to Default UserAgent', 'multi-device-switcher' ); ?>"></p></td>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
475
  </tr>
 
 
 
 
476
  </table>
477
  </fieldset>
478
  </div>
@@ -545,6 +655,35 @@ function multi_device_switcher_validate( $input ) {
545
  $output['userAgent_game'] = $input['userAgent_game'];
546
  }
547
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
548
  return apply_filters( 'multi_device_switcher_validate', $output, $input, $default_options );
549
  }
550
 
2
  /*
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.0
7
  Author: thingsym
8
  Author URI: http://www.thingslabo.com/
9
  License: GPL2
32
  public function __construct() {
33
 
34
  $userAgent = $this->get_options_userAgent();
35
+ $this->device = '';
36
 
37
  if ( $userAgent['smart'] && preg_match( '/' . implode( '|', $userAgent['smart'] ) . '/i', $_SERVER['HTTP_USER_AGENT']) ) {
38
  $this->device = 'smart';
47
  $this->device = 'game';
48
  }
49
  else {
50
+ foreach ( $userAgent as $key => $val ) {
51
+ if ( ! preg_match( "/^custom_switcher_/", $key ) )
52
+ continue;
53
+ if ($userAgent[$key] && preg_match( '/' . implode( '|', $userAgent[$key] ) . '/i', $_SERVER['HTTP_USER_AGENT']) ) {
54
+ $this->device = $key;
55
+ break;
56
+ }
57
+ }
58
  }
59
 
60
  if ($this->device) {
85
  if ( $options['userAgent_game'] )
86
  $userAgent['game'] = preg_split( "/,\s*/", $options['userAgent_game'] );
87
 
88
+ foreach ( $options as $key => $val ) {
89
+ if ( ! preg_match( "/^custom_switcher_userAgent_/", $key ) )
90
+ continue;
91
+
92
+ $custom_switcher_name = preg_replace("/^custom_switcher_userAgent_/", '', $key);
93
+
94
+ if ($val)
95
+ $userAgent['custom_switcher_' . $custom_switcher_name] = preg_split( "/,\s*/", $val );
96
+ }
97
+
98
  return $userAgent;
99
  }
100
 
159
  elseif ($this->device == 'game') {
160
  return $options['theme_game'];
161
  }
162
+ else {
163
+ foreach ( $options as $key => $val ) {
164
+ if ( ! preg_match( "/^custom_switcher_theme_/", $key ) )
165
+ continue;
166
+
167
+ $custom_switcher_name = preg_replace("/^custom_switcher_theme_/", '', $key);
168
+
169
+ if ($this->device == 'custom_switcher_' . $custom_switcher_name) {
170
+ return $options[$key];
171
+ }
172
+ }
173
+ }
174
 
175
  return;
176
  }
483
  </td>
484
  </tr>
485
  </table>
486
+
487
+ <h3><?php _e( 'Custom Switcher Theme', 'multi-device-switcher' ); ?></h3>
488
+ <table class="form-table">
489
+
490
+ <?php
491
+ foreach ( $options as $key => $val ) {
492
+ if ( ! preg_match( "/^custom_switcher_theme_/", $key ) )
493
+ continue;
494
+
495
+ $custom_switcher_name = preg_replace("/^custom_switcher_theme_/", '', $key);
496
+ $custom_switcher_option = $key;
497
+ $custom_switcher_theme = $val;
498
+ ?>
499
+
500
+ <tr><th scope="row"><?php _e( $custom_switcher_name, 'multi-device-switcher' ); ?></th>
501
+ <td>
502
+
503
+ <?php
504
+ if (count($theme_names)) {
505
+ $html = '<select name="multi_device_switcher_options[' . $custom_switcher_option . ']">';
506
+
507
+ if (($custom_switcher_theme == 'None') || ($custom_switcher_theme == '')) {
508
+ $html .= '<option value="None" selected="selected">None</option>';
509
+ }
510
+ else {
511
+ $html .= '<option value="None">None</option>';
512
+ }
513
+
514
+ foreach ($theme_names as $theme_name) {
515
+ if ($default_theme == $theme_name)
516
+ continue;
517
+ if ($custom_switcher_theme == $theme_name) {
518
+ $html .= '<option value="' . $theme_name . '" selected="selected">' . htmlspecialchars($theme_name) . '</option>';
519
+ }
520
+ else {
521
+ $html .= '<option value="' . $theme_name . '">' . htmlspecialchars($theme_name) . '</option>';
522
+ }
523
+ }
524
+ $html .= '</select>';
525
+ $html .= '<span class="submit"><input type="submit" name="multi_device_switcher_options[delete_custom_switcher_' . $custom_switcher_name . ']" value="' . __( 'Delete', 'multi-device-switcher' ) . '" onclick="return confirm(\'' . sprintf( __( 'Are you sure you want to delete %1$s ?', 'multi-device-switcher' ), $custom_switcher_name ) . '\');""></span>';
526
+ }
527
+ echo $html;
528
+ ?>
529
+ </td>
530
+ </tr>
531
+
532
+ <?php
533
+ }
534
+ ?>
535
+
536
+ <tr><th scope="row"><?php _e( 'Add Custom Switcher', 'multi-device-switcher' ); ?></th>
537
+ <td>
538
+ <fieldset><legend class="screen-reader-text"><span><?php _e( 'Add Custom Switcher', 'thingscms' ); ?></span></legend>
539
+ <input type="text" name="multi_device_switcher_options[custom_switcher]" id="custom-switcher" value="" size="24" />
540
+ <span class="submit"><input type="submit" name="multi_device_switcher_options[add_custom_switcher]" value="<?php _e( 'Add', 'multi-device-switcher' ); ?>"></span><br>
541
+ <?php _e( '20 characters max, alphanumeric', 'multi-device-switcher' ); ?>
542
+ </td>
543
+ </tr>
544
+ </table>
545
+
546
  </fieldset>
547
 
548
  <fieldset id="UserAgent" class="options">
549
  <h3 class="label"><?php _e( 'UserAgent', 'multi-device-switcher' ); ?></h3>
550
+ <p><?php _e( 'Enter Comma-separated values (csv) format.', 'multi-device-switcher' ); ?></p>
551
+
552
  <table class="form-table">
553
  <tr><th scope="row"><?php _e( 'Smart Phone', 'multi-device-switcher' ); ?></th>
554
  <td><textarea name="multi_device_switcher_options[userAgent_smart]" rows="4" cols="42"><?php echo $options['userAgent_smart']; ?></textarea></td>
563
  <td><textarea name="multi_device_switcher_options[userAgent_game]" rows="4" cols="42"><?php echo $options['userAgent_game']; ?></textarea></td>
564
  </tr>
565
  <tr><th></th>
566
+ <td><span class="submit"><input type="submit" name="multi_device_switcher_options[restore_UserAgent]" value="<?php _e( 'Reset Settings to Default UserAgent', 'multi-device-switcher' ); ?>"></span></td>
567
+ </tr>
568
+
569
+ <?php
570
+ foreach ( $options as $key => $val ) {
571
+ if ( ! preg_match( "/^custom_switcher_userAgent_/", $key ) )
572
+ continue;
573
+
574
+ $custom_switcher_name = preg_replace("/^custom_switcher_userAgent_/", '', $key);
575
+ $custom_switcher_option = $key;
576
+ $custom_switcher_userAgent = $val;
577
+ ?>
578
+
579
+ <tr><th scope="row"><?php _e( $custom_switcher_name, 'multi-device-switcher' ); ?></th>
580
+ <td><textarea name="multi_device_switcher_options[<?php echo $custom_switcher_option; ?>]" rows="4" cols="42"><?php echo $custom_switcher_userAgent; ?></textarea></td>
581
  </tr>
582
+ <?php
583
+ }
584
+ ?>
585
+
586
  </table>
587
  </fieldset>
588
  </div>
655
  $output['userAgent_game'] = $input['userAgent_game'];
656
  }
657
 
658
+ foreach ( $input as $key => $val ) {
659
+ if ( ! preg_match( "/^custom_switcher_theme_/", $key ) )
660
+ continue;
661
+
662
+ $custom_switcher_name = preg_replace("/^custom_switcher_theme_/", '', $key);
663
+
664
+ if ( isset( $input['custom_switcher_theme_' . $custom_switcher_name] ) )
665
+ $output['custom_switcher_theme_' . $custom_switcher_name] = $input['custom_switcher_theme_' . $custom_switcher_name];
666
+ if ( isset( $input['custom_switcher_userAgent_' . $custom_switcher_name] ) )
667
+ $output['custom_switcher_userAgent_' . $custom_switcher_name] = $input['custom_switcher_userAgent_' . $custom_switcher_name];
668
+ }
669
+
670
+ foreach ( $input as $key => $val ) {
671
+ if ( ! preg_match( "/^delete_custom_switcher_/", $key ) )
672
+ continue;
673
+
674
+ $custom_switcher_name = preg_replace("/^delete_custom_switcher_/", '', $key);
675
+
676
+ unset($output['custom_switcher_theme_' . $custom_switcher_name]);
677
+ unset($output['custom_switcher_userAgent_' . $custom_switcher_name]);
678
+ }
679
+
680
+ if ( isset( $input['add_custom_switcher'] ) && ! empty( $input['custom_switcher'] ) && ! $output['custom_switcher_theme_' . $input['custom_switcher']] ) {
681
+ if ( preg_match( "/^[A-Za-z0-9]{1,20}$/", $input['custom_switcher'] ) ) {
682
+ $output['custom_switcher_theme_' . $input['custom_switcher']] = 'None';
683
+ $output['custom_switcher_userAgent_' . $input['custom_switcher']] = '';
684
+ }
685
+ }
686
+
687
  return apply_filters( 'multi_device_switcher_validate', $output, $input, $default_options );
688
  }
689
 
readme.md CHANGED
@@ -1,7 +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).
4
  This plugin detects if your site is being viewed by UserAgent and switches to selected theme.
 
5
 
6
  ## How do I use it?
7
 
@@ -13,8 +14,17 @@ This plugin detects if your site is being viewed by UserAgent and switches to se
13
  6. Configure settings to your needs. Select Theme by Theme option. Add and fix UserAgent by UserAgent option if necessary.
14
  7. Have fun!
15
 
 
 
 
 
 
 
 
16
  ## Changelog
17
 
 
 
18
  * Version 1.0.4
19
  * fixed: fix the object model PHP5, __construct() to replace Multi_Device_Switcher
20
  * fixed: wp_get_themes(), and wp_get_theme() to replace get_themes(), get_theme()
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 to every device.
6
 
7
  ## How do I use it?
8
 
14
  6. Configure settings to your needs. Select Theme by Theme option. Add and fix UserAgent by UserAgent option if necessary.
15
  7. Have fun!
16
 
17
+ ## How to add the Custom Switcher
18
+
19
+ 1. Go to the "Multi Device Switcher" options page through the 'Appearance' menu in WordPress.
20
+ 2. Enter the name of the Custom Switcher (20 characters max, alphanumeric) to the 'Add Custom Switcher'. Push the button 'Add'.
21
+ 3. Configure settings. Select Theme by Theme option. Add UserAgent by UserAgent option.
22
+ 4. Have fun!
23
+
24
  ## Changelog
25
 
26
+ * Version 1.1.0
27
+ * new features: Custom Switcher
28
  * Version 1.0.4
29
  * fixed: fix the object model PHP5, __construct() to replace Multi_Device_Switcher
30
  * fixed: wp_get_themes(), and wp_get_theme() to replace get_themes(), get_theme()
readme.txt CHANGED
@@ -6,16 +6,17 @@ 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.1
9
- Stable tag: 1.0.4
10
  License: GPL2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
13
- This WordPress plugin allows you to set a separate theme for device (Smart Phone, Tablet PC, Mobile Phone, Game).
14
 
15
  == Description ==
16
 
17
- This WordPress plugin allows you to set a separate theme for device (Smart Phone, Tablet PC, Mobile Phone, Game).
18
  This plugin detects if your site is being viewed by UserAgent and switches to selected theme.
 
19
 
20
  == Screenshots ==
21
 
@@ -32,8 +33,17 @@ This plugin detects if your site is being viewed by UserAgent and switches to se
32
  6. Configure settings to your needs. Select Theme by Theme option. Add and fix UserAgent by UserAgent option if necessary.
33
  7. Have fun!
34
 
 
 
 
 
 
 
 
35
  == Changelog ==
36
 
 
 
37
  = 1.0.4 =
38
  * fixed: fix the object model PHP5, __construct() to replace Multi_Device_Switcher
39
  * fixed: wp_get_themes(), and wp_get_theme() to replace get_themes(), get_theme()
6
  Tags: switcher, theme, ipad, iphone, android, tablet, mobile, game
7
  Requires at least: 3.2.1
8
  Tested up to: 3.4.1
9
+ Stable tag: 1.1.0
10
  License: GPL2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
13
+ This WordPress plugin allows you to set a separate theme for device (Smart Phone, Tablet PC, Mobile Phone, Game and custom).
14
 
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 to every device.
20
 
21
  == Screenshots ==
22
 
33
  6. Configure settings to your needs. Select Theme by Theme option. Add and fix UserAgent by UserAgent option if necessary.
34
  7. Have fun!
35
 
36
+ = How to add the Custom Switcher =
37
+
38
+ 1. Go to the "Multi Device Switcher" options page through the 'Appearance' menu in WordPress.
39
+ 2. Enter the name of the Custom Switcher (20 characters max, alphanumeric) to the 'Add Custom Switcher'. Push the button 'Add'.
40
+ 3. Configure settings. Select Theme by Theme option. Add UserAgent by UserAgent option.
41
+ 4. Have fun!
42
+
43
  == Changelog ==
44
 
45
+ = 1.1.0 =
46
+ * new features: Custom Switcher
47
  = 1.0.4 =
48
  * fixed: fix the object model PHP5, __construct() to replace Multi_Device_Switcher
49
  * fixed: wp_get_themes(), and wp_get_theme() to replace get_themes(), get_theme()
screenshot-1.png CHANGED
Binary file
screenshot-2.png CHANGED
Binary file