start_controls_section( 'section_content', array( 'label' => __( 'FAQs', 'accordion-faq-plugin' ), 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, ) ); $this->add_control( 'category', array( 'label' => __( 'Category slug', 'accordion-faq-plugin' ), 'type' => \Elementor\Controls_Manager::TEXT, 'default' => '', 'description' => __( 'Leave blank to show all FAQs.', 'accordion-faq-plugin' ), ) ); $this->add_control( 'style', array( 'label' => __( 'Style', 'accordion-faq-plugin' ), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => 'modern', 'options' => array( 'modern' => 'Modern', 'card' => 'Card', 'bordered' => 'Bordered', 'filled' => 'Filled', 'separated' => 'Separated', 'minimal' => 'Minimal', ), ) ); $this->add_control( 'mode', array( 'label' => __( 'Mode', 'accordion-faq-plugin' ), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => 'accordion', 'options' => array( 'accordion' => __( 'Accordion (one open)', 'accordion-faq-plugin' ), 'toggle' => __( 'Toggle (many open)', 'accordion-faq-plugin' ), ), ) ); $this->add_control( 'search', array( 'label' => __( 'Show search', 'accordion-faq-plugin' ), 'type' => \Elementor\Controls_Manager::SWITCHER, 'return_value' => '1', ) ); $this->add_control( 'filter', array( 'label' => __( 'Show category filter', 'accordion-faq-plugin' ), 'type' => \Elementor\Controls_Manager::SWITCHER, 'return_value' => '1', ) ); $this->add_control( 'expand_all', array( 'label' => __( 'Show expand / collapse all', 'accordion-faq-plugin' ), 'type' => \Elementor\Controls_Manager::SWITCHER, 'return_value' => '1', ) ); $this->add_control( 'toc', array( 'label' => __( 'Show table of contents', 'accordion-faq-plugin' ), 'type' => \Elementor\Controls_Manager::SWITCHER, 'return_value' => '1', ) ); $this->add_control( 'limit', array( 'label' => __( 'Maximum FAQs (-1 = all)', 'accordion-faq-plugin' ), 'type' => \Elementor\Controls_Manager::NUMBER, 'default' => -1, ) ); $this->end_controls_section(); } /** * Render on the front end. * * @return void */ protected function render() { $s = $this->get_settings_for_display(); $args = array( 'category' => isset( $s['category'] ) ? $s['category'] : '', 'style' => isset( $s['style'] ) ? $s['style'] : 'modern', 'mode' => isset( $s['mode'] ) ? $s['mode'] : 'accordion', 'search' => ! empty( $s['search'] ), 'filter' => ! empty( $s['filter'] ), 'expand_all' => ! empty( $s['expand_all'] ), 'toc' => ! empty( $s['toc'] ), 'limit' => isset( $s['limit'] ) ? (int) $s['limit'] : -1, ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- renderer output is escaped internally. echo accordion_faq()->renderer()->render( $args ); } }