Multi Device Switcher - Version 1.3.0

Version Description

  • fixed: fix script, style, html and readme
  • new features: is_multi_device() function
  • fixed: fix translation
  • updated: update default UserAgent
  • fixed: replace WP_PLUGIN_URL with plugins_url()
  • fixed: using Page Hook Suffix
  • merged: pull request #3
Download this release

Release Info

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

Code changes from version 1.2.3 to 1.3.0

languages/multi-device-switcher-ja.mo CHANGED
Binary file
languages/multi-device-switcher-ja.po CHANGED
@@ -3,9 +3,10 @@ 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: 2014-04-20 16:40+0900\n"
7
  "Last-Translator: \n"
8
- "Language-Team: \n"
 
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
@@ -13,6 +14,9 @@ msgstr ""
13
  msgid "Multi Device Switcher"
14
  msgstr "マルチデバイス"
15
 
 
 
 
16
  msgid "Settings"
17
  msgstr "設定"
18
 
@@ -101,6 +105,9 @@ msgid "If you like this plugin, please donate to support development and mainten
101
  msgstr "よろしければ、開発とメンテナンスのために寄付していただければうれしいです。"
102
 
103
  # pc-switcher-widget.php
 
 
 
104
  msgid "Add the PC Switcher to a widget."
105
  msgstr "PC Switcher をウィジェットに追加"
106
 
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: 2014-09-11 20:02+0900\n"
7
  "Last-Translator: \n"
8
+ "Language-Team: Thingsym\n"
9
+ "Language: ja_JP\n"
10
  "MIME-Version: 1.0\n"
11
  "Content-Type: text/plain; charset=UTF-8\n"
12
  "Content-Transfer-Encoding: 8bit\n"
14
  msgid "Multi Device Switcher"
15
  msgstr "マルチデバイス"
16
 
17
+ msgid "This WordPress plugin allows you to set a separate theme for device (Smart Phone, Tablet PC, Mobile Phone, Game and custom)."
18
+ msgstr "デバイスごとに個別のテーマを設定して自動的にテーマが切り替わります。 (スマートフォン、タブレット端末、携帯モバイル、ゲーム、カスタム設定に対応)"
19
+
20
  msgid "Settings"
21
  msgstr "設定"
22
 
105
  msgstr "よろしければ、開発とメンテナンスのために寄付していただければうれしいです。"
106
 
107
  # pc-switcher-widget.php
108
+ msgid "PC Switcher Widget add-on for the Multi Device Switcher. Use this widget to add the PC Switcher to a widget."
109
+ msgstr ""
110
+
111
  msgid "Add the PC Switcher to a widget."
112
  msgstr "PC Switcher をウィジェットに追加"
113
 
languages/multi-device-switcher.pot CHANGED
@@ -6,6 +6,7 @@ msgstr ""
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"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
@@ -13,6 +14,9 @@ msgstr ""
13
  msgid "Multi Device Switcher"
14
  msgstr ""
15
 
 
 
 
16
  msgid "Settings"
17
  msgstr ""
18
 
@@ -101,5 +105,8 @@ msgid "If you like this plugin, please donate to support development and mainten
101
  msgstr ""
102
 
103
  # pc-switcher-widget.php
 
 
 
104
  msgid "Add the PC Switcher to a widget."
105
  msgstr ""
6
  "PO-Revision-Date: 2012-07-11 0:23+0900\n"
7
  "Last-Translator: \n"
8
  "Language-Team: \n"
9
+ "Language: \n"
10
  "MIME-Version: 1.0\n"
11
  "Content-Type: text/plain; charset=UTF-8\n"
12
  "Content-Transfer-Encoding: 8bit\n"
14
  msgid "Multi Device Switcher"
15
  msgstr ""
16
 
17
+ msgid "This WordPress plugin allows you to set a separate theme for device (Smart Phone, Tablet PC, Mobile Phone, Game and custom)."
18
+ msgstr ""
19
+
20
  msgid "Settings"
21
  msgstr ""
22
 
105
  msgstr ""
106
 
107
  # pc-switcher-widget.php
108
+ msgid "PC Switcher Widget add-on for the Multi Device Switcher. Use this widget to add the PC Switcher to a widget."
109
+ msgstr ""
110
+
111
  msgid "Add the PC Switcher to a widget."
112
  msgstr ""
multi-device-switcher.js CHANGED
@@ -1,11 +1,14 @@
1
- jQuery(document).ready(function(){
2
- if (! jQuery('#admin-tabs').length) return;
3
- jQuery('#admin-tabs').prepend('<ul><\/ul>');
4
- jQuery('#admin-tabs > fieldset').each(function (i) {
5
- id = jQuery(this).attr('id');
6
- caption = jQuery(this).find('h3.label').text();
7
- jQuery('#admin-tabs > ul').append('<li><a href="#'+id+'"><span>'+caption+'<\/span><\/a><\/li>');
8
- });
9
 
10
- jQuery('#admin-tabs').tabs();
11
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
 
2
+ (function($) {
3
+ $(function() {
4
+ if ( !$('#admin-tabs').length ) return;
5
+ $('#admin-tabs').prepend('<ul><\/ul>');
6
+ $('#admin-tabs > fieldset').each(function (i) {
7
+ id = $(this).attr('id');
8
+ caption = $(this).find('h3.label').text();
9
+ $('#admin-tabs > ul').append('<li><a href="#' + id + '"><span>' + caption + '<\/span><\/a><\/li>');
10
+ });
11
+
12
+ $('#admin-tabs').tabs();
13
+ });
14
+ })(jQuery);
multi-device-switcher.php CHANGED
@@ -3,10 +3,12 @@
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.2.3
7
  Author: thingsym
8
  Author URI: http://www.thingslabo.com/
9
  License: GPL2
 
 
10
  */
11
 
12
  /*
@@ -34,27 +36,28 @@ class Multi_Device_Switcher {
34
 
35
  $userAgent = $this->get_options_userAgent();
36
  $this->device = '';
 
37
 
38
  foreach ( array_reverse($userAgent) as $key => $val ) {
39
- if ( ! preg_match( "/^custom_switcher_/", $key ) )
40
  continue;
41
- if ( $userAgent[$key] && preg_match( '/' . implode( '|', $userAgent[$key] ) . '/i', $_SERVER['HTTP_USER_AGENT']) ) {
42
  $this->device = $key;
43
  break;
44
  }
45
  }
46
 
47
- if ( ! $this->device ) {
48
- if ( $userAgent['game'] && preg_match( '/' . implode( '|', $userAgent['game'] ) . '/i', $_SERVER['HTTP_USER_AGENT']) ) {
49
  $this->device = 'game';
50
  }
51
- elseif ( $userAgent['tablet'] && preg_match( '/' . implode( '|', $userAgent['tablet'] ) . '/i', $_SERVER['HTTP_USER_AGENT']) ) {
52
  $this->device = 'tablet';
53
  }
54
- elseif ( $userAgent['smart'] && preg_match( '/' . implode( '|', $userAgent['smart'] ) . '/i', $_SERVER['HTTP_USER_AGENT']) ) {
55
  $this->device = 'smart';
56
  }
57
- elseif ( $userAgent['mobile'] && preg_match( '/' . implode( '|', $userAgent['mobile'] ) . '/i', $_SERVER['HTTP_USER_AGENT']) ) {
58
  $this->device = 'mobile';
59
  }
60
  }
@@ -76,13 +79,13 @@ class Multi_Device_Switcher {
76
  $options = get_option('multi_device_switcher_options');
77
  $default_options = multi_device_switcher_get_default_options();
78
 
79
- if ( ! isset( $options['userAgent_smart'] ) )
80
  $options['userAgent_smart'] = $default_options['userAgent_smart'];
81
- if ( ! isset( $options['userAgent_tablet'] ) )
82
  $options['userAgent_tablet'] = $default_options['userAgent_tablet'];
83
- if ( ! isset( $options['userAgent_mobile'] ) )
84
  $options['userAgent_mobile'] = $default_options['userAgent_mobile'];
85
- if ( ! isset( $options['userAgent_game'] ) )
86
  $options['userAgent_game'] = $default_options['userAgent_game'];
87
 
88
  if ( $options['userAgent_smart'] )
@@ -95,12 +98,12 @@ class Multi_Device_Switcher {
95
  $userAgent['game'] = preg_split( "/,\s*/", $options['userAgent_game'] );
96
 
97
  foreach ( $options as $key => $val ) {
98
- if ( ! preg_match( "/^custom_switcher_userAgent_/", $key ) )
99
  continue;
100
 
101
  $custom_switcher_name = preg_replace("/^custom_switcher_userAgent_/", '', $key);
102
 
103
- if ($val)
104
  $userAgent['custom_switcher_' . $custom_switcher_name] = preg_split( "/,\s*/", $val );
105
  }
106
 
@@ -110,7 +113,7 @@ class Multi_Device_Switcher {
110
  public function get_stylesheet($stylesheet = '') {
111
  $name = $this->get_device_theme();
112
 
113
- if ( empty($name) )
114
  return $stylesheet;
115
 
116
  $themes = wp_get_themes();
@@ -121,7 +124,7 @@ class Multi_Device_Switcher {
121
  }
122
  }
123
 
124
- if ( empty($theme) )
125
  return $stylesheet;
126
 
127
  if ( $theme->get('Status') != 'publish' )
@@ -170,7 +173,7 @@ class Multi_Device_Switcher {
170
  }
171
  else {
172
  foreach ( $options as $key => $val ) {
173
- if ( ! preg_match( "/^custom_switcher_theme_/", $key ) )
174
  continue;
175
 
176
  $custom_switcher_name = preg_replace("/^custom_switcher_theme_/", '', $key);
@@ -190,8 +193,8 @@ class Multi_Device_Switcher {
190
 
191
  $uri = preg_replace( '/^(.+?)(\?.*)$/', '$1', $_SERVER['REQUEST_URI'] );
192
 
193
- unset($_GET['pc-switcher']);
194
- if ( ! empty($_GET) )
195
  $uri = $uri . '?' . http_build_query($_GET);
196
 
197
  wp_redirect( esc_attr($uri) );
@@ -203,12 +206,12 @@ class Multi_Device_Switcher {
203
  $options = get_option('multi_device_switcher_options');
204
  $name = $this->get_device_theme();
205
 
206
- if ($options['pc_switcher'])
207
  $pc_switcher = 1;
208
 
209
  if ( $pc_switcher && $name && $name != 'None' ) {
210
- if ($options['default_css'])
211
- wp_enqueue_style( 'pc-switcher-options', WP_PLUGIN_URL . '/multi-device-switcher/pc-switcher.css', false, '2013-03-20' );
212
 
213
  if ( isset($_COOKIE['pc-switcher']) ) {
214
  $uri = add_query_arg( 'pc-switcher', 0 );
@@ -224,9 +227,18 @@ class Multi_Device_Switcher {
224
  }
225
  }
226
  }
 
 
 
 
 
 
 
 
 
227
  }
228
 
229
- if ( ! is_admin() )
230
  $multi_device_switcher = new Multi_Device_Switcher();
231
 
232
  /**
@@ -236,7 +248,7 @@ if ( ! is_admin() )
236
  *
237
  */
238
  function multi_device_switcher_add_header_vary( $headers ) {
239
- if ( ! is_admin() ) {
240
  $headers['Vary'] = 'User-Agent';
241
  return $headers;
242
  }
@@ -254,6 +266,20 @@ function multi_device_switcher_add_pc_switcher() {
254
  $multi_device_switcher->add_pc_switcher(1);
255
  }
256
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
257
  /**
258
  * Properly enqueue scripts for our multi_device_switcher options page.
259
  *
@@ -263,8 +289,7 @@ function multi_device_switcher_add_pc_switcher() {
263
  *
264
  */
265
  function multi_device_switcher_admin_enqueue_scripts( $hook_suffix ) {
266
- wp_enqueue_script( 'jquery-ui-tabs' );
267
- wp_enqueue_script( 'multi-device-switcher-options', WP_PLUGIN_URL . '/multi-device-switcher/multi-device-switcher.js', array( 'jquery' ), '2011-08-22' );
268
  }
269
 
270
  /**
@@ -276,8 +301,7 @@ function multi_device_switcher_admin_enqueue_scripts( $hook_suffix ) {
276
  *
277
  */
278
  function multi_device_switcher_admin_enqueue_styles( $hook_suffix ) {
279
- wp_enqueue_style( 'multi-device-switcher-options', WP_PLUGIN_URL . '/multi-device-switcher/multi-device-switcher.css', false, '2011-08-22' );
280
- wp_enqueue_style( 'thickbox', includes_url() . '/js/thickbox/thickbox.css', false, '20090514' );
281
  }
282
 
283
  /**
@@ -335,7 +359,7 @@ function multi_device_switcher_add_page() {
335
 
336
  add_filter( 'plugin_action_links', 'multi_device_switcher_plugin_action_links', 10, 2 );
337
 
338
- $theme_page = add_theme_page(
339
  __( 'Multi Device Switcher', 'multi-device-switcher' ), // Name of page
340
  __( 'Multi Device Switcher', 'multi-device-switcher' ), // Label in menu
341
  'manage_options', // Capability required
@@ -343,14 +367,25 @@ function multi_device_switcher_add_page() {
343
  'multi_device_switcher_render_page' // Function that renders the options page
344
  );
345
 
346
- if ( ! $theme_page )
347
  return;
348
 
349
- add_action( "admin_print_scripts-$theme_page", 'multi_device_switcher_admin_enqueue_scripts' );
350
- add_action( "admin_print_styles-$theme_page", 'multi_device_switcher_admin_enqueue_styles' );
351
  }
352
  add_action( 'admin_menu', 'multi_device_switcher_add_page' );
353
 
 
 
 
 
 
 
 
 
 
 
 
 
354
  /**
355
  * Add the settings link to the plugin page.
356
  *
@@ -383,7 +418,7 @@ function multi_device_switcher_get_default_options() {
383
  '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',
384
  'userAgent_tablet' => 'iPad, Kindle, Sony Tablet, Nexus 7',
385
  'userAgent_mobile' => 'DoCoMo, SoftBank, J-PHONE, Vodafone, KDDI, UP.Browser, WILLCOM, emobile, DDIPOCKET, Windows CE, BlackBerry, Symbian, PalmOS, Huawei, IAC, Nokia',
386
- 'userAgent_game' => 'PlayStation Portable, PlayStation Vita, PSP, PS2, PLAYSTATION 3, Nitro, Nintendo 3DS, Nintendo Wii, Xbox',
387
  );
388
 
389
  return $default_theme_options;
@@ -398,27 +433,27 @@ function multi_device_switcher_get_options() {
398
  $options = get_option( 'multi_device_switcher_options' );
399
  $default_options = multi_device_switcher_get_default_options();
400
 
401
- if ( ! isset( $options['pc_switcher'] ) )
402
  $options['pc_switcher'] = $default_options['pc_switcher'];
403
- if ( ! isset( $options['default_css'] ) )
404
  $options['default_css'] = $default_options['default_css'];
405
 
406
- if ( ! isset( $options['theme_smartphone'] ) )
407
  $options['theme_smartphone'] = $default_options['theme_smartphone'];
408
- if ( ! isset( $options['theme_tablet'] ) )
409
  $options['theme_tablet'] = $default_options['theme_tablet'];
410
- if ( ! isset( $options['theme_mobile'] ) )
411
  $options['theme_mobile'] = $default_options['theme_mobile'];
412
- if ( ! isset( $options['theme_game'] ) )
413
  $options['theme_game'] = $default_options['theme_game'];
414
 
415
- if ( ! isset( $options['userAgent_smart'] ) )
416
  $options['userAgent_smart'] = $default_options['userAgent_smart'];
417
- if ( ! isset( $options['userAgent_tablet'] ) )
418
  $options['userAgent_tablet'] = $default_options['userAgent_tablet'];
419
- if ( ! isset( $options['userAgent_mobile'] ) )
420
  $options['userAgent_mobile'] = $default_options['userAgent_mobile'];
421
- if ( ! isset( $options['userAgent_game'] ) )
422
  $options['userAgent_game'] = $default_options['userAgent_game'];
423
 
424
  return $options;
@@ -472,7 +507,7 @@ function multi_device_switcher_render_page() {
472
  }
473
 
474
  foreach ( $theme_names as $theme_name ) {
475
- if ( $default_theme == $theme_name )
476
  continue;
477
  if ( $options['theme_smartphone'] == $theme_name ) {
478
  $html .= '<option value="' . $theme_name . '" selected="selected">' . htmlspecialchars($theme_name) . '</option>';
@@ -502,7 +537,7 @@ function multi_device_switcher_render_page() {
502
  }
503
 
504
  foreach ( $theme_names as $theme_name ) {
505
- if ( $default_theme == $theme_name )
506
  continue;
507
  if ( $options['theme_tablet'] == $theme_name ) {
508
  $html .= '<option value="' . $theme_name . '" selected="selected">' . htmlspecialchars($theme_name) . '</option>';
@@ -532,7 +567,7 @@ function multi_device_switcher_render_page() {
532
  }
533
 
534
  foreach ( $theme_names as $theme_name ) {
535
- if ( $default_theme == $theme_name )
536
  continue;
537
  if ( $options['theme_mobile'] == $theme_name ) {
538
  $html .= '<option value="' . $theme_name . '" selected="selected">' . htmlspecialchars($theme_name) . '</option>';
@@ -562,7 +597,7 @@ function multi_device_switcher_render_page() {
562
  }
563
 
564
  foreach ( $theme_names as $theme_name ) {
565
- if ( $default_theme == $theme_name )
566
  continue;
567
  if ( $options['theme_game'] == $theme_name ) {
568
  $html .= '<option value="' . $theme_name . '" selected="selected">' . htmlspecialchars($theme_name) . '</option>';
@@ -584,7 +619,7 @@ function multi_device_switcher_render_page() {
584
 
585
  <?php
586
  foreach ( $options as $key => $val ) {
587
- if ( ! preg_match( "/^custom_switcher_theme_/", $key ) )
588
  continue;
589
 
590
  $custom_switcher_name = preg_replace("/^custom_switcher_theme_/", '', $key);
@@ -607,7 +642,7 @@ function multi_device_switcher_render_page() {
607
  }
608
 
609
  foreach ( $theme_names as $theme_name ) {
610
- if ( $default_theme == $theme_name )
611
  continue;
612
  if ( $custom_switcher_theme == $theme_name ) {
613
  $html .= '<option value="' . $theme_name . '" selected="selected">' . htmlspecialchars($theme_name) . '</option>';
@@ -630,7 +665,7 @@ function multi_device_switcher_render_page() {
630
 
631
  <tr><th scope="row"><?php _e( 'Add Custom Switcher', 'multi-device-switcher' ); ?></th>
632
  <td>
633
- <fieldset><legend class="screen-reader-text"><span><?php _e( 'Add Custom Switcher', 'thingscms' ); ?></span></legend>
634
  <input type="text" name="multi_device_switcher_options[custom_switcher]" id="custom-switcher" value="" size="24">
635
  <span class="submit"><input type="submit" name="multi_device_switcher_options[add_custom_switcher]" value="<?php _e( 'Add', 'multi-device-switcher' ); ?>" class="button"></span><br>
636
  <?php _e( '20 characters max, alphanumeric', 'multi-device-switcher' ); ?>
@@ -667,7 +702,7 @@ function multi_device_switcher_render_page() {
667
  <table class="form-table">
668
  <?php
669
  foreach ( $options as $key => $val ) {
670
- if ( ! preg_match( "/^custom_switcher_userAgent_/", $key ) )
671
  continue;
672
 
673
  $custom_switcher_name = preg_replace("/^custom_switcher_userAgent_/", '', $key);
@@ -691,13 +726,13 @@ function multi_device_switcher_render_page() {
691
  <table class="form-table">
692
  <tr><th scope="row"><?php _e( 'Add PC Switcher', 'multi-device-switcher' ); ?></th>
693
  <td>
694
- <fieldset><legend class="screen-reader-text"><span><?php _e( 'Add PC Switcher', 'multi-device-switcher' ); ?></span></legend>
695
  <label><input type="checkbox" name="multi_device_switcher_options[pc_switcher]" id="pc-switcher" value="1"<?php checked(1, $options['pc_switcher']); ?>> <?php _e( 'Add a PC Switcher to the footer.', 'multi-device-switcher' ); ?></label>
696
  </td>
697
  </tr>
698
  <tr><th scope="row"><?php _e( 'Add default CSS', 'multi-device-switcher' ); ?></th>
699
  <td>
700
- <fieldset><legend class="screen-reader-text"><span><?php _e( 'Add default CSS', 'multi-device-switcher' ); ?></span></legend>
701
  <label><input type="checkbox" name="multi_device_switcher_options[default_css]" id="add-default-css" value="1"<?php checked(1, $options['default_css']); ?>> <?php _e( 'Add a default CSS.', 'multi-device-switcher' ); ?></label>
702
  </td>
703
  </tr>
@@ -775,7 +810,7 @@ function multi_device_switcher_validate( $input ) {
775
  }
776
 
777
  foreach ( $input as $key => $val ) {
778
- if ( ! preg_match( "/^custom_switcher_theme_/", $key ) )
779
  continue;
780
 
781
  $custom_switcher_name = preg_replace("/^custom_switcher_theme_/", '', $key);
@@ -787,7 +822,7 @@ function multi_device_switcher_validate( $input ) {
787
  }
788
 
789
  foreach ( $input as $key => $val ) {
790
- if ( ! preg_match( "/^delete_custom_switcher_/", $key ) )
791
  continue;
792
 
793
  $custom_switcher_name = preg_replace("/^delete_custom_switcher_/", '', $key);
@@ -796,7 +831,7 @@ function multi_device_switcher_validate( $input ) {
796
  unset($output['custom_switcher_userAgent_' . $custom_switcher_name]);
797
  }
798
 
799
- if ( isset( $input['add_custom_switcher'] ) && ! empty( $input['custom_switcher'] ) && ! $output['custom_switcher_theme_' . $input['custom_switcher']] ) {
800
  if ( preg_match( "/^[A-Za-z0-9]{1,20}$/", $input['custom_switcher'] ) ) {
801
  $output['custom_switcher_theme_' . $input['custom_switcher']] = 'None';
802
  $output['custom_switcher_userAgent_' . $input['custom_switcher']] = '';
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.3.0
7
  Author: thingsym
8
  Author URI: http://www.thingslabo.com/
9
  License: GPL2
10
+ Text Domain: multi-device-switcher
11
+ Domain Path: /languages/
12
  */
13
 
14
  /*
36
 
37
  $userAgent = $this->get_options_userAgent();
38
  $this->device = '';
39
+ $server_ua = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
40
 
41
  foreach ( array_reverse($userAgent) as $key => $val ) {
42
+ if ( !preg_match( "/^custom_switcher_/", $key ) )
43
  continue;
44
+ if ( $userAgent[$key] && preg_match( '/' . implode( '|', $userAgent[$key] ) . '/i', $server_ua) ) {
45
  $this->device = $key;
46
  break;
47
  }
48
  }
49
 
50
+ if ( !$this->device ) {
51
+ if ( $userAgent['game'] && preg_match( '/' . implode( '|', $userAgent['game'] ) . '/i', $server_ua) ) {
52
  $this->device = 'game';
53
  }
54
+ elseif ( $userAgent['tablet'] && preg_match( '/' . implode( '|', $userAgent['tablet'] ) . '/i', $server_ua) ) {
55
  $this->device = 'tablet';
56
  }
57
+ elseif ( $userAgent['smart'] && preg_match( '/' . implode( '|', $userAgent['smart'] ) . '/i', $server_ua) ) {
58
  $this->device = 'smart';
59
  }
60
+ elseif ( $userAgent['mobile'] && preg_match( '/' . implode( '|', $userAgent['mobile'] ) . '/i', $server_ua) ) {
61
  $this->device = 'mobile';
62
  }
63
  }
79
  $options = get_option('multi_device_switcher_options');
80
  $default_options = multi_device_switcher_get_default_options();
81
 
82
+ if ( !isset( $options['userAgent_smart'] ) )
83
  $options['userAgent_smart'] = $default_options['userAgent_smart'];
84
+ if ( !isset( $options['userAgent_tablet'] ) )
85
  $options['userAgent_tablet'] = $default_options['userAgent_tablet'];
86
+ if ( !isset( $options['userAgent_mobile'] ) )
87
  $options['userAgent_mobile'] = $default_options['userAgent_mobile'];
88
+ if ( !isset( $options['userAgent_game'] ) )
89
  $options['userAgent_game'] = $default_options['userAgent_game'];
90
 
91
  if ( $options['userAgent_smart'] )
98
  $userAgent['game'] = preg_split( "/,\s*/", $options['userAgent_game'] );
99
 
100
  foreach ( $options as $key => $val ) {
101
+ if ( !preg_match( "/^custom_switcher_userAgent_/", $key ) )
102
  continue;
103
 
104
  $custom_switcher_name = preg_replace("/^custom_switcher_userAgent_/", '', $key);
105
 
106
+ if ($val)
107
  $userAgent['custom_switcher_' . $custom_switcher_name] = preg_split( "/,\s*/", $val );
108
  }
109
 
113
  public function get_stylesheet($stylesheet = '') {
114
  $name = $this->get_device_theme();
115
 
116
+ if ( empty($name) )
117
  return $stylesheet;
118
 
119
  $themes = wp_get_themes();
124
  }
125
  }
126
 
127
+ if ( empty($theme) )
128
  return $stylesheet;
129
 
130
  if ( $theme->get('Status') != 'publish' )
173
  }
174
  else {
175
  foreach ( $options as $key => $val ) {
176
+ if ( !preg_match( "/^custom_switcher_theme_/", $key ) )
177
  continue;
178
 
179
  $custom_switcher_name = preg_replace("/^custom_switcher_theme_/", '', $key);
193
 
194
  $uri = preg_replace( '/^(.+?)(\?.*)$/', '$1', $_SERVER['REQUEST_URI'] );
195
 
196
+ unset( $_GET['pc-switcher'] );
197
+ if ( !empty($_GET) )
198
  $uri = $uri . '?' . http_build_query($_GET);
199
 
200
  wp_redirect( esc_attr($uri) );
206
  $options = get_option('multi_device_switcher_options');
207
  $name = $this->get_device_theme();
208
 
209
+ if ($options['pc_switcher'])
210
  $pc_switcher = 1;
211
 
212
  if ( $pc_switcher && $name && $name != 'None' ) {
213
+ if ($options['default_css'])
214
+ wp_enqueue_style( 'pc-switcher-options', plugins_url() . '/multi-device-switcher/pc-switcher.css', false, '2013-03-20' );
215
 
216
  if ( isset($_COOKIE['pc-switcher']) ) {
217
  $uri = add_query_arg( 'pc-switcher', 0 );
227
  }
228
  }
229
  }
230
+
231
+ public function is_multi_device( $device = '' ) {
232
+ if ( $this->device == $device )
233
+ return (boolean) 1;
234
+ if ( $this->device == 'custom_switcher_' . $device )
235
+ return (boolean) 1;
236
+
237
+ return (boolean) 0;
238
+ }
239
  }
240
 
241
+ if ( !is_admin() )
242
  $multi_device_switcher = new Multi_Device_Switcher();
243
 
244
  /**
248
  *
249
  */
250
  function multi_device_switcher_add_header_vary( $headers ) {
251
+ if ( !is_admin() ) {
252
  $headers['Vary'] = 'User-Agent';
253
  return $headers;
254
  }
266
  $multi_device_switcher->add_pc_switcher(1);
267
  }
268
 
269
+ /**
270
+ * Return boolean whether a particular device.
271
+ *
272
+ * @since 1.2.4
273
+ *
274
+ */
275
+ if ( !function_exists( 'is_multi_device' ) ) :
276
+
277
+ function is_multi_device( $device = '' ) {
278
+ global $multi_device_switcher;
279
+ return $multi_device_switcher->is_multi_device($device);
280
+ }
281
+ endif;
282
+
283
  /**
284
  * Properly enqueue scripts for our multi_device_switcher options page.
285
  *
289
  *
290
  */
291
  function multi_device_switcher_admin_enqueue_scripts( $hook_suffix ) {
292
+ wp_enqueue_script( 'multi-device-switcher-options', plugins_url() . '/multi-device-switcher/multi-device-switcher.js', array( 'jquery', 'jquery-ui-tabs' ), '2011-08-22' );
 
293
  }
294
 
295
  /**
301
  *
302
  */
303
  function multi_device_switcher_admin_enqueue_styles( $hook_suffix ) {
304
+ wp_enqueue_style( 'multi-device-switcher-options', plugins_url() . '/multi-device-switcher/multi-device-switcher.css', false, '2011-08-22' );
 
305
  }
306
 
307
  /**
359
 
360
  add_filter( 'plugin_action_links', 'multi_device_switcher_plugin_action_links', 10, 2 );
361
 
362
+ $page_hook = add_theme_page(
363
  __( 'Multi Device Switcher', 'multi-device-switcher' ), // Name of page
364
  __( 'Multi Device Switcher', 'multi-device-switcher' ), // Label in menu
365
  'manage_options', // Capability required
367
  'multi_device_switcher_render_page' // Function that renders the options page
368
  );
369
 
370
+ if ( !$page_hook )
371
  return;
372
 
373
+ add_action( 'load-' . $page_hook , 'multi_device_switcher_page_hook_suffix' );
 
374
  }
375
  add_action( 'admin_menu', 'multi_device_switcher_add_page' );
376
 
377
+ /**
378
+ * Page Hook Suffix
379
+ *
380
+ * This function is attached to the load-** action hook.
381
+ *
382
+ * @since 1.2.4
383
+ */
384
+ function multi_device_switcher_page_hook_suffix() {
385
+ add_action( 'admin_enqueue_scripts', 'multi_device_switcher_admin_enqueue_scripts' );
386
+ add_action( 'admin_enqueue_scripts', 'multi_device_switcher_admin_enqueue_styles' );
387
+ }
388
+
389
  /**
390
  * Add the settings link to the plugin page.
391
  *
418
  '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',
419
  'userAgent_tablet' => 'iPad, Kindle, Sony Tablet, Nexus 7',
420
  'userAgent_mobile' => 'DoCoMo, SoftBank, J-PHONE, Vodafone, KDDI, UP.Browser, WILLCOM, emobile, DDIPOCKET, Windows CE, BlackBerry, Symbian, PalmOS, Huawei, IAC, Nokia',
421
+ 'userAgent_game' => 'PlayStation Portable, PlayStation Vita, PSP, PS2, PLAYSTATION 3, PlayStation 4, Nitro, Nintendo 3DS, Nintendo Wii, Nintendo WiiU, Xbox',
422
  );
423
 
424
  return $default_theme_options;
433
  $options = get_option( 'multi_device_switcher_options' );
434
  $default_options = multi_device_switcher_get_default_options();
435
 
436
+ if ( !isset( $options['pc_switcher'] ) )
437
  $options['pc_switcher'] = $default_options['pc_switcher'];
438
+ if ( !isset( $options['default_css'] ) )
439
  $options['default_css'] = $default_options['default_css'];
440
 
441
+ if ( !isset( $options['theme_smartphone'] ) )
442
  $options['theme_smartphone'] = $default_options['theme_smartphone'];
443
+ if ( !isset( $options['theme_tablet'] ) )
444
  $options['theme_tablet'] = $default_options['theme_tablet'];
445
+ if ( !isset( $options['theme_mobile'] ) )
446
  $options['theme_mobile'] = $default_options['theme_mobile'];
447
+ if ( !isset( $options['theme_game'] ) )
448
  $options['theme_game'] = $default_options['theme_game'];
449
 
450
+ if ( !isset( $options['userAgent_smart'] ) )
451
  $options['userAgent_smart'] = $default_options['userAgent_smart'];
452
+ if ( !isset( $options['userAgent_tablet'] ) )
453
  $options['userAgent_tablet'] = $default_options['userAgent_tablet'];
454
+ if ( !isset( $options['userAgent_mobile'] ) )
455
  $options['userAgent_mobile'] = $default_options['userAgent_mobile'];
456
+ if ( !isset( $options['userAgent_game'] ) )
457
  $options['userAgent_game'] = $default_options['userAgent_game'];
458
 
459
  return $options;
507
  }
508
 
509
  foreach ( $theme_names as $theme_name ) {
510
+ if ( $default_theme == $theme_name )
511
  continue;
512
  if ( $options['theme_smartphone'] == $theme_name ) {
513
  $html .= '<option value="' . $theme_name . '" selected="selected">' . htmlspecialchars($theme_name) . '</option>';
537
  }
538
 
539
  foreach ( $theme_names as $theme_name ) {
540
+ if ( $default_theme == $theme_name )
541
  continue;
542
  if ( $options['theme_tablet'] == $theme_name ) {
543
  $html .= '<option value="' . $theme_name . '" selected="selected">' . htmlspecialchars($theme_name) . '</option>';
567
  }
568
 
569
  foreach ( $theme_names as $theme_name ) {
570
+ if ( $default_theme == $theme_name )
571
  continue;
572
  if ( $options['theme_mobile'] == $theme_name ) {
573
  $html .= '<option value="' . $theme_name . '" selected="selected">' . htmlspecialchars($theme_name) . '</option>';
597
  }
598
 
599
  foreach ( $theme_names as $theme_name ) {
600
+ if ( $default_theme == $theme_name )
601
  continue;
602
  if ( $options['theme_game'] == $theme_name ) {
603
  $html .= '<option value="' . $theme_name . '" selected="selected">' . htmlspecialchars($theme_name) . '</option>';
619
 
620
  <?php
621
  foreach ( $options as $key => $val ) {
622
+ if ( !preg_match( "/^custom_switcher_theme_/", $key ) )
623
  continue;
624
 
625
  $custom_switcher_name = preg_replace("/^custom_switcher_theme_/", '', $key);
642
  }
643
 
644
  foreach ( $theme_names as $theme_name ) {
645
+ if ( $default_theme == $theme_name )
646
  continue;
647
  if ( $custom_switcher_theme == $theme_name ) {
648
  $html .= '<option value="' . $theme_name . '" selected="selected">' . htmlspecialchars($theme_name) . '</option>';
665
 
666
  <tr><th scope="row"><?php _e( 'Add Custom Switcher', 'multi-device-switcher' ); ?></th>
667
  <td>
668
+ <legend class="screen-reader-text"><span><?php _e( 'Add Custom Switcher', 'thingscms' ); ?></span></legend>
669
  <input type="text" name="multi_device_switcher_options[custom_switcher]" id="custom-switcher" value="" size="24">
670
  <span class="submit"><input type="submit" name="multi_device_switcher_options[add_custom_switcher]" value="<?php _e( 'Add', 'multi-device-switcher' ); ?>" class="button"></span><br>
671
  <?php _e( '20 characters max, alphanumeric', 'multi-device-switcher' ); ?>
702
  <table class="form-table">
703
  <?php
704
  foreach ( $options as $key => $val ) {
705
+ if ( !preg_match( "/^custom_switcher_userAgent_/", $key ) )
706
  continue;
707
 
708
  $custom_switcher_name = preg_replace("/^custom_switcher_userAgent_/", '', $key);
726
  <table class="form-table">
727
  <tr><th scope="row"><?php _e( 'Add PC Switcher', 'multi-device-switcher' ); ?></th>
728
  <td>
729
+ <legend class="screen-reader-text"><span><?php _e( 'Add PC Switcher', 'multi-device-switcher' ); ?></span></legend>
730
  <label><input type="checkbox" name="multi_device_switcher_options[pc_switcher]" id="pc-switcher" value="1"<?php checked(1, $options['pc_switcher']); ?>> <?php _e( 'Add a PC Switcher to the footer.', 'multi-device-switcher' ); ?></label>
731
  </td>
732
  </tr>
733
  <tr><th scope="row"><?php _e( 'Add default CSS', 'multi-device-switcher' ); ?></th>
734
  <td>
735
+ <legend class="screen-reader-text"><span><?php _e( 'Add default CSS', 'multi-device-switcher' ); ?></span></legend>
736
  <label><input type="checkbox" name="multi_device_switcher_options[default_css]" id="add-default-css" value="1"<?php checked(1, $options['default_css']); ?>> <?php _e( 'Add a default CSS.', 'multi-device-switcher' ); ?></label>
737
  </td>
738
  </tr>
810
  }
811
 
812
  foreach ( $input as $key => $val ) {
813
+ if ( !preg_match( "/^custom_switcher_theme_/", $key ) )
814
  continue;
815
 
816
  $custom_switcher_name = preg_replace("/^custom_switcher_theme_/", '', $key);
822
  }
823
 
824
  foreach ( $input as $key => $val ) {
825
+ if ( !preg_match( "/^delete_custom_switcher_/", $key ) )
826
  continue;
827
 
828
  $custom_switcher_name = preg_replace("/^delete_custom_switcher_/", '', $key);
831
  unset($output['custom_switcher_userAgent_' . $custom_switcher_name]);
832
  }
833
 
834
+ if ( isset( $input['add_custom_switcher'] ) && !empty( $input['custom_switcher'] ) && !$output['custom_switcher_theme_' . $input['custom_switcher']] ) {
835
  if ( preg_match( "/^[A-Za-z0-9]{1,20}$/", $input['custom_switcher'] ) ) {
836
  $output['custom_switcher_theme_' . $input['custom_switcher']] = 'None';
837
  $output['custom_switcher_userAgent_' . $input['custom_switcher']] = '';
pc-switcher-widget.php CHANGED
@@ -3,10 +3,12 @@
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.2.3
7
  Author: thingsym
8
  Author URI: http://www.thingslabo.com/
9
  License: GPL2
 
 
10
  */
11
 
12
  /*
@@ -32,7 +34,7 @@ License: GPL2
32
  *
33
  * @since 1.2
34
  */
35
- if ( class_exists('Multi_Device_Switcher') )
36
  add_action('widgets_init', 'PC_Switcher_load_widgets');
37
 
38
  function PC_Switcher_load_widgets() {
@@ -53,7 +55,7 @@ class PC_Switcher extends WP_Widget {
53
  }
54
 
55
  function widget($args, $instance) {
56
- if ( ! function_exists( 'multi_device_switcher_add_pc_switcher' ) )
57
  return;
58
 
59
  global $multi_device_switcher;
@@ -66,8 +68,8 @@ class PC_Switcher extends WP_Widget {
66
  if ( !is_array($cache) )
67
  $cache = array();
68
 
69
- if ( isset($cache[$args['widget_id']]) ) {
70
- echo $cache[$args['widget_id']];
71
  return;
72
  }
73
 
@@ -78,7 +80,7 @@ class PC_Switcher extends WP_Widget {
78
  multi_device_switcher_add_pc_switcher();
79
  echo $after_widget;
80
 
81
- $cache[$args['widget_id']] = ob_get_flush();
82
  wp_cache_set('widget_pc_switcher', $cache, 'widget');
83
  }
84
  }
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.3.0
7
  Author: thingsym
8
  Author URI: http://www.thingslabo.com/
9
  License: GPL2
10
+ Text Domain: multi-device-switcher
11
+ Domain Path: /languages/
12
  */
13
 
14
  /*
34
  *
35
  * @since 1.2
36
  */
37
+ if ( class_exists('Multi_Device_Switcher') )
38
  add_action('widgets_init', 'PC_Switcher_load_widgets');
39
 
40
  function PC_Switcher_load_widgets() {
55
  }
56
 
57
  function widget($args, $instance) {
58
+ if ( !function_exists( 'multi_device_switcher_add_pc_switcher' ) )
59
  return;
60
 
61
  global $multi_device_switcher;
68
  if ( !is_array($cache) )
69
  $cache = array();
70
 
71
+ if ( isset($cache[ $args['widget_id'] ]) ) {
72
+ echo $cache[ $args['widget_id'] ];
73
  return;
74
  }
75
 
80
  multi_device_switcher_add_pc_switcher();
81
  echo $after_widget;
82
 
83
+ $cache[ $args['widget_id'] ] = ob_get_flush();
84
  wp_cache_set('widget_pc_switcher', $cache, 'widget');
85
  }
86
  }
readme.md CHANGED
@@ -9,6 +9,7 @@ The Custom Switcher can add every device.
9
  - Set a separate theme for device (Smart Phone, Tablet PC, Mobile Phone, Game), switches to selected theme.
10
  - Add every device by the Custom Switcher.
11
  - Add links 'Mobile' or 'PC' in the theme by the PC Switcher, switch to the default theme.
 
12
 
13
  ## How do I use it ?
14
 
@@ -20,6 +21,12 @@ The Custom Switcher can add every device.
20
  6. Configure settings to your needs. Select Theme by Theme option. Add and fix UserAgent by UserAgent option if necessary.
21
  7. Have fun!
22
 
 
 
 
 
 
 
23
  ## How to add the Custom Switcher
24
 
25
  1. Go to the "Multi Device Switcher" options page through the 'Appearance' menu in WordPress.
@@ -31,6 +38,8 @@ The Custom Switcher can add every device.
31
 
32
  There are three ways how to Using the PC Switcher.
33
 
 
 
34
  ### 1. Add a PC Switcher to the footer
35
 
36
  1. Go to the "Multi Device Switcher" options page through the 'Appearance' menu in WordPress.
@@ -47,7 +56,9 @@ There are three ways how to Using the PC Switcher.
47
  ### 3. For the theme authors and developers, add a PC Switcher to your theme.
48
 
49
  1. Add the following code into the PHP files, when you develop your theme.
50
- `<?php if ( function_exists('multi_device_switcher_add_pc_switcher') ) { multi_device_switcher_add_pc_switcher(); } ?>`
 
 
51
  2. Have fun!
52
 
53
  ### Using default CSS and customized CSS
@@ -60,22 +71,74 @@ There are three ways how to Using the PC Switcher.
60
 
61
  * [Default UserAgent](https://github.com/thingsym/multi-device-switcher/wiki/Default-UserAgent)
62
 
63
- ## Translations
64
 
65
- - Japanese (ja) - <a href="http://global.thingslabo.com/blog/">Thingsym</a>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
 
67
  Translating a plugin takes a lot of time, effort, and patience. I really appreciate the hard work from these contributors.
68
 
69
- If you have created or updated your own language pack, you can send [gettext PO and MO files](http://codex.wordpress.org/Translating_WordPress) to me. I can bundle it into Multi Device Switcher.
 
 
 
 
70
 
71
- #### The latest PO and MO files
72
 
73
  - [POT file](http://plugins.svn.wordpress.org/multi-device-switcher/trunk/languages/multi-device-switcher.pot)
74
  - [PO files](http://plugins.svn.wordpress.org/multi-device-switcher/trunk/languages/)
75
 
76
- #### Contact to me
77
 
78
- You can send your own language pack to me.
79
 
80
  - [multi-device-switcher - GitHub](https://github.com/thingsym/multi-device-switcher)
81
  - [http://global.thingslabo.com/blog/ (en)](http://global.thingslabo.com/blog/)
@@ -83,6 +146,14 @@ You can send your own language pack to me.
83
 
84
  ## Changelog
85
 
 
 
 
 
 
 
 
 
86
  * Version 1.2.3
87
  * fixed: fix redirect uri with query string, using add_query_arg
88
  * fixed: fix translation
9
  - Set a separate theme for device (Smart Phone, Tablet PC, Mobile Phone, Game), switches to selected theme.
10
  - Add every device by the Custom Switcher.
11
  - Add links 'Mobile' or 'PC' in the theme by the PC Switcher, switch to the default theme.
12
+ - Can be using is_multi_device() function that detect of the device.
13
 
14
  ## How do I use it ?
15
 
21
  6. Configure settings to your needs. Select Theme by Theme option. Add and fix UserAgent by UserAgent option if necessary.
22
  7. Have fun!
23
 
24
+ ## Screenshot
25
+
26
+ <img src="screenshot-1.png">
27
+ <img src="screenshot-2.png">
28
+ <img src="screenshot-3.png">
29
+
30
  ## How to add the Custom Switcher
31
 
32
  1. Go to the "Multi Device Switcher" options page through the 'Appearance' menu in WordPress.
38
 
39
  There are three ways how to Using the PC Switcher.
40
 
41
+ <img src="screenshot-4.png">
42
+
43
  ### 1. Add a PC Switcher to the footer
44
 
45
  1. Go to the "Multi Device Switcher" options page through the 'Appearance' menu in WordPress.
56
  ### 3. For the theme authors and developers, add a PC Switcher to your theme.
57
 
58
  1. Add the following code into the PHP files, when you develop your theme.
59
+ ```
60
+ <?php if ( function_exists('multi_device_switcher_add_pc_switcher') ) { multi_device_switcher_add_pc_switcher(); } ?>
61
+ ```
62
  2. Have fun!
63
 
64
  ### Using default CSS and customized CSS
71
 
72
  * [Default UserAgent](https://github.com/thingsym/multi-device-switcher/wiki/Default-UserAgent)
73
 
74
+ ## is_multi_device() function
75
 
76
+ is_multi_device() function is a boolean function, meaning it returns either TRUE or FALSE. Works through the detection of the device by the Multi_Device_Switcher class.
77
+
78
+ ### Usage
79
+
80
+ ```
81
+ <?php is_multi_device('smart'); ?>
82
+ ```
83
+
84
+ ### Examples
85
+
86
+ ```
87
+ <?php
88
+ if ( function_exists( 'is_multi_device' ) ) {
89
+ if ( is_multi_device('smart') ) {
90
+ /* Display and echo smartphone specific stuff here */
91
+ } elseif ( is_multi_device('tablet') ) {
92
+ /* Display and echo tablet specific stuff here */
93
+ }
94
+ }
95
+ ?>
96
+ ```
97
+
98
+ ### Parameters
99
+
100
+ **device name** (required)
101
+
102
+ (string) The name of the device
103
+
104
+ * smart
105
+ * tablet
106
+ * mobile
107
+ * game
108
+ * the name of the Custom Switcher
109
+
110
+ ### Return Values
111
+
112
+ (boolean) Return boolean whether a particular device.
113
+
114
+ ## Contributing
115
+
116
+ ### Patches and Bug Fixes
117
+
118
+ 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.
119
+
120
+ #### Contributors
121
+
122
+ * hykw [Github](https://github.com/hykw/multi-device-switcher)
123
+
124
+ ### Translations
125
 
126
  Translating a plugin takes a lot of time, effort, and patience. I really appreciate the hard work from these contributors.
127
 
128
+ If you have created or updated your own language pack, you can send [gettext PO and MO files](http://codex.wordpress.org/Translating_WordPress) to author. I can bundle it into Multi Device Switcher.
129
+
130
+ #### Translator
131
+
132
+ - Japanese (ja) - <a href="http://global.thingslabo.com/blog/">Thingsym</a>
133
 
134
+ ##### The latest PO and MO files
135
 
136
  - [POT file](http://plugins.svn.wordpress.org/multi-device-switcher/trunk/languages/multi-device-switcher.pot)
137
  - [PO files](http://plugins.svn.wordpress.org/multi-device-switcher/trunk/languages/)
138
 
139
+ ##### Send your own language pack
140
 
141
+ You can send your own language pack to author.
142
 
143
  - [multi-device-switcher - GitHub](https://github.com/thingsym/multi-device-switcher)
144
  - [http://global.thingslabo.com/blog/ (en)](http://global.thingslabo.com/blog/)
146
 
147
  ## Changelog
148
 
149
+ * Version 1.3.0
150
+ * fixed: fix script, style, html and readme
151
+ * new features: is_multi_device() function
152
+ * fixed: fix translation
153
+ * updated: update default UserAgent
154
+ * fixed: replace WP_PLUGIN_URL with plugins_url()
155
+ * fixed: using Page Hook Suffix
156
+ * merged: pull request [#3](https://github.com/thingsym/multi-device-switcher/pull/3)
157
  * Version 1.2.3
158
  * fixed: fix redirect uri with query string, using add_query_arg
159
  * fixed: fix translation
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: 3.9
9
- Stable tag: 1.2.3
10
  License: GPL2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
@@ -24,23 +24,36 @@ 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
 
28
- = Translations =
29
 
30
- * Japanese (ja) - <a href="http://global.thingslabo.com/blog/">Thingsym</a>
 
 
 
 
 
 
 
 
31
 
32
  Translating a plugin takes a lot of time, effort, and patience. I really appreciate the hard work from these contributors.
33
 
34
- If you have created or updated your own language pack, you can send [gettext PO and MO files](http://codex.wordpress.org/Translating_WordPress) to me. I can bundle it into Multi Device Switcher.
 
 
 
 
35
 
36
  = The latest PO and MO files =
37
 
38
  * [POT file](http://plugins.svn.wordpress.org/multi-device-switcher/trunk/languages/multi-device-switcher.pot)
39
  * [PO files](http://plugins.svn.wordpress.org/multi-device-switcher/trunk/languages/)
40
 
41
- = Contact to me =
42
 
43
- You can send your own language pack to me.
44
 
45
  * [multi-device-switcher - GitHub](https://github.com/thingsym/multi-device-switcher)
46
  * [http://global.thingslabo.com/blog/ (en)](http://global.thingslabo.com/blog/)
@@ -104,9 +117,58 @@ There are three ways how to Using the PC Switcher.
104
 
105
  * [Default UserAgent](https://github.com/thingsym/multi-device-switcher/wiki/Default-UserAgent)
106
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  == Changelog ==
108
 
109
- = Version 1.2.3 =
 
 
 
 
 
 
 
 
110
  * fixed: fix redirect uri with query string, using add_query_arg
111
  * fixed: fix translation
112
  * fixed: fix readme
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.0
9
+ Stable tag: 1.3.0
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
+ * Can be using is_multi_device() function that detect of the device.
28
 
29
+ = Contributing =
30
 
31
+ = Patches and Bug Fixes =
32
+
33
+ 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.
34
+
35
+ = Contributors =
36
+
37
+ * hykw
38
+
39
+ = Translations =
40
 
41
  Translating a plugin takes a lot of time, effort, and patience. I really appreciate the hard work from these contributors.
42
 
43
+ If you have created or updated your own language pack, you can send [gettext PO and MO files](http://codex.wordpress.org/Translating_WordPress) to author. I can bundle it into Multi Device Switcher.
44
+
45
+ = Translator =
46
+
47
+ * Japanese (ja) - <a href="http://global.thingslabo.com/blog/">Thingsym</a>
48
 
49
  = The latest PO and MO files =
50
 
51
  * [POT file](http://plugins.svn.wordpress.org/multi-device-switcher/trunk/languages/multi-device-switcher.pot)
52
  * [PO files](http://plugins.svn.wordpress.org/multi-device-switcher/trunk/languages/)
53
 
54
+ = Send your own language pack =
55
 
56
+ You can send your own language pack to author.
57
 
58
  * [multi-device-switcher - GitHub](https://github.com/thingsym/multi-device-switcher)
59
  * [http://global.thingslabo.com/blog/ (en)](http://global.thingslabo.com/blog/)
117
 
118
  * [Default UserAgent](https://github.com/thingsym/multi-device-switcher/wiki/Default-UserAgent)
119
 
120
+ = is_multi_device() function =
121
+
122
+ is_multi_device() function is a boolean function, meaning it returns either TRUE or FALSE. Works through the detection of the device by the Multi_Device_Switcher class.
123
+
124
+ = Usage =
125
+
126
+ `
127
+ <?php is_multi_device('smart'); ?>
128
+ `
129
+
130
+ = Examples =
131
+
132
+ `
133
+ <?php
134
+ if ( function_exists( 'is_multi_device' ) ) {
135
+ if ( is_multi_device('smart') ) {
136
+ /* Display and echo smartphone specific stuff here */
137
+ } elseif ( is_multi_device('tablet') ) {
138
+ /* Display and echo tablet specific stuff here */
139
+ }
140
+ }
141
+ ?>
142
+ `
143
+
144
+ = Parameters =
145
+
146
+ **device name** (required)
147
+
148
+ (string) The name of the device
149
+
150
+ * smart
151
+ * tablet
152
+ * mobile
153
+ * game
154
+ * the name of the Custom Switcher
155
+
156
+ = Return Values =
157
+
158
+ (boolean) Return boolean whether a particular device.
159
+
160
+
161
  == Changelog ==
162
 
163
+ = 1.3.0 =
164
+ * fixed: fix script, style, html and readme
165
+ * new features: is_multi_device() function
166
+ * fixed: fix translation
167
+ * updated: update default UserAgent
168
+ * fixed: replace WP_PLUGIN_URL with plugins_url()
169
+ * fixed: using Page Hook Suffix
170
+ * merged: pull request [#3](https://github.com/thingsym/multi-device-switcher/pull/3)
171
+ = 1.2.3 =
172
  * fixed: fix redirect uri with query string, using add_query_arg
173
  * fixed: fix translation
174
  * fixed: fix readme
uninstall.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) )
4
  exit();
5
 
6
  function multi_device_switcher_delete_plugin() {
1
  <?php
2
 
3
+ if ( !defined( 'WP_UNINSTALL_PLUGIN' ) )
4
  exit();
5
 
6
  function multi_device_switcher_delete_plugin() {