start_controls_section('section_content', [ 'label' => __('Table of Contents', 'thinkrank'), ]); $this->add_control('heading', [ 'label' => __('Title', 'thinkrank'), 'type' => \Elementor\Controls_Manager::TEXT, 'default' => __('Table of Contents', 'thinkrank'), 'label_block' => true, ]); $this->add_control('heading_tag', [ 'label' => __('Heading tag', 'thinkrank'), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => 'h2', 'options' => ['h2' => 'H2', 'h3' => 'H3', 'h4' => 'H4', 'p' => __('Paragraph', 'thinkrank')], ]); $this->add_control('max_level', [ 'label' => __('Include headings up to', 'thinkrank'), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => '3', 'options' => ['2' => 'H2', '3' => 'H3', '4' => 'H4'], ]); $this->add_control('list_style', [ 'label' => __('List style', 'thinkrank'), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => 'disc', 'options' => [ 'disc' => __('Bulleted', 'thinkrank'), 'decimal' => __('Numbered', 'thinkrank'), 'none' => __('Plain', 'thinkrank'), ], ]); $this->end_controls_section(); } protected function render(): void { $settings = $this->get_settings_for_display(); $heading_tag = in_array($settings['heading_tag'] ?? 'h2', ['h2', 'h3', 'h4', 'p'], true) ? $settings['heading_tag'] : 'h2'; $max_level = in_array($settings['max_level'] ?? '3', ['2', '3', '4'], true) ? (int) $settings['max_level'] : 3; $list_style = in_array($settings['list_style'] ?? 'disc', ['disc', 'decimal', 'none'], true) ? $settings['list_style'] : 'disc'; $widget_id = 'thinkrank-toc-' . esc_attr($this->get_id()); echo '