Changeset 3460471
- Timestamp:
- 02/13/2026 03:51:07 AM (6 days ago)
- Location:
- webbiz-toolkit
- Files:
-
- 16 edited
- 1 copied
-
tags/1.0.1 (copied) (copied from webbiz-toolkit/trunk)
-
tags/1.0.1/includes/class-wbz-toolkit-admin.php (modified) (3 diffs)
-
tags/1.0.1/includes/class-wbz-toolkit.php (modified) (2 diffs)
-
tags/1.0.1/modules/emphasis/emphasis.js (modified) (2 diffs)
-
tags/1.0.1/modules/pangu/pangu.js (modified) (1 diff)
-
tags/1.0.1/modules/qa-reveal/qa-reveal.js (modified) (1 diff)
-
tags/1.0.1/modules/spoiler/spoiler.js (modified) (1 diff)
-
tags/1.0.1/readme.txt (modified) (3 diffs)
-
tags/1.0.1/webbiz-toolkit.php (modified) (2 diffs)
-
trunk/includes/class-wbz-toolkit-admin.php (modified) (3 diffs)
-
trunk/includes/class-wbz-toolkit.php (modified) (2 diffs)
-
trunk/modules/emphasis/emphasis.js (modified) (2 diffs)
-
trunk/modules/pangu/pangu.js (modified) (1 diff)
-
trunk/modules/qa-reveal/qa-reveal.js (modified) (1 diff)
-
trunk/modules/spoiler/spoiler.js (modified) (1 diff)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/webbiz-toolkit.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
webbiz-toolkit/tags/1.0.1/includes/class-wbz-toolkit-admin.php
r3459973 r3460471 71 71 add_action( 'admin_init', array( $this, 'register_settings' ) ); 72 72 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_assets' ) ); 73 add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_dynamic_css' ) );74 73 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_dynamic_css' ) ); 75 74 … … 492 491 <p> 493 492 <strong>WebBiz Toolkit</strong> v<?php echo esc_html( WEBBIZ_TOOLKIT_VERSION ); ?> | 494 <a href=" https://webbiz.tw/" target="_blank">WebBiz</a>493 <a href="<?php echo esc_url( 'https://webbiz.tw/' ); ?>" target="_blank">WebBiz</a> 495 494 </p> 496 495 </div> … … 508 507 $settings_link = sprintf( 509 508 '<a href="%s">%s</a>', 510 admin_url( 'options-general.php?page=webbiz-toolkit'),511 __( '設定', 'webbiz-toolkit' )509 esc_url( admin_url( 'options-general.php?page=webbiz-toolkit' ) ), 510 esc_html__( '設定', 'webbiz-toolkit' ) 512 511 ); 513 512 array_unshift( $links, $settings_link ); -
webbiz-toolkit/tags/1.0.1/includes/class-wbz-toolkit.php
r3459973 r3460471 57 57 // 載入前台樣式 58 58 add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_frontend_styles' ) ); 59 60 // 載入前台動態 CSS(強調樣式等) 61 add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_dynamic_css' ) ); 59 62 } 60 63 … … 72 75 73 76 /** 77 * 透過 wp_add_inline_style 輸出前台動態 CSS 78 */ 79 public function enqueue_dynamic_css() { 80 // 如果強調模組未啟用,不輸出 81 if ( empty( $this->options['modules']['emphasis'] ) ) { 82 return; 83 } 84 85 $emphasis_styles = isset( $this->options['emphasis_styles'] ) ? $this->options['emphasis_styles'] : array(); 86 87 // 預設樣式 88 $defaults = array( 89 1 => array( 90 'text_color' => '#1e40af', 91 'bg_color' => 'rgba(239, 246, 255, 0.8)', 92 'border_color' => '#3b82f6', 93 'border_style' => 'left', 94 'border_width' => '2', 95 'font_weight' => 'bold', 96 ), 97 2 => array( 98 'text_color' => '#991b1b', 99 'bg_color' => 'rgba(254, 242, 242, 0.8)', 100 'border_color' => '#dc2626', 101 'border_style' => 'all', 102 'border_width' => '1', 103 'font_weight' => 'bold', 104 ), 105 3 => array( 106 'text_color' => '#92400e', 107 'bg_color' => 'transparent', 108 'border_color' => '#f59e0b', 109 'border_style' => 'bottom', 110 'border_width' => '2', 111 'font_weight' => 'bold', 112 ), 113 ); 114 115 $css = ''; 116 117 foreach ( $defaults as $key => $default ) { 118 $style = isset( $emphasis_styles[ $key ] ) ? wp_parse_args( $emphasis_styles[ $key ], $default ) : $default; 119 120 $safe_key = absint( $key ); 121 $selector = ".webbiz-emphasis-{$safe_key}"; 122 123 $css .= "{$selector} {\n"; 124 $css .= " display: inline !important;\n"; 125 $css .= " white-space: normal !important;\n"; 126 $css .= " border-radius: 2px !important;\n"; 127 $css .= " transition: all 0.2s ease !important;\n"; 128 $css .= " box-decoration-break: clone;\n"; 129 $css .= " -webkit-box-decoration-break: clone;\n"; 130 131 $text_color = $this->sanitize_css_color( $style['text_color'] ?? '' ); 132 if ( ! empty( $text_color ) ) { 133 $css .= " color: {$text_color} !important;\n"; 134 } 135 136 $bg_color = $this->sanitize_css_color( $style['bg_color'] ?? '' ); 137 if ( ! empty( $bg_color ) ) { 138 $css .= " background: {$bg_color} !important;\n"; 139 } 140 141 $font_weight = 'bold' === $style['font_weight'] ? '600' : 'normal'; 142 $css .= " font-weight: {$font_weight} !important;\n"; 143 144 $border_width = absint( $style['border_width'] ); 145 $border_color = $this->sanitize_css_color( $style['border_color'] ?? '' ); 146 if ( empty( $border_color ) ) { 147 $border_color = '#000'; 148 } 149 150 $css .= " border: none !important;\n"; 151 152 switch ( $style['border_style'] ) { 153 case 'left': 154 $css .= " border-left: {$border_width}px solid {$border_color} !important;\n"; 155 $css .= " padding: 0 4px 0 6px !important;\n"; 156 break; 157 case 'all': 158 $css .= " border: {$border_width}px solid {$border_color} !important;\n"; 159 $css .= " padding: 0 4px !important;\n"; 160 break; 161 case 'bottom': 162 $css .= " border-bottom: {$border_width}px solid {$border_color} !important;\n"; 163 $css .= " padding: 0 2px 1px 2px !important;\n"; 164 break; 165 case 'none': 166 $css .= " padding: 0 4px !important;\n"; 167 break; 168 } 169 170 $css .= "}\n\n"; 171 } 172 173 wp_register_style( 'webbiz-emphasis-dynamic', false, array(), WEBBIZ_TOOLKIT_VERSION ); 174 wp_enqueue_style( 'webbiz-emphasis-dynamic' ); 175 wp_add_inline_style( 'webbiz-emphasis-dynamic', $css ); 176 } 177 178 /** 179 * 清理 CSS 顏色值(output escaping) 180 * 181 * @param string $color 顏色值。 182 * @return string 安全的顏色值,無效時回傳空字串。 183 */ 184 private function sanitize_css_color( $color ) { 185 if ( empty( $color ) || ! is_string( $color ) ) { 186 return ''; 187 } 188 189 if ( preg_match( '/^#([A-Fa-f0-9]{3}){1,2}$/', $color ) ) { 190 return $color; 191 } 192 193 if ( preg_match( '/^rgba?\(\s*[\d]{1,3}\s*,\s*[\d]{1,3}\s*,\s*[\d]{1,3}\s*(,\s*[\d]?\.?[\d]+\s*)?\)$/', $color ) ) { 194 return $color; 195 } 196 197 if ( 'transparent' === $color ) { 198 return $color; 199 } 200 201 return ''; 202 } 203 204 /** 74 205 * 載入啟用的模組 75 206 */ -
webbiz-toolkit/tags/1.0.1/modules/emphasis/emphasis.js
r3459973 r3460471 9 9 10 10 if (!window.wp?.richText || !window.wp?.element) { 11 console.warn('Webbiz Emphasis: WordPress editor APIs not available');12 11 return; 13 12 } … … 42 41 return result; 43 42 } catch (error) { 44 console.error('Webbiz Emphasis: Format toggle error', error);45 43 return toggleFormat(value, format); 46 44 } -
webbiz-toolkit/tags/1.0.1/modules/pangu/pangu.js
r3459973 r3460471 12 12 // 安全檢查 13 13 if (!window.wp?.data || !window.wp?.hooks || !window.wp?.element) { 14 console.warn('Webbiz Pangu: WordPress editor APIs not available');15 14 return; 16 15 } -
webbiz-toolkit/tags/1.0.1/modules/qa-reveal/qa-reveal.js
r3459973 r3460471 13 13 // 安全檢查 14 14 if (!window.wp?.blocks || !window.wp?.element || !window.wp?.blockEditor) { 15 console.warn('Webbiz QA Reveal: WordPress block APIs not available');16 15 return; 17 16 } -
webbiz-toolkit/tags/1.0.1/modules/spoiler/spoiler.js
r3459973 r3460471 13 13 // 安全檢查 14 14 if (!window.wp?.richText || !window.wp?.element) { 15 console.warn('Webbiz Spoiler: WordPress editor APIs not available');16 15 return; 17 16 } -
webbiz-toolkit/tags/1.0.1/readme.txt
r3459973 r3460471 5 5 Tested up to: 6.9 6 6 Requires PHP: 7.4 7 Stable tag: 1.0. 07 Stable tag: 1.0.1 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 98 98 = Is this plugin translation-ready? = 99 99 100 Yes, WebBiz Toolkit is fully internationalized and ready for translation. The admin interface is available in Traditional Chinese.100 Yes, WebBiz Toolkit is fully internationalized and ready for translation. 101 101 102 102 == Screenshots == … … 109 109 110 110 == Changelog == 111 112 = 1.0.1 = 113 * Fixed: Text emphasis styles not displaying on the frontend (CSS was only loaded in admin context) 111 114 112 115 = 1.0.0 = -
webbiz-toolkit/tags/1.0.1/webbiz-toolkit.php
r3459973 r3460471 3 3 * Plugin Name: WebBiz Toolkit 4 4 * Description: WordPress 部落客工具箱 - 文字強調樣式、劇透遮罩、中英文自動加空格、互動問答 5 * Version: 1.0. 05 * Version: 1.0.1 6 6 * Author: WebBiz 7 7 * Author URI: https://webbiz.tw/ … … 20 20 21 21 // 外掛常數 22 define( 'WEBBIZ_TOOLKIT_VERSION', '1.0. 0' );22 define( 'WEBBIZ_TOOLKIT_VERSION', '1.0.1' ); 23 23 define( 'WEBBIZ_TOOLKIT_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); 24 24 define( 'WEBBIZ_TOOLKIT_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); -
webbiz-toolkit/trunk/includes/class-wbz-toolkit-admin.php
r3459973 r3460471 71 71 add_action( 'admin_init', array( $this, 'register_settings' ) ); 72 72 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_assets' ) ); 73 add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_dynamic_css' ) );74 73 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_dynamic_css' ) ); 75 74 … … 492 491 <p> 493 492 <strong>WebBiz Toolkit</strong> v<?php echo esc_html( WEBBIZ_TOOLKIT_VERSION ); ?> | 494 <a href=" https://webbiz.tw/" target="_blank">WebBiz</a>493 <a href="<?php echo esc_url( 'https://webbiz.tw/' ); ?>" target="_blank">WebBiz</a> 495 494 </p> 496 495 </div> … … 508 507 $settings_link = sprintf( 509 508 '<a href="%s">%s</a>', 510 admin_url( 'options-general.php?page=webbiz-toolkit'),511 __( '設定', 'webbiz-toolkit' )509 esc_url( admin_url( 'options-general.php?page=webbiz-toolkit' ) ), 510 esc_html__( '設定', 'webbiz-toolkit' ) 512 511 ); 513 512 array_unshift( $links, $settings_link ); -
webbiz-toolkit/trunk/includes/class-wbz-toolkit.php
r3459973 r3460471 57 57 // 載入前台樣式 58 58 add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_frontend_styles' ) ); 59 60 // 載入前台動態 CSS(強調樣式等) 61 add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_dynamic_css' ) ); 59 62 } 60 63 … … 72 75 73 76 /** 77 * 透過 wp_add_inline_style 輸出前台動態 CSS 78 */ 79 public function enqueue_dynamic_css() { 80 // 如果強調模組未啟用,不輸出 81 if ( empty( $this->options['modules']['emphasis'] ) ) { 82 return; 83 } 84 85 $emphasis_styles = isset( $this->options['emphasis_styles'] ) ? $this->options['emphasis_styles'] : array(); 86 87 // 預設樣式 88 $defaults = array( 89 1 => array( 90 'text_color' => '#1e40af', 91 'bg_color' => 'rgba(239, 246, 255, 0.8)', 92 'border_color' => '#3b82f6', 93 'border_style' => 'left', 94 'border_width' => '2', 95 'font_weight' => 'bold', 96 ), 97 2 => array( 98 'text_color' => '#991b1b', 99 'bg_color' => 'rgba(254, 242, 242, 0.8)', 100 'border_color' => '#dc2626', 101 'border_style' => 'all', 102 'border_width' => '1', 103 'font_weight' => 'bold', 104 ), 105 3 => array( 106 'text_color' => '#92400e', 107 'bg_color' => 'transparent', 108 'border_color' => '#f59e0b', 109 'border_style' => 'bottom', 110 'border_width' => '2', 111 'font_weight' => 'bold', 112 ), 113 ); 114 115 $css = ''; 116 117 foreach ( $defaults as $key => $default ) { 118 $style = isset( $emphasis_styles[ $key ] ) ? wp_parse_args( $emphasis_styles[ $key ], $default ) : $default; 119 120 $safe_key = absint( $key ); 121 $selector = ".webbiz-emphasis-{$safe_key}"; 122 123 $css .= "{$selector} {\n"; 124 $css .= " display: inline !important;\n"; 125 $css .= " white-space: normal !important;\n"; 126 $css .= " border-radius: 2px !important;\n"; 127 $css .= " transition: all 0.2s ease !important;\n"; 128 $css .= " box-decoration-break: clone;\n"; 129 $css .= " -webkit-box-decoration-break: clone;\n"; 130 131 $text_color = $this->sanitize_css_color( $style['text_color'] ?? '' ); 132 if ( ! empty( $text_color ) ) { 133 $css .= " color: {$text_color} !important;\n"; 134 } 135 136 $bg_color = $this->sanitize_css_color( $style['bg_color'] ?? '' ); 137 if ( ! empty( $bg_color ) ) { 138 $css .= " background: {$bg_color} !important;\n"; 139 } 140 141 $font_weight = 'bold' === $style['font_weight'] ? '600' : 'normal'; 142 $css .= " font-weight: {$font_weight} !important;\n"; 143 144 $border_width = absint( $style['border_width'] ); 145 $border_color = $this->sanitize_css_color( $style['border_color'] ?? '' ); 146 if ( empty( $border_color ) ) { 147 $border_color = '#000'; 148 } 149 150 $css .= " border: none !important;\n"; 151 152 switch ( $style['border_style'] ) { 153 case 'left': 154 $css .= " border-left: {$border_width}px solid {$border_color} !important;\n"; 155 $css .= " padding: 0 4px 0 6px !important;\n"; 156 break; 157 case 'all': 158 $css .= " border: {$border_width}px solid {$border_color} !important;\n"; 159 $css .= " padding: 0 4px !important;\n"; 160 break; 161 case 'bottom': 162 $css .= " border-bottom: {$border_width}px solid {$border_color} !important;\n"; 163 $css .= " padding: 0 2px 1px 2px !important;\n"; 164 break; 165 case 'none': 166 $css .= " padding: 0 4px !important;\n"; 167 break; 168 } 169 170 $css .= "}\n\n"; 171 } 172 173 wp_register_style( 'webbiz-emphasis-dynamic', false, array(), WEBBIZ_TOOLKIT_VERSION ); 174 wp_enqueue_style( 'webbiz-emphasis-dynamic' ); 175 wp_add_inline_style( 'webbiz-emphasis-dynamic', $css ); 176 } 177 178 /** 179 * 清理 CSS 顏色值(output escaping) 180 * 181 * @param string $color 顏色值。 182 * @return string 安全的顏色值,無效時回傳空字串。 183 */ 184 private function sanitize_css_color( $color ) { 185 if ( empty( $color ) || ! is_string( $color ) ) { 186 return ''; 187 } 188 189 if ( preg_match( '/^#([A-Fa-f0-9]{3}){1,2}$/', $color ) ) { 190 return $color; 191 } 192 193 if ( preg_match( '/^rgba?\(\s*[\d]{1,3}\s*,\s*[\d]{1,3}\s*,\s*[\d]{1,3}\s*(,\s*[\d]?\.?[\d]+\s*)?\)$/', $color ) ) { 194 return $color; 195 } 196 197 if ( 'transparent' === $color ) { 198 return $color; 199 } 200 201 return ''; 202 } 203 204 /** 74 205 * 載入啟用的模組 75 206 */ -
webbiz-toolkit/trunk/modules/emphasis/emphasis.js
r3459973 r3460471 9 9 10 10 if (!window.wp?.richText || !window.wp?.element) { 11 console.warn('Webbiz Emphasis: WordPress editor APIs not available');12 11 return; 13 12 } … … 42 41 return result; 43 42 } catch (error) { 44 console.error('Webbiz Emphasis: Format toggle error', error);45 43 return toggleFormat(value, format); 46 44 } -
webbiz-toolkit/trunk/modules/pangu/pangu.js
r3459973 r3460471 12 12 // 安全檢查 13 13 if (!window.wp?.data || !window.wp?.hooks || !window.wp?.element) { 14 console.warn('Webbiz Pangu: WordPress editor APIs not available');15 14 return; 16 15 } -
webbiz-toolkit/trunk/modules/qa-reveal/qa-reveal.js
r3459973 r3460471 13 13 // 安全檢查 14 14 if (!window.wp?.blocks || !window.wp?.element || !window.wp?.blockEditor) { 15 console.warn('Webbiz QA Reveal: WordPress block APIs not available');16 15 return; 17 16 } -
webbiz-toolkit/trunk/modules/spoiler/spoiler.js
r3459973 r3460471 13 13 // 安全檢查 14 14 if (!window.wp?.richText || !window.wp?.element) { 15 console.warn('Webbiz Spoiler: WordPress editor APIs not available');16 15 return; 17 16 } -
webbiz-toolkit/trunk/readme.txt
r3459973 r3460471 5 5 Tested up to: 6.9 6 6 Requires PHP: 7.4 7 Stable tag: 1.0. 07 Stable tag: 1.0.1 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 98 98 = Is this plugin translation-ready? = 99 99 100 Yes, WebBiz Toolkit is fully internationalized and ready for translation. The admin interface is available in Traditional Chinese.100 Yes, WebBiz Toolkit is fully internationalized and ready for translation. 101 101 102 102 == Screenshots == … … 109 109 110 110 == Changelog == 111 112 = 1.0.1 = 113 * Fixed: Text emphasis styles not displaying on the frontend (CSS was only loaded in admin context) 111 114 112 115 = 1.0.0 = -
webbiz-toolkit/trunk/webbiz-toolkit.php
r3459973 r3460471 3 3 * Plugin Name: WebBiz Toolkit 4 4 * Description: WordPress 部落客工具箱 - 文字強調樣式、劇透遮罩、中英文自動加空格、互動問答 5 * Version: 1.0. 05 * Version: 1.0.1 6 6 * Author: WebBiz 7 7 * Author URI: https://webbiz.tw/ … … 20 20 21 21 // 外掛常數 22 define( 'WEBBIZ_TOOLKIT_VERSION', '1.0. 0' );22 define( 'WEBBIZ_TOOLKIT_VERSION', '1.0.1' ); 23 23 define( 'WEBBIZ_TOOLKIT_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); 24 24 define( 'WEBBIZ_TOOLKIT_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
Note: See TracChangeset
for help on using the changeset viewer.