393 lines
12 KiB
PHP
393 lines
12 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 Funfacts 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_funfacts';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 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 Funfacts', 'thinkai' );
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Get widget icon.
|
||
|
* Retrieve button widget icon.
|
||
|
*
|
||
|
* @since 1.0.0
|
||
|
* @access public
|
||
|
* @return string Widget icon.
|
||
|
*/
|
||
|
public function get_icon() {
|
||
|
return 'eicon-gallery-grid';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 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(
|
||
|
'funfacts',
|
||
|
[
|
||
|
'label' => esc_html__( 'Thinkai Funfacts', 'thinkai' ),
|
||
|
]
|
||
|
);
|
||
|
|
||
|
//Layout
|
||
|
$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'),
|
||
|
),
|
||
|
]
|
||
|
);
|
||
|
|
||
|
//Banner Carousel Repeater
|
||
|
$repeater = new Repeater();
|
||
|
$repeater->add_control(
|
||
|
'counter_value',
|
||
|
[
|
||
|
'label' => __( 'Counter Value', 'thinkai' ),
|
||
|
'type' => Controls_Manager::TEXT,
|
||
|
'label_block' => true,
|
||
|
'dynamic' => [
|
||
|
'active' => true,
|
||
|
],
|
||
|
'placeholder' => __( 'Enter your Counter Value', 'thinkai' ),
|
||
|
]
|
||
|
);
|
||
|
$repeater->add_control(
|
||
|
'currency_unit',
|
||
|
[
|
||
|
'label' => __( 'Currency Unit', 'thinkai' ),
|
||
|
'type' => Controls_Manager::TEXT,
|
||
|
'label_block' => true,
|
||
|
'dynamic' => [
|
||
|
'active' => true,
|
||
|
],
|
||
|
'placeholder' => __( 'Enter your Counter Value', 'thinkai' ),
|
||
|
]
|
||
|
);
|
||
|
//Text
|
||
|
$repeater->add_control(
|
||
|
'text',
|
||
|
[
|
||
|
'label' => __( 'Description', 'thinkai' ),
|
||
|
'label_block' => true,
|
||
|
'type' => Controls_Manager::TEXTAREA,
|
||
|
'dynamic' => [
|
||
|
'active' => true,
|
||
|
],
|
||
|
'placeholder' => __( 'Enter your Description', 'thinkai' ),
|
||
|
]
|
||
|
);
|
||
|
//Title
|
||
|
$repeater->add_control(
|
||
|
'title',
|
||
|
[
|
||
|
'label' => __( 'Title', 'thinkai' ),
|
||
|
'label_block' => true,
|
||
|
'type' => Controls_Manager::TEXT,
|
||
|
'dynamic' => [
|
||
|
'active' => true,
|
||
|
],
|
||
|
'placeholder' => __( 'Enter your Title', 'thinkai' ),
|
||
|
]
|
||
|
);
|
||
|
$this->add_control(
|
||
|
'funfact',
|
||
|
[
|
||
|
'label' => __('Add Funfact Item', 'thinkai'),
|
||
|
'type' => Controls_Manager::REPEATER,
|
||
|
'fields' => $repeater->get_controls(),
|
||
|
'condition' => [
|
||
|
'layout_control' => '1'
|
||
|
],
|
||
|
'title_field' => '{{{ title }}}',
|
||
|
'default' => [
|
||
|
[
|
||
|
'counter_value' => esc_html__( '4.8', 'thinkai' ),
|
||
|
'currency_unit' => esc_html__( 'Million', 'thinkai' ),
|
||
|
'text' => esc_html__( 'Worldwide Users of<br> ThinkAi', 'thinkai' ),
|
||
|
'title' => esc_html__( 'Fun Numbers', 'thinkai' ),
|
||
|
],
|
||
|
[
|
||
|
'counter_value' => esc_html__( '174', 'thinkai' ),
|
||
|
'currency_unit' => esc_html__( 'User Territory', 'thinkai' ),
|
||
|
'text' => esc_html__( 'Worldwide Users of<br> ThinkAi', 'thinkai' ),
|
||
|
'title' => esc_html__( 'Fun Numbers', 'thinkai' ),
|
||
|
],
|
||
|
[
|
||
|
'counter_value' => esc_html__( '236', 'thinkai' ),
|
||
|
'currency_unit' => esc_html__( 'Million', 'thinkai' ),
|
||
|
'text' => esc_html__( 'Images Generated in<br> Last Year', 'thinkai' ),
|
||
|
'title' => esc_html__( 'Fun Numbers', 'thinkai' ),
|
||
|
],
|
||
|
],
|
||
|
]
|
||
|
);
|
||
|
|
||
|
|
||
|
|
||
|
//Banner Carousel Repeater
|
||
|
$repeater = new Repeater();
|
||
|
//Title
|
||
|
$repeater->add_control(
|
||
|
'title',
|
||
|
[
|
||
|
'label' => __( 'Title', 'thinkai' ),
|
||
|
'label_block' => true,
|
||
|
'type' => Controls_Manager::TEXT,
|
||
|
'dynamic' => [
|
||
|
'active' => true,
|
||
|
],
|
||
|
'placeholder' => __( 'Enter your Title', 'thinkai' ),
|
||
|
]
|
||
|
);
|
||
|
//Text
|
||
|
$repeater->add_control(
|
||
|
'text',
|
||
|
[
|
||
|
'label' => __( 'Description', 'thinkai' ),
|
||
|
'label_block' => true,
|
||
|
'type' => Controls_Manager::TEXTAREA,
|
||
|
'dynamic' => [
|
||
|
'active' => true,
|
||
|
],
|
||
|
'placeholder' => __( 'Enter your Description', 'thinkai' ),
|
||
|
]
|
||
|
);
|
||
|
$repeater->add_control(
|
||
|
'counter_value',
|
||
|
[
|
||
|
'label' => __( 'Counter Value', 'thinkai' ),
|
||
|
'type' => Controls_Manager::TEXT,
|
||
|
'label_block' => true,
|
||
|
'dynamic' => [
|
||
|
'active' => true,
|
||
|
],
|
||
|
'placeholder' => __( 'Enter your Counter Value', 'thinkai' ),
|
||
|
]
|
||
|
);
|
||
|
$repeater->add_control(
|
||
|
'currency_unit',
|
||
|
[
|
||
|
'label' => __( 'Currency Unit', 'thinkai' ),
|
||
|
'type' => Controls_Manager::TEXT,
|
||
|
'label_block' => true,
|
||
|
'dynamic' => [
|
||
|
'active' => true,
|
||
|
],
|
||
|
'placeholder' => __( 'Enter your Counter Value', 'thinkai' ),
|
||
|
]
|
||
|
);
|
||
|
//Select Box
|
||
|
$repeater->add_control(
|
||
|
'style_two',
|
||
|
[
|
||
|
'label' => esc_html__( 'Choose Style', 'thinkai' ),
|
||
|
'label_block' => true,
|
||
|
'type' => Controls_Manager::SELECT,
|
||
|
'default' => 'two',
|
||
|
'options' => array(
|
||
|
'one' => esc_html__( 'Sec Style ', 'thinkai'),
|
||
|
'two' => esc_html__( 'Percent Style ', 'thinkai'),
|
||
|
),
|
||
|
]
|
||
|
);
|
||
|
$this->add_control(
|
||
|
'funfact_v2',
|
||
|
[
|
||
|
'label' => __('Add Funfact Item', 'thinkai'),
|
||
|
'type' => Controls_Manager::REPEATER,
|
||
|
'fields' => $repeater->get_controls(),
|
||
|
'condition' => [
|
||
|
'layout_control' => '2'
|
||
|
],
|
||
|
'title_field' => '{{{ title }}}',
|
||
|
'default' => [
|
||
|
[
|
||
|
'title' => esc_html__( 'Savings Potential', 'thinkai' ),
|
||
|
'text' => esc_html__( 'We can help businesses reduce customer <br> service costs.', 'thinkai' ),
|
||
|
'counter_value' => esc_html__( '25', 'thinkai' ),
|
||
|
'currency_unit' => esc_html__( '%', 'thinkai' ),
|
||
|
],
|
||
|
[
|
||
|
'title' => esc_html__( 'Quick Responses', 'thinkai' ),
|
||
|
'text' => esc_html__( 'ThinkAi Provide immediate responses to <br> customer queries.', 'thinkai' ),
|
||
|
'counter_value' => esc_html__( '0.4', 'thinkai' ),
|
||
|
'currency_unit' => esc_html__( 'Sec', 'thinkai' ),
|
||
|
],
|
||
|
[
|
||
|
'title' => esc_html__( 'Business Adoption', 'thinkai' ),
|
||
|
'text' => esc_html__( 'Businesses are projected to use ThinkAi <br> in some capacity.', 'thinkai' ),
|
||
|
'counter_value' => esc_html__( '80', 'thinkai' ),
|
||
|
'currency_unit' => esc_html__( '%', 'thinkai' ),
|
||
|
],
|
||
|
],
|
||
|
]
|
||
|
);
|
||
|
$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'] == '2') :?>
|
||
|
|
||
|
<!--Start Fact Counter Style2-->
|
||
|
<section class="fact-counter-style2 p-0 m-0">
|
||
|
<div class="container">
|
||
|
<ul class="row">
|
||
|
<?php
|
||
|
foreach($settings['funfact_v2'] as $key => $items):
|
||
|
?>
|
||
|
<!--Start Fact Counter Style2 Single-->
|
||
|
<li class="col-xl-4 col-lg-4 wow fadeInUp" data-wow-delay=".2s">
|
||
|
<div class="fact-counter-style2__single text-center">
|
||
|
<div class="round-box"></div>
|
||
|
<h3><?php echo wp_kses($items['title'], true);?></h3>
|
||
|
<p><?php echo wp_kses($items['text'], true);?></p>
|
||
|
<div class="counter-box">
|
||
|
<h2><span class="odometer" data-count="<?php echo esc_attr($items['counter_value']);?>"></span>
|
||
|
<span class="<?php if($items['style_two'] == 'two') echo 'percent'; else echo 'sec'; ?>"><?php echo wp_kses($items['currency_unit'], true);?></span></h2>
|
||
|
</div>
|
||
|
</div>
|
||
|
</li>
|
||
|
<!--End Fact Counter Style2 Single-->
|
||
|
<?php endforeach; ?>
|
||
|
</ul>
|
||
|
</div>
|
||
|
</section>
|
||
|
<!--End Fact Counter Style2-->
|
||
|
|
||
|
<?php else: ?>
|
||
|
|
||
|
<!--Start Fact Counter Style1-->
|
||
|
<section class="fact-counter-style1">
|
||
|
<div class="container">
|
||
|
<div class="row">
|
||
|
<div class="col-xl-12">
|
||
|
<div class="fact-counter-style1__content">
|
||
|
<ul class="clearfix">
|
||
|
<?php
|
||
|
$count = 1;
|
||
|
foreach($settings['funfact'] as $key => $items):
|
||
|
if($count % 2) {
|
||
|
?>
|
||
|
<!--Start Single Fact Counter-->
|
||
|
<li class="single-fact-counter wow fadeInRight" data-wow-delay="100ms"
|
||
|
data-wow-duration="2500ms">
|
||
|
<div class="counting">
|
||
|
<h2 class="odometer te-count" data-count="<?php echo esc_attr($items['counter_value']);?>"><?php echo esc_attr($items['counter_value']);?></h2>
|
||
|
<p class="te-currency"><?php echo wp_kses($items['currency_unit'], true);?></p>
|
||
|
</div>
|
||
|
<div class="text">
|
||
|
<p class="te-text"><?php echo wp_kses($items['text'], true);?></p>
|
||
|
<div class="dot"></div>
|
||
|
</div>
|
||
|
<div class="big-title te-title" data-hover="Fun Numbers">
|
||
|
<?php echo wp_kses($items['title'], true);?>
|
||
|
</div>
|
||
|
</li>
|
||
|
<!--End Single Fact Counter-->
|
||
|
<?php } else { ?>
|
||
|
<!--Start Single Fact Counter-->
|
||
|
<li class="single-fact-counter wow fadeInLeft" data-wow-delay="200ms"
|
||
|
data-wow-duration="2500ms">
|
||
|
<div class="text">
|
||
|
<p class="te-text"><?php echo wp_kses($items['text'], true);?></p>
|
||
|
<div class="dot"></div>
|
||
|
</div>
|
||
|
<div class="counting">
|
||
|
<h2 class="odometer te-count" data-count="<?php echo esc_attr($items['counter_value']);?>"><?php echo esc_attr($items['counter_value']);?></h2>
|
||
|
<p class="te-currency"><?php echo wp_kses($items['currency_unit'], true);?></p>
|
||
|
</div>
|
||
|
<div class="big-title te-title"><?php echo wp_kses($items['title'], true);?></div>
|
||
|
</li>
|
||
|
<!--End Single Fact Counter-->
|
||
|
<?php } $count++; endforeach; ?>
|
||
|
</ul>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</section>
|
||
|
<!--End Fact Counter Style1-->
|
||
|
|
||
|
<?php endif; ?>
|
||
|
|
||
|
<?php
|
||
|
}
|
||
|
}
|