<?php /** * FAQ Widget */ namespace Elementor; // Exit if accessed directly if ( ! defined( 'ABSPATH' ) ) { exit; } class Cyarb_Faq extends Widget_Base { public function get_name() { return 'FAQ'; } public function get_title() { return __( 'Cyarb FAQ', 'cyarb-toolkit' ); } public function get_icon() { return 'eicon-help-o'; } public function get_categories() { return [ 'cyarb-elements' ]; } protected function register_controls() { $this->start_controls_section( 'Cyarb_Faq', [ 'label' => __( 'Faq Control', 'cyarb-toolkit' ), 'tab' => Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'section_hide', [ 'label' =>__( 'Hide Section?', 'cyarb-toolkit' ), 'type' => Controls_Manager::SWITCHER, 'label_on' => __( 'Show', 'cyarb-toolkit' ), 'label_off' => __( 'Hide', 'cyarb-toolkit' ), 'return_value' => 'yes', 'default' => 'no', ] ); $this->add_control( 'title', [ 'label' => esc_html__( 'Title', 'cyarb-toolkit' ), 'type' => Controls_Manager::TEXT, 'condition' => [ 'section_hide' => 'yes', ] ] ); $this->add_control( 'title_tag', [ 'label' => esc_html__( 'Title Tag', 'cyarb-toolkit' ), 'type' => Controls_Manager::SELECT, 'options' => [ 'h1' => esc_html__( 'h1', 'cyarb-toolkit' ), 'h2' => esc_html__( 'h2', 'cyarb-toolkit' ), 'h3' => esc_html__( 'h3', 'cyarb-toolkit' ), 'h4' => esc_html__( 'h4', 'cyarb-toolkit' ), 'h5' => esc_html__( 'h5', 'cyarb-toolkit' ), 'h6' => esc_html__( 'h6', 'cyarb-toolkit' ), ], 'default' => 'h2', 'condition' => [ 'section_hide' => 'yes', ] ] ); $this->add_control( 'content', [ 'label' => esc_html__( 'Content', 'cyarb-toolkit' ), 'type'=>Controls_Manager:: WYSIWYG, 'condition' => [ 'section_hide' => 'yes', ] ] ); $repeater = new Repeater(); $repeater->add_control( 'tab_title', [ 'label' => __( 'Tab Title', 'cyarb-toolkit' ), 'type' => Controls_Manager::TEXT, ] ); $repeater->add_control( 'list_desc', [ 'label'=>__('List Description', 'cyarb-toolkit'), 'type'=>Controls_Manager:: WYSIWYG, 'description' => __('This text editor for p','cyarb-toolkit'), ] ); $this->add_control( 'faq_tabs', [ 'label' => esc_html__('Faq Tabs', 'cyarb-toolkit'), 'type' => Controls_Manager::REPEATER, 'fields' => $repeater->get_controls(), ] ); $this->end_controls_section(); $this->start_controls_section( 'Cyarb_Faq_Sidebar', [ 'label' => __( 'Faq Sidebar', 'cyarb-toolkit' ), 'tab' => Controls_Manager::TAB_CONTENT, ] ); $repeater2 = new Repeater(); $repeater2->add_control( 'button_text', [ 'label' => __( 'Sidebar Lists Title', 'cyarb-toolkit' ), 'type' => Controls_Manager::TEXT, 'default' => __('Help Center', 'cyarb-toolkit'), ] ); $repeater2->add_control( 'link_type', [ 'label' => __( 'Link Type', 'cyarb-toolkit' ), 'type' => Controls_Manager::SELECT, 'label_block' => true, 'options' => [ '1' => __( 'Link To Page', 'cyarb-toolkit' ), '2' => __( 'External Link', 'cyarb-toolkit' ), ], ] ); $repeater2->add_control( 'link_to_page', [ 'label' => __( 'Link Page', 'cyarb-toolkit' ), 'type' => Controls_Manager::SELECT, 'label_block' => true, 'options' => cyarb_toolkit_get_page_as_list(), 'condition' => [ 'link_type' => '1', ] ] ); $repeater2->add_control( 'external_link', [ 'label'=>__('External Link', 'cyarb-toolkit'), 'type'=>Controls_Manager:: TEXT, 'condition' => [ 'link_type' => '2', ] ] ); //Target Page $repeater2->add_control( 'target_page', [ 'label' => __( 'Link Open In New Tab?', 'cyarb-toolkit' ), 'type' => Controls_Manager::SWITCHER, 'label_on' => __( 'Yes', 'cyarb-toolkit' ), 'label_off' => __( 'No', 'cyarb-toolkit' ), 'return_value' => 'yes', 'default' => 'yes', ] ); $this->add_control( 'sidebar_lists', [ 'label' => esc_html__('Sidebar Lists', 'cyarb-toolkit'), 'type' => Controls_Manager::REPEATER, 'fields' => $repeater2->get_controls(), ] ); $this->end_controls_section(); $this->start_controls_section( 'faq_style', [ 'label' => __( 'Style', 'cyarb-toolkit' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_control( 'title_color', [ 'label' => esc_html__( 'Title Color', 'cyarb-toolkit' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .section-title h1, .section-title h2, .section-title h3, .section-title h4, .section-title h5, .section-title h6' => 'color: {{VALUE}}', ], 'condition' => [ 'section_hide' => 'yes', ] ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'title_typography', 'label' => __( 'Title Typography', 'cyarb-toolkit' ), 'selector' => '{{WRAPPER}} .section-title h1, .section-title h2, .section-title h3, .section-title h4, .section-title h5, .section-title h6', 'condition' => [ 'section_hide' => 'yes', ] ] ); $this->add_control( 'desc_color', [ 'label' => esc_html__( 'Description Color', 'cyarb-toolkit' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} p' => 'color: {{VALUE}}', ], 'condition' => [ 'section_hide' => 'yes', ] ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'desc_typography', 'label' => __( 'Description Typography', 'cyarb-toolkit' ), 'selector' => '{{WRAPPER}} p', 'condition' => [ 'section_hide' => 'yes', ] ] ); $this->add_control( 'faq_sidebar_title_color', [ 'label' => __( 'FAQ Sidebar Title Color', 'cyarb-toolkit' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .faq-sidebar ul li a' => 'color: {{VALUE}}', ], ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'f_sidebar_title_typography', 'label' => __( 'FAQ Sidebar Title Typography', 'cyarb-toolkit' ), 'selector' => '{{WRAPPER}} .faq-sidebar ul li a', ] ); $this->add_control( 'f_title_color', [ 'label' => __( 'FAQ Title Color', 'cyarb-toolkit' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .faq-accordion .accordion-item .accordion-button' => 'color: {{VALUE}}', ], ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'f_title_typography', 'label' => __( 'FAQ Title Typography', 'cyarb-toolkit' ), 'selector' => '{{WRAPPER}} .faq-accordion .accordion-item .accordion-button', ] ); $this->add_control( 'f_desc_color', [ 'label' => __( 'FAQ Description Color', 'cyarb-toolkit' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} p, .faq-accordion .accordion-item .accordion-body ul li' => 'color: {{VALUE}}', ], ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'f_desc_typography', 'label' => __( 'FAQ Description Typography', 'cyarb-toolkit' ), 'selector' => '{{WRAPPER}} p, .faq-accordion .accordion-item .accordion-body ul li', ] ); $this->end_controls_section(); } protected function render() { $settings = $this->get_settings_for_display(); ?> <div class="faq-area ptb-100"> <div class="container"> <?php if ( 'yes' === $settings['section_hide'] ) : ?> <div class="section-title"> <<?php echo esc_attr( $settings['title_tag'] ); ?>><?php echo esc_html( $settings['title'] ); ?></<?php echo esc_attr( $settings['title_tag'] ); ?>> <?php echo wp_kses_post( $settings['content'] ); ?> </div> <?php endif; ?> <div class="row"> <div class="col-lg-4 col-md-12"> <div class="faq-sidebar"> <ul> <?php $i = 1; foreach( $settings['sidebar_lists'] as $item2 ): // Active Class if ($i == 1) { $active = 'active'; }else { $active = ''; } $btn1_text = $item2['button_text']; // Button Link $link_source = ''; if( $item2['link_type'] == 1 ){ $link_source = get_page_link($item2['link_to_page']); } else { $link_source = $item2['external_link']; } if($btn1_text != '') { ?> <li> <?php if ( 'yes' === $item2['target_page'] ) { ?> <a class="<?php echo esc_attr( $active ); ?>" target="_blank" href="<?php echo esc_url($link_source); ?>"> <?php echo esc_html($btn1_text); ?> </a> <?php } else { ?> <a href="<?php echo esc_url($link_source); ?>" class="<?php echo esc_attr( $active ); ?>"> <?php echo esc_html($btn1_text); ?> </a> <?php } ?> </li><?php } $i++; endforeach; ?> </ul> </div> </div> <div class="col-lg-8 col-md-12"> <div class="faq-accordion accordion" id="faqAccordion"> <?php $i = 1; foreach( $settings['faq_tabs'] as $item ): // Active Class if ($i == 1) { $show = 'accordion-collapse collapse show'; } else { $show = 'accordion-collapse collapse'; } ?> <div class="accordion-item"> <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapse<?php echo esc_attr( $i ); ?>" aria-expanded="true" aria-controls="collapse<?php echo esc_attr( $i ); ?>"> <?php echo esc_html( $item['tab_title'] ); ?> <i class="lni lni-chevron-down"></i> </button> <div id="collapse<?php echo esc_attr( $i ); ?>" class="<?php echo esc_attr( $show ); ?>" data-bs-parent="#faqAccordion"> <div class="accordion-body"> <?php echo wp_kses_post( $item['list_desc'] ); ?> </div> </div> </div> <?php $i++; endforeach; ?> </div> </div> </div> </div> </div> <?php } } Plugin::instance()->widgets_manager->register_widget_type( new Cyarb_Faq );