Changeset 3349744
- Timestamp:
- 08/25/2025 01:50:47 PM (7 months ago)
- Location:
- smarttoc-lite/trunk
- Files:
-
- 6 edited
-
css/smarttoc-lite-admin.css (modified) (1 diff)
-
includes/admin-settings.php (modified) (3 diffs)
-
includes/class-smarttoc-lite.php (modified) (5 diffs)
-
js/smarttoc-lite-admin.js (modified) (4 diffs)
-
readme.txt (modified) (3 diffs)
-
smarttoc-lite.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
smarttoc-lite/trunk/css/smarttoc-lite-admin.css
r3335881 r3349744 185 185 color: #2E2E2E; 186 186 } 187 .wrap.sparttoc-admin-wrap .smarttoc-options-section input[type="number"]{ 188 padding-right: 0; 189 } 187 190 .wrap.sparttoc-admin-wrap .smarttoc-info{ 188 191 display: block; -
smarttoc-lite/trunk/includes/admin-settings.php
r3335881 r3349744 200 200 )); 201 201 register_setting('smarttoc_lite_settings_group', 'smarttoc_lite_padding', array( 202 'sanitize_callback' => array($this, 'sanitize_ non_negative_int'),202 'sanitize_callback' => array($this, 'sanitize_padding_array'), 203 203 )); 204 204 register_setting( … … 716 716 } 717 717 718 public function padding_field_html() 719 { 720 $value = get_option('smarttoc_lite_padding', '10'); 721 ?> 722 <input type="number" name="smarttoc_lite_padding" value="<?php echo esc_attr($value); ?>" min="0" /> 723 <?php 724 echo '<span class="smarttoc-info">' . esc_html__('Adjusts the inner spacing between the TOC content and its borders.', 'smarttoc-lite') . '</span>'; 725 } 718 public function padding_field_html() { 719 $defaults = array('top'=>10,'right'=>10,'bottom'=>10,'left'=>10); 720 $raw = get_option('smarttoc_lite_padding', $defaults); 721 $value = wp_parse_args( (array) $raw, $defaults ); 722 ?> 723 <div class="smarttoc-padding-fields" style="display:flex; gap:8px; align-items:center; flex-wrap:wrap;"> 724 <label for="smarttoc_padding_top"> 725 <?php esc_html_e('Top', 'smarttoc-lite'); ?> 726 <input id="smarttoc_padding_top" type="number" name="smarttoc_lite_padding[top]" 727 value="<?php echo esc_attr($value['top']); ?>" min="0" style="width:50px;" /> 728 </label> 729 730 <label for="smarttoc_padding_right"> 731 <?php esc_html_e('Right', 'smarttoc-lite'); ?> 732 <input id="smarttoc_padding_right" type="number" name="smarttoc_lite_padding[right]" 733 value="<?php echo esc_attr($value['right']); ?>" min="0" style="width:50px;" /> 734 </label> 735 736 <label for="smarttoc_padding_bottom"> 737 <?php esc_html_e('Bottom', 'smarttoc-lite'); ?> 738 <input id="smarttoc_padding_bottom" type="number" name="smarttoc_lite_padding[bottom]" 739 value="<?php echo esc_attr($value['bottom']); ?>" min="0" style="width:50px;" /> 740 </label> 741 742 <label for="smarttoc_padding_left"> 743 <?php esc_html_e('Left', 'smarttoc-lite'); ?> 744 <input id="smarttoc_padding_left" type="number" name="smarttoc_lite_padding[left]" 745 value="<?php echo esc_attr($value['left']); ?>" min="0" style="width:50px;" /> 746 </label> 747 </div> 748 <?php 749 echo '<span class="smarttoc-info">' . 750 esc_html__('Adjusts inner spacing for each side of the TOC box.', 'smarttoc-lite') . 751 '</span>'; 752 } 753 726 754 727 755 public function margin_field_html() … … 753 781 $input = sanitize_text_field($input); 754 782 return in_array($input, $allowed, true) ? $input : $allowed[0]; 783 } 784 public function sanitize_padding_array($input) 785 { 786 $sanitized = array(); 787 foreach (['top', 'right', 'bottom', 'left'] as $side) { 788 $sanitized[$side] = isset($input[$side]) ? max(0, intval($input[$side])) : 0; 789 } 790 return $sanitized; 755 791 } 756 792 public function sanitize_width_option($input) -
smarttoc-lite/trunk/includes/class-smarttoc-lite.php
r3336003 r3349744 271 271 272 272 public function output_dynamic_css() 273 { 274 // Doar pe paginile de tip singular (posturi/pagini) 275 if (!is_singular()) { 276 return; 277 } 278 279 // Obținem opțiunile 280 $bg = get_option('smarttoc_lite_bg_color', '#ffffff'); 281 $title_color = get_option('smarttoc_lite_title_color', '#000000'); 282 $text_color = get_option('smarttoc_lite_text_color', '#333333'); 283 $link = get_option('smarttoc_lite_link_color', '#0073aa'); 284 $hover = get_option('smarttoc_lite_link_hover_color', '#005177'); 285 $border = get_option('smarttoc_lite_border_color', '#dddddd'); 286 $title_size = get_option('smarttoc_lite_title_font_size', '20'); 287 $title_weight = get_option('smarttoc_lite_title_font_weight', '600'); 288 $item_size = get_option('smarttoc_lite_font_size', '16'); 289 $item_weight = get_option('smarttoc_lite_font_weight', '400'); 290 $child_size = get_option('smarttoc_lite_child_font_size', '14'); 291 $numbering_style = get_option('smarttoc_lite_numbering_style', 'disc'); 292 $custom_bullet = get_option('smarttoc_lite_custom_bullet', '→'); 293 $numbering_position = get_option('smarttoc_lite_numbering_position', 'outside'); 294 295 $width = get_option('smarttoc_lite_width', '100%'); 296 $alignment = get_option('smarttoc_lite_alignment', 'none'); 297 $text_direction = get_option('smarttoc_lite_text_direction', 'ltr'); 298 $padding = get_option('smarttoc_lite_padding', '10'); 299 $margin = get_option('smarttoc_lite_margin', '20'); 300 $text_align = get_option('smarttoc_lite_text_align', 'left'); 301 $border_width = get_option('smarttoc_lite_border_width', '1'); 302 $border_radius = get_option('smarttoc_lite_border_radius', '0'); 303 $icon_size = get_option('smarttoc_lite_toggle_icon_size', '15'); 304 $icon_color = get_option('smarttoc_lite_toggle_icon_color', '#7a232f'); 305 306 // Construim CSS-ul dinamic 307 $dynamic_css = ''; 308 309 // Numărătoare personalizată 310 if ($numbering_style === 'custom') { 311 $dynamic_css .= " 273 { 274 if (!is_singular()) { 275 return; 276 } 277 278 $bg = get_option('smarttoc_lite_bg_color', '#ffffff'); 279 $title_color = get_option('smarttoc_lite_title_color', '#000000'); 280 $text_color = get_option('smarttoc_lite_text_color', '#333333'); 281 $link = get_option('smarttoc_lite_link_color', '#0073aa'); 282 $hover = get_option('smarttoc_lite_link_hover_color', '#005177'); 283 $border = get_option('smarttoc_lite_border_color', '#dddddd'); 284 $title_size = get_option('smarttoc_lite_title_font_size', '20'); 285 $title_weight = get_option('smarttoc_lite_title_font_weight', '600'); 286 $item_size = get_option('smarttoc_lite_font_size', '16'); 287 $item_weight = get_option('smarttoc_lite_font_weight', '400'); 288 $child_size = get_option('smarttoc_lite_child_font_size', '14'); 289 $numbering_style = get_option('smarttoc_lite_numbering_style', 'disc'); 290 $custom_bullet = get_option('smarttoc_lite_custom_bullet', '→'); 291 $numbering_position = get_option('smarttoc_lite_numbering_position', 'outside'); 292 293 $width = get_option('smarttoc_lite_width', '100%'); 294 $alignment = get_option('smarttoc_lite_alignment', 'none'); 295 $text_direction = get_option('smarttoc_lite_text_direction', 'ltr'); 296 $padding_opt = get_option('smarttoc_lite_padding', 10); 297 $margin = get_option('smarttoc_lite_margin', '20'); 298 $text_align = get_option('smarttoc_lite_text_align', 'left'); 299 $border_width = get_option('smarttoc_lite_border_width', '1'); 300 $border_radius = get_option('smarttoc_lite_border_radius', '0'); 301 $icon_size = get_option('smarttoc_lite_toggle_icon_size', '15'); 302 $icon_color = get_option('smarttoc_lite_toggle_icon_color', '#7a232f'); 303 304 $defaults = array('top' => 10, 'right' => 10, 'bottom' => 10, 'left' => 10); 305 if (is_array($padding_opt)) { 306 $pad = wp_parse_args($padding_opt, $defaults); 307 } elseif (is_numeric($padding_opt)) { 308 $v = max(0, intval($padding_opt)); 309 $pad = array('top' => $v, 'right' => $v, 'bottom' => $v, 'left' => $v); 310 } else { 311 $pad = $defaults; 312 } 313 $padding_css = sprintf( 314 '%dpx %dpx %dpx %dpx', 315 max(0, intval($pad['top'])), 316 max(0, intval($pad['right'])), 317 max(0, intval($pad['bottom'])), 318 max(0, intval($pad['left'])) 319 ); 320 // Construim CSS-ul dinamic 321 $dynamic_css = ''; 322 323 // Numărătoare personalizată 324 if ($numbering_style === 'custom') { 325 $dynamic_css .= " 312 326 .smarttoc-lite-toc #smarttoc-list .smarttoc-list-content ul { 313 327 list-style: none; … … 325 339 } 326 340 "; 327 } else {328 $dynamic_css .= "341 } else { 342 $dynamic_css .= " 329 343 .smarttoc-lite-toc #smarttoc-list .smarttoc-list-content ul { 330 344 list-style-type: " . esc_attr($numbering_style) . "; … … 333 347 } 334 348 "; 335 }336 337 // Stiluri generale338 $dynamic_css .= "349 } 350 351 // Stiluri generale 352 $dynamic_css .= " 339 353 .smarttoc-lite-wrapper { 340 354 text-align: " . ($alignment === 'left' ? 'left' : ($alignment === 'center' ? 'center' : 'right')) . "; … … 347 361 margin: " . ($alignment === 'center' ? '0 auto' : '0') . "; 348 362 direction: " . esc_attr($text_direction) . "; 349 padding: " . intval($padding) . "px;363 padding: " . esc_attr($padding_css) . "; 350 364 margin-bottom: " . intval($margin) . "px; 351 365 border: " . esc_attr($border_width) . "px solid " . esc_attr($border) . "; … … 400 414 "; 401 415 402 // Adăugăm stilul inline403 wp_add_inline_style('smarttoc-lite-style', $dynamic_css);404 }416 // Adăugăm stilul inline 417 wp_add_inline_style('smarttoc-lite-style', $dynamic_css); 418 } 405 419 } 406 420 -
smarttoc-lite/trunk/js/smarttoc-lite-admin.js
r3335881 r3349744 73 73 const textDirection = get("smarttoc_lite_text_direction", "ltr"); 74 74 const textAlign = get("smarttoc_lite_text_align", "left"); 75 const tocPadding = get("smarttoc_lite_padding", "10"); 75 const padTop = get("smarttoc_lite_padding[top]", "10"); 76 const padRight = get("smarttoc_lite_padding[right]", "10"); 77 const padBottom = get("smarttoc_lite_padding[bottom]", "10"); 78 const padLeft = get("smarttoc_lite_padding[left]", "10"); 79 const paddingCss = `${padTop}px ${padRight}px ${padBottom}px ${padLeft}px`; 76 80 const numberingStyle = get("smarttoc_lite_numbering_style", "disc"); 77 81 const customBullet = get("smarttoc_lite_custom_bullet", "→"); … … 92 96 preview.style.borderRadius = `${borderRadius}px`; 93 97 preview.style.direction = textDirection; 94 preview.style.padding = `${tocPadding}px`;98 preview.style.padding = paddingCss; 95 99 preview.style.textAlign = textAlign; 96 100 … … 118 122 if (["minimal", "compact", "underline"].includes(theme)) { 119 123 toggleBtn.style.border = `2px solid ${iconColor}`; 120 } else{124 } else { 121 125 toggleBtn.style.border = `none`; 122 126 } … … 145 149 const bullet = li.querySelector(".custom-bullet"); 146 150 if (numberingStyle === "custom") { 147 ul.style.listStyleType = 'none';151 ul.style.listStyleType = "none"; 148 152 if (!bullet) { 149 153 li.insertAdjacentHTML( -
smarttoc-lite/trunk/readme.txt
r3336776 r3349744 1 1 === Table of Contents Generator - SmartTOC Lite === 2 2 Contributors: sinergodata 3 Tags: table of contents, toc, wordpress toc, toc plugin, post index, headings, anchor links, auto toc, accessibility, seo3 Tags: table of contents, wordpress toc, anchor links, accessibility, seo 4 4 Requires at least: 5.6 5 5 Tested up to: 6.8 6 6 Requires PHP: 7.2 7 Stable tag: 1. 0.37 Stable tag: 1.1.0 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 56 56 == Changelog == 57 57 58 = 1.1.0 = 59 * Added per-side padding controls (top/right/bottom/left) 60 * Updated live preview & dynamic CSS to use per-side padding 61 * Back-compat: automatic migration for old numeric padding option 62 58 63 = 1.0.3 = 59 64 * Updated plugin name for SEO … … 69 74 70 75 == Upgrade Notice == 76 77 = 1.1.0 = 78 * Per-side padding replaces the single padding option; old numeric values migrate automatically. 71 79 72 80 = 1.0.3 = -
smarttoc-lite/trunk/smarttoc-lite.php
r3336776 r3349744 4 4 * Plugin URI: https://wordpress.org/plugins/smarttoc-lite/ 5 5 * Description: Create a responsive Table of Contents (TOC) for WordPress posts and pages. Features include automatic insertion, customizable styles, live preview, shortcode support, and accessibility. 6 * Version: 1. 0.36 * Version: 1.1.0 7 7 * Author: SinergoData 8 8 * Author URI: https://sinergodata.com/ … … 26 26 * Plugin version. 27 27 */ 28 const VERSION = '1. 0.0';28 const VERSION = '1.1.0'; 29 29 30 30 /**
Note: See TracChangeset
for help on using the changeset viewer.