From 5bcc7d2e7b3f9ec4ed332669bb182010f8cda913 Mon Sep 17 00:00:00 2001 From: thingsym Date: Mon, 10 Jan 2022 16:55:49 +0900 Subject: [PATCH 1/8] perf: add hook_suffix argument --- multi-device-switcher.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/multi-device-switcher.php b/multi-device-switcher.php index f945123..57a7534 100644 --- a/multi-device-switcher.php +++ b/multi-device-switcher.php @@ -676,7 +676,7 @@ public function add_header_vary( $headers ) { * * @since 1.0.0 */ - public function admin_enqueue_scripts( $hook_suffix ) { + public function admin_enqueue_scripts( $hook_suffix = '' ) { wp_enqueue_script( 'multi-device-switcher-options', plugins_url() . '/multi-device-switcher/multi-device-switcher.js', @@ -694,7 +694,7 @@ public function admin_enqueue_scripts( $hook_suffix ) { * * @since 1.0.0 */ - public function admin_enqueue_styles( $hook_suffix ) { + public function admin_enqueue_styles( $hook_suffix = '' ) { wp_enqueue_style( 'multi-device-switcher-options', plugins_url() . '/multi-device-switcher/multi-device-switcher.css', From 066b70624062cd6f612ae2d6b44b05454cce3b91 Mon Sep 17 00:00:00 2001 From: thingsym Date: Mon, 10 Jan 2022 16:57:26 +0900 Subject: [PATCH 2/8] fix: set the initial value an empty array --- multi-device-switcher.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/multi-device-switcher.php b/multi-device-switcher.php index 57a7534..c872061 100644 --- a/multi-device-switcher.php +++ b/multi-device-switcher.php @@ -134,7 +134,7 @@ class Multi_Device_Switcher { * * @var array|null $plugin_data */ - public $plugin_data; + public $plugin_data = array(); /** * Constructor From 4af1da1ef2f341a754c12ed50fe21709c6482813 Mon Sep 17 00:00:00 2001 From: thingsym Date: Mon, 10 Jan 2022 17:02:21 +0900 Subject: [PATCH 3/8] test: add test case --- tests/test-constructor.php | 4 +++- tests/test-functions.php | 14 +++++++------ tests/test-shortcode.php | 42 ++++++++++++++++++++++++++++++++++++++ tests/test-wp-cli.php | 12 ++++++++++- 4 files changed, 64 insertions(+), 8 deletions(-) create mode 100644 tests/test-shortcode.php diff --git a/tests/test-constructor.php b/tests/test-constructor.php index 46197c5..704bf34 100644 --- a/tests/test-constructor.php +++ b/tests/test-constructor.php @@ -40,7 +40,9 @@ function public_variable() { $this->assertEquals( $expected, $this->multi_device_switcher->default_options ); $this->assertEquals( '', $this->multi_device_switcher->device ); - $this->assertNull( $this->multi_device_switcher->plugin_data ); + + $this->assertIsArray( $this->multi_device_switcher->plugin_data ); + $this->assertEmpty( $this->multi_device_switcher->plugin_data ); } /** diff --git a/tests/test-functions.php b/tests/test-functions.php index eb41a8f..9c7f7cd 100644 --- a/tests/test-functions.php +++ b/tests/test-functions.php @@ -266,10 +266,10 @@ function add_header_vary() { function admin_enqueue() { $this->multi_device_switcher->load_plugin_data(); - $this->multi_device_switcher->admin_enqueue_scripts( '' ); + $this->multi_device_switcher->admin_enqueue_scripts(); $this->assertTrue( wp_script_is( 'multi-device-switcher-options' ) ); - $this->multi_device_switcher->admin_enqueue_styles( '' ); + $this->multi_device_switcher->admin_enqueue_styles(); $this->assertTrue( wp_style_is( 'multi-device-switcher-options' ) ); } @@ -296,8 +296,7 @@ function option_page_capability() { function add_option_page() { $this->markTestIncomplete( 'This test has not been implemented yet.' ); - $this->multi_device_switcher->add_option_page(); - + // $this->multi_device_switcher->add_option_page(); // $this->assertEquals( 10, has_action( 'load-appearance_page_multi-device-switcher', array( $this->multi_device_switcher, 'page_hook_suffix' ) ) ); } @@ -362,8 +361,11 @@ function load_textdomain() { * @test * @group functions */ - function load_plugin_data() { - $this->assertTrue( $this->multi_device_switcher->load_plugin_data() ); + public function load_plugin_data() { + $this->multi_device_switcher->load_plugin_data(); + $result = $this->multi_device_switcher->plugin_data; + + $this->assertTrue( is_array( $result ) ); } } diff --git a/tests/test-shortcode.php b/tests/test-shortcode.php new file mode 100644 index 0000000..2d0b3f2 --- /dev/null +++ b/tests/test-shortcode.php @@ -0,0 +1,42 @@ +multi_device_switcher = new Multi_Device_Switcher(); + + $options = array( + 'pc_switcher' => 1, + 'default_css' => 1, + 'theme_smartphone' => 'Twenty Sixteen', + 'theme_tablet' => 'Twenty Sixteen', + 'theme_mobile' => 'None', + 'theme_game' => 'None', + 'userAgent_smart' => 'iPhone, iPod, Android.*Mobile, dream, CUPCAKE, Windows Phone, IEMobile.*Touch, webOS, BB10.*Mobile, BlackBerry.*Mobile, Mobile.*Gecko', + 'userAgent_tablet' => 'iPad, Kindle, Silk, Android(?!.*Mobile), Windows.*Touch, PlayBook, Tablet.*Gecko', + 'userAgent_mobile' => 'DoCoMo, SoftBank, J-PHONE, Vodafone, KDDI, UP.Browser, WILLCOM, emobile, DDIPOCKET, Windows CE, BlackBerry, Symbian, PalmOS, Huawei, IAC, Nokia', + 'userAgent_game' => 'PlayStation Portable, PlayStation Vita, PSP, PS2, PLAYSTATION 3, PlayStation 4, Nitro, Nintendo 3DS, Nintendo Wii, Nintendo WiiU, Xbox', + 'disable_path' => '', + 'enable_regex' => 0, + 'custom_switcher_theme_test' => 'Twenty Sixteen', + 'custom_switcher_userAgent_test' => 'test1,test2', + ); + + update_option( 'multi_device_switcher_options', $options ); + } + + function tearDown() { + parent::tearDown(); + } + + /** + * @test + * @group shortcode + */ + function is_shortcode() { + $this->assertTrue( shortcode_exists( 'multi' ) ); + } + +} diff --git a/tests/test-wp-cli.php b/tests/test-wp-cli.php index cf02137..d720f59 100644 --- a/tests/test-wp-cli.php +++ b/tests/test-wp-cli.php @@ -4,7 +4,17 @@ class Test_Multi_Device_Switcher_WP_Cli extends WP_UnitTestCase { public function setUp() { parent::setUp(); - $this->multi_device_switcher = new Multi_Device_Switcher(); + // $this->multi_device_switcher_command = new Multi_Device_Switcher_Command(); + } + + /** + * @test + * @group basic + */ + function public_variable() { + $this->markTestIncomplete( 'This test has not been implemented yet.' ); + + // $this->assertEquals( 'multi_device_switcher_options', $this->multi_device_switcher_command->options ); } /** From 1762b4aabfe3f2f8cd7e07f14d9f69ba87aa0030 Mon Sep 17 00:00:00 2001 From: thingsym Date: Wed, 19 Jan 2022 17:59:47 +0900 Subject: [PATCH 4/8] test: add test case --- tests/test-constructor.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test-constructor.php b/tests/test-constructor.php index 704bf34..e2afb63 100644 --- a/tests/test-constructor.php +++ b/tests/test-constructor.php @@ -50,6 +50,7 @@ function public_variable() { * @group constructor */ function constructor() { + $this->assertEquals( 10, has_action( 'init', array( $this->multi_device_switcher, 'load_plugin_data' ) ) ); $this->assertEquals( 10, has_filter( 'init', array( $this->multi_device_switcher, 'load_textdomain' ) ) ); $this->assertEquals( 10, has_filter( 'init', array( $this->multi_device_switcher, 'init' ) ) ); From ec936a7aebd11dc48566826e4cf2a548dbb73b1d Mon Sep 17 00:00:00 2001 From: thingsym Date: Wed, 19 Jan 2022 18:01:20 +0900 Subject: [PATCH 5/8] chore: change requires to PHP 5.6 --- readme.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index 83b841e..d4199f4 100644 --- a/readme.txt +++ b/readme.txt @@ -7,7 +7,7 @@ Tags: switcher, theme, ipad, iphone, android, tablet, mobile, game Stable tag: 1.8.1 Tested up to: 5.8.0 Requires at least: 3.7 -Requires PHP: 5.4 +Requires PHP: 5.6 License: GPL2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html From 39745c70f83a14b50a6d8809c898ed83a52df301 Mon Sep 17 00:00:00 2001 From: thingsym Date: Wed, 19 Jan 2022 18:01:42 +0900 Subject: [PATCH 6/8] chore: change requires at least to wordpress 4.9 --- readme.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index d4199f4..04fd3a4 100644 --- a/readme.txt +++ b/readme.txt @@ -6,7 +6,7 @@ Donate link: https://github.com/sponsors/thingsym Tags: switcher, theme, ipad, iphone, android, tablet, mobile, game Stable tag: 1.8.1 Tested up to: 5.8.0 -Requires at least: 3.7 +Requires at least: 4.9 Requires PHP: 5.6 License: GPL2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html From a1e1403dd070ee603d24fb45b72a6eb2dcf6d2ee Mon Sep 17 00:00:00 2001 From: thingsym Date: Wed, 19 Jan 2022 18:07:00 +0900 Subject: [PATCH 7/8] docs: add Upgrade Notice --- README.md | 3 +++ readme.txt | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/README.md b/README.md index 332d12b..3e920b5 100644 --- a/README.md +++ b/README.md @@ -557,6 +557,9 @@ Small patches and bug reports can be submitted a issue tracker in Github. Forkin ## Upgrade Notice +* Version 1.8.2 + * Requires at least version 4.9 of the WordPress + * Requires PHP version 5.6 * Version 1.6.0 * Requires at least version 3.7 of the WordPress * Version 1.1.2 diff --git a/readme.txt b/readme.txt index 04fd3a4..a428d40 100644 --- a/readme.txt +++ b/readme.txt @@ -540,6 +540,10 @@ For more information about the Multi Device Switcher Command, see `wp help multi == Upgrade Notice == += 1.8.2 = +* Requires at least version 4.9 of the WordPress +* Requires PHP version 5.6 + = 1.6.0 = * Requires at least version 3.7 of the WordPress From 4f08b083b1e9c89f42776c3aa1e1b00415b4f643 Mon Sep 17 00:00:00 2001 From: thingsym Date: Wed, 19 Jan 2022 18:17:42 +0900 Subject: [PATCH 8/8] Version 1.8.2 --- README.md | 6 ++++++ languages/multi-device-switcher-ja.po | 4 ++-- languages/multi-device-switcher.pot | 4 ++-- multi-device-switcher.php | 2 +- pc-switcher-widget.php | 2 +- readme.txt | 9 ++++++++- 6 files changed, 20 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 3e920b5..e8431c6 100644 --- a/README.md +++ b/README.md @@ -407,6 +407,12 @@ Small patches and bug reports can be submitted a issue tracker in Github. Forkin ## Changelog +* Version 1.8.2 + * change requires at least to wordpress 4.9 + * change requires to PHP 5.6 + * add test case + * set the initial value an empty array + * add hook_suffix argument * Version 1.8.1 * update japanese translation * update pot diff --git a/languages/multi-device-switcher-ja.po b/languages/multi-device-switcher-ja.po index 6d7a373..b717acf 100644 --- a/languages/multi-device-switcher-ja.po +++ b/languages/multi-device-switcher-ja.po @@ -2,7 +2,7 @@ # This file is distributed under the same license as the Multi Device Switcher package. msgid "" msgstr "" -"Project-Id-Version: Multi Device Switcher 1.8.1\n" +"Project-Id-Version: Multi Device Switcher 1.8.2n" "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/multi-device-" "switcher\n" "POT-Creation-Date: 2021-12-26 08:37:47+00:00\n" @@ -21,7 +21,7 @@ msgstr "モバイル" msgid "PC" msgstr "PC" -#. #-#-#-#-# multi-device-switcher.pot (Multi Device Switcher 1.8.1) #-#-#-#-# +#. #-#-#-#-# multi-device-switcher.pot (Multi Device Switcher 1.8.2) #-#-#-#-# #. Plugin Name of the plugin/theme #: multi-device-switcher.php:755 multi-device-switcher.php:756 #: multi-device-switcher.php:939 multi-device-switcher.php:1394 diff --git a/languages/multi-device-switcher.pot b/languages/multi-device-switcher.pot index ae32002..5928278 100644 --- a/languages/multi-device-switcher.pot +++ b/languages/multi-device-switcher.pot @@ -2,7 +2,7 @@ # This file is distributed under the same license as the Multi Device Switcher package. msgid "" msgstr "" -"Project-Id-Version: Multi Device Switcher 1.8.1\n" +"Project-Id-Version: Multi Device Switcher 1.8.2\n" "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/multi-device-" "switcher\n" "POT-Creation-Date: 2021-12-26 08:37:47+00:00\n" @@ -21,7 +21,7 @@ msgstr "" msgid "PC" msgstr "" -#. #-#-#-#-# multi-device-switcher.pot (Multi Device Switcher 1.8.1) #-#-#-#-# +#. #-#-#-#-# multi-device-switcher.pot (Multi Device Switcher 1.8.2) #-#-#-#-# #. Plugin Name of the plugin/theme #: multi-device-switcher.php:755 multi-device-switcher.php:756 #: multi-device-switcher.php:939 multi-device-switcher.php:1394 diff --git a/multi-device-switcher.php b/multi-device-switcher.php index c872061..18d0fb4 100644 --- a/multi-device-switcher.php +++ b/multi-device-switcher.php @@ -3,7 +3,7 @@ * Plugin Name: Multi Device Switcher * Plugin URI: https://github.com/thingsym/multi-device-switcher * Description: This WordPress plugin allows you to set a separate theme for device (Smart Phone, Tablet PC, Mobile Phone, Game and custom). - * Version: 1.8.1 + * Version: 1.8.2 * Author: thingsym * Author URI: https://www.thingslabo.com/ * License: GPL2 or later diff --git a/pc-switcher-widget.php b/pc-switcher-widget.php index c7c8458..220f1cf 100644 --- a/pc-switcher-widget.php +++ b/pc-switcher-widget.php @@ -3,7 +3,7 @@ * Widget Name: PC Switcher Widget * Plugin URI: https://github.com/thingsym/multi-device-switcher * Description: PC Switcher Widget add-on for the Multi Device Switcher. Use this widget to add the PC Switcher to a widget. - * Version: 1.8.1 + * Version: 1.8.2 * Author: thingsym * Author URI: https://www.thingslabo.com/ * License: GPL2 or later diff --git a/readme.txt b/readme.txt index a428d40..9aa0216 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Contributors: thingsym Link: https://github.com/thingsym/multi-device-switcher Donate link: https://github.com/sponsors/thingsym Tags: switcher, theme, ipad, iphone, android, tablet, mobile, game -Stable tag: 1.8.1 +Stable tag: 1.8.2 Tested up to: 5.8.0 Requires at least: 4.9 Requires PHP: 5.6 @@ -365,6 +365,13 @@ For more information about the Multi Device Switcher Command, see `wp help multi == Changelog == += 1.8.2 = +* change requires at least to wordpress 4.9 +* change requires to PHP 5.6 +* add test case +* set the initial value an empty array +* add hook_suffix argument + = 1.8.1 = * update japanese translation * update pot