PluginProbe
Multi Device Switcher / 1.6.2
Multi Device Switcher v1.6.2
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.1.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 All 34 releases
multi-device-switcher / README.md

README.md in Multi Device Switcher 1.6.2, at README.md

508 lines 16.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 # Introducing Multi Device Switcher
2
3 [](https://travis-ci.org/thingsym/multi-device-switcher![Build Status](https://travis-ci.org/thingsym/multi-device-switcher.svg?branch=master)](https://travis-ci.org/thingsym/multi-device-switcher](https://travis-ci.org/thingsym/multi-device-switcher)
4
5 This WordPress plugin allows you to set a separate theme for device (Smart Phone, Tablet PC, Mobile Phone, Game and custom).
6 This plugin detects if your site is being viewed by UserAgent, and switches to selected theme. The Custom Switcher can add every device.
7
8 ## Features
9
10 - Set a separate theme for device (Smart Phone, Tablet PC, Mobile Phone, Game), switches to selected theme.
11 - Add every device by the **Custom Switcher**.
12 - Add links 'Mobile' or 'PC' in the theme by the **PC Switcher**, switch to the default theme.
13 - Switch the content of the post or page for each device by the **Display Switcher** Shortcode.
14 - Disable the switching of the theme by a particular URL by the **Disable Switcher**.
15 - Can be using is_multi_device() function that detect of the device.
16 - **Multi Device Switcher Command** command-line tool (required WP-CLI)
17
18 ## How do I use it ?
19
20 1. Download and unzip files. Or install multi-device-switcher using the WordPress plugin installer. In that case, skip 2.
21 2. Upload "multi-device-switcher" to the "/wp-content/plugins/" directory.
22 3. Activate the plugin through the 'Plugins' menu in WordPress.
23 4. Upload a separate theme to the "/wp-content/themes/" directory.
24 5. Go to the "Multi Device Switcher" options page through the 'Appearance' menu in WordPress.
25 6. Configure settings to your needs. Select Theme by Theme option. Add and fix UserAgent by UserAgent option if necessary.
26 7. Have fun!
27
28 ## Screenshot
29
30 <img src="screenshot-1.png">
31 <img src="screenshot-2.png">
32 <img src="screenshot-3.png">
33 <img src="screenshot-4.png">
34 <img src="screenshot-5.png">
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 ## Setting and Using the PC Switcher
44
45 There are three ways how to Using the PC Switcher.
46
47 <img src="screenshot-4.png">
48
49 ### 1. Add a PC Switcher to the footer
50
51 1. Go to the "Multi Device Switcher" options page through the 'Appearance' menu in WordPress.
52 2. Configure settings. Check the checkbox 'Add a PC Switcher to the footer.' by PC Switcher option.
53 3. Have fun!
54
55 ### 2. Add a PC Switcher to your sidebars/widget areas
56
57 1. Add-on the widget 'PC Switcher', when you activate the plugin "Multi Device Switcher".
58 2. Go to the "Widgets" options page through the 'Appearance' menu in WordPress.
59 3. Drag and drop the title bars 'PC Switcher' into the desired area.
60 4. Have fun!
61
62 ### 3. For the theme authors and developers, add a PC Switcher to your theme.
63
64 1. Add the following code into the PHP files, when you develop your theme.
65 ```
66 <?php if ( function_exists('multi_device_switcher_add_pc_switcher') ) { multi_device_switcher_add_pc_switcher(); } ?>
67 ```
68 2. Have fun!
69
70 ### Using default CSS and customized CSS
71
72 1. Go to the "Multi Device Switcher" options page through the 'Appearance' menu in WordPress.
73 2. Configure settings. Check the checkbox 'Add a default CSS.' by PC Switcher option. If you want to customize CSS, uncheck the checkbox.
74 3. Have fun!
75
76 You can design the PC Switcher in the Style Sheet.
77
78 #### HTML output of the PC Switcher
79
80 ```
81 <div class="pc-switcher"><span class="active">Mobile</span><a href="http://DOMEIN/PATH/TO/?pc-switcher=1">PC</a></div>
82 ```
83
84 #### HTML output of the PC Switcher when switched
85
86 ```
87 <div class="pc-switcher"><a href="http://DOMEIN/PATH/TO/?pc-switcher=0">Mobile</a><span class="active">PC</span></div>
88 ```
89
90 ## How to use the Display Switcher Shortcode
91
92 The **Display Switcher** Shortcode switch the content of the post or page through the detection of the device.
93
94 Add the shortcode `[multi]` in a post or page and use the `device` attribute to device name. if the device attribute is empty, detect the desktop PC.
95
96 ### Attributes
97
98 **device**
99
100 (string | empty) The name of the device
101
102 * smart
103 * tablet
104 * mobile
105 * game
106 * the name of the Custom Switcher
107
108 if empty, detect the desktop PC
109
110 ### Example Shortcode
111
112 ```
113 [multi]pc or other specific stuff here[/multi]
114 [multi device="smart"]smartphone specific stuff here[/multi]
115 [multi device="tablet"]tablet specific stuff here[/multi]
116 [multi device="test"]test Custom Switcher specific stuff here[/multi]
117 ```
118
119 For theme or plugin developers. Filters The Display Switcher Shortcode through hooks. In that case, edit theme or plugin files.
120
121 ```
122 <?php
123 echo do_shortcode('[multi device="smart"]smartphone specific stuff here[/multi]');
124 ?>
125 ```
126
127 ## How to use the Disable Switcher
128
129 The **Disable Switcher** disable the switching of the theme by a particular URL. If you match the access the url and a string or a regular expression (Regex mode), disable the switching of the theme. Regex mode is for advanced users.
130
131 1. Go to the "Multi Device Switcher" options page through the 'Appearance' menu in WordPress.
132 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.
133 3. Have fun!
134
135 ### Example
136
137 ```
138 /sample-page
139 /2015/01/hello-world
140 ```
141
142 ##### Regex mode (in the case of regular expression)
143
144 ```
145 \/sample\-
146 \/2015\/01
147 ```
148
149 ## UserAgent option Samples
150
151 * [](https://github.com/thingsym/multi-device-switcher/wiki/Default-UserAgentDefault UserAgent](https://github.com/thingsym/multi-device-switcher/wiki/Default-UserAgent](https://github.com/thingsym/multi-device-switcher/wiki/Default-UserAgent)
152
153
154 ## Detect the device by JavaScript
155
156 Multi Device Switcher set the Cookie that holds the state of the switch. You can get the Cookie and detect the device by JavaScript.
157
158 ### Cookies
159
160 * `multi-device-switcher` The name of the device is switched (value: null | device name)
161 * `disable-switcher` State of disabled (value: null | 1)
162 * `pc-switcher` State of the PC Switcher when switched (value: null | 1)
163
164 ### Example
165
166 ```
167 <script src="http://DOMEIN/PATH/TO/jquery.cookie.js"></script>
168 <script>
169 (function($) {
170 $(function() {
171 if ( $.cookie( 'multi-device-switcher' ) == 'smart' ) {
172 /* smartphone specific stuff here */
173 } else if ( $.cookie( 'multi-device-switcher' ) == 'tablet' ) {
174 /* tablet specific stuff here */
175 } else {
176 /* pc or other specific stuff here */
177 }
178 });
179 })(jQuery);
180 </script>
181 ```
182
183 ## is_multi_device() function
184
185 **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.
186
187 ### Usage
188
189 ```
190 <?php is_multi_device('smart'); ?>
191 ```
192
193 ### Example
194
195 ```
196 <?php
197 if ( function_exists( 'is_multi_device' ) ) {
198 if ( is_multi_device('smart') ) {
199 /* Display and echo smartphone specific stuff here */
200 } elseif ( is_multi_device('tablet') ) {
201 /* Display and echo tablet specific stuff here */
202 } else {
203 /* Display and echo pc or other specific stuff here */
204 }
205 }
206 ?>
207 ```
208
209 ### Parameters
210
211 **device name** (required)
212
213 (string) The name of the device
214
215 * smart
216 * tablet
217 * mobile
218 * game
219 * the name of the Custom Switcher
220
221 ### Return Values
222
223 (boolean) Return boolean whether a particular device.
224
225 ## is_pc_switcher() function
226
227 **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.
228
229 ### Usage
230
231 ```
232 <?php is_pc_switcher(); ?>
233 ```
234
235 ### Example
236
237 ```
238 <?php
239 if ( function_exists( 'is_pc_switcher' ) ) {
240 if ( is_pc_switcher() ) {
241 /* Theme switched by the PC Switcher. Display and echo specific stuff here */
242 } else {
243 /* Display and echo specific stuff here */
244 }
245 }
246 ?>
247 ```
248
249 ### Parameters
250
251 None
252
253 ### Return Values
254
255 (boolean) Return the state of PC Switcher.
256
257
258 ## is_disable_switcher() function
259
260 **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.
261
262 ### Usage
263
264 ```
265 <?php is_disable_switcher(); ?>
266 ```
267
268 ### Example
269
270 ```
271 <?php
272 if ( function_exists( 'is_disable_switcher' ) ) {
273 if ( is_disable_switcher() ) {
274 /* Disabled. Display and echo specific stuff here */
275 } else {
276 /* Display and echo specific stuff here */
277 }
278 }
279 ?>
280 ```
281
282 ### Parameters
283
284 None
285
286 ### Return Values
287
288 (boolean) Return the state of disabled.
289
290 ## Multi Device Switcher Command
291
292 The **Multi Device Switcher Command** is command-line tool.
293
294 Add-on the Multi Device Switcher Command, when you activate the plugin "Multi Device Switcher". To use the Multi Device Switcher Command is WP-CLI required.
295
296 ### NAME
297
298 wp multi-device
299
300 ### DESCRIPTION
301
302 Multi Device Switcher Command
303
304 ### SYNOPSIS
305
306 wp multi-device <command>
307
308 ### SUBCOMMANDS
309
310 add add Custom Switcher
311 css turn on/off default CSS
312 delete delete Custom Switcher
313 pc-switcher turn on/off PC Switcher
314 reset reset Settings to Default UserAgent
315 status get status of settings
316 theme get or switch a theme
317 useragent get or set UserAgent
318
319
320 For more information about the Multi Device Switcher Command, see `wp help multi-device <SUBCOMMANDS>`.
321
322
323 ### Command examples
324
325 get status of settings
326
327 wp multi-device status
328
329 Active Theme: Twenty Fifteen | twentyfifteen
330 +--------------------------+-----------------+----------------+-------------------------------------------------------------------------+
331 | Device | Theme | Slug | UserAgent |
332 +--------------------------+-----------------+----------------+-------------------------------------------------------------------------+
333 | smartphone (Smart Phone) | Twenty Fourteen | twentyfourteen | iPhone, iPod, Android, dream, CUPCAKE, Windows Phone, webOS, BB10, Blac |
334 | | | | kBerry8707, BlackBerry9000, BlackBerry9300, BlackBerry9500, BlackBerry9 |
335 | | | | 530, BlackBerry9520, BlackBerry9550, BlackBerry9700, BlackBerry 93, Bla |
336 | | | | ckBerry 97, BlackBerry 99, BlackBerry 98 |
337 | tablet (Tablet PC) | Twenty Thirteen | twentythirteen | iPad, Kindle, Sony Tablet, Nexus 7 |
338 | mobile (Mobile Phone) | Twenty Twelve | twentytwelve | DoCoMo, SoftBank, J-PHONE, Vodafone, KDDI, UP.Browser, WILLCOM, emobile |
339 | | | | , DDIPOCKET, Windows CE, BlackBerry, Symbian, PalmOS, Huawei, IAC, Noki |
340 | | | | a |
341 | game (Game Platforms) | Twenty Eleven | twentyeleven | PlayStation Portable, PlayStation Vita, PSP, PS2, PLAYSTATION 3, PlaySt |
342 | | | | ation 4, Nitro, Nintendo 3DS, Nintendo Wii, Nintendo WiiU, Xbox |
343 +--------------------------+-----------------+----------------+-------------------------------------------------------------------------+
344 PC Switcher: on
345 default CSS: on
346
347 switch twentyfifteen in theme of smartphone using theme slug
348
349 wp multi-device theme smartphone twentyfifteen
350
351 set UserAgent in theme of tablet
352
353 wp multi-device useragent tablet 'iPad, Kindle, Sony Tablet, Nexus 7'
354
355 add example Custom Switcher
356
357 wp multi-device add example
358
359 add example Custom Switcher. set twentyfifteen theme and UserAgent using theme slug
360
361 wp multi-device add example twentyfifteen 'iPad, Kindle, Sony Tablet, Nexus 7'
362
363 delete example Custom Switcher
364
365 wp multi-device delete example
366
367 turn on default CSS
368
369 wp multi-device css on
370
371 ## Resources
372
373 * [](https://blog.thingslabo.com/archives/category/multi_device_switcherDeveloper Blog (Japanese) - http://blog.thingslabo.com/ ](https://blog.thingslabo.com/archives/category/multi_device_switcher](https://blog.thingslabo.com/archives/category/multi_device_switcher)
374
375 ## WordPress Plugin Directory
376
377 Multi Device Switcher is hosted on the WordPress Plugin Directory.
378
379 [](https://wordpress.org/plugins/multi-device-switcher/https://wordpress.org/plugins/multi-device-switcher/](https://wordpress.org/plugins/multi-device-switcher/](https://wordpress.org/plugins/multi-device-switcher/)
380
381 ## Test Matrix
382
383 For operation compatibility between PHP version and WordPress version, see below [](https://travis-ci.org/thingsym/multi-device-switcherTravis CI](https://travis-ci.org/thingsym/multi-device-switcher](https://travis-ci.org/thingsym/multi-device-switcher).
384
385 ## Contribution
386
387 ### Patches and Bug Fixes
388
389 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.
390
391 1. Fork [](https://github.com/thingsym/multi-device-switcherMulti Device Switcher](https://github.com/thingsym/multi-device-switcher](https://github.com/thingsym/multi-device-switcher) from GitHub repository
392 2. Create a feature branch: git checkout -b my-new-feature
393 3. Commit your changes: git commit -am 'Add some feature'
394 4. Push to the branch: git push origin my-new-feature
395 5. Create new Pull Request
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
405 * improve cookie settings via wp_headers hook
406 * change readme.md file name to upper case
407 * add LICENSE file
408 * Version 1.6.0
409 * change Requires at least version 3.7
410 * remove cache with PC Switcher widget
411 * add init function
412 * change hook destination from plugin_action_links to plugin_action_links_{$plugin_file}
413 * add load_textdomain function
414 * add define variable \_\_MULTI_DEVICE_SWITCHER_FILE\_\_
415 * check class Multi_Device_Switcher
416 * check ABSPATH
417 * add isset to conditional statement
418 * fix boolean
419 * add tests
420 * Version 1.5.4
421 * fixed: fix property keyword for testability
422 * fixed: fix add_action 'customize_register' with \_\_construct()
423 * fixed: fix capability
424 * Version 1.5.3
425 * fixed: add function multi_device_switcher_get_default_options for wp multi-device [#9](https://github.com/thingsym/multi-device-switcher/pull/9)
426 * Version 1.5.2
427 * fixed: fix setcookie() [#8](https://github.com/thingsym/multi-device-switcher/pull/8)
428 * Version 1.5.1
429 * fixed: fix preg_split()
430 * Version 1.5.0
431 * fixed: refactoring by the PHP_CodeSniffer
432 * fixed: change admin functions to class/object methods
433 * Version 1.4.2
434 * edited: edit readme
435 * new features: Display Switcher Shortcode
436 * updated: update default UserAgent
437 * fixed: fix pc-switcher ssl url
438 * Version 1.4.1
439 * edited: edit readme
440 * new features: is_disable_switcher() function
441 * new features: is_pc_switcher() function
442 * fixed: fix redirect url and pc-switcher url
443 * Version 1.4.0
444 * edited: edit readme
445 * added: add cookies 'multi-device-switcher', 'disable-switcher'
446 * new features: Disable Switcher
447 * fixed: fix get_options_userAgent(), multi_device_switcher_get_options()
448 * fixed: add reserved words validate
449 * new features: Multi Device Switcher Command
450 * added: add option settings into Theme Customizer
451 * fixed: refactoring by the PHP_CodeSniffer
452 * Version 1.3.0
453 * fixed: fix script, style, html and readme
454 * new features: is_multi_device() function
455 * fixed: fix translation
456 * updated: update default UserAgent
457 * fixed: replace WP_PLUGIN_URL with plugins_url()
458 * fixed: using Page Hook Suffix
459 * merged: pull request [#3](https://github.com/thingsym/multi-device-switcher/pull/3)
460 * Version 1.2.3
461 * fixed: fix redirect uri with query string, using add_query_arg
462 * fixed: fix translation
463 * fixed: fix readme
464 * Version 1.2.2
465 * improved: improve responsiveness UI
466 * fixed: fix html
467 * Version 1.2.1
468 * fixed: delete add_contextual_help
469 * fixed: fix readme and html
470 * Version 1.2.0
471 * added: add PC Switcher Widget
472 * new features: PC Switcher
473 * added: add the settings link to the plugin page
474 * Version 1.1.2
475 * required: at least version 3.4
476 * fixed: fix tabs and buttons
477 * Version 1.1.1
478 * fixed: change the order of the UserAgent detection
479 * updated: update default UserAgent
480 * added: add HTTP/1.1 Vary header
481 * Version 1.1.0
482 * new features: Custom Switcher
483 * Version 1.0.4
484 * fixed: fix the object model PHP5, \_\_construct() to replace Multi_Device_Switcher
485 * fixed: wp_get_themes(), and wp_get_theme() to replace get_themes(), get_theme()
486 * Version 1.0.3
487 * updated: update screenshots
488 * fixed: fix reset button
489 * Version 1.0.2
490 * added: add file uninstall.php
491 * fixed: split admin_enqueue_scripts() into two functions
492 * fixed: detects is_admin()
493 * Version 1.0.1
494 * fixed: split multi_device_switcher_init() into two functions
495 * Version 1.0.0
496 * Initial release.
497
498 ## Upgrade Notice
499
500 * Version 1.6.0
501 * Requires at least version 3.7 of the WordPress
502 * Version 1.1.2
503 * Requires at least version 3.4 of the WordPress
504
505 ## License
506
507 Licensed under [](https://www.gnu.org/licenses/gpl-2.0.htmlGPLv2](https://www.gnu.org/licenses/gpl-2.0.html](https://www.gnu.org/licenses/gpl-2.0.html).
508