File: /home/confeduphaar/public_html/wp-content/plugins/ova-framework/ova-elementor/widgets/ova_slide.php
<?php
namespace ova_framework\Widgets;
use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use Elementor\Core\Schemes\Typography;
use Elementor\Group_Control_Typography;
use Elementor\Core\Schemes\Color;
use Elementor\Utils;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
class ova_slide extends Widget_Base {
public function get_name() {
return 'ova_slide';
}
public function get_title() {
return __( 'Slide', 'ova-framework' );
}
public function get_icon() {
return 'eicon-testimonial';
}
public function get_categories() {
return [ 'ovatheme' ];
}
public function get_script_depends() {
// Carousel
wp_enqueue_style( 'owl-carousel', OVA_PLUGIN_URI.'assets/libs/owl-carousel/assets/owl.carousel.min.css' );
wp_enqueue_script( 'owl-carousel', OVA_PLUGIN_URI.'assets/libs/owl-carousel/owl.carousel.min.js', array('jquery'), false, true );
return [ 'script-elementor' ];
}
protected function register_controls() {
$this->start_controls_section(
'section_content',
[
'label' => __( 'Content', 'ova-framework' ),
]
);
$repeater = new \Elementor\Repeater();
$repeater->add_control(
'image',
[
'label' => ' Image',
'type' => \Elementor\Controls_Manager::MEDIA,
'default' => [
'url' => Utils::get_placeholder_image_src(),
],
]
);
$repeater->add_control(
'title',
[
'label' => 'Title',
'type' => \Elementor\Controls_Manager::TEXT,
]
);
$repeater->add_control(
'link',
[
'label' => __( 'Link', 'ova-framework' ),
'type' => Controls_Manager::TEXT,
'default' => '#',
]
);
$this->add_control(
'tab_item',
[
'label' => 'Items Slide',
'type' => Controls_Manager::REPEATER,
'fields' => $repeater->get_controls(),
'default' => [
[
'title' => __('Departments', 'ova-framework'),
'link' => __('http://ovapt.com/egovt/wp/department/', 'ova-framework'),
],
],
'title_field' => '{{{ title }}}',
]
);
$this->end_controls_section();
/***************** END SECTION CONTENT ******************/
/*****************************************************************
START SECTION ADDITIONAL
******************************************************************/
$this->start_controls_section(
'section_additional_options',
[
'label' => __( 'Additional Options', 'ova-framework' ),
]
);
/*************************** VERSION 1 ***********************/
$this->add_control(
'margin_items',
[
'label' => __( 'Margin Right Items', 'ova-framework' ),
'type' => Controls_Manager::NUMBER,
'default' => 30,
]
);
$this->add_control(
'item_number',
[
'label' => __( 'Item Number', 'ova-framework' ),
'type' => Controls_Manager::NUMBER,
'description' => __( 'Number Item', 'ova-framework' ),
'default' => 3,
]
);
$this->add_control(
'slides_to_scroll',
[
'label' => __( 'Slides to Scroll', 'ova-framework' ),
'type' => Controls_Manager::NUMBER,
'description' => __( 'Set how many slides are scrolled per swipe.', 'ova-framework' ),
'default' => 1,
]
);
$this->add_control(
'pause_on_hover',
[
'label' => __( 'Pause on Hover', 'ova-framework' ),
'type' => Controls_Manager::SWITCHER,
'default' => 'yes',
'options' => [
'yes' => __( 'Yes', 'ova-framework' ),
'no' => __( 'No', 'ova-framework' ),
],
'frontend_available' => true,
]
);
$this->add_control(
'infinite',
[
'label' => __( 'Infinite Loop', 'ova-framework' ),
'type' => Controls_Manager::SWITCHER,
'default' => 'yes',
'options' => [
'yes' => __( 'Yes', 'ova-framework' ),
'no' => __( 'No', 'ova-framework' ),
],
'frontend_available' => true,
]
);
$this->add_control(
'autoplay',
[
'label' => __( 'Autoplay', 'ova-framework' ),
'type' => Controls_Manager::SWITCHER,
'default' => 'yes',
'options' => [
'yes' => __( 'Yes', 'ova-framework' ),
'no' => __( 'No', 'ova-framework' ),
],
'frontend_available' => true,
]
);
$this->add_control(
'autoplay_speed',
[
'label' => __( 'Autoplay Speed', 'ova-framework' ),
'type' => Controls_Manager::NUMBER,
'default' => 3000,
'step' => 500,
'condition' => [
'autoplay' => 'yes',
],
'frontend_available' => true,
]
);
$this->add_control(
'smartspeed',
[
'label' => __( 'Smart Speed', 'ova-framework' ),
'type' => Controls_Manager::NUMBER,
'default' => 500,
]
);
$this->add_control(
'dot_control',
[
'label' => __( 'Show Dots', 'ova-framework' ),
'type' => Controls_Manager::SWITCHER,
'default' => 'yes',
'options' => [
'yes' => __( 'Yes', 'ova-framework' ),
'no' => __( 'No', 'ova-framework' ),
],
'frontend_available' => true,
]
);
$this->end_controls_section();
/**************************** END SECTION ADDITIONAL *********************/
/************* SECTION content testimonial *******************/
$this->start_controls_section(
'section_content_slide',
[
'label' => __( 'Style', 'ova-framework' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'content_testimonial_typography',
'selector' => '{{WRAPPER}} .ova-slide .title_slide a',
]
);
$this->add_control(
'content_color',
[
'label' => __( 'Color', 'ova-framework' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .ova-slide .title_slide a' => 'color : {{VALUE}};',
],
]
);
$this->add_control(
'content_color_hover',
[
'label' => __( 'Color Hover', 'ova-framework' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .ova-slide .title_slide a:hover' => 'color : {{VALUE}};',
],
]
);
$this->add_responsive_control(
'content_padding',
[
'label' => __( 'Padding', 'ova-framework' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', 'em', '%' ],
'selectors' => [
'{{WRAPPER}} .ova-slide .title_slide' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_control(
'content_color_dot',
[
'label' => __( 'Color Dot', 'ova-framework' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .ova-slide .owl-dots .owl-dot.active span' => 'background-color : {{VALUE}};',
],
]
);
$this->end_controls_section();
############### end section content testimonial ###############
}
protected function render() {
$settings = $this->get_settings();
$tab_item = $settings['tab_item'];
$data_options['items'] = $settings['item_number'];
$data_options['slideBy'] = $settings['slides_to_scroll'];
$data_options['margin'] = $settings['margin_items'];
$data_options['autoplayHoverPause'] = $settings['pause_on_hover'] === 'yes' ? true : false;
$data_options['loop'] = $settings['infinite'] === 'yes' ? true : false;
$data_options['autoplay'] = $settings['autoplay'] === 'yes' ? true : false;
$data_options['autoplayTimeout'] = $settings['autoplay_speed'];
$data_options['smartSpeed'] = $settings['smartspeed'];
$data_options['dots'] = $settings['dot_control'] === 'yes' ? true : false;
?>
<div class="ova-slide ">
<div class="slide owl-carousel owl-theme " data-options="<?php echo esc_attr(json_encode($data_options)) ?>">
<?php if(!empty($tab_item)) : foreach ($tab_item as $item) : ?>
<div class="item">
<div class="image_slide">
<?php if( $item['image'] != '' ) { ?>
<a href="<?php echo esc_html($item['link']) ?>" target="_blank"><img src="<?php echo esc_attr($item['image']['url']) ?>" alt=""></a>
<?php } ?>
</div>
<div class="title_slide">
<?php if( $item['title'] != '' ) { ?>
<a href="<?php echo esc_url($item['link']) ?>" target="_blank"><span class="title"><?php echo esc_html($item['title']) ?></span></a>
<?php } ?>
</div>
</div>
<?php endforeach; endif; ?>
</div>
</div>
<?php
}
// end render
}