434 lines
14 KiB
PHP
434 lines
14 KiB
PHP
<?php namespace THINKAIPLUGIN\Element;
|
||
|
||
use Elementor\Controls_Manager;
|
||
use Elementor\Controls_Stack;
|
||
use Elementor\Group_Control_Typography;
|
||
use Elementor\Group_Control_Border;
|
||
use Elementor\Repeater;
|
||
use Elementor\Widget_Base;
|
||
use Elementor\Utils;
|
||
use Elementor\Group_Control_Text_Shadow;
|
||
use \Elementor\Group_Control_Box_Shadow;
|
||
use \Elementor\Group_Control_Background;
|
||
use \Elementor\Group_Control_Image_Size;
|
||
use \Elementor\Group_Control_Text_Stroke;
|
||
use Elementor\Plugin;
|
||
|
||
/**
|
||
* Elementor button widget.
|
||
* Elementor widget that displays a button with the ability to control every
|
||
* aspect of the button design.
|
||
*
|
||
* @since 1.0.0
|
||
*/
|
||
class Faqs extends Widget_Base {
|
||
|
||
/**
|
||
* Get widget name.
|
||
* Retrieve button widget name.
|
||
*
|
||
* @since 1.0.0
|
||
* @access public
|
||
* @return string Widget name.
|
||
*/
|
||
public function get_name() {
|
||
return 'thinkai_faqs';
|
||
}
|
||
|
||
/**
|
||
* Get widget title.
|
||
* Retrieve button widget title.
|
||
*
|
||
* @since 1.0.0
|
||
* @access public
|
||
* @return string Widget title.
|
||
*/
|
||
public function get_title() {
|
||
return esc_html__( 'Thinkai Faqs', 'thinkai' );
|
||
}
|
||
|
||
/**
|
||
* Get widget icon.
|
||
* Retrieve button widget icon.
|
||
*
|
||
* @since 1.0.0
|
||
* @access public
|
||
* @return string Widget icon.
|
||
*/
|
||
public function get_icon() {
|
||
return 'eicon-accordion';
|
||
}
|
||
|
||
/**
|
||
* Get widget categories.
|
||
* Retrieve the list of categories the button widget belongs to.
|
||
* Used to determine where to display the widget in the editor.
|
||
*
|
||
* @since 2.0.0
|
||
* @access public
|
||
* @return array Widget categories.
|
||
*/
|
||
public function get_categories() {
|
||
return [ 'thinkai' ];
|
||
}
|
||
|
||
/**
|
||
* Register button widget controls.
|
||
* Adds different input fields to allow the user to change and customize the widget settings.
|
||
*
|
||
* @since 1.0.0
|
||
* @access protected
|
||
*/
|
||
protected function register_controls() {
|
||
$this->start_controls_section(
|
||
'faqs',
|
||
[
|
||
'label' => esc_html__( 'Thinkai Faqs', 'thinkai' ),
|
||
]
|
||
);
|
||
|
||
$this->add_control(
|
||
'layout_control',
|
||
[
|
||
'label' => esc_html__( 'Layout Style', 'thinkai' ),
|
||
'label_block' => true,
|
||
'type' => Controls_Manager::SELECT,
|
||
'default' => '1',
|
||
'options' => array(
|
||
'1' => esc_html__( 'Style One ', 'thinkai'),
|
||
'2' => esc_html__( 'Style Two ', 'thinkai'),
|
||
'3' => esc_html__( 'Style Three ', 'thinkai'),
|
||
'4' => esc_html__( 'Style Four ', 'thinkai'),
|
||
'5' => esc_html__( 'Style Five ', 'thinkai'),
|
||
),
|
||
]
|
||
);
|
||
|
||
//BG Image
|
||
$this->add_control(
|
||
'bg_img',
|
||
[
|
||
'label' => __( 'BG Image', 'thinkai' ),
|
||
'type' => Controls_Manager::MEDIA,
|
||
'default' => ['url' => Utils::get_placeholder_image_src(),],
|
||
'condition' => [
|
||
'layout_control' => ['1','2']
|
||
]
|
||
]
|
||
);
|
||
//BG Shadow Image
|
||
$this->add_control(
|
||
'bg_shadow_img',
|
||
[
|
||
'label' => __( 'BG Shadow Image', 'thinkai' ),
|
||
'type' => Controls_Manager::MEDIA,
|
||
'default' => ['url' => Utils::get_placeholder_image_src(),],
|
||
'condition' => [
|
||
'layout_control' => '2'
|
||
]
|
||
]
|
||
);
|
||
|
||
//Switcher
|
||
$this->add_control(
|
||
'show_title_area',
|
||
[
|
||
'label' => esc_html__( 'Enable Title Section', 'thinkai' ),
|
||
'type' => Controls_Manager::SWITCHER,
|
||
'label_on' => esc_html__( 'On', 'thinkai' ),
|
||
'label_off' => esc_html__( 'Off', 'thinkai' ),
|
||
'return_value' => 'yes',
|
||
'default' => 'no',
|
||
'condition' => [
|
||
'layout_control' => ['1','2']
|
||
]
|
||
]
|
||
);
|
||
//Sub Title
|
||
$this->add_control(
|
||
'subtitle',
|
||
[
|
||
'label' => __( 'Sub Title', 'thinkai' ),
|
||
'label_block' => true,
|
||
'type' => Controls_Manager::TEXT,
|
||
'dynamic' => [
|
||
'active' => true,
|
||
],
|
||
'default' => esc_html__( '[ FAQ’S ],', 'thinkai' ),
|
||
'condition' => [
|
||
'layout_control' => ['1','2'],
|
||
'show_title_area' => 'yes'
|
||
]
|
||
]
|
||
);
|
||
//Title
|
||
$this->add_control(
|
||
'title',
|
||
[
|
||
'label' => __( 'Title', 'thinkai' ),
|
||
'label_block' => true,
|
||
'type' => Controls_Manager::TEXTAREA,
|
||
'dynamic' => [
|
||
'active' => true,
|
||
],
|
||
'placeholder' => __( 'Enter your Title', 'thinkai' ),
|
||
'condition' => [
|
||
'layout_control' => ['1','2'],
|
||
'show_title_area' => 'yes'
|
||
]
|
||
]
|
||
);
|
||
|
||
//Faqs Repeater
|
||
$repeater = new Repeater();
|
||
$repeater->add_control(
|
||
'faqs_title',
|
||
[
|
||
'label' => __( 'Title', 'thinkai' ),
|
||
'label_block' => true,
|
||
'type' => Controls_Manager::TEXTAREA,
|
||
'dynamic' => [
|
||
'active' => true,
|
||
],
|
||
'placeholder' => __( 'Enter your Title', 'thinkai' ),
|
||
]
|
||
);
|
||
$repeater->add_control(
|
||
'faqs_text',
|
||
[
|
||
'label' => __( 'Description', 'thinkai' ),
|
||
'label_block' => true,
|
||
'type' => Controls_Manager::TEXTAREA,
|
||
'dynamic' => [
|
||
'active' => true,
|
||
],
|
||
'placeholder' => __( 'Enter your Description', 'thinkai' ),
|
||
]
|
||
);
|
||
$this->add_control(
|
||
'faq',
|
||
[
|
||
'label' => __('Add faq Item', 'thinkai'),
|
||
'type' => Controls_Manager::REPEATER,
|
||
'fields' => $repeater->get_controls(),
|
||
'title_field' => '{{{ faqs_title }}}',
|
||
'condition' => [
|
||
'layout_control' => ['1','2','3','4','5']
|
||
]
|
||
]
|
||
);
|
||
$this->end_controls_section();
|
||
|
||
}
|
||
|
||
/**
|
||
* Render button widget output on the frontend.
|
||
* Written in PHP and used to generate the final HTML.
|
||
*
|
||
* @since 1.0.0
|
||
* @access protected
|
||
*/
|
||
protected function render() {
|
||
$settings = $this->get_settings_for_display();
|
||
$allowed_tags = wp_kses_allowed_html('post');
|
||
?>
|
||
|
||
<?php if($settings['layout_control'] == '5') :?>
|
||
|
||
<div class="universal-image-generator p-0 m-0">
|
||
<ul class="accordion-box-style2 p-0 m-0">
|
||
<?php
|
||
foreach($settings['faq'] as $key => $item):
|
||
?>
|
||
<!--Start single accordion box-->
|
||
<li class="accordion accordion-block acc-accordion">
|
||
<div class="accord-btn acc-accord-btn <?php if($key == 0) echo 'active'; ?>">
|
||
<h4><?php echo wp_kses($item['faqs_title'], true);?></h4>
|
||
<div class="icon-box">
|
||
<span class="icon-right-arrow"></span>
|
||
</div>
|
||
</div>
|
||
<div class="accord-content acc-accord-content <?php if($key == 0) echo 'collapsed'; ?>">
|
||
<p>
|
||
<?php echo wp_kses($item['faqs_text'], true);?>
|
||
</p>
|
||
</div>
|
||
</li>
|
||
<!--End single accordion box-->
|
||
<?php endforeach; ?>
|
||
</ul>
|
||
</div>
|
||
|
||
<?php elseif($settings['layout_control'] == '4') :?>
|
||
|
||
<!--Start Faq Page One-->
|
||
<section class="faq-page-one p-0 m-0">
|
||
<div class="faq-style1__content">
|
||
<div class="faq-content-box">
|
||
<ul class="accordion-box-style1 style2">
|
||
<?php
|
||
foreach($settings['faq'] as $key => $item):
|
||
?>
|
||
<!--Start single accordion box-->
|
||
<li class="accordion accordion-block acc-accordion">
|
||
<div class="accord-btn acc-accord-btn">
|
||
<h4>
|
||
<?php echo wp_kses($item['faqs_title'], true);?>
|
||
</h4>
|
||
</div>
|
||
<div class="accord-content acc-accord-content">
|
||
<p>
|
||
<?php echo wp_kses($item['faqs_text'], true);?>
|
||
</p>
|
||
</div>
|
||
</li>
|
||
<!--End single accordion box-->
|
||
<?php endforeach; ?>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
<!--End Faq Page One-->
|
||
|
||
<?php elseif($settings['layout_control'] == '3') :?>
|
||
|
||
<!--Start Faq Page One-->
|
||
<section class="faq-page-one p-0 m-0">
|
||
<div class="faq-style1__content">
|
||
<div class="faq-content-box">
|
||
<ul class="accordion-box-style1">
|
||
<?php
|
||
foreach($settings['faq'] as $key => $item):
|
||
?>
|
||
<!--Start single accordion box-->
|
||
<li class="accordion accordion-block acc-accordion">
|
||
<div class="accord-btn acc-accord-btn">
|
||
<h4>
|
||
<?php echo wp_kses($item['faqs_title'], true);?>
|
||
</h4>
|
||
</div>
|
||
<div class="accord-content acc-accord-content">
|
||
<p>
|
||
<?php echo wp_kses($item['faqs_text'], true);?>
|
||
</p>
|
||
</div>
|
||
</li>
|
||
<!--End single accordion box-->
|
||
<?php endforeach; ?>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
<!--End Faq Page One-->
|
||
|
||
<?php elseif($settings['layout_control'] == '2') :?>
|
||
|
||
<!--Start Faq Style1-->
|
||
<section class="faq-style1 faq-style1--style2">
|
||
<?php if($settings['bg_img']){ ?>
|
||
<div class="faq-style1__bg float-bob-x"
|
||
style="background-image: url(<?php echo esc_url(wp_get_attachment_url($settings['bg_img']['id'])); ?>);">
|
||
</div>
|
||
<?php } ?>
|
||
<?php if($settings['bg_shadow_img']){ ?>
|
||
<div class="faq-style1--style2__shadow wow slideInRight animated" data-wow-delay="300ms" data-wow-duration="1500ms">
|
||
<img class="zoominout" src="<?php echo esc_url(wp_get_attachment_url($settings['bg_shadow_img']['id'])); ?>" alt="<?php bloginfo( 'name' ); ?>">
|
||
</div>
|
||
<?php } ?>
|
||
|
||
<div class="container">
|
||
<div class="faq-style1__content">
|
||
|
||
<div class="faq-content-box">
|
||
<?php if($settings['show_title_area'] == 'yes'){ ?>
|
||
<div class="sec-title sec-title-animation animation-style2">
|
||
<?php if($settings['subtitle']){ ?>
|
||
<div class="sub-title">
|
||
<h4><?php echo wp_kses($settings['subtitle'], true);?></h4>
|
||
</div>
|
||
<?php } ?>
|
||
<?php if($settings['title']){ ?><h2 class="title-animation"><?php echo wp_kses($settings['title'], true);?></h2><?php } ?>
|
||
</div>
|
||
<?php } ?>
|
||
<ul class="accordion-box-style1 accordion-box-style1--instyle2">
|
||
<?php
|
||
foreach($settings['faq'] as $key => $item):
|
||
?>
|
||
<!--Start single accordion box-->
|
||
<li class="accordion accordion-block acc-accordion wow fadeInRight animated" data-wow-delay="300ms" data-wow-duration="1500ms">
|
||
<div class="accord-btn acc-accord-btn <?php if($key == 0 ) echo 'active'; ?>">
|
||
<h4>
|
||
<?php echo wp_kses($item['faqs_title'], true);?>
|
||
</h4>
|
||
</div>
|
||
<div class="accord-content acc-accord-content <?php if($key == 0 ) echo 'collapsed'; ?>">
|
||
<p>
|
||
<?php echo wp_kses($item['faqs_text'], true);?>
|
||
</p>
|
||
</div>
|
||
</li>
|
||
<!--End single accordion box-->
|
||
<?php endforeach; ?>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
<!--End Faq Style1-->
|
||
|
||
<?php else: ?>
|
||
|
||
<!--Start Faq Style1-->
|
||
<section class="faq-style1">
|
||
<?php if($settings['bg_img']){ ?>
|
||
<div class="faq-style1__bg float-bob-x"
|
||
style="background-image: url(<?php echo esc_url(wp_get_attachment_url($settings['bg_img']['id'])); ?>);">
|
||
</div>
|
||
<?php } ?>
|
||
<div class="container">
|
||
<div class="faq-style1__content">
|
||
|
||
<div class="faq-content-box">
|
||
<?php if($settings['show_title_area'] == 'yes'){ ?>
|
||
<div class="sec-title sec-title-animation animation-style2">
|
||
<?php if($settings['subtitle']){ ?>
|
||
<div class="sub-title">
|
||
<h4><?php echo wp_kses($settings['subtitle'], true);?></h4>
|
||
</div>
|
||
<?php } ?>
|
||
<?php if($settings['title']){ ?><h2 class="title-animation"><?php echo wp_kses($settings['title'], true);?></h2><?php } ?>
|
||
</div>
|
||
<?php } ?>
|
||
<ul class="accordion-box-style1">
|
||
<?php
|
||
foreach($settings['faq'] as $key => $item):
|
||
?>
|
||
<!--Start single accordion box-->
|
||
<li class="accordion accordion-block acc-accordion">
|
||
<div class="accord-btn acc-accord-btn <?php if($key == 0 ) echo 'active'; ?>">
|
||
<h4>
|
||
<?php echo wp_kses($item['faqs_title'], true);?>
|
||
</h4>
|
||
</div>
|
||
<div class="accord-content acc-accord-content <?php if($key == 0 ) echo 'collapsed'; ?>">
|
||
<p>
|
||
<?php echo wp_kses($item['faqs_text'], true);?>
|
||
</p>
|
||
</div>
|
||
</li>
|
||
<!--End single accordion box-->
|
||
<?php endforeach; ?>
|
||
</ul>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
</section>
|
||
<!--End Faq Style1-->
|
||
|
||
<?php endif; ?>
|
||
|
||
<?php
|
||
}
|
||
}
|