From a777d7b3256c3b091ccdad760e57b141aae966c2 Mon Sep 17 00:00:00 2001 From: shimotmk Date: Wed, 28 Sep 2022 13:22:02 +0900 Subject: [PATCH 1/2] =?UTF-8?q?clean=20/=20vk=5Fblocks=5Foptions=20?= =?UTF-8?q?=E3=82=AA=E3=83=97=E3=82=B7=E3=83=A7=E3=83=B3=E5=80=A4=E3=81=AE?= =?UTF-8?q?=E5=87=A6=E7=90=86=E3=82=92=E7=84=A1=E6=96=99=E7=89=88=E3=81=AB?= =?UTF-8?q?=E7=A7=BB=E5=8B=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/deploy-free.sh | 2 +- .../class-vk-blocks-pro-options.php | 69 -------- inc/vk-blocks-pro/vk-blocks-pro-functions.php | 3 - inc/vk-blocks/class-vk-blocks-options.php | 15 +- test/phpunit/free/test-get-options-free.php | 141 --------------- test/phpunit/pro/test-vk-blocks-options.php | 166 ------------------ 6 files changed, 14 insertions(+), 382 deletions(-) delete mode 100644 inc/vk-blocks-pro/class-vk-blocks-pro-options.php delete mode 100644 test/phpunit/free/test-get-options-free.php diff --git a/bin/deploy-free.sh b/bin/deploy-free.sh index e7ace97df..a5f152cc2 100755 --- a/bin/deploy-free.sh +++ b/bin/deploy-free.sh @@ -24,7 +24,7 @@ mv vk-blocks/ vk-blocks-copy-target/ # Cloneした無料版のディレクトリに移動 cd ./vk-blocks-copy-target/ # コピー先の トップディレクトリ を一旦削除 -rm -rf editor-css/* inc/* lib/* options-css/* src/* +rm -rf editor-css/* inc/* lib/* options-css/* src/* test/* # プロ版のディレクトリに移動 cd ../ diff --git a/inc/vk-blocks-pro/class-vk-blocks-pro-options.php b/inc/vk-blocks-pro/class-vk-blocks-pro-options.php deleted file mode 100644 index 7e27303bd..000000000 --- a/inc/vk-blocks-pro/class-vk-blocks-pro-options.php +++ /dev/null @@ -1,69 +0,0 @@ - array( - 'type' => 'string', - 'default' => 'display', - ), - 'new_faq_accordion' => array( - 'type' => 'string', - 'default' => 'disable', - ), - ); - - /** - * VK Blocks License Option schema - * - * @var array - */ - private $license_key_option_scheme = array( - 'vk_blocks_pro_license_key' => array( - 'type' => 'string', - 'default' => null, - ), - ); - - /** - * Constructor. - */ - private function __construct() { - add_filter( 'vk_blocks_default_options_scheme', array( $this, 'vk_blocks_pro_default_options_scheme' ) ); - } - - /** - * Initialize - * - * @return VK_Blocks_Pro_Options - */ - public static function init() { - // static 宣言しているので既に定義されている場合は $instance に null は入らずに既存のインスタンスのまま. - static $instance = null; - return $instance ? $instance : $instance = new static(); - } - - /** - * Pro Option - */ - public function vk_blocks_pro_default_options_scheme() { - $array = $this->vk_blocks_pro_option_schema; - if ( vk_blocks_is_license_setting() ) { - $array = array_merge( $this->license_key_option_scheme, $this->vk_blocks_pro_option_schema ); - } - return $array; - } -} diff --git a/inc/vk-blocks-pro/vk-blocks-pro-functions.php b/inc/vk-blocks-pro/vk-blocks-pro-functions.php index 06e381e8a..cb44d7d8b 100644 --- a/inc/vk-blocks-pro/vk-blocks-pro-functions.php +++ b/inc/vk-blocks-pro/vk-blocks-pro-functions.php @@ -8,9 +8,6 @@ // Pro 用の管理画面を読み込み. require_once dirname( __FILE__ ) . '/admin-pro/admin-pro.php'; -require_once dirname( __FILE__ ) . '/class-vk-blocks-pro-options.php'; -VK_Blocks_Pro_Options::init(); - /** * Pro 専用のスクリプトの読み込み */ diff --git a/inc/vk-blocks/class-vk-blocks-options.php b/inc/vk-blocks/class-vk-blocks-options.php index c698fbee0..fd22b9d4b 100644 --- a/inc/vk-blocks/class-vk-blocks-options.php +++ b/inc/vk-blocks/class-vk-blocks-options.php @@ -137,9 +137,20 @@ public static function options_scheme() { 'type' => 'boolean', 'default' => false, ), + 'vk_blocks_pro_license_key' => array( + 'type' => 'string', + 'default' => null, + ), + 'display_vk_block_template' => array( + 'type' => 'string', + 'default' => 'display', + ), + 'new_faq_accordion' => array( + 'type' => 'string', + 'default' => 'disable', + ), ); - $array = array_merge( $default_options_schema, apply_filters( 'vk_blocks_default_options_scheme', array() ) ); - return $array; + return $default_options_schema; } /** diff --git a/test/phpunit/free/test-get-options-free.php b/test/phpunit/free/test-get-options-free.php deleted file mode 100644 index 6bc6077ab..000000000 --- a/test/phpunit/free/test-get-options-free.php +++ /dev/null @@ -1,141 +0,0 @@ - null, - 'correct' => array( - 'balloon_border_width' => 1, - 'margin_unit' => 'rem', - 'margin_size' => array( - 'xl' => array( - 'mobile' => null, - 'tablet' => null, - 'pc' => null, - ), - 'lg' => array( - 'mobile' => null, - 'tablet' => null, - 'pc' => null, - ), - 'md' => array( - 'mobile' => null, - 'tablet' => null, - 'pc' => null, - ), - 'sm' => array( - 'mobile' => null, - 'tablet' => null, - 'pc' => null, - ), - 'xs' => array( - 'mobile' => null, - 'tablet' => null, - 'pc' => null, - ), - ), - 'load_separate_option' => false, - ), - ), - array( - 'option' => array( - 'balloon_border_width' => 2, - 'margin_unit' => 'px', - 'margin_size' => array( - 'xl' => array( - 'mobile' => null, - 'tablet' => null, - 'pc' => null, - ), - 'lg' => array( - 'mobile' => 1, - 'tablet' => 2, - 'pc' => 3, - ), - 'md' => array( - 'mobile' => 1, - 'tablet' => 2, - 'pc' => 3, - ), - 'sm' => array( - 'mobile' => 1, - 'tablet' => 2, - 'pc' => 3, - ), - 'xs' => array( - 'mobile' => null, - 'tablet' => null, - 'pc' => null, - ), - ), - 'load_separate_option' => true, - ), - 'correct' => array( - 'balloon_border_width' => 2, - 'margin_unit' => 'px', - 'margin_size' => array( - 'xl' => array( - 'mobile' => null, - 'tablet' => null, - 'pc' => null, - ), - 'lg' => array( - 'mobile' => 1, - 'tablet' => 2, - 'pc' => 3, - ), - 'md' => array( - 'mobile' => 1, - 'tablet' => 2, - 'pc' => 3, - ), - 'sm' => array( - 'mobile' => 1, - 'tablet' => 2, - 'pc' => 3, - ), - 'xs' => array( - 'mobile' => null, - 'tablet' => null, - 'pc' => null, - ), - ), - 'load_separate_option' => true, - ), - ), - ); - print PHP_EOL; - print '------------------------------------' . PHP_EOL; - print 'VK_Blocks_Options::get_options()' . PHP_EOL; - print '------------------------------------' . PHP_EOL; - foreach ( $test_data as $test_value ) { - - if ( empty( $test_value['option'] ) ){ - delete_option( 'vk_blocks_options' ); - } else { - update_option( 'vk_blocks_options', $test_value['option'] ); - } - - $return = VK_Blocks_Options::get_options(); - $correct = $test_value['correct']; - - print 'return :'; - print PHP_EOL; - var_dump( $return ); - print PHP_EOL; - print 'correct :'; - print PHP_EOL; - var_dump( $correct ); - print PHP_EOL; - $this->assertSame( $correct, $return ); - - } - } -} diff --git a/test/phpunit/pro/test-vk-blocks-options.php b/test/phpunit/pro/test-vk-blocks-options.php index cb34972a1..8adc21f58 100644 --- a/test/phpunit/pro/test-vk-blocks-options.php +++ b/test/phpunit/pro/test-vk-blocks-options.php @@ -7,172 +7,6 @@ class VKBlocksOptionsTest extends WP_UnitTestCase { - public function test_options_scheme() { - $test_data = array( - // Pro版 マージ - array( - 'option' => array( - 'vk_blocks_pro_license_key' => array( - 'type' => 'string', - 'default' => null, - ), - 'display_vk_block_template' => array( - 'type' => 'string', - 'default' => 'display', - ), - 'new_faq_accordion' => array( - 'type' => 'string', - 'default' => 'disable', - ), - ), - 'correct' => array( - 'balloon_border_width' => array( - 'type' => 'number', - 'default' => 1, - ), - 'margin_unit' => array( - 'type' => 'string', - 'default' => 'rem', - ), - 'margin_size' => array( - 'type' => 'object', - 'items' => array( - 'xl' => array( - 'type' => 'object', - 'items' => array( - 'mobile' => array( - 'type' => 'number', - 'default' => null, - ), - 'tablet' => array( - 'type' => 'number', - 'default' => null, - ), - 'pc' => array( - 'type' => 'number', - 'default' => null, - ), - ), - ), - 'lg' => array( - 'type' => 'object', - 'items' => array( - 'mobile' => array( - 'type' => 'number', - 'default' => null, - ), - 'tablet' => array( - 'type' => 'number', - 'default' => null, - ), - 'pc' => array( - 'type' => 'number', - 'default' => null, - ), - ), - ), - 'md' => array( - 'type' => 'object', - 'items' => array( - 'mobile' => array( - 'type' => 'number', - 'default' => null, - ), - 'tablet' => array( - 'type' => 'number', - 'default' => null, - ), - 'pc' => array( - 'type' => 'number', - 'default' => null, - ), - ), - ), - 'sm' => array( - 'type' => 'object', - 'items' => array( - 'mobile' => array( - 'type' => 'number', - 'default' => null, - ), - 'tablet' => array( - 'type' => 'number', - 'default' => null, - ), - 'pc' => array( - 'type' => 'number', - 'default' => null, - ), - ), - ), - 'xs' => array( - 'type' => 'object', - 'items' => array( - 'mobile' => array( - 'type' => 'number', - 'default' => null, - ), - 'tablet' => array( - 'type' => 'number', - 'default' => null, - ), - 'pc' => array( - 'type' => 'number', - 'default' => null, - ), - ), - ), - ), - ), - 'load_separate_option' => array( - 'type' => 'boolean', - 'default' => false, - ), - 'vk_blocks_pro_license_key' => array( - 'type' => 'string', - 'default' => null, - ), - 'display_vk_block_template' => array( - 'type' => 'string', - 'default' => 'display', - ), - 'new_faq_accordion' => array( - 'type' => 'string', - 'default' => 'disable', - ), - ), - ), - ); - print PHP_EOL; - print '------------------------------------' . PHP_EOL; - print 'options_scheme()' . PHP_EOL; - print '------------------------------------' . PHP_EOL; - foreach ( $test_data as $test_value ) { - if ( ! empty( $test_value['option'] ) ){ - $array = isset( $test_value['option'] ) ? $test_value['option'] : null; - add_filter( - 'vk_blocks_default_options_scheme', - function() use( $array ) { - return $array; - } - ); - } - $return = VK_Blocks_Options::options_scheme(); - $correct = $test_value['correct']; - - // print 'return :'; - // print PHP_EOL; - // var_dump( $return ); - // print PHP_EOL; - // print 'correct :'; - // print PHP_EOL; - // var_dump( $correct ); - // print PHP_EOL; - $this->assertSame( $correct, $return ); - - } - } - public function test_balloon_image_number() { $test_data = array( array( From 3a548c90e0ecf42a82786bce30d449784da4680b Mon Sep 17 00:00:00 2001 From: shimotmk Date: Wed, 28 Sep 2022 13:31:10 +0900 Subject: [PATCH 2/2] phpcs --- inc/vk-blocks/class-vk-blocks-options.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/inc/vk-blocks/class-vk-blocks-options.php b/inc/vk-blocks/class-vk-blocks-options.php index fd22b9d4b..c1e82e5ea 100644 --- a/inc/vk-blocks/class-vk-blocks-options.php +++ b/inc/vk-blocks/class-vk-blocks-options.php @@ -35,15 +35,15 @@ private function __construct() { */ public static function options_scheme() { $default_options_schema = array( - 'balloon_border_width' => array( + 'balloon_border_width' => array( 'type' => 'number', 'default' => 1, ), - 'margin_unit' => array( + 'margin_unit' => array( 'type' => 'string', 'default' => 'rem', ), - 'margin_size' => array( + 'margin_size' => array( 'type' => 'object', 'items' => array( 'xl' => array( @@ -133,7 +133,7 @@ public static function options_scheme() { ), ), ), - 'load_separate_option' => array( + 'load_separate_option' => array( 'type' => 'boolean', 'default' => false, ),