Plugin Directory

Changeset 3349744


Ignore:
Timestamp:
08/25/2025 01:50:47 PM (7 months ago)
Author:
sinergodata
Message:

Release 1.1.0: per-side padding, live preview update, back-compat.

Location:
smarttoc-lite/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • smarttoc-lite/trunk/css/smarttoc-lite-admin.css

    r3335881 r3349744  
    185185    color: #2E2E2E;
    186186}
     187.wrap.sparttoc-admin-wrap .smarttoc-options-section input[type="number"]{
     188    padding-right: 0;
     189}
    187190.wrap.sparttoc-admin-wrap .smarttoc-info{
    188191    display: block;
  • smarttoc-lite/trunk/includes/admin-settings.php

    r3335881 r3349744  
    200200        ));
    201201        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'),
    203203        ));
    204204        register_setting(
     
    716716    }
    717717
    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
    726754
    727755    public function margin_field_html()
     
    753781        $input = sanitize_text_field($input);
    754782        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;
    755791    }
    756792    public function sanitize_width_option($input)
  • smarttoc-lite/trunk/includes/class-smarttoc-lite.php

    r3336003 r3349744  
    271271
    272272    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 .= "
    312326        .smarttoc-lite-toc #smarttoc-list .smarttoc-list-content ul {
    313327            list-style: none;
     
    325339        }
    326340        ";
    327     } else {
    328         $dynamic_css .= "
     341        } else {
     342            $dynamic_css .= "
    329343        .smarttoc-lite-toc #smarttoc-list .smarttoc-list-content ul {
    330344            list-style-type: " . esc_attr($numbering_style) . ";
     
    333347        }
    334348        ";
    335     }
    336 
    337     // Stiluri generale
    338     $dynamic_css .= "
     349        }
     350
     351        // Stiluri generale
     352        $dynamic_css .= "
    339353    .smarttoc-lite-wrapper {
    340354        text-align: " . ($alignment === 'left' ? 'left' : ($alignment === 'center' ? 'center' : 'right')) . ";
     
    347361        margin: " . ($alignment === 'center' ? '0 auto' : '0') . ";
    348362        direction: " . esc_attr($text_direction) . ";
    349         padding: " . intval($padding) . "px;
     363        padding: " . esc_attr($padding_css) . ";
    350364        margin-bottom: " . intval($margin) . "px;
    351365        border: " . esc_attr($border_width) . "px solid " . esc_attr($border) . ";
     
    400414    ";
    401415
    402     // Adăugăm stilul inline
    403     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    }
    405419}
    406420
  • smarttoc-lite/trunk/js/smarttoc-lite-admin.js

    r3335881 r3349744  
    7373    const textDirection = get("smarttoc_lite_text_direction", "ltr");
    7474    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`;
    7680    const numberingStyle = get("smarttoc_lite_numbering_style", "disc");
    7781    const customBullet = get("smarttoc_lite_custom_bullet", "→");
     
    9296    preview.style.borderRadius = `${borderRadius}px`;
    9397    preview.style.direction = textDirection;
    94     preview.style.padding = `${tocPadding}px`;
     98    preview.style.padding = paddingCss;
    9599    preview.style.textAlign = textAlign;
    96100
     
    118122      if (["minimal", "compact", "underline"].includes(theme)) {
    119123        toggleBtn.style.border = `2px solid ${iconColor}`;
    120       }else{
     124      } else {
    121125        toggleBtn.style.border = `none`;
    122126      }
     
    145149        const bullet = li.querySelector(".custom-bullet");
    146150        if (numberingStyle === "custom") {
    147           ul.style.listStyleType = 'none';
     151          ul.style.listStyleType = "none";
    148152          if (!bullet) {
    149153            li.insertAdjacentHTML(
  • smarttoc-lite/trunk/readme.txt

    r3336776 r3349744  
    11=== Table of Contents Generator - SmartTOC Lite ===
    22Contributors: sinergodata 
    3 Tags: table of contents, toc, wordpress toc, toc plugin, post index, headings, anchor links, auto toc, accessibility, seo
     3Tags: table of contents, wordpress toc, anchor links, accessibility, seo
    44Requires at least: 5.6 
    55Tested up to: 6.8 
    66Requires PHP: 7.2 
    7 Stable tag: 1.0.3 
     7Stable tag: 1.1.0 
    88License: GPLv2 or later 
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    5656== Changelog ==
    5757
     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
    5863= 1.0.3 =
    5964* Updated plugin name for SEO
     
    6974
    7075== Upgrade Notice ==
     76
     77= 1.1.0 =
     78* Per-side padding replaces the single padding option; old numeric values migrate automatically.
    7179
    7280= 1.0.3 =
  • smarttoc-lite/trunk/smarttoc-lite.php

    r3336776 r3349744  
    44 * Plugin URI: https://wordpress.org/plugins/smarttoc-lite/
    55 * 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.3
     6 * Version: 1.1.0
    77 * Author: SinergoData
    88 * Author URI: https://sinergodata.com/
     
    2626         * Plugin version.
    2727         */
    28         const VERSION = '1.0.0';
     28        const VERSION = '1.1.0';
    2929
    3030        /**
Note: See TracChangeset for help on using the changeset viewer.