Plugin Directory

Changeset 3707164


Ignore:
Timestamp:
09/22/2026 11:21:03 AM (5 weeks ago)
Author:
shravanchoudhary
Message:

version 1.3.3

Location:
softech-addons-for-elementor
Files:
228 added
9 edited

Legend:

Unmodified
Added
Removed
  • softech-addons-for-elementor/trunk/assets/css/hf-editor.css

    r3611551 r3707164  
    1313        display: block;
    1414        cursor: pointer;
    15 }
    16 .site-header {
    17     display: none !important;
    18    
    1915}
    2016
  • softech-addons-for-elementor/trunk/assets/css/mega-menu-frontend.css

    r3644202 r3707164  
    115115    background: #fff;
    116116    z-index: 96;
     117    margin:0;
    117118}
    118119
  • softech-addons-for-elementor/trunk/includes/class-header-footer-builder.php

    r3629434 r3707164  
    861861
    862862                if ( $post_id && ! is_wp_error( $post_id ) ) {
     863                        update_post_meta( $post_id, '_wp_page_template', 'elementor_canvas' );
     864                        update_post_meta( $post_id, '_elementor_template_type', 'sits-hf-template' );
    863865                        wp_safe_redirect( admin_url( 'post.php?post=' . $post_id . '&action=elementor' ) );
    864866                        exit;
    … …  
    887889                        wp_send_json_error( [ 'message' => __( 'Could not create template draft.', 'softech-addons-for-elementor' ) ] );
    888890                }
     891
     892                update_post_meta( $post_id, '_wp_page_template', 'elementor_canvas' );
     893                update_post_meta( $post_id, '_elementor_template_type', 'sits-hf-template' );
    889894
    890895                wp_send_json_success( [
  • softech-addons-for-elementor/trunk/includes/class-hf-elementor-document.php

    r3578373 r3707164  
    167167                        return true;
    168168                }
    169                 protected function register_controls() {
    170     parent::register_controls();
    171 
    172     // Force-register Hide Title if Pro stripped it out
    173     if ( ! $this->get_controls( 'hide_title' ) ) {
    174         $this->add_control(
    175             'hide_title',
    176             [
    177                 'label'     => esc_html__( 'Hide Title', 'softech-addons-for-elementor' ),
    178                 'type'      => \Elementor\Controls_Manager::SWITCHER,
    179                 'default'   => '',
    180                 'separator' => 'before',
    181             ]
    182         );
    183     }
    184 
    185     // Force-register Page Layout (template) if Pro stripped it out
    186     if ( ! $this->get_controls( 'template' ) ) {
    187         $templates = [];
    188         foreach ( get_page_templates() as $label => $value ) {
    189             $templates[ $value ] = $label;
    190         }
    191         $templates = array_merge(
    192             [ 'default' => esc_html__( 'Default', 'softech-addons-for-elementor' ) ],
    193             $templates
    194         );
    195 
    196         $this->add_control(
    197             'template',
    198             [
    199                 'label'   => esc_html__( 'Page Layout', 'softech-addons-for-elementor' ),
    200                 'type'    => \Elementor\Controls_Manager::SELECT,
    201                 'default' => 'elementor_canvas',
    202                 'options' => $templates,
    203             ]
    204         );
    205     }
    206 }
     169                                protected function register_controls() {
     170                        parent::register_controls();
     171
     172                        $this->start_controls_section(
     173                                'sits_hf_layout_settings',
     174                                [
     175                                        'label' => esc_html__( 'Page Layout', 'softech-addons-for-elementor' ),
     176                                        'tab'   => \Elementor\Controls_Manager::TAB_SETTINGS,
     177                                ]
     178                        );
     179
     180                        if ( ! $this->get_controls( 'hide_title' ) ) {
     181                                $this->add_control(
     182                                        'hide_title',
     183                                        [
     184                                                'label'   => esc_html__( 'Hide Title', 'softech-addons-for-elementor' ),
     185                                                'type'    => \Elementor\Controls_Manager::SWITCHER,
     186                                                'default' => 'yes',
     187                                        ]
     188                                );
     189                        }
     190
     191                        if ( ! $this->get_controls( 'template' ) ) {
     192                                $this->add_control(
     193                                        'template',
     194                                        [
     195                                                'label'   => esc_html__( 'Page Layout', 'softech-addons-for-elementor' ),
     196                                                'type'    => \Elementor\Controls_Manager::SELECT,
     197                                                'default' => 'elementor_canvas',
     198                                                'options' => [
     199                                                        ''                        => esc_html__( 'Default', 'softech-addons-for-elementor' ),
     200                                                        'elementor_header_footer' => esc_html__( 'Elementor Full Width', 'softech-addons-for-elementor' ),
     201                                                        'elementor_canvas'        => esc_html__( 'Elementor Canvas', 'softech-addons-for-elementor' ),
     202                                                ],
     203                                        ]
     204                                );
     205                        }
     206
     207                        $this->end_controls_section();
     208                }
    207209        }
    208210} else {
    … …  
    300302                }
    301303
    302                 protected function filter_print_content() {
     304                                protected function filter_print_content() {
    303305                        $type = $this->get_hf_type();
    304306                        return ! in_array( $type, [ 'header', 'footer' ], true );
    305307                }
     308
     309                protected function register_controls() {
     310                        parent::register_controls();
     311
     312                        $this->start_controls_section(
     313                                'sits_hf_layout_settings',
     314                                [
     315                                        'label' => esc_html__( 'Page Layout', 'softech-addons-for-elementor' ),
     316                                        'tab'   => \Elementor\Controls_Manager::TAB_SETTINGS,
     317                                ]
     318                        );
     319
     320                        if ( ! $this->get_controls( 'hide_title' ) ) {
     321                                $this->add_control(
     322                                        'hide_title',
     323                                        [
     324                                                'label'   => esc_html__( 'Hide Title', 'softech-addons-for-elementor' ),
     325                                                'type'    => \Elementor\Controls_Manager::SWITCHER,
     326                                                'default' => 'yes',
     327                                        ]
     328                                );
     329                        }
     330
     331                        if ( ! $this->get_controls( 'template' ) ) {
     332                                $this->add_control(
     333                                        'template',
     334                                        [
     335                                                'label'   => esc_html__( 'Page Layout', 'softech-addons-for-elementor' ),
     336                                                'type'    => \Elementor\Controls_Manager::SELECT,
     337                                                'default' => 'elementor_canvas',
     338                                                'options' => [
     339                                                        ''                        => esc_html__( 'Default', 'softech-addons-for-elementor' ),
     340                                                        'elementor_header_footer' => esc_html__( 'Elementor Full Width', 'softech-addons-for-elementor' ),
     341                                                        'elementor_canvas'        => esc_html__( 'Elementor Canvas', 'softech-addons-for-elementor' ),
     342                                                ],
     343                                        ]
     344                                );
     345                        }
     346
     347                        $this->end_controls_section();
     348                }
    306349        }
    307350}
  • softech-addons-for-elementor/trunk/readme.txt

    r3684891 r3707164  
    66Tested up to: 7.1
    77Requires PHP: 7.4
    8 Stable tag: 1.3.2
     8Stable tag: 1.3.3   
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html 
    … …  
    133133* [Search](https://softechaddons.sitslab.com/elementor-search-widget/)
    134134* [Marquee](https://softechaddons.sitslab.com/elementor-marquee-widget/)
    135 * [Table of Contents](https://softechaddons.sitslab.com/elementor-post-info-widget/)
     135* [Table of Contents](https://softechaddons.sitslab.com/elementor-table-of-contents-widget/)
    136136
    137137
    … …  
    276276
    277277== 25. Table of Contents ==
    278 [View Demo](https://softechaddons.sitslab.com/elementor-post-info-widget/)
     278[View Demo](https://softechaddons.sitslab.com/elementor-table-of-contents-widget/)
    279279
    280280Table of Contents - A smart Elementor widget that automatically generates a navigable table of contents from your page or post headings. Perfect for long-form articles, documentation, guides, and tutorials. Features server-side rendered output for SEO, smooth scroll navigation, active-link highlighting as visitors read, customizable dot/number markers, optional dividers between items, and heading label truncation for long titles. Fully responsive with complete typography and color controls.
    … …  
    356356
    357357== Changelog ==
     358
     359= 1.3.3 =
     360* **Widget Settings UI/UX**: Refined and improved the widget settings panel across the plugin for a cleaner, more intuitive editing experience
     361* **Table of Contents & Mega Menu**: Fixed several small issues affecting widget behavior for smoother, more reliable rendering
     362* **Multilingual Support**: Widgets now support foreign languages, improving compatibility for non-English and multilingual sites
     363* **General**: Regular update with bug fixes and stability improvements
    358364
    359365= 1.3.2 =
    … …  
    520526== Upgrade Notice ==
    521527
     528= 1.3.3 =
     529Improved widget settings UI/UX for a smoother editing experience, small fixes for Table of Contents and Mega Menu, and new support for foreign languages across widgets. Recommended update for all users.
     530
    522531= 1.3.2 =
    523532Introduces the new free Table of Contents widget for auto-generating a navigable heading outline on your pages and posts. Also adds new grid item options to Loop Grid Slider. Recommended update for all users.
  • softech-addons-for-elementor/trunk/softech-addons-for-elementor.php

    r3684891 r3707164  
    33Plugin Name: Softech Addons for Elementor
    44Description: A custom addon that provides additional widgets to extend Elementor’s functionality with flexible and reusable components.
    5 Version: 1.3.2
     5Version: 1.3.3
    66Author: Shravan Choudhary
    77Author URI: https://softechaddons.sitslab.com/
    … …  
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    1010Text Domain: softech-addons-for-elementor
     11Domain Path: /languages
    1112Requires Plugins: elementor
    1213Elementor tested up to: 4.2.2
    … …  
    4243}
    4344
    44 define('SITS_ELEMENTOR_ADDONS_VERSION', '1.3.2');
     45define('SITS_ELEMENTOR_ADDONS_VERSION', '1.3.3');
    4546define('SITS_ELEMENTOR_ADDONS_PLUGIN_URL', plugin_dir_url(__FILE__));
    4647define('SITS_ELEMENTOR_ADDONS_PLUGIN_PATH', plugin_dir_path(__FILE__));
  • softech-addons-for-elementor/trunk/widgets/sitsel-marquee.php

    r3656059 r3707164  
    15071507    $sel = '#sitsel-marquee-' . esc_attr($widget_id);
    15081508
    1509     $css = "
     1509        $css = "
     1510        {$sel} .sitsel-marquee-viewport{
     1511            overflow:hidden;width:100%;position:relative;z-index:1;min-height:1.5em;
     1512        }
    15101513        {$sel} .sitsel-marquee-track{
    15111514            display:flex;flex-wrap:nowrap;align-items:center;
    … …  
    15191522            opacity:1;visibility:visible;
    15201523        }
    1521         {$sel} .sitsel-marquee-item{flex:0 0 auto;white-space:nowrap;}
     1524        {$sel} .sitsel-marquee-item{
     1525            flex:0 0 auto;display:flex;align-items:center;white-space:nowrap;
     1526        }
    15221527        {$sel} .sitsel-marquee-icon,
    15231528        {$sel} .sitsel-marquee-icon i{line-height:1;display:inline-flex;}
    … …  
    15411546    ";
    15421547
    1543     // Make sure the style handle is registered/enqueued before attaching inline CSS.
    15441548    $this->register_widget_assets();
    15451549    if (! wp_style_is('sitsel-marquee-css', 'enqueued')) {
    15461550        wp_enqueue_style('sitsel-marquee-css');
    15471551    }
    1548     wp_add_inline_style('sitsel-marquee-css', $css);
     1552
     1553    echo '<style id="sitsel-marquee-critical-' . esc_attr($widget_id) . '">' . $css . '</style>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
    15491554}
    15501555
  • softech-addons-for-elementor/trunk/widgets/sitsel-mega-menu-widget.php

    r3656059 r3707164  
    5757
    5858        if (!wp_style_is('sitsel-frontend-mega-menu-css', 'registered')) {
    59             wp_register_style('sitsel-frontend-mega-menu-css', $plugin_url . 'assets/css/mega-menu-frontend.css', [], $version);
    60             wp_enqueue_style('sitsel-frontend-mega-menu-css');
    61         }
     59    wp_register_style('sitsel-frontend-mega-menu-css', $plugin_url . 'assets/css/mega-menu-frontend.css', [], $version);
     60}
    6261    }
    6362    private function get_default_menu_id() {
    … …  
    414413            'label'     => esc_html__('Text Color', 'softech-addons-for-elementor'),
    415414            'type'      => Controls_Manager::COLOR,
    416             'default'   => '#fff',
     415            'default'   => '#0F3D4A',
    417416            'selectors' => [
    418417                '{{WRAPPER}} .sitsel-mega-menu-main > .sits-menu-item > a' => 'color: {{VALUE}};',
    … …  
    423422            'label'     => esc_html__('Background Color', 'softech-addons-for-elementor'),
    424423            'type'      => Controls_Manager::COLOR,
    425             'default'   => '#0f3d4a',
     424            'default'   => '#fff',
    426425            'selectors' => [
    427426                '{{WRAPPER}} .sitsel-mega-menu-main > .sits-menu-item > a' => 'background-color: {{VALUE}};',
    … …  
    552551            'fields_options'=> [
    553552                'background' => ['default' => 'classic'],
    554                 'color'      => ['default' => '#1a5968'],
     553                'color'      => ['default' => '#fff'],
    555554            ],
    556555            'selector' => '{{WRAPPER}} .sitsel-mega-menu-widget:not(.sitsel-mobile-version) .sitsel-sub-menu',
    … …  
    618617            'label'     => esc_html__('Text Color', 'softech-addons-for-elementor'),
    619618            'type'      => Controls_Manager::COLOR,
    620             'default'   => '#fff',
     619            'default'   => '#0F3D4A',
    621620            'selectors' => [
    622621                '{{WRAPPER}} .sitsel-mega-menu-main .sitsel-sub-menu li a' => 'color: {{VALUE}};',
    … …  
    634633            'label'     => esc_html__('Text Color', 'softech-addons-for-elementor'),
    635634            'type'      => Controls_Manager::COLOR,
     635            'default'   => '#fff',
    636636            'selectors' => [
    637637                '{{WRAPPER}} .sitsel-mega-menu-main .sitsel-sub-menu li a:hover' => 'color: {{VALUE}};',
    … …  
    642642            'label'     => esc_html__('Background Color', 'softech-addons-for-elementor'),
    643643            'type'      => Controls_Manager::COLOR,
    644             'default'   => '#dfdfdf',
     644            'default'   => '#989898',
    645645            'selectors' => [
    646646                '{{WRAPPER}} .sitsel-mega-menu-widget .sitsel-sub-menu > .sits-menu-item > a:hover' => 'background: {{VALUE}};',
    … …  
    733733            'label'     => esc_html__('Size (px)', 'softech-addons-for-elementor'),
    734734            'type'      => Controls_Manager::NUMBER,
    735             'default'   => 12,
     735            'default'   => 10,
    736736            'selectors' => [
    737737                '{{WRAPPER}} .sitsel-submenu-icon svg' => 'width: {{VALUE}}px;',
    … …  
    749749            'label'     => esc_html__('Color', 'softech-addons-for-elementor'),
    750750            'type'      => Controls_Manager::COLOR,
    751             'default'   => '#fff',
     751            'default'   => '#0F3D4A',
    752752            'selectors' => [
    753753                '{{WRAPPER}} .sitsel-submenu-icon svg'      => 'fill: {{VALUE}};',
    … …  
    824824            'fields_options'=> [
    825825                'background' => ['default' => 'classic'],
    826                 'color'      => ['default' => '#0f3d4a'],
     826                'color'      => ['default' => '#fff'],
    827827            ],
    828828            'selector'  => '{{WRAPPER}} .sitsel-mobile-version .sitsel-mega-menu-main-wrapper',
    … …  
    11201120            'label'     => esc_html__('Size (px)', 'softech-addons-for-elementor'),
    11211121            'type'      => Controls_Manager::NUMBER,
    1122             'default'   => 12,
     1122            'default'   => 10,
    11231123            'selectors' => [
    11241124                '{{WRAPPER}} .sitsel-mobile-version .sitsel-submenu-icon svg' => 'width: {{VALUE}}px; height: {{VALUE}}px;',
    … …  
    11421142        // ─────────────────────────────────────────────
    11431143        $this->start_controls_section('style_toggle_button', [
    1144             'label' => esc_html__('Toggle Button', 'softech-addons-for-elementor'),
     1144            'label' => esc_html__('Hamburger & Close Button', 'softech-addons-for-elementor'),
    11451145            'tab'   => Controls_Manager::TAB_STYLE,
    11461146        ]);
    … …  
    11501150            'type'      => Controls_Manager::SLIDER,
    11511151            'range'     => ['px' => ['min' => 8, 'max' => 80]],
    1152             'default'   => ['size' => 24],
     1152            'default'   => ['size' => 16],
    11531153            'selectors' => [
    11541154                '{{WRAPPER}} .sitsel-icon-open i'    => 'font-size: {{SIZE}}px;',
    … …  
    11631163            'type'      => Controls_Manager::SLIDER,
    11641164            'range'     => ['px' => ['min' => 8, 'max' => 80]],
    1165             'default'   => ['size' => 24],
     1165            'default'   => ['size' => 16],
    11661166            'selectors' => [
    11671167                '{{WRAPPER}} .sitsel-icon-close i'   => 'font-size: {{SIZE}}px;',
  • softech-addons-for-elementor/trunk/widgets/sitsel-toc.php

    r3684903 r3707164  
    1919        const ID_PREFIX = 'sits-toc-';
    2020
    21         private static $content_headings = array();
     21        private static $content_headings_map = array();
     22        private static $heading_key_counter  = 0;
    2223        private static $content_filter_added = false;
    2324
    … …  
    6566        }
    6667
    67         private static function hook_content_filter() {
     68                private static function hook_content_filter() {
    6869                if ( self::$content_filter_added ) {
    6970                        return;
    … …  
    7576        }
    7677
     78        private static function is_trackable_frontend_request() {
     79                if ( is_admin() ) {
     80                        return false;
     81                }
     82
     83                if ( function_exists( 'wp_doing_ajax' ) && wp_doing_ajax() ) {
     84                        return false;
     85                }
     86
     87                if ( function_exists( 'wp_doing_cron' ) && wp_doing_cron() ) {
     88                        return false;
     89                }
     90
     91                if ( ( defined( 'REST_REQUEST' ) && REST_REQUEST ) || ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST ) ) {
     92                        return false;
     93                }
     94
     95                if ( function_exists( 'is_feed' ) && is_feed() ) {
     96                        return false;
     97                }
     98
     99                return true;
     100        }
     101
    77102        public static function capture_content_headings( $content ) {
    78                 if ( ! is_string( $content ) || false === stripos( $content, '<h' ) ) {
    79                         return $content;
    80                 }
    81 
    82                 $used_slugs = array();
    83 
    84                 $content = preg_replace_callback(
    85                         '/<(h[2-4])((?:\s+[^>]*)?)>(.*?)<\/\1>/is',
    86                         static function ( $matches ) use ( &$used_slugs ) {
    87                                 $tag   = strtolower( $matches[1] );
    88                                 $attrs = $matches[2];
    89                                 $inner = $matches[3];
    90                                 $text  = trim( wp_strip_all_tags( $inner ) );
    91 
    92                                 if ( '' === $text ) {
    93                                         return $matches[0];
    94                                 }
    95 
    96                                 if ( preg_match( '/\bid=(["\'])(.*?)\1/i', $attrs, $id_match ) ) {
    97                                         $id = $id_match[2];
    98                                 } else {
    99                                         $id     = sitsel_toc::generate_slug( $text, $used_slugs );
    100                                         $attrs .= ' id="' . esc_attr( $id ) . '"';
    101                                 }
    102 
    103                                 $used_slugs[ $id ] = true;
    104 
    105                                 sitsel_toc::$content_headings[] = array(
    106                                         'id'    => $id,
    107                                         'level' => $tag,
    108                                         'text'  => $text,
    109                                 );
    110 
    111                                 return '<' . $tag . $attrs . '>' . $inner . '</' . $tag . '>';
    112                         },
    113                         $content
    114                 );
    115 
     103        if ( ! self::is_trackable_frontend_request() ) {
    116104                return $content;
    117105        }
     106
     107        if ( ! is_singular( 'post' ) ) {
     108                return $content;
     109        }
     110
     111        if ( ! is_string( $content ) || false === strpos( $content, '<h' ) ) {
     112                return $content;
     113        }
     114
     115        return preg_replace_callback(
     116                '/<(h[2-4])((?:\s+[^>]*)?)>(.*?)<\/\1>/is',
     117                static function ( $matches ) {
     118                        $tag   = strtolower( $matches[1] );
     119                        $attrs = $matches[2];
     120                        $inner = $matches[3];
     121                        $text  = trim( wp_strip_all_tags( $inner ) );
     122
     123                        if ( '' === $text ) {
     124                                return $matches[0];
     125                        }
     126
     127                        $existing_id = '';
     128                        if ( preg_match( '/\bid=(["\'])(.*?)\1/i', $attrs, $id_match ) ) {
     129                                $existing_id = $id_match[2];
     130                        }
     131
     132                        ++self::$heading_key_counter;
     133                        $key = self::$heading_key_counter;
     134
     135                        self::$content_headings_map[ $key ] = array(
     136                                'text'  => $text,
     137                                'level' => $tag,
     138                                'id'    => $existing_id,
     139                        );
     140
     141                        $attrs .= ' data-sitsel-hkey="' . $key . '"';
     142
     143                        return '<' . $tag . $attrs . '>' . $inner . '</' . $tag . '>';
     144                },
     145                $content
     146        );
     147}
    118148
    119149        protected function register_controls() {
    … …  
    945975
    946976        public static function start_page_buffer() {
    947                 if ( is_admin() ) {
     977                if ( ! self::is_trackable_frontend_request() ) {
    948978                        return;
    949979                }
    950980
    951                 if ( function_exists( 'wp_doing_ajax' ) && wp_doing_ajax() ) {
    952                         return;
    953                 }
    954 
    955                 if ( function_exists( 'wp_doing_cron' ) && wp_doing_cron() ) {
    956                         return;
    957                 }
    958 
    959                 if ( ( defined( 'REST_REQUEST' ) && REST_REQUEST ) || ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST ) ) {
    960                         return;
    961                 }
    962 
    963                 if ( function_exists( 'is_feed' ) && is_feed() ) {
    964                         return;
    965                 }
    966 
    967981                ob_start( array( __CLASS__, 'process_page_buffer' ) );
    968982        }
    969983
    970984        public static function process_page_buffer( $html ) {
    971         if ( ! is_string( $html ) || false === strpos( $html, 'data-sitsel-toc-id=' ) ) {
     985        if ( ! is_string( $html ) ) {
    972986                return $html;
    973987        }
    974988
    975         $content_headings = self::$content_headings; // may be empty array, that's fine now
     989        if ( false === strpos( $html, 'data-sitsel-toc-id=' ) ) {
     990                return self::strip_leftover_hkeys( $html );
     991        }
     992
     993                $allowed_levels = array();
     994        if ( preg_match_all( '/data-heading-levels="([^"]*)"/', $html, $level_matches ) ) {
     995                foreach ( $level_matches[1] as $levels_str ) {
     996                        foreach ( explode( ',', $levels_str ) as $level ) {
     997                                $level = trim( $level );
     998                                if ( '' !== $level ) {
     999                                        $allowed_levels[ $level ] = true;
     1000                                }
     1001                        }
     1002                }
     1003        }
     1004
     1005        $used_slugs       = array();
     1006        $content_headings = array();
     1007
     1008        $html = preg_replace_callback(
     1009                '/<(h[2-4])((?:\s+[^>]*)?)>/is',
     1010                static function ( $matches ) use ( &$used_slugs, &$content_headings, $allowed_levels ) {
     1011                        $tag   = strtolower( $matches[1] );
     1012                        $attrs = $matches[2];
     1013
     1014                        if ( ! preg_match( '/\sdata-sitsel-hkey="(\d+)"/', $attrs, $key_match ) ) {
     1015                                return $matches[0];
     1016                        }
     1017
     1018                        $key   = (int) $key_match[1];
     1019                        $attrs = preg_replace( '/\s*data-sitsel-hkey="\d+"/', '', $attrs );
     1020
     1021                        if ( ! isset( sitsel_toc::$content_headings_map[ $key ] ) || ! isset( $allowed_levels[ $tag ] ) ) {
     1022                                return '<' . $tag . $attrs . '>';
     1023                        }
     1024
     1025                        $heading = sitsel_toc::$content_headings_map[ $key ];
     1026                        $id      = $heading['id'];
     1027
     1028                        if ( '' === $id ) {
     1029                                $id     = sitsel_toc::generate_slug( $heading['text'], $used_slugs );
     1030                                $attrs .= ' id="' . esc_attr( $id ) . '"';
     1031                        }
     1032
     1033                        $used_slugs[ $id ] = true;
     1034
     1035                        $content_headings[] = array(
     1036                                'id'    => $id,
     1037                                'level' => $heading['level'],
     1038                                'text'  => $heading['text'],
     1039                        );
     1040
     1041                        return '<' . $tag . $attrs . '>';
     1042                },
     1043                $html
     1044        );
     1045
     1046        if ( null === $html ) {
     1047                return $html;
     1048        }
    9761049
    9771050        $html = preg_replace_callback(
    … …  
    9991072        }
    10001073
    1001         $html = preg_replace(
     1074                $html = preg_replace(
    10021075                array(
    10031076                        '/<!--sitsel-toc-start-[a-z0-9]+-->/i',
    … …  
    10081081        );
    10091082
    1010         return $html;
     1083        return self::strip_leftover_hkeys( $html );
     1084}
     1085
     1086private static function strip_leftover_hkeys( $html ) {
     1087        if ( ! is_string( $html ) || false === strpos( $html, 'data-sitsel-hkey=' ) ) {
     1088                return $html;
     1089        }
     1090
     1091        return preg_replace( '/\s*data-sitsel-hkey="\d+"/', '', $html );
    10111092}
    10121093
Note: See TracChangeset for help on using the changeset viewer.