From c5a4397bae77b495a4a95d89b8bfed1758cbc572 Mon Sep 17 00:00:00 2001 From: mtdkei Date: Wed, 22 May 2024 09:00:59 +0900 Subject: [PATCH 01/31] Fix: Remove HTML tags and their content from custom CSS while preserving media query operators --- inc/css-customize/css-customize-single.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/inc/css-customize/css-customize-single.php b/inc/css-customize/css-customize-single.php index c30e57b3..d5642cc9 100644 --- a/inc/css-customize/css-customize-single.php +++ b/inc/css-customize/css-customize-single.php @@ -14,11 +14,12 @@ function veu_css_customize_single_load(){ 入力された CSS をソースに出力 /* ------------------------------------------------ */ function veu_insert_custom_css() { - if ( is_singular() ) { global $post; $css = veu_get_the_custom_css_single( $post ); - if ( $css ){ + if ( $css ) { + // Decode entities and remove HTML tags and their contents + $css = html_entity_decode($css); echo ''; } } @@ -27,14 +28,14 @@ function veu_insert_custom_css() { function veu_get_the_custom_css_single( $post ) { $css_customize = get_post_meta( $post->ID, '_veu_custom_css', true ); if ( $css_customize ) { - // delete br + // Delete br $css_customize = str_replace( PHP_EOL, '', $css_customize ); - // delete tab + // Delete tab $css_customize = preg_replace( '/[\n\r\t]/', '', $css_customize ); - // multi space convert to single space + // Multi space convert to single space $css_customize = preg_replace( '/\s(?=\s)/', '', $css_customize ); - // Delete Comment + // Delete comment $css_customize = preg_replace( '/[\s\t]*\/\*\/?(\n|[^\/]|[^*]\/)*\*\//', '', $css_customize ); } - return strip_tags( $css_customize ); + return $css_customize; } From 989078e870bc980968659af3e18b3d3f20267642 Mon Sep 17 00:00:00 2001 From: mtdkei Date: Wed, 22 May 2024 09:02:53 +0900 Subject: [PATCH 02/31] Fix: Remove HTML tags and their content from custom CSS while preserving media query operators --- readme.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.txt b/readme.txt index b36d0ea2..b13b31bd 100644 --- a/readme.txt +++ b/readme.txt @@ -81,6 +81,7 @@ e.g. == Changelog == +[ Bug fix ][ Custom CSS ] Preserving media query operators in custom CSS. [ Add setting ][ Post Type Manager ] Add a menu icon setting. = 9.97.2 = From cb5e7cbd418aa8533e87b2a2cd1c313b90d2348d Mon Sep 17 00:00:00 2001 From: mtdkei Date: Wed, 22 May 2024 09:59:07 +0900 Subject: [PATCH 03/31] Fix: Preserving media query operators in custom CSS --- inc/css-customize/css-customize.php | 77 +++++++++++++---------------- 1 file changed, 35 insertions(+), 42 deletions(-) diff --git a/inc/css-customize/css-customize.php b/inc/css-customize/css-customize.php index 37f8e5f8..bd4c8039 100644 --- a/inc/css-customize/css-customize.php +++ b/inc/css-customize/css-customize.php @@ -20,13 +20,12 @@ public static function load_css_action() { add_action( $hook_point, array( get_called_class(), 'css_customize_push_css' ), 200 ); } - public function set_hook() { + public function set_hook() { add_action( 'admin_footer', array( $this, 'css_customize_page_js_and_css' ) ); - // 編集画面への反映 // add_filter( 'tiny_mce_before_init', array( $this, 'css_customize_push_editor_css' ) ); - // + add_action( 'admin_menu', array( $this, 'css_customize_menu' ), 20 ); add_action( 'vkExUnit_action_adminbar', array( $this, 'admin_bar' ) ); require_once( dirname( __FILE__ ) . '/css-customize-single.php' ); @@ -41,7 +40,6 @@ public function set_hook() { require_once( dirname( __FILE__ ) . '/class-veu-metabox-css-customize.php' ); } ); - } public function admin_bar( $wp_admin_bar ) { @@ -62,27 +60,21 @@ public function admin_bar( $wp_admin_bar ) { 「CSSカスタマイズ」のメニュー /*-------------------------------------------*/ public function css_customize_menu() { - // $capability_required = veu_get_capability_required(); add_submenu_page( 'vkExUnit_setting_page', __( 'CSS Customize', 'vk-all-in-one-expansion-unit' ), __( 'CSS Customize', 'vk-all-in-one-expansion-unit' ), - // $capability_required, // edit_theme_optionsのユーザーにもアクセスさせないため 'activate_plugins', 'vkExUnit_css_customize', array( $this, 'css_customize_render_page' ) ); } - public function css_customize_render_page() { - $data = $this->css_customize_valid_form(); - include( VEU_DIRECTORY_PATH . '/inc/css-customize/css-customize-edit.php' ); } - /* 設定画面のCSSとJS /*-------------------------------------------*/ @@ -91,52 +83,53 @@ public function css_customize_page_js_and_css( $hook_suffix ) { if ( $hook_suffix == 'appearance_page_theme-css-customize' || $hook_suffix == 'appearance_page_bv_grid_unit_options' - ) { - ?> - - + + '', 'customCss' => '', ); - + if ( isset( $_POST['bv-css-submit'] ) && ! empty( $_POST['bv-css-submit'] ) && isset( $_POST['bv-css-css'] ) && isset( $_POST['biz-vektor-css-nonce'] ) && wp_verify_nonce( $_POST['biz-vektor-css-nonce'], 'biz-vektor-css-submit' ) ) { - $cleanCSS = strip_tags( stripslashes( trim( $_POST['bv-css-css'] ) ) ); - + // エスケープ処理を行わずに保存 + $cleanCSS = stripslashes( trim( $_POST['bv-css-css'] ) ); + if ( update_option( 'vkExUnit_css_customize', $cleanCSS ) ) { - $data['mess'] = '

' . __( 'Your custom CSS was saved.', 'biz-vektor' ) . '

'; } + $data['mess'] = '

' . __( 'Your custom CSS was saved.', 'biz-vektor' ) . '

'; + } } else { if ( isset( $_POST['bv-css-submit'] ) && ! empty( $_POST['bv-css-submit'] ) ) { - $data['mess'] = '

' . __( 'Error occured. Please try again.', 'biz-vektor' ) . '

'; } + $data['mess'] = '

' . __( 'Error occured. Please try again.', 'biz-vektor' ) . '

'; + } } - - $data['customCss'] = get_option( 'vkExUnit_css_customize' ); - + + $custom_css_option = get_option( 'vkExUnit_css_customize' ); + $data['customCss'] = $custom_css_option !== false ? $custom_css_option : ''; + return $data; } public static function css_customize_get_css_min() { - $css_customize = get_option( 'vkExUnit_css_customize' ); - - if ( $css_customize ) { + + if ( $css_customize !== false ) { // delete br $css_customize = str_replace( PHP_EOL, '', $css_customize ); // delete tab @@ -146,22 +139,22 @@ public static function css_customize_get_css_min() { // Delete Comment $css_customize = preg_replace( '/[\s\t]*\/\*\/?(\n|[^\/]|[^*]\/)*\*\//', '', $css_customize ); } - return $css_customize; - + return $css_customize !== false ? $css_customize : ''; } public static function css_customize_get_the_css_min() { - $css_customize = strip_tags( veu_css_customize::css_customize_get_css_min() ); + $css_customize = veu_css_customize::css_customize_get_css_min(); return $css_customize; } public static function css_customize_push_css() { $css_customize = veu_css_customize::css_customize_get_the_css_min(); if ( $css_customize ) { - ?> - + ?> + Date: Wed, 22 May 2024 10:12:23 +0900 Subject: [PATCH 04/31] Reverting missing comments --- inc/css-customize/css-customize.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/inc/css-customize/css-customize.php b/inc/css-customize/css-customize.php index bd4c8039..30f4436d 100644 --- a/inc/css-customize/css-customize.php +++ b/inc/css-customize/css-customize.php @@ -60,21 +60,27 @@ public function admin_bar( $wp_admin_bar ) { 「CSSカスタマイズ」のメニュー /*-------------------------------------------*/ public function css_customize_menu() { + // $capability_required = veu_get_capability_required(); add_submenu_page( 'vkExUnit_setting_page', __( 'CSS Customize', 'vk-all-in-one-expansion-unit' ), __( 'CSS Customize', 'vk-all-in-one-expansion-unit' ), + // $capability_required, // edit_theme_optionsのユーザーにもアクセスさせないため 'activate_plugins', 'vkExUnit_css_customize', array( $this, 'css_customize_render_page' ) ); } + public function css_customize_render_page() { + $data = $this->css_customize_valid_form(); + include( VEU_DIRECTORY_PATH . '/inc/css-customize/css-customize-edit.php' ); } + /* 設定画面のCSSとJS /*-------------------------------------------*/ @@ -99,12 +105,14 @@ public function css_customize_page_js_and_css( $hook_suffix ) { } } + public function css_customize_valid_form() { + $data = array( 'mess' => '', 'customCss' => '', ); - + if ( isset( $_POST['bv-css-submit'] ) && ! empty( $_POST['bv-css-submit'] ) && isset( $_POST['bv-css-css'] ) && isset( $_POST['biz-vektor-css-nonce'] ) && wp_verify_nonce( $_POST['biz-vektor-css-nonce'], 'biz-vektor-css-submit' ) ) { @@ -128,7 +136,7 @@ public function css_customize_valid_form() { public static function css_customize_get_css_min() { $css_customize = get_option( 'vkExUnit_css_customize' ); - + if ( $css_customize !== false ) { // delete br $css_customize = str_replace( PHP_EOL, '', $css_customize ); @@ -150,11 +158,10 @@ public static function css_customize_get_the_css_min() { public static function css_customize_push_css() { $css_customize = veu_css_customize::css_customize_get_the_css_min(); if ( $css_customize ) { - ?> - + ?> + Date: Wed, 22 May 2024 10:43:15 +0900 Subject: [PATCH 05/31] Avoiding errors in PHP 8.2 --- inc/css-customize/css-customize-single.php | 2 +- inc/css-customize/css-customize.php | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/inc/css-customize/css-customize-single.php b/inc/css-customize/css-customize-single.php index d5642cc9..96bda5b2 100644 --- a/inc/css-customize/css-customize-single.php +++ b/inc/css-customize/css-customize-single.php @@ -37,5 +37,5 @@ function veu_get_the_custom_css_single( $post ) { // Delete comment $css_customize = preg_replace( '/[\s\t]*\/\*\/?(\n|[^\/]|[^*]\/)*\*\//', '', $css_customize ); } - return $css_customize; + return $css_customize !== false ? $css_customize : ''; } diff --git a/inc/css-customize/css-customize.php b/inc/css-customize/css-customize.php index 30f4436d..373a2446 100644 --- a/inc/css-customize/css-customize.php +++ b/inc/css-customize/css-customize.php @@ -72,15 +72,11 @@ public function css_customize_menu() { ); } - public function css_customize_render_page() { - $data = $this->css_customize_valid_form(); - include( VEU_DIRECTORY_PATH . '/inc/css-customize/css-customize-edit.php' ); } - /* 設定画面のCSSとJS /*-------------------------------------------*/ @@ -105,9 +101,7 @@ public function css_customize_page_js_and_css( $hook_suffix ) { } } - public function css_customize_valid_form() { - $data = array( 'mess' => '', 'customCss' => '', @@ -129,7 +123,7 @@ public function css_customize_valid_form() { } $custom_css_option = get_option( 'vkExUnit_css_customize' ); - $data['customCss'] = $custom_css_option !== false ? $custom_css_option : ''; + $data['customCss'] = $custom_css_option !== false ? htmlspecialchars_decode( $custom_css_option ) : ''; return $data; } @@ -138,6 +132,7 @@ public static function css_customize_get_css_min() { $css_customize = get_option( 'vkExUnit_css_customize' ); if ( $css_customize !== false ) { + $css_customize = htmlspecialchars_decode($css_customize); // delete br $css_customize = str_replace( PHP_EOL, '', $css_customize ); // delete tab From 3b316b773cb2d4fe4ad73376712600cbf0e5c2fe Mon Sep 17 00:00:00 2001 From: mtdkei Date: Wed, 22 May 2024 10:45:21 +0900 Subject: [PATCH 06/31] Change the case of the comments --- inc/css-customize/css-customize.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/inc/css-customize/css-customize.php b/inc/css-customize/css-customize.php index 373a2446..1923cf1d 100644 --- a/inc/css-customize/css-customize.php +++ b/inc/css-customize/css-customize.php @@ -133,13 +133,13 @@ public static function css_customize_get_css_min() { if ( $css_customize !== false ) { $css_customize = htmlspecialchars_decode($css_customize); - // delete br + // Delete br $css_customize = str_replace( PHP_EOL, '', $css_customize ); - // delete tab + // Delete tab $css_customize = preg_replace( '/[\n\r\t]/', '', $css_customize ); - // multi space convert to single space + // Multi space convert to single space $css_customize = preg_replace( '/\s(?=\s)/', '', $css_customize ); - // Delete Comment + // Delete comment $css_customize = preg_replace( '/[\s\t]*\/\*\/?(\n|[^\/]|[^*]\/)*\*\//', '', $css_customize ); } return $css_customize !== false ? $css_customize : ''; From 064f08921a049bd0349106562f013010fa7969a6 Mon Sep 17 00:00:00 2001 From: mtdkei Date: Wed, 22 May 2024 10:55:52 +0900 Subject: [PATCH 07/31] Avoiding errors in PHP 8.2 --- tests/test-css-customize.php | 65 +++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/tests/test-css-customize.php b/tests/test-css-customize.php index a84bea4d..73036cd2 100644 --- a/tests/test-css-customize.php +++ b/tests/test-css-customize.php @@ -14,28 +14,28 @@ class CssCustomizeTest extends WP_UnitTestCase { * カスタマイズCSSのテスト */ function test_css_customize_get_the_css_min() { - $tests = array( - array( - 'option' => 'div > h1 { color:red; }', - 'correct' => 'div > h1 { color:red; }', - ), - array( - 'option' => 'div > h1 { - color:red; - }', - 'correct' => 'div > h1 {color:red;}', - ), - array( - 'option' => 'div > h1 {color:red;}', - 'correct' => 'div > h1 {color:red;}', - ), - ); + $tests = array( + array( + 'option' => 'div > h1 { color:red; }', + 'correct' => 'div > h1 { color:red; }', + ), + array( + 'option' => 'div > h1 { + color:red; + }', + 'correct' => 'div > h1 {color:red;}', + ), + array( + 'option' => 'div > h1 {color:red;}', + 'correct' => 'div > h1 {color:red;}', + ), + ); - print PHP_EOL; - print '------------------------------------' . PHP_EOL; - print 'veu_css_customize' . PHP_EOL; - print '------------------------------------' . PHP_EOL; - $before_option = get_option( 'vkExUnit_css_customize' ); + print PHP_EOL; + print '------------------------------------' . PHP_EOL; + print 'veu_css_customize' . PHP_EOL; + print '------------------------------------' . PHP_EOL; + $before_option = get_option( 'vkExUnit_css_customize' ); foreach ( $tests as $key => $test_value ) { update_option( 'vkExUnit_css_customize', $test_value['option'] ); @@ -44,9 +44,9 @@ function test_css_customize_get_the_css_min() { print 'return :' . $return . PHP_EOL; print 'correct :' . $test_value['correct'] . PHP_EOL; $this->assertEquals( $test_value['correct'], $return ); - } // foreach ( $tests as $key => $test_value ) { - $before_option = update_option( 'vkExUnit_css_customize', $before_option ); - } // function test_css_customize_get_the_css_min() { + } + update_option( 'vkExUnit_css_customize', $before_option ); + } /* Singular page css */ function test_veu_get_the_custom_css_single() { @@ -61,8 +61,8 @@ function test_veu_get_the_custom_css_single() { array( 'post_title' => 'タイトル', 'post_meta' => 'div > h1 { - color:red; - }', + color:red; + }', 'correct' => 'div > h1 {color:red;}', ), array( @@ -80,7 +80,12 @@ function test_veu_get_the_custom_css_single() { foreach ( $test_array as $key => $value ) { // テスト用のデータを投稿する - $post_data['post_content'] = $value['post_title']; + $post_data = array( + 'post_title' => $value['post_title'], + 'post_content' => $value['post_title'], + 'post_status' => 'publish', + 'post_type' => 'post', + ); // 投稿が成功すると投稿IDが返ってくる $post_id = wp_insert_post( $post_data ); @@ -103,8 +108,6 @@ function test_veu_get_the_custom_css_single() { // テスト用データを消去 wp_delete_post( $post_id, true ); - } // foreach ( $test_array as $key => $value ) { - - } // function test_veu_get_the_custom_css_single() { - + } + } } From d7868730681a54ecf3a24802f6e3cffc545d0008 Mon Sep 17 00:00:00 2001 From: mtdkei Date: Wed, 22 May 2024 11:48:46 +0900 Subject: [PATCH 08/31] Fix: Refactor veu-css-customize-single.php for correct CSS output in singular pages --- inc/css-customize/css-customize-single.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/css-customize/css-customize-single.php b/inc/css-customize/css-customize-single.php index 96bda5b2..d5642cc9 100644 --- a/inc/css-customize/css-customize-single.php +++ b/inc/css-customize/css-customize-single.php @@ -37,5 +37,5 @@ function veu_get_the_custom_css_single( $post ) { // Delete comment $css_customize = preg_replace( '/[\s\t]*\/\*\/?(\n|[^\/]|[^*]\/)*\*\//', '', $css_customize ); } - return $css_customize !== false ? $css_customize : ''; + return $css_customize; } From ef68f03d20c286e7333593c29673aafdb80961e9 Mon Sep 17 00:00:00 2001 From: mtdkei Date: Wed, 22 May 2024 11:49:24 +0900 Subject: [PATCH 09/31] Fix: Adjust veu_css_customize class to ensure proper CSS minification and loading --- inc/css-customize/css-customize.php | 110 ++++++++++++++-------------- 1 file changed, 54 insertions(+), 56 deletions(-) diff --git a/inc/css-customize/css-customize.php b/inc/css-customize/css-customize.php index 1923cf1d..1405815a 100644 --- a/inc/css-customize/css-customize.php +++ b/inc/css-customize/css-customize.php @@ -110,66 +110,64 @@ public function css_customize_valid_form() { if ( isset( $_POST['bv-css-submit'] ) && ! empty( $_POST['bv-css-submit'] ) && isset( $_POST['bv-css-css'] ) && isset( $_POST['biz-vektor-css-nonce'] ) && wp_verify_nonce( $_POST['biz-vektor-css-nonce'], 'biz-vektor-css-submit' ) ) { - // エスケープ処理を行わずに保存 - $cleanCSS = stripslashes( trim( $_POST['bv-css-css'] ) ); - - if ( update_option( 'vkExUnit_css_customize', $cleanCSS ) ) { - $data['mess'] = '

' . __( 'Your custom CSS was saved.', 'biz-vektor' ) . '

'; + // エスケープ処理を行わずに保存 + $cleanCSS = stripslashes( trim( $_POST['bv-css-css'] ) ); + + if ( update_option( 'vkExUnit_css_customize', $cleanCSS ) ) { + $data['mess'] = '

' . __( 'Your custom CSS was saved.', 'biz-vektor' ) . '

'; + } + } else { + if ( isset( $_POST['bv-css-submit'] ) && ! empty( $_POST['bv-css-submit'] ) ) { + $data['mess'] = '

' . __( 'Error occured. Please try again.', 'biz-vektor' ) . '

'; + } } - } else { - if ( isset( $_POST['bv-css-submit'] ) && ! empty( $_POST['bv-css-submit'] ) ) { - $data['mess'] = '

' . __( 'Error occured. Please try again.', 'biz-vektor' ) . '

'; + + $custom_css_option = get_option( 'vkExUnit_css_customize' ); + $data['customCss'] = $custom_css_option !== false ? htmlspecialchars_decode( $custom_css_option ) : ''; + + return $data; + } + + public static function css_customize_get_css_min() { + $css_customize = get_option( 'vkExUnit_css_customize' ); + if ( $css_customize ) { + // Delete br + $css_customize = str_replace( PHP_EOL, '', $css_customize ); + // Delete tab + $css_customize = preg_replace( '/[\n\r\t]/', '', $css_customize ); + // Multi space convert to single space + $css_customize = preg_replace( '/\s(?=\s)/', '', $css_customize ); + // Delete comment + $css_customize = preg_replace( '/[\s\t]*\/\*\/?(\n|[^\/]|[^*]\/)*\*\//', '', $css_customize ); } + return $css_customize; } - $custom_css_option = get_option( 'vkExUnit_css_customize' ); - $data['customCss'] = $custom_css_option !== false ? htmlspecialchars_decode( $custom_css_option ) : ''; + public static function css_customize_get_the_css_min() { + $css_customize = self::css_customize_get_css_min(); + return $css_customize; + } - return $data; - } - - public static function css_customize_get_css_min() { - $css_customize = get_option( 'vkExUnit_css_customize' ); - - if ( $css_customize !== false ) { - $css_customize = htmlspecialchars_decode($css_customize); - // Delete br - $css_customize = str_replace( PHP_EOL, '', $css_customize ); - // Delete tab - $css_customize = preg_replace( '/[\n\r\t]/', '', $css_customize ); - // Multi space convert to single space - $css_customize = preg_replace( '/\s(?=\s)/', '', $css_customize ); - // Delete comment - $css_customize = preg_replace( '/[\s\t]*\/\*\/?(\n|[^\/]|[^*]\/)*\*\//', '', $css_customize ); + public static function css_customize_push_css() { + $css_customize = self::css_customize_get_the_css_min(); + if ( $css_customize ) { + ?> + + css_customize_get_css_min(); + // + // .editor-styles-wrapper h2 { font-size:30px; } + // + // if ( isset( $settings['content_style'] ) ) { + // $settings['content_style'] .= $css_customize; + // } else { + // $settings['content_style'] = $css_customize; + // } + // $settings['content_style'] = $css_customize; + // return $settings; + // } } - - public static function css_customize_push_css() { - $css_customize = veu_css_customize::css_customize_get_the_css_min(); - if ( $css_customize ) { - ?> - - css_customize_get_css_min(); - // - // .editor-styles-wrapper h2 { font-size:30px; } - // - // if ( isset( $settings['content_style'] ) ) { - // $settings['content_style'] .= $css_customize; - // } else { - // $settings['content_style'] = $css_customize; - // } - // $settings['content_style'] = $css_customize; - // return $settings; - // } -} From 408ffb7b4be607f6c6f79e8357458f73026a0e66 Mon Sep 17 00:00:00 2001 From: mtdkei Date: Wed, 22 May 2024 11:50:11 +0900 Subject: [PATCH 10/31] Test: Update CssCustomizeTest to ensure CSS minification and singular page CSS functionality --- tests/test-css-customize.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/test-css-customize.php b/tests/test-css-customize.php index 73036cd2..b6581d60 100644 --- a/tests/test-css-customize.php +++ b/tests/test-css-customize.php @@ -1,19 +1,19 @@ 'div > h1 { color:red; }', @@ -48,8 +48,10 @@ function test_css_customize_get_the_css_min() { update_option( 'vkExUnit_css_customize', $before_option ); } - /* Singular page css */ - function test_veu_get_the_custom_css_single() { + /** + * Singular page css + */ + public function test_veu_get_the_custom_css_single() { // 要件と期待する結果 $test_array = array( From 7c6b9074c2eab8eb1e7598f6fd663664bb91c963 Mon Sep 17 00:00:00 2001 From: mtdkei Date: Wed, 22 May 2024 11:57:59 +0900 Subject: [PATCH 11/31] Remove HTML tags --- inc/css-customize/css-customize-single.php | 2 ++ inc/css-customize/css-customize.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/inc/css-customize/css-customize-single.php b/inc/css-customize/css-customize-single.php index d5642cc9..a122e690 100644 --- a/inc/css-customize/css-customize-single.php +++ b/inc/css-customize/css-customize-single.php @@ -36,6 +36,8 @@ function veu_get_the_custom_css_single( $post ) { $css_customize = preg_replace( '/\s(?=\s)/', '', $css_customize ); // Delete comment $css_customize = preg_replace( '/[\s\t]*\/\*\/?(\n|[^\/]|[^*]\/)*\*\//', '', $css_customize ); + // Remove HTML tags + $css_customize = strip_tags($css_customize); } return $css_customize; } diff --git a/inc/css-customize/css-customize.php b/inc/css-customize/css-customize.php index 1405815a..56d47cc0 100644 --- a/inc/css-customize/css-customize.php +++ b/inc/css-customize/css-customize.php @@ -139,6 +139,8 @@ public static function css_customize_get_css_min() { $css_customize = preg_replace( '/\s(?=\s)/', '', $css_customize ); // Delete comment $css_customize = preg_replace( '/[\s\t]*\/\*\/?(\n|[^\/]|[^*]\/)*\*\//', '', $css_customize ); + // Remove HTML tags + $css_customize = strip_tags($css_customize); } return $css_customize; } From 70ac682da1e71f5c570e2f35aca6277893d1f691 Mon Sep 17 00:00:00 2001 From: mtdkei Date: Wed, 22 May 2024 12:08:46 +0900 Subject: [PATCH 12/31] Fix: Correct CSS minification to preserve media queries and remove unnecessary HTML tags --- inc/css-customize/css-customize-single.php | 3 +-- inc/css-customize/css-customize.php | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/inc/css-customize/css-customize-single.php b/inc/css-customize/css-customize-single.php index a122e690..35bf3b86 100644 --- a/inc/css-customize/css-customize-single.php +++ b/inc/css-customize/css-customize-single.php @@ -20,6 +20,7 @@ function veu_insert_custom_css() { if ( $css ) { // Decode entities and remove HTML tags and their contents $css = html_entity_decode($css); + $css = strip_tags($css); echo ''; } } @@ -28,8 +29,6 @@ function veu_insert_custom_css() { function veu_get_the_custom_css_single( $post ) { $css_customize = get_post_meta( $post->ID, '_veu_custom_css', true ); if ( $css_customize ) { - // Delete br - $css_customize = str_replace( PHP_EOL, '', $css_customize ); // Delete tab $css_customize = preg_replace( '/[\n\r\t]/', '', $css_customize ); // Multi space convert to single space diff --git a/inc/css-customize/css-customize.php b/inc/css-customize/css-customize.php index 56d47cc0..462ae083 100644 --- a/inc/css-customize/css-customize.php +++ b/inc/css-customize/css-customize.php @@ -131,6 +131,8 @@ public function css_customize_valid_form() { public static function css_customize_get_css_min() { $css_customize = get_option( 'vkExUnit_css_customize' ); if ( $css_customize ) { + // Remove HTML tags, but keep + css_customize_get_css_min(); + // + // .editor-styles-wrapper h2 { font-size:30px; } + // + // if ( isset( $settings['content_style'] ) ) { + // $settings['content_style'] .= $css_customize; + // } else { + // $settings['content_style'] = $css_customize; + // } + // $settings['content_style'] = $css_customize; + // return $settings; + // } } -} From 3e41d4afa8b1742dd548ceb16466944ccb8febaa Mon Sep 17 00:00:00 2001 From: mtdkei Date: Wed, 22 May 2024 12:45:18 +0900 Subject: [PATCH 18/31] Changed whitespace handling --- inc/css-customize/css-customize-single.php | 7 +- inc/css-customize/css-customize.php | 14 +- tests/test-css-customize.php | 261 ++++++++------------- 3 files changed, 110 insertions(+), 172 deletions(-) diff --git a/inc/css-customize/css-customize-single.php b/inc/css-customize/css-customize-single.php index b03245b4..41381fe9 100644 --- a/inc/css-customize/css-customize-single.php +++ b/inc/css-customize/css-customize-single.php @@ -33,11 +33,12 @@ function veu_get_the_custom_css_single( $post ) { // Delete tab $css_customize = preg_replace( '/[\n\r\t]/', '', $css_customize ); // Multi space convert to single space - $css_customize = preg_replace( '/\s(?=\s)/', '', $css_customize ); + $css_customize = preg_replace( '/\s+/', ' ', $css_customize ); + $css_customize = preg_replace( '/\s*([{}:;])\s*/', '$1', $css_customize ); // Delete comment - $css_customize = preg_replace( '/[\s\t]*\/\*\/?(\n|[^\/]|[^*]\/)*\*\//', '', $css_customize ); + $css_customize = preg_replace( '/\/\*.*?\*\//', '', $css_customize ); // Remove HTML tags $css_customize = strip_tags($css_customize); } return $css_customize; -} +} \ No newline at end of file diff --git a/inc/css-customize/css-customize.php b/inc/css-customize/css-customize.php index f5251196..03cf23f3 100644 --- a/inc/css-customize/css-customize.php +++ b/inc/css-customize/css-customize.php @@ -25,7 +25,7 @@ public function set_hook() { // 編集画面への反映 // add_filter( 'tiny_mce_before_init', array( $this, 'css_customize_push_editor_css' ) ); - // + add_action( 'admin_menu', array( $this, 'css_customize_menu' ), 20 ); add_action( 'vkExUnit_action_adminbar', array( $this, 'admin_bar' ) ); require_once( dirname( __FILE__ ) . '/css-customize-single.php' ); @@ -40,7 +40,6 @@ public function set_hook() { require_once( dirname( __FILE__ ) . '/class-veu-metabox-css-customize.php' ); } ); - } public function admin_bar( $wp_admin_bar ) { @@ -73,15 +72,11 @@ public function css_customize_menu() { ); } - public function css_customize_render_page() { - $data = $this->css_customize_valid_form(); include( VEU_DIRECTORY_PATH . '/inc/css-customize/css-customize-edit.php' ); - } - /* 設定画面のCSSとJS /*-------------------------------------------*/ @@ -106,9 +101,7 @@ public function css_customize_page_js_and_css( $hook_suffix ) { } } - public function css_customize_valid_form() { - $data = array( 'mess' => '', 'customCss' => '', @@ -145,9 +138,10 @@ public static function css_customize_get_css_min() { // Delete tab $css_customize = preg_replace( '/[\n\r\t]/', '', $css_customize ); // Multi space convert to single space - $css_customize = preg_replace( '/\s(?=\s)/', '', $css_customize ); + $css_customize = preg_replace( '/\s+/', ' ', $css_customize ); + $css_customize = preg_replace( '/\s*([{}:;])\s*/', '$1', $css_customize ); // Delete comment - $css_customize = preg_replace( '/[\s\t]*\/\*\/?(\n|[^\/]|[^*]\/)*\*\//', '', $css_customize ); + $css_customize = preg_replace( '/\/\*.*?\*\//', '', $css_customize ); } return $css_customize; } diff --git a/tests/test-css-customize.php b/tests/test-css-customize.php index 03cf23f3..3204da68 100644 --- a/tests/test-css-customize.php +++ b/tests/test-css-customize.php @@ -1,176 +1,119 @@ '@media (width > 1000px) {p { color: red ;}}', + 'correct' => '@media (width > 1000px) {p {color: red;}}', + ), + array( + 'option' => '@media (width > 1000px) { + p { + color: red; + } + }', + 'correct' => '@media (width > 1000px) {p {color: red;}}', + ), + array( + 'option' => '@media (width > 1000px) {p { color: red;}}', + 'correct' => '@media (width > 1000px) {p {color: red;}}', + ), + ); - public function __construct() { - $this->set_hook(); - /** - * Reason of Using through the after_setup_theme is - * to be able to change the action hook point of css load from theme.. - */ - add_action( 'after_setup_theme', array( get_called_class(), 'load_css_action' ) ); - } + print PHP_EOL; + print '------------------------------------' . PHP_EOL; + print 'veu_css_customize' . PHP_EOL; + print '------------------------------------' . PHP_EOL; + $before_option = get_option( 'vkExUnit_css_customize' ); - public static function load_css_action() { - $hook_point = apply_filters( 'veu_enqueue_point_css_customize_common', 'wp_head' ); - // get_called_class()じゃないと外しにくい - add_action( $hook_point, array( get_called_class(), 'css_customize_push_css' ), 200 ); + foreach ( $tests as $key => $test_value ) { + update_option( 'vkExUnit_css_customize', $test_value['option'] ); + $return = veu_css_customize::css_customize_get_the_css_min(); + print PHP_EOL; + print 'return :' . $return . PHP_EOL; + print 'correct :' . $test_value['correct'] . PHP_EOL; + $this->assertEquals( $test_value['correct'], $return ); + } + update_option( 'vkExUnit_css_customize', $before_option ); } - public function set_hook() { - add_action( 'admin_footer', array( $this, 'css_customize_page_js_and_css' ) ); - - // 編集画面への反映 - // add_filter( 'tiny_mce_before_init', array( $this, 'css_customize_push_editor_css' ) ); - - add_action( 'admin_menu', array( $this, 'css_customize_menu' ), 20 ); - add_action( 'vkExUnit_action_adminbar', array( $this, 'admin_bar' ) ); - require_once( dirname( __FILE__ ) . '/css-customize-single.php' ); - - /* - VEU_Metabox 内の get_post_type が実行タイミングによっては - カスタム投稿タイプマネージャーで作成した投稿タイプが取得できないために - admin_menu のタイミングで読み込んでいる - */ - add_action( - 'admin_menu', function() { - require_once( dirname( __FILE__ ) . '/class-veu-metabox-css-customize.php' ); - } + /** + * Singular page css + */ + public function test_veu_get_the_custom_css_single() { + + // 要件と期待する結果 + $test_array = array( + array( + 'post_title' => 'タイトル', + 'post_meta' => '@media (width > 1000px) {p { color: red ;}}', + 'correct' => '@media (width > 1000px) {p {color: red;}}', + ), + array( + 'post_title' => 'タイトル', + 'post_meta' => '@media (width > 1000px) { + p { + color: red; + } + }', + 'correct' => '@media (width > 1000px) {p {color: red;}}', + ), + array( + 'post_title' => 'タイトル', + 'post_meta' => '@media (width > 1000px) {p { color: red;}}', + 'correct' => '@media (width > 1000px) {p {color: red;}}', + ), ); - } - public function admin_bar( $wp_admin_bar ) { - // 「CSSカスタマイズ」は edit_theme_options 権限にはアクセスさせない - if ( current_user_can( 'activate_plugins' ) ) { - $wp_admin_bar->add_node( - array( - 'parent' => 'veu_adminlink', - 'id' => 'veu_adminlink_css', - 'title' => __( 'CSS Customize', 'vk-all-in-one-expansion-unit' ), - 'href' => admin_url() . 'admin.php?page=vkExUnit_css_customize', - ) + print PHP_EOL; + print '------------------------------------' . PHP_EOL; + print 'test_veu_get_the_custom_css_single' . PHP_EOL; + print '------------------------------------' . PHP_EOL; + + foreach ( $test_array as $key => $value ) { + + // テスト用のデータを投稿する + $post_data = array( + 'post_title' => $value['post_title'], + 'post_content' => $value['post_title'], + 'post_status' => 'publish', + 'post_type' => 'post', ); - } - } - /* - 「CSSカスタマイズ」のメニュー - /*-------------------------------------------*/ - public function css_customize_menu() { - // $capability_required = veu_get_capability_required(); - add_submenu_page( - 'vkExUnit_setting_page', - __( 'CSS Customize', 'vk-all-in-one-expansion-unit' ), - __( 'CSS Customize', 'vk-all-in-one-expansion-unit' ), - // $capability_required, // edit_theme_optionsのユーザーにもアクセスさせないため - 'activate_plugins', - 'vkExUnit_css_customize', - array( $this, 'css_customize_render_page' ) - ); - } + // 投稿が成功すると投稿IDが返ってくる + $post_id = wp_insert_post( $post_data ); - public function css_customize_render_page() { - $data = $this->css_customize_valid_form(); - include( VEU_DIRECTORY_PATH . '/inc/css-customize/css-customize-edit.php' ); - } + // カスタムCSSをカスタムフィールドに投稿 + add_post_meta( $post_id, '_veu_custom_css', $value['post_meta'] ); - /* - 設定画面のCSSとJS - /*-------------------------------------------*/ - public function css_customize_page_js_and_css( $hook_suffix ) { - global $hook_suffix; - if ( - $hook_suffix == 'appearance_page_theme-css-customize' || - $hook_suffix == 'appearance_page_bv_grid_unit_options' - ) { - ?> - - '', - 'customCss' => '', - ); + // その投稿データの場合のカスタムCSS + $return = veu_get_the_custom_css_single( $post ); + + // 返ってきた値と期待する結果が同じかどうかテスト + $this->assertEquals( $value['correct'], $return ); + + print 'return :' . $return . PHP_EOL; + print 'correct :' . $value['correct'] . PHP_EOL; + + // テスト用データを消去 + wp_delete_post( $post_id, true ); - if ( isset( $_POST['bv-css-submit'] ) && ! empty( $_POST['bv-css-submit'] ) - && isset( $_POST['bv-css-css'] ) - && isset( $_POST['biz-vektor-css-nonce'] ) && wp_verify_nonce( $_POST['biz-vektor-css-nonce'], 'biz-vektor-css-submit' ) ) { - // エスケープ処理を行わずに保存 - $cleanCSS = stripslashes( trim( $_POST['bv-css-css'] ) ); - - if ( update_option( 'vkExUnit_css_customize', $cleanCSS ) ) { - $data['mess'] = '

' . __( 'Your custom CSS was saved.', 'biz-vektor' ) . '

'; - } - } else { - if ( isset( $_POST['bv-css-submit'] ) && ! empty( $_POST['bv-css-submit'] ) ) { - $data['mess'] = '

' . __( 'Error occured. Please try again.', 'biz-vektor' ) . '

'; - } - } - - $custom_css_option = get_option( 'vkExUnit_css_customize' ); - $data['customCss'] = $custom_css_option !== false ? htmlspecialchars_decode( $custom_css_option ) : ''; - - return $data; - } - - public static function css_customize_get_css_min() { - $css_customize = get_option( 'vkExUnit_css_customize' ); - if ( $css_customize ) { - // Remove HTML tags, but keep - css_customize_get_css_min(); - // - // .editor-styles-wrapper h2 { font-size:30px; } - // - // if ( isset( $settings['content_style'] ) ) { - // $settings['content_style'] .= $css_customize; - // } else { - // $settings['content_style'] = $css_customize; - // } - // $settings['content_style'] = $css_customize; - // return $settings; - // } } +} From 888f8906a6b0a3397f1cef164220b8e3a0526b32 Mon Sep 17 00:00:00 2001 From: mtdkei Date: Wed, 22 May 2024 12:51:08 +0900 Subject: [PATCH 19/31] Changed whitespace handling --- inc/css-customize/css-customize-single.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/inc/css-customize/css-customize-single.php b/inc/css-customize/css-customize-single.php index 41381fe9..15481ee5 100644 --- a/inc/css-customize/css-customize-single.php +++ b/inc/css-customize/css-customize-single.php @@ -34,6 +34,7 @@ function veu_get_the_custom_css_single( $post ) { $css_customize = preg_replace( '/[\n\r\t]/', '', $css_customize ); // Multi space convert to single space $css_customize = preg_replace( '/\s+/', ' ', $css_customize ); + // Ensure proper spacing and remove extra spaces $css_customize = preg_replace( '/\s*([{}:;])\s*/', '$1', $css_customize ); // Delete comment $css_customize = preg_replace( '/\/\*.*?\*\//', '', $css_customize ); @@ -41,4 +42,4 @@ function veu_get_the_custom_css_single( $post ) { $css_customize = strip_tags($css_customize); } return $css_customize; -} \ No newline at end of file +} From 9a52b3a9f202db963268893cb1f6512c6d8bf37f Mon Sep 17 00:00:00 2001 From: mtdkei Date: Wed, 22 May 2024 12:53:35 +0900 Subject: [PATCH 20/31] Changed whitespace handling --- inc/css-customize/css-customize.php | 1 + 1 file changed, 1 insertion(+) diff --git a/inc/css-customize/css-customize.php b/inc/css-customize/css-customize.php index 03cf23f3..8207f854 100644 --- a/inc/css-customize/css-customize.php +++ b/inc/css-customize/css-customize.php @@ -139,6 +139,7 @@ public static function css_customize_get_css_min() { $css_customize = preg_replace( '/[\n\r\t]/', '', $css_customize ); // Multi space convert to single space $css_customize = preg_replace( '/\s+/', ' ', $css_customize ); + // Ensure proper spacing and remove extra spaces $css_customize = preg_replace( '/\s*([{}:;])\s*/', '$1', $css_customize ); // Delete comment $css_customize = preg_replace( '/\/\*.*?\*\//', '', $css_customize ); From c2aea12428658f5e0e8ddda61facad4d455cff0d Mon Sep 17 00:00:00 2001 From: mtdkei Date: Wed, 22 May 2024 13:00:22 +0900 Subject: [PATCH 21/31] Changed whitespace handling --- inc/css-customize/css-customize-single.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/inc/css-customize/css-customize-single.php b/inc/css-customize/css-customize-single.php index 15481ee5..8c0fba4e 100644 --- a/inc/css-customize/css-customize-single.php +++ b/inc/css-customize/css-customize-single.php @@ -40,6 +40,8 @@ function veu_get_the_custom_css_single( $post ) { $css_customize = preg_replace( '/\/\*.*?\*\//', '', $css_customize ); // Remove HTML tags $css_customize = strip_tags($css_customize); + // Trim leading and trailing spaces + $css_customize = trim($css_customize); } return $css_customize; } From 1b20f552997ec561d3210537327434669b5dfc01 Mon Sep 17 00:00:00 2001 From: mtdkei Date: Wed, 22 May 2024 13:05:01 +0900 Subject: [PATCH 22/31] Changed whitespace handling --- inc/css-customize/css-customize.php | 2 ++ tests/test-css-customize.php | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/inc/css-customize/css-customize.php b/inc/css-customize/css-customize.php index 8207f854..19f8e560 100644 --- a/inc/css-customize/css-customize.php +++ b/inc/css-customize/css-customize.php @@ -143,6 +143,8 @@ public static function css_customize_get_css_min() { $css_customize = preg_replace( '/\s*([{}:;])\s*/', '$1', $css_customize ); // Delete comment $css_customize = preg_replace( '/\/\*.*?\*\//', '', $css_customize ); + // Trim leading and trailing spaces + $css_customize = trim($css_customize); } return $css_customize; } diff --git a/tests/test-css-customize.php b/tests/test-css-customize.php index 3204da68..b61f2f0b 100644 --- a/tests/test-css-customize.php +++ b/tests/test-css-customize.php @@ -17,7 +17,7 @@ public function test_css_customize_get_the_css_min() { $tests = array( array( 'option' => '@media (width > 1000px) {p { color: red ;}}', - 'correct' => '@media (width > 1000px) {p {color: red;}}', + 'correct' => '@media (width > 1000px){p{color:red;}}', ), array( 'option' => '@media (width > 1000px) { @@ -25,11 +25,11 @@ public function test_css_customize_get_the_css_min() { color: red; } }', - 'correct' => '@media (width > 1000px) {p {color: red;}}', + 'correct' => '@media (width > 1000px){p{color:red;}}', ), array( 'option' => '@media (width > 1000px) {p { color: red;}}', - 'correct' => '@media (width > 1000px) {p {color: red;}}', + 'correct' => '@media (width > 1000px){p{color:red;}}', ), ); @@ -60,7 +60,7 @@ public function test_veu_get_the_custom_css_single() { array( 'post_title' => 'タイトル', 'post_meta' => '@media (width > 1000px) {p { color: red ;}}', - 'correct' => '@media (width > 1000px) {p {color: red;}}', + 'correct' => '@media (width > 1000px){p{color:red;}}', ), array( 'post_title' => 'タイトル', @@ -69,12 +69,12 @@ public function test_veu_get_the_custom_css_single() { color: red; } }', - 'correct' => '@media (width > 1000px) {p {color: red;}}', + 'correct' => '@media (width > 1000px){p{color:red;}}', ), array( 'post_title' => 'タイトル', 'post_meta' => '@media (width > 1000px) {p { color: red;}}', - 'correct' => '@media (width > 1000px) {p {color: red;}}', + 'correct' => '@media (width > 1000px){p{color:red;}}', ), ); From 171301490b3e22802021b553dcb4c180d26af19c Mon Sep 17 00:00:00 2001 From: mtdkei Date: Wed, 22 May 2024 13:13:26 +0900 Subject: [PATCH 23/31] Add comments --- tests/test-css-customize.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test-css-customize.php b/tests/test-css-customize.php index b61f2f0b..3bda4c56 100644 --- a/tests/test-css-customize.php +++ b/tests/test-css-customize.php @@ -46,9 +46,9 @@ public function test_css_customize_get_the_css_min() { print 'return :' . $return . PHP_EOL; print 'correct :' . $test_value['correct'] . PHP_EOL; $this->assertEquals( $test_value['correct'], $return ); - } - update_option( 'vkExUnit_css_customize', $before_option ); - } + } // foreach ( $tests as $key => $test_value ) { + $before_option = update_option( 'vkExUnit_css_customize', $before_option ); + } // function test_css_customize_get_the_css_min() { /** * Singular page css From 4c604e3b186fc7cc81dbbee007a260e73f82cac1 Mon Sep 17 00:00:00 2001 From: mtdkei Date: Wed, 22 May 2024 13:14:00 +0900 Subject: [PATCH 24/31] Add comments --- tests/test-css-customize.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/test-css-customize.php b/tests/test-css-customize.php index 3bda4c56..bc884203 100644 --- a/tests/test-css-customize.php +++ b/tests/test-css-customize.php @@ -114,6 +114,8 @@ public function test_veu_get_the_custom_css_single() { // テスト用データを消去 wp_delete_post( $post_id, true ); - } - } -} + } // foreach ( $test_array as $key => $value ) { + + } // function test_veu_get_the_custom_css_single() { + +} \ No newline at end of file From 2a7956f63c70c1ceb6ad9d6148d25ef95b53b241 Mon Sep 17 00:00:00 2001 From: mtdkei Date: Fri, 24 May 2024 12:36:36 +0900 Subject: [PATCH 25/31] Fixed to prevent <= from being escaped --- inc/css-customize/css-customize-single.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/inc/css-customize/css-customize-single.php b/inc/css-customize/css-customize-single.php index 8c0fba4e..76967140 100644 --- a/inc/css-customize/css-customize-single.php +++ b/inc/css-customize/css-customize-single.php @@ -19,9 +19,8 @@ function veu_insert_custom_css() { global $post; $css = veu_get_the_custom_css_single( $post ); if ( $css ) { - // Decode entities and remove HTML tags and their contents - $css = html_entity_decode($css); - $css = strip_tags($css); + // HTMLエンティティをデコードし、HTMLタグとその内容を削除 + $css = html_entity_decode($css, ENT_QUOTES | ENT_HTML5); echo ''; } } @@ -30,17 +29,19 @@ function veu_insert_custom_css() { function veu_get_the_custom_css_single( $post ) { $css_customize = get_post_meta( $post->ID, '_veu_custom_css', true ); if ( $css_customize ) { - // Delete tab + // タブの削除 $css_customize = preg_replace( '/[\n\r\t]/', '', $css_customize ); - // Multi space convert to single space + // 複数スペースを単一スペースに変換 $css_customize = preg_replace( '/\s+/', ' ', $css_customize ); - // Ensure proper spacing and remove extra spaces + // 適切なスペースを確保し、余分なスペースを削除 $css_customize = preg_replace( '/\s*([{}:;])\s*/', '$1', $css_customize ); - // Delete comment + // コメントの削除 $css_customize = preg_replace( '/\/\*.*?\*\//', '', $css_customize ); - // Remove HTML tags - $css_customize = strip_tags($css_customize); - // Trim leading and trailing spaces + // HTMLタグの削除(styleやmediaタグは保持) + $css_customize = preg_replace('/<(?!\/?style|\/?media\b)[^>]+>/', '', $css_customize); + // 改行の削除 + $css_customize = str_replace( PHP_EOL, '', $css_customize ); + // 先頭と末尾のスペースを削除 $css_customize = trim($css_customize); } return $css_customize; From b49009b6275229956cb43e3e2941e064ea607f25 Mon Sep 17 00:00:00 2001 From: mtdkei Date: Mon, 3 Jun 2024 08:22:41 +0900 Subject: [PATCH 26/31] Comment Moderation --- inc/css-customize/css-customize-single.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/inc/css-customize/css-customize-single.php b/inc/css-customize/css-customize-single.php index 76967140..f8b1e6a3 100644 --- a/inc/css-customize/css-customize-single.php +++ b/inc/css-customize/css-customize-single.php @@ -29,19 +29,19 @@ function veu_insert_custom_css() { function veu_get_the_custom_css_single( $post ) { $css_customize = get_post_meta( $post->ID, '_veu_custom_css', true ); if ( $css_customize ) { - // タブの削除 + // Delete br + $css_customize = str_replace( PHP_EOL, '', $css_customize ); + // Delete tab $css_customize = preg_replace( '/[\n\r\t]/', '', $css_customize ); - // 複数スペースを単一スペースに変換 + // Multi space convert to single space $css_customize = preg_replace( '/\s+/', ' ', $css_customize ); - // 適切なスペースを確保し、余分なスペースを削除 + // Ensure proper spacing and remove extra spaces $css_customize = preg_replace( '/\s*([{}:;])\s*/', '$1', $css_customize ); - // コメントの削除 + // Delete Comment $css_customize = preg_replace( '/\/\*.*?\*\//', '', $css_customize ); - // HTMLタグの削除(styleやmediaタグは保持) + // Delete HTML tags, but keep