navasena/wp-content/plugins/thinkai-plugin/elementor/video_tabs.php

296 lines
9.1 KiB
PHP
Raw Normal View History

2024-07-31 13:12:38 +07:00
<?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 Video_Tabs 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_video_tabs';
}
/**
* 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 Video Tabs', '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(
'video_tabs',
[
'label' => esc_html__( 'Thinkai Video Tabs', 'thinkai' ),
]
);
//BG Image
$this->add_control(
'bg_image',
[
'label' => __( 'BG Image Url', 'thinkai' ),
'type' => Controls_Manager::MEDIA,
'default' => ['url' => Utils::get_placeholder_image_src(),],
]
);
//Video Repeater
$repeater = new Repeater();
$repeater->add_control(
'tab_btn_title',
[
'label' => __( 'Tab Button Title', 'thinkai' ),
'label_block' => true,
'type' => Controls_Manager::TEXT,
'dynamic' => [
'active' => true,
],
'placeholder' => __( 'Enter your Tab BTN Title', 'thinkai' ),
]
);
//title
$repeater->add_control(
'title',
[
'label' => __( 'Title', 'thinkai' ),
'label_block' => true,
'type' => Controls_Manager::TEXTAREA,
'dynamic' => [
'active' => true,
],
'placeholder' => __( 'Enter your Title', 'thinkai' ),
]
);
//Video Link Option
$repeater->add_control(
'video_option',
[
'label' => __( 'Select Video Type', 'thinkai' ),
'label_block' => true,
'type' => Controls_Manager::SELECT,
'default' => 'src_url',
'options' => array(
'src_url' => esc_html__( 'Source URL', 'thinkai' ),
'src_media' => esc_html__( 'Source Media', 'thinkai' ),
),
]
);
$repeater->add_control(
'video_link',
[
'label' => __( 'Video Source Url', 'thinkai' ),
'type' => Controls_Manager::URL,
'label_block' => true,
'placeholder' => __( 'https://your-link.com', 'thinkai' ),
'show_external' => true,
'default' => [
'url' => '',
],
'condition' => [
'video_option' => 'src_url'
],
]
);
$repeater->add_control(
'video_source_image',
[
'label' => __( 'Video Source Media', 'thinkai' ),
'type' => Controls_Manager::MEDIA,
'media_types' => ['video'],
'condition' => [
'video_option' => 'src_media'
],
]
);
//title
$repeater->add_control(
'video_caption',
[
'label' => __( 'Video Caption', 'thinkai' ),
'label_block' => true,
'type' => Controls_Manager::TEXT,
'dynamic' => [
'active' => true,
],
'placeholder' => __( 'Enter your Video Caption', 'thinkai' ),
]
);
$this->add_control(
'tabs',
[
'label' => __('Add Video Tab Item', 'thinkai'),
'type' => Controls_Manager::REPEATER,
'fields' => $repeater->get_controls(),
'title_field' => '{{{ tab_btn_title }}}',
'default' => [
[
'tab_btn_title' => esc_html__( 'Frame-by-Frame', 'thinkai' ),
'title' => esc_html__( 'We can help businesses reduce customer <br> service costs.', 'thinkai' ),
'src_url' => esc_html__( 'https://www.youtube.com/watch?v=oV74Najm6Nc', 'thinkai' ),
'video_caption' => esc_html__( 'Watch Demo', 'thinkai' ),
],
[
'tab_btn_title' => esc_html__( 'Backward', 'thinkai' ),
'title' => esc_html__( 'Replay, Redefine, Repeat<br> with ThinkAi video<br> Repeating.', 'thinkai' ),
'src_url' => esc_html__( 'https://www.youtube.com/watch?v=oV74Najm6Nc', 'thinkai' ),
'video_caption' => esc_html__( 'Watch Demo', 'thinkai' ),
],
[
'tab_btn_title' => esc_html__( 'Voice Over', 'thinkai' ),
'title' => esc_html__( 'Replay, Redefine, Repeat<br> with ThinkAi video<br> Repeating.', 'thinkai' ),
'src_url' => esc_html__( 'https://www.youtube.com/watch?v=oV74Najm6Nc', 'thinkai' ),
'video_caption' => esc_html__( 'Watch Demo', 'thinkai' ),
],
[
'tab_btn_title' => esc_html__( 'Screen Record', 'thinkai' ),
'title' => esc_html__( 'Replay, Redefine, Repeat<br> with ThinkAi video<br> Repeating.', 'thinkai' ),
'src_url' => esc_html__( 'https://www.youtube.com/watch?v=oV74Najm6Nc', 'thinkai' ),
'video_caption' => esc_html__( 'Watch Demo', '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');
?>
<!--Start Features Style5-->
<section class="features-style5">
<?php if($settings['bg_image']){ ?>
<div class="features-style5__bg" data-jarallax data-speed="0.1" data-imgPosition="0% 0%"
style="background-image: url(<?php echo esc_url(wp_get_attachment_url($settings['bg_image']['id'])); ?>);"></div>
<?php } ?>
<div class="container">
<div class="features-style5__inner tab-box-style1">
<div class="tabs-content-box">
<?php
foreach($settings['tabs'] as $key => $items){
$video_option = $items[ 'video_option' ];
if( $video_option == 'src_url' ){
$video = $items[ 'video_link' ][ 'url' ];
}elseif( $video_option == 'src_media' ){
$video = $items[ 'video_source_image' ]['url'];
}else{
$video = esc_html__( 'There is no Video', 'thinkai' );
}
?>
<!--Tab-->
<div class="tab-content-box-item <?php if($key == 0) echo 'tab-content-box-item-active'; ?>" id="frame-by-frame<?php echo esc_attr($key); ?>">
<div class="features-style5__content-tab-item">
<div class="video-holder-box-style5 text-center">
<h2><?php echo wp_kses($items['title'], true); ?></h2>
<?php if($video){ ?>
<div class="icon wow zoomIn animated" data-wow-delay="300ms"
data-wow-duration="1500ms">
<a class="video-popup" title="Video Gallery"
href="<?php echo esc_url( $video );?>">
<span class="icon-play-button-arrowhead"></span>
</a>
</div>
<?php } ?>
<h5><?php echo wp_kses($items['video_caption'], true); ?></h5>
</div>
</div>
</div>
<?php } ?>
</div>
<div class="features-style5-tab__button">
<ul class="tabs-button-box clearfix">
<?php
foreach($settings['tabs'] as $key => $items){
?>
<li data-tab="#frame-by-frame<?php echo esc_attr($key); ?>" class="tab-btn-item <?php if($key == 0) echo 'active-btn-item'; ?>">
<span><?php echo wp_kses($items['tab_btn_title'], true); ?></span>
</li>
<?php } ?>
</ul>
</div>
</div>
</div>
</section>
<!--End Features Style5-->
<?php
}
}