File: //home/parhudrw/www/wp-content/plugins/around-elementor/modules/carousel/widgets/base.php
<?php
namespace AroundElementor\Modules\Carousel\Widgets;
use Elementor\Controls_Manager;
use Elementor\Repeater;
use AroundElementor\Base\Base_Widget;
use Elementor\Core\Files\Assets\Files_Upload_Handler;
use Elementor\Group_Control_Image_Size;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
abstract class Base extends Base_Widget {
private $slide_prints_count = 0;
public function get_script_depends() {
return [ 'imagesloaded', 'jquery', 'tiny-slider' ];
}
abstract protected function add_repeater_controls( Repeater $repeater );
abstract protected function get_repeater_defaults();
abstract protected function print_slide( array $slide, array $settings, $element_key );
protected function register_controls() {
$this->start_controls_section(
'section_slides',
[
'label' => esc_html__( 'Slides', 'around-elementor' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$repeater = new Repeater();
$this->add_repeater_controls( $repeater );
$this->add_control(
'slides',
[
'label' => esc_html__( 'Slides', 'around-elementor' ),
'type' => Controls_Manager::REPEATER,
'fields' => $repeater->get_controls(),
'default' => $this->get_repeater_defaults(),
'separator' => 'after',
]
);
$this->add_responsive_control(
'slides_per_view',
[
'type' => Controls_Manager::SELECT,
'label' => esc_html__( 'Slides Per View', 'around-elementor' ),
'options' => [
'' => __( 'Default', 'around-elementor' ),
'1' => __( '1', 'around-elementor' ),
'2' => __( '2', 'around-elementor' ),
'3' => __( '3', 'around-elementor' ),
'4' => __( '4', 'around-elementor' ),
'5' => __( '5', 'around-elementor' ),
'6' => __( '6', 'around-elementor' ),
],
'frontend_available' => true,
]
);
$this->end_controls_section();
$this->start_controls_section(
'section_additional_options',
[
'label' => esc_html__( 'Additional Options', 'around-elementor' ),
]
);
$this->add_control(
'controls',
[
'type' => Controls_Manager::SWITCHER,
'label' => esc_html__( 'Arrows', 'around-elementor' ),
'default' => 'yes',
'label_off' => esc_html__( 'Hide', 'around-elementor' ),
'label_on' => esc_html__( 'Show', 'around-elementor' ),
'prefix_class' => 'elementor-arrows-',
'render_type' => 'template',
'frontend_available' => true,
]
);
$this->add_responsive_control(
'controls_position',
[
'type' => Controls_Manager::SELECT,
'label' => esc_html__( 'Controls Position', 'around-elementor' ),
'options' => [
'cs-controls-center' => esc_html__( 'Center', 'around-elementor' ),
'cs-controls-left' => esc_html__( 'Left', 'around-elementor' ),
'cs-controls-right' => esc_html__( 'Right', 'around-elementor' ),
'cs-controls-inside' => esc_html__( 'Inside', 'around-elementor' ),
'cs-controls-outside' => esc_html__( 'Outside', 'around-elementor' ),
'cs-controls-onhover' => esc_html__( 'On Hover', 'around-elementor' ),
],
'default' => 'cs-controls-right',
'condition' => [
'controls' => 'yes',
],
'frontend_available' => true,
]
);
$this->add_control(
'nav',
[
'type' => Controls_Manager::SWITCHER,
'label' => esc_html__( 'Dots', 'around-elementor' ),
'default' => 'false',
'label_off' => esc_html__( 'Hide', 'around-elementor' ),
'label_on' => esc_html__( 'Show', 'around-elementor' ),
'prefix_class' => 'elementor-pagination-',
'render_type' => 'template',
'frontend_available' => true,
]
);
$this->add_control(
'nav_position',
[
'type' => Controls_Manager::SWITCHER,
'label' => esc_html__( 'Dots Position', 'around-elementor' ),
'default' => 'false',
'label_off' => esc_html__( 'Hide', 'around-elementor' ),
'label_on' => esc_html__( 'Show', 'around-elementor' ),
'prefix_class' => 'elementor-pagination-',
'render_type' => 'template',
'frontend_available' => true,
'condition' => [
'nav' => 'yes',
],
]
);
$this->add_control(
'nav_skin',
[
'type' => Controls_Manager::SWITCHER,
'label' => esc_html__( 'Dots Skin', 'around-elementor' ),
'default' => 'false',
'label_off' => esc_html__( 'Hide', 'around-elementor' ),
'label_on' => esc_html__( 'Show', 'around-elementor' ),
'prefix_class' => 'elementor-pagination-',
'render_type' => 'template',
'frontend_available' => true,
'condition' => [
'nav' => 'yes',
],
]
);
$this->add_control(
'loop',
[
'label' => esc_html__( 'Infinite Loop', 'around-elementor' ),
'type' => Controls_Manager::SWITCHER,
'default' => 'yes',
'frontend_available' => true,
]
);
$this->add_control(
'autoplay',
[
'label' => esc_html__( 'Autoplay', 'around-elementor' ),
'type' => Controls_Manager::SWITCHER,
'default' => 'no',
'separator' => 'before',
'frontend_available' => true,
]
);
$this->add_control(
'autoheight',
[
'label' => esc_html__( 'AutoHeight', 'around-elementor' ),
'type' => Controls_Manager::SWITCHER,
'default' => 'no',
'separator' => 'before',
'frontend_available' => true,
]
);
$this->add_control(
'autoplay_speed',
[
'label' => esc_html__( 'Autoplay Speed', 'around-elementor' ),
'type' => Controls_Manager::NUMBER,
'default' => 1500,
'condition' => [
'autoplay' => 'yes',
],
'frontend_available' => true,
]
);
$this->add_control(
'pause_on_hover',
[
'label' => esc_html__( 'Pause on Hover', 'around-elementor' ),
'type' => Controls_Manager::SWITCHER,
'default' => 'yes',
'condition' => [
'autoplay' => 'yes',
],
'frontend_available' => true,
]
);
$this->add_control(
'image_class',
[
'label' => esc_html__( 'Image Class', 'around-elementor' ),
'type' => Controls_Manager::TEXT,
'title' => esc_html__( 'Add your custom class for <img> tag without the dot. e.g: my-class', 'around-elementor' ),
'default' => 'img-fluid',
'label_block' => true,
'description' => esc_html__( 'Additional CSS class that you want to apply to the img tag', 'around-elementor' ),
]
);
$this->add_responsive_control(
'gutter',
[
'label' => esc_html__( 'Gutter Padding', 'around-elementor' ),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 10,
'max' => 100,
],
],
'devices' => [ 'desktop', 'tablet', 'mobile' ],
'desktop_default' => [
'size' => 23,
'unit' => 'px',
],
'tablet_default' => [
'size' => '16',
'unit' => 'px',
],
'mobile_default' => [
'size' => 16,
'unit' => 'px',
],
'size_units' => [ 'px' ],
]
);
$this->end_controls_section();
}
protected function get_slide_image_url( $slide, array $settings ) {
$image_url = Group_Control_Image_Size::get_attachment_image_src( $slide['image']['id'], 'image_size', $settings );
if ( ! $image_url ) {
$image_url = $slide['image']['url'];
}
;
return $image_url;
}
}