Version Description
- add phpcs job to ci
- add healthcheck to database container
- add bats test to ci
- fix bats test case
- add test case
- fix phpcs.ruleset.xml
- add enqueue_styles method
- imporve code with phpcs
- fix composer scripts
- update github actions
Download this release
Release Info
Developer | thingsym |
Plugin | Multi Device Switcher |
Version | 1.8.5 |
Comparing to | |
See all releases |
Code changes from version 1.8.4 to 1.8.5
- languages/multi-device-switcher-ja.po +1 -1
- languages/multi-device-switcher.pot +1 -1
- multi-device-switcher.php +34 -16
- pc-switcher-widget.php +1 -1
- readme.txt +13 -1
- wp-cli.php +19 -19
languages/multi-device-switcher-ja.po
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
# This file is distributed under the GPLv2 or later.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: Multi Device Switcher 1.8.
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/multi-device-"
|
7 |
"switcher\n"
|
8 |
"POT-Creation-Date: 2022-11-25T10:39:41+00:00\n"
|
2 |
# This file is distributed under the GPLv2 or later.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: Multi Device Switcher 1.8.5\n"
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/multi-device-"
|
7 |
"switcher\n"
|
8 |
"POT-Creation-Date: 2022-11-25T10:39:41+00:00\n"
|
languages/multi-device-switcher.pot
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
# This file is distributed under the GPLv2 or later.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: Multi Device Switcher 1.8.
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/multi-device-switcher\n"
|
7 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
8 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
2 |
# This file is distributed under the GPLv2 or later.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: Multi Device Switcher 1.8.5\n"
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/multi-device-switcher\n"
|
7 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
8 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
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.8.
|
7 |
* Author: thingsym
|
8 |
* Author URI: https://www.thingslabo.com/
|
9 |
* License: GPLv2 or later
|
@@ -470,25 +470,48 @@ class Multi_Device_Switcher {
|
|
470 |
* @since 1.0.0
|
471 |
*/
|
472 |
public function session() {
|
|
|
473 |
if ( isset( $_GET['pc-switcher'] ) ) {
|
474 |
-
// phpcs:ignore WordPress.Security.
|
475 |
-
setcookie( $this->cookie_name_pc_switcher, $_GET['pc-switcher'] ? '1' : '', 0, '/', '', is_ssl(), false );
|
476 |
|
477 |
if ( isset( $_SERVER['REQUEST_URI'] ) ) {
|
478 |
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
|
479 |
$uri = preg_replace( '/^(.+?)(\?.*)$/', '$1', $_SERVER['REQUEST_URI'] );
|
480 |
}
|
481 |
|
|
|
482 |
unset( $_GET['pc-switcher'] );
|
|
|
483 |
if ( ! empty( $_GET ) ) {
|
|
|
484 |
$uri = $uri . '?' . http_build_query( $_GET );
|
485 |
}
|
486 |
|
487 |
-
|
488 |
exit;
|
489 |
}
|
490 |
}
|
491 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
492 |
/**
|
493 |
* Add pc switcher button.
|
494 |
*
|
@@ -510,16 +533,10 @@ class Multi_Device_Switcher {
|
|
510 |
|
511 |
if ( $pc_switcher && $name && 'None' !== $name ) {
|
512 |
if ( $options['default_css'] ) {
|
513 |
-
|
514 |
-
'pc-switcher-options',
|
515 |
-
plugins_url() . '/multi-device-switcher/pc-switcher.css',
|
516 |
-
array(),
|
517 |
-
$this->plugin_data['Version'],
|
518 |
-
'all'
|
519 |
-
);
|
520 |
}
|
521 |
|
522 |
-
$uri
|
523 |
|
524 |
if ( isset( $_SERVER['HTTP_HOST'] ) ) {
|
525 |
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
|
@@ -681,7 +698,8 @@ class Multi_Device_Switcher {
|
|
681 |
'multi-device-switcher-options',
|
682 |
plugins_url() . '/multi-device-switcher/multi-device-switcher.js',
|
683 |
array( 'jquery', 'jquery-ui-tabs' ),
|
684 |
-
$this->plugin_data['Version']
|
|
|
685 |
);
|
686 |
}
|
687 |
|
@@ -821,7 +839,7 @@ class Multi_Device_Switcher {
|
|
821 |
* @since 1.8.1
|
822 |
*/
|
823 |
public function plugin_metadata_links( $links, $file ) {
|
824 |
-
if ( $file
|
825 |
$links[] = '<a href="https://github.com/sponsors/thingsym">' . __( 'Become a sponsor', 'multi-device-switcher' ) . '</a>';
|
826 |
}
|
827 |
|
@@ -910,7 +928,7 @@ class Multi_Device_Switcher {
|
|
910 |
*/
|
911 |
public function load_plugin_data() {
|
912 |
if ( ! function_exists( 'get_plugin_data' ) ) {
|
913 |
-
require_once
|
914 |
}
|
915 |
|
916 |
$this->plugin_data = get_plugin_data( __MULTI_DEVICE_SWITCHER_FILE__ );
|
@@ -1321,7 +1339,7 @@ class Multi_Device_Switcher {
|
|
1321 |
}
|
1322 |
|
1323 |
if ( isset( $input['add_custom_switcher'] ) && ! empty( $input['custom_switcher'] ) && ! isset( $output[ 'custom_switcher_theme_' . $input['custom_switcher'] ] ) ) {
|
1324 |
-
if ( ! in_array( $input['custom_switcher'], array( 'smartphone', 'smart', 'tablet', 'mobile', 'game' ) )
|
1325 |
&& preg_match( '/^[A-Za-z0-9]{1,20}$/', $input['custom_switcher'] ) ) {
|
1326 |
$output[ 'custom_switcher_theme_' . $input['custom_switcher'] ] = 'None';
|
1327 |
$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.8.5
|
7 |
* Author: thingsym
|
8 |
* Author URI: https://www.thingslabo.com/
|
9 |
* License: GPLv2 or later
|
470 |
* @since 1.0.0
|
471 |
*/
|
472 |
public function session() {
|
473 |
+
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
474 |
if ( isset( $_GET['pc-switcher'] ) ) {
|
475 |
+
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
476 |
+
setcookie( $this->cookie_name_pc_switcher, sanitize_text_field( wp_unslash( $_GET['pc-switcher'] ) ) ? '1' : '', 0, '/', '', is_ssl(), false );
|
477 |
|
478 |
if ( isset( $_SERVER['REQUEST_URI'] ) ) {
|
479 |
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
|
480 |
$uri = preg_replace( '/^(.+?)(\?.*)$/', '$1', $_SERVER['REQUEST_URI'] );
|
481 |
}
|
482 |
|
483 |
+
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
484 |
unset( $_GET['pc-switcher'] );
|
485 |
+
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
486 |
if ( ! empty( $_GET ) ) {
|
487 |
+
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
488 |
$uri = $uri . '?' . http_build_query( $_GET );
|
489 |
}
|
490 |
|
491 |
+
wp_safe_redirect( esc_url( $uri ) );
|
492 |
exit;
|
493 |
}
|
494 |
}
|
495 |
|
496 |
+
/**
|
497 |
+
* Enqueue styles for default_css
|
498 |
+
*
|
499 |
+
* @access public
|
500 |
+
*
|
501 |
+
* @return void
|
502 |
+
*
|
503 |
+
* @since 1.8.5
|
504 |
+
*/
|
505 |
+
public function enqueue_styles() {
|
506 |
+
wp_enqueue_style(
|
507 |
+
'pc-switcher-options',
|
508 |
+
plugins_url() . '/multi-device-switcher/pc-switcher.css',
|
509 |
+
array(),
|
510 |
+
$this->plugin_data['Version'],
|
511 |
+
'all'
|
512 |
+
);
|
513 |
+
}
|
514 |
+
|
515 |
/**
|
516 |
* Add pc switcher button.
|
517 |
*
|
533 |
|
534 |
if ( $pc_switcher && $name && 'None' !== $name ) {
|
535 |
if ( $options['default_css'] ) {
|
536 |
+
$this->enqueue_styles();
|
|
|
|
|
|
|
|
|
|
|
|
|
537 |
}
|
538 |
|
539 |
+
$uri = is_ssl() ? 'https://' : 'http://';
|
540 |
|
541 |
if ( isset( $_SERVER['HTTP_HOST'] ) ) {
|
542 |
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
|
698 |
'multi-device-switcher-options',
|
699 |
plugins_url() . '/multi-device-switcher/multi-device-switcher.js',
|
700 |
array( 'jquery', 'jquery-ui-tabs' ),
|
701 |
+
$this->plugin_data['Version'],
|
702 |
+
false
|
703 |
);
|
704 |
}
|
705 |
|
839 |
* @since 1.8.1
|
840 |
*/
|
841 |
public function plugin_metadata_links( $links, $file ) {
|
842 |
+
if ( $file === plugin_basename( __MULTI_DEVICE_SWITCHER_FILE__ ) ) {
|
843 |
$links[] = '<a href="https://github.com/sponsors/thingsym">' . __( 'Become a sponsor', 'multi-device-switcher' ) . '</a>';
|
844 |
}
|
845 |
|
928 |
*/
|
929 |
public function load_plugin_data() {
|
930 |
if ( ! function_exists( 'get_plugin_data' ) ) {
|
931 |
+
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
932 |
}
|
933 |
|
934 |
$this->plugin_data = get_plugin_data( __MULTI_DEVICE_SWITCHER_FILE__ );
|
1339 |
}
|
1340 |
|
1341 |
if ( isset( $input['add_custom_switcher'] ) && ! empty( $input['custom_switcher'] ) && ! isset( $output[ 'custom_switcher_theme_' . $input['custom_switcher'] ] ) ) {
|
1342 |
+
if ( ! in_array( $input['custom_switcher'], array( 'smartphone', 'smart', 'tablet', 'mobile', 'game' ), true )
|
1343 |
&& preg_match( '/^[A-Za-z0-9]{1,20}$/', $input['custom_switcher'] ) ) {
|
1344 |
$output[ 'custom_switcher_theme_' . $input['custom_switcher'] ] = 'None';
|
1345 |
$output[ 'custom_switcher_userAgent_' . $input['custom_switcher'] ] = '';
|
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.8.
|
7 |
* Author: thingsym
|
8 |
* Author URI: https://www.thingslabo.com/
|
9 |
* License: GPLv2 or later
|
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.8.5
|
7 |
* Author: thingsym
|
8 |
* Author URI: https://www.thingslabo.com/
|
9 |
* License: GPLv2 or later
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Contributors: thingsym
|
|
4 |
Link: https://github.com/thingsym/multi-device-switcher
|
5 |
Donate link: https://github.com/sponsors/thingsym
|
6 |
Tags: switcher, theme, ipad, iphone, android, tablet, mobile, game
|
7 |
-
Stable tag: 1.8.
|
8 |
Tested up to: 6.1.0
|
9 |
Requires at least: 4.9
|
10 |
Requires PHP: 5.6
|
@@ -395,6 +395,18 @@ For more information about the Multi Device Switcher Command, see `wp help multi
|
|
395 |
|
396 |
== Changelog ==
|
397 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
398 |
= 1.8.4 =
|
399 |
* tested up to 6.1.0
|
400 |
* update japanese translation
|
4 |
Link: https://github.com/thingsym/multi-device-switcher
|
5 |
Donate link: https://github.com/sponsors/thingsym
|
6 |
Tags: switcher, theme, ipad, iphone, android, tablet, mobile, game
|
7 |
+
Stable tag: 1.8.5
|
8 |
Tested up to: 6.1.0
|
9 |
Requires at least: 4.9
|
10 |
Requires PHP: 5.6
|
395 |
|
396 |
== Changelog ==
|
397 |
|
398 |
+
= 1.8.5 =
|
399 |
+
* add phpcs job to ci
|
400 |
+
* add healthcheck to database container
|
401 |
+
* add bats test to ci
|
402 |
+
* fix bats test case
|
403 |
+
* add test case
|
404 |
+
* fix phpcs.ruleset.xml
|
405 |
+
* add enqueue_styles method
|
406 |
+
* imporve code with phpcs
|
407 |
+
* fix composer scripts
|
408 |
+
* update github actions
|
409 |
+
|
410 |
= 1.8.4 =
|
411 |
* tested up to 6.1.0
|
412 |
* update japanese translation
|
wp-cli.php
CHANGED
@@ -132,7 +132,7 @@ class Multi_Device_Switcher_Command extends WP_CLI_Command {
|
|
132 |
$options = get_option( $this->option_name );
|
133 |
|
134 |
if ( isset( $slug ) ) {
|
135 |
-
if ( ''
|
136 |
$theme = 'None';
|
137 |
}
|
138 |
}
|
@@ -141,7 +141,7 @@ class Multi_Device_Switcher_Command extends WP_CLI_Command {
|
|
141 |
$themes = wp_get_themes();
|
142 |
foreach ( $themes as $theme_slug => $header ) {
|
143 |
$slug_table[ $header->get( 'Name' ) ] = $theme_slug;
|
144 |
-
if ( $slug
|
145 |
$theme = $header->get( 'Name' );
|
146 |
}
|
147 |
}
|
@@ -152,7 +152,7 @@ class Multi_Device_Switcher_Command extends WP_CLI_Command {
|
|
152 |
|
153 |
if ( isset( $theme ) ) {
|
154 |
$default_theme = wp_get_theme()->get( 'Name' );
|
155 |
-
if ( $default_theme
|
156 |
WP_CLI::error( $theme . ' theme is in active' );
|
157 |
}
|
158 |
|
@@ -160,8 +160,8 @@ class Multi_Device_Switcher_Command extends WP_CLI_Command {
|
|
160 |
WP_CLI::error( $theme . ' theme is not installed' );
|
161 |
}
|
162 |
|
163 |
-
if ( in_array( $name, array( 'smartphone', 'smart', 'tablet', 'mobile', 'game' ) ) ) {
|
164 |
-
if ( 'smart'
|
165 |
$name = 'smartphone';
|
166 |
}
|
167 |
$options[ 'theme_' . $name ] = $theme;
|
@@ -180,8 +180,8 @@ class Multi_Device_Switcher_Command extends WP_CLI_Command {
|
|
180 |
}
|
181 |
}
|
182 |
else {
|
183 |
-
if ( in_array( $name, array( 'smartphone', 'smart', 'tablet', 'mobile', 'game' ) ) ) {
|
184 |
-
if ( 'smart'
|
185 |
$name = 'smartphone';
|
186 |
}
|
187 |
WP_CLI::success( $options[ 'theme_' . $name ] . ' | ' . $slug_table[ $options[ 'theme_' . $name ] ] );
|
@@ -224,8 +224,8 @@ class Multi_Device_Switcher_Command extends WP_CLI_Command {
|
|
224 |
$options = get_option( $this->option_name );
|
225 |
|
226 |
if ( isset( $useragent ) ) {
|
227 |
-
if ( in_array( $name, array( 'smartphone', 'smart', 'tablet', 'mobile', 'game' ) ) ) {
|
228 |
-
if ( 'smartphone'
|
229 |
$name = 'smart';
|
230 |
}
|
231 |
$options[ 'userAgent_' . $name ] = $useragent;
|
@@ -244,8 +244,8 @@ class Multi_Device_Switcher_Command extends WP_CLI_Command {
|
|
244 |
}
|
245 |
}
|
246 |
else {
|
247 |
-
if ( in_array( $name, array( 'smartphone', 'smart', 'tablet', 'mobile', 'game' ) ) ) {
|
248 |
-
if ( 'smartphone'
|
249 |
$name = 'smart';
|
250 |
}
|
251 |
WP_CLI::success( $options[ 'userAgent_' . $name ] );
|
@@ -327,13 +327,13 @@ class Multi_Device_Switcher_Command extends WP_CLI_Command {
|
|
327 |
$themes = wp_get_themes();
|
328 |
foreach ( $themes as $theme_slug => $header ) {
|
329 |
$slug_table[ $header->get( 'Name' ) ] = $theme_slug;
|
330 |
-
if ( ! isset( $assoc_args['theme'] ) && $slug
|
331 |
$theme = $header->get( 'Name' );
|
332 |
}
|
333 |
}
|
334 |
|
335 |
$options = get_option( $this->option_name );
|
336 |
-
if ( in_array( $name, array( 'smartphone', 'smart', 'tablet', 'mobile', 'game' ) ) ) {
|
337 |
WP_CLI::error( 'Default Switcher can\'t add' );
|
338 |
}
|
339 |
elseif ( isset( $options[ 'custom_switcher_theme_' . $name ] ) ) {
|
@@ -341,7 +341,7 @@ class Multi_Device_Switcher_Command extends WP_CLI_Command {
|
|
341 |
}
|
342 |
else {
|
343 |
$default_theme = wp_get_theme()->get( 'Name' );
|
344 |
-
if ( $default_theme
|
345 |
WP_CLI::error( $theme . ' theme is in active' );
|
346 |
}
|
347 |
|
@@ -384,7 +384,7 @@ class Multi_Device_Switcher_Command extends WP_CLI_Command {
|
|
384 |
|
385 |
$options = get_option( $this->option_name );
|
386 |
|
387 |
-
if ( in_array( $name, array( 'smartphone', 'smart', 'tablet', 'mobile', 'game' ) ) ) {
|
388 |
WP_CLI::error( 'Default Switcher can\'t delete' );
|
389 |
}
|
390 |
elseif ( isset( $options[ 'custom_switcher_theme_' . $name ] ) ) {
|
@@ -424,12 +424,12 @@ class Multi_Device_Switcher_Command extends WP_CLI_Command {
|
|
424 |
|
425 |
$options = get_option( $this->option_name );
|
426 |
|
427 |
-
if ( 'on'
|
428 |
$options['pc_switcher'] = 1;
|
429 |
update_option( $this->option_name, $options );
|
430 |
WP_CLI::success( 'turn on PC Switcher' );
|
431 |
}
|
432 |
-
elseif ( 'off'
|
433 |
$options['pc_switcher'] = 0;
|
434 |
update_option( $this->option_name, $options );
|
435 |
WP_CLI::success( 'turn off PC Switcher' );
|
@@ -463,12 +463,12 @@ class Multi_Device_Switcher_Command extends WP_CLI_Command {
|
|
463 |
|
464 |
$options = get_option( $this->option_name );
|
465 |
|
466 |
-
if ( 'on'
|
467 |
$options['default_css'] = 1;
|
468 |
update_option( $this->option_name, $options );
|
469 |
WP_CLI::success( 'turn on default CSS' );
|
470 |
}
|
471 |
-
elseif ( 'off'
|
472 |
$options['default_css'] = 0;
|
473 |
update_option( $this->option_name, $options );
|
474 |
WP_CLI::success( 'turn off default CSS' );
|
132 |
$options = get_option( $this->option_name );
|
133 |
|
134 |
if ( isset( $slug ) ) {
|
135 |
+
if ( '' === $slug || 'None' === $slug ) {
|
136 |
$theme = 'None';
|
137 |
}
|
138 |
}
|
141 |
$themes = wp_get_themes();
|
142 |
foreach ( $themes as $theme_slug => $header ) {
|
143 |
$slug_table[ $header->get( 'Name' ) ] = $theme_slug;
|
144 |
+
if ( $slug === $theme_slug ) {
|
145 |
$theme = $header->get( 'Name' );
|
146 |
}
|
147 |
}
|
152 |
|
153 |
if ( isset( $theme ) ) {
|
154 |
$default_theme = wp_get_theme()->get( 'Name' );
|
155 |
+
if ( $default_theme === $theme ) {
|
156 |
WP_CLI::error( $theme . ' theme is in active' );
|
157 |
}
|
158 |
|
160 |
WP_CLI::error( $theme . ' theme is not installed' );
|
161 |
}
|
162 |
|
163 |
+
if ( in_array( $name, array( 'smartphone', 'smart', 'tablet', 'mobile', 'game' ), true ) ) {
|
164 |
+
if ( 'smart' === $name ) {
|
165 |
$name = 'smartphone';
|
166 |
}
|
167 |
$options[ 'theme_' . $name ] = $theme;
|
180 |
}
|
181 |
}
|
182 |
else {
|
183 |
+
if ( in_array( $name, array( 'smartphone', 'smart', 'tablet', 'mobile', 'game' ), true ) ) {
|
184 |
+
if ( 'smart' === $name ) {
|
185 |
$name = 'smartphone';
|
186 |
}
|
187 |
WP_CLI::success( $options[ 'theme_' . $name ] . ' | ' . $slug_table[ $options[ 'theme_' . $name ] ] );
|
224 |
$options = get_option( $this->option_name );
|
225 |
|
226 |
if ( isset( $useragent ) ) {
|
227 |
+
if ( in_array( $name, array( 'smartphone', 'smart', 'tablet', 'mobile', 'game' ), true ) ) {
|
228 |
+
if ( 'smartphone' === $name ) {
|
229 |
$name = 'smart';
|
230 |
}
|
231 |
$options[ 'userAgent_' . $name ] = $useragent;
|
244 |
}
|
245 |
}
|
246 |
else {
|
247 |
+
if ( in_array( $name, array( 'smartphone', 'smart', 'tablet', 'mobile', 'game' ), true ) ) {
|
248 |
+
if ( 'smartphone' === $name ) {
|
249 |
$name = 'smart';
|
250 |
}
|
251 |
WP_CLI::success( $options[ 'userAgent_' . $name ] );
|
327 |
$themes = wp_get_themes();
|
328 |
foreach ( $themes as $theme_slug => $header ) {
|
329 |
$slug_table[ $header->get( 'Name' ) ] = $theme_slug;
|
330 |
+
if ( ! isset( $assoc_args['theme'] ) && $slug === $theme_slug ) {
|
331 |
$theme = $header->get( 'Name' );
|
332 |
}
|
333 |
}
|
334 |
|
335 |
$options = get_option( $this->option_name );
|
336 |
+
if ( in_array( $name, array( 'smartphone', 'smart', 'tablet', 'mobile', 'game' ), true ) ) {
|
337 |
WP_CLI::error( 'Default Switcher can\'t add' );
|
338 |
}
|
339 |
elseif ( isset( $options[ 'custom_switcher_theme_' . $name ] ) ) {
|
341 |
}
|
342 |
else {
|
343 |
$default_theme = wp_get_theme()->get( 'Name' );
|
344 |
+
if ( $default_theme === $theme ) {
|
345 |
WP_CLI::error( $theme . ' theme is in active' );
|
346 |
}
|
347 |
|
384 |
|
385 |
$options = get_option( $this->option_name );
|
386 |
|
387 |
+
if ( in_array( $name, array( 'smartphone', 'smart', 'tablet', 'mobile', 'game' ), true ) ) {
|
388 |
WP_CLI::error( 'Default Switcher can\'t delete' );
|
389 |
}
|
390 |
elseif ( isset( $options[ 'custom_switcher_theme_' . $name ] ) ) {
|
424 |
|
425 |
$options = get_option( $this->option_name );
|
426 |
|
427 |
+
if ( 'on' === $flag ) {
|
428 |
$options['pc_switcher'] = 1;
|
429 |
update_option( $this->option_name, $options );
|
430 |
WP_CLI::success( 'turn on PC Switcher' );
|
431 |
}
|
432 |
+
elseif ( 'off' === $flag ) {
|
433 |
$options['pc_switcher'] = 0;
|
434 |
update_option( $this->option_name, $options );
|
435 |
WP_CLI::success( 'turn off PC Switcher' );
|
463 |
|
464 |
$options = get_option( $this->option_name );
|
465 |
|
466 |
+
if ( 'on' === $flag ) {
|
467 |
$options['default_css'] = 1;
|
468 |
update_option( $this->option_name, $options );
|
469 |
WP_CLI::success( 'turn on default CSS' );
|
470 |
}
|
471 |
+
elseif ( 'off' === $flag ) {
|
472 |
$options['default_css'] = 0;
|
473 |
update_option( $this->option_name, $options );
|
474 |
WP_CLI::success( 'turn off default CSS' );
|