File "wgl-carousel.php"
Full Path: /home/ubunrgit/public_html/wp-content/plugins/unicoach-core/includes/elementor/widgets/wgl-carousel.php
File size: 16.48 KB
MIME-type: text/x-php
Charset: utf-8
<?php
/*
* This template can be overridden by copying it to yourtheme/unicoach-core/elementor/widgets/wgl-carousel.php.
*/
namespace WglAddons\Widgets;
defined('ABSPATH') || exit; // Abort, if called directly.
use Elementor\{Widget_Base, Controls_Manager, Repeater};
use WglAddons\Unicoach_Global_Variables as Unicoach_Globals;
use WglAddons\Includes\{Wgl_Carousel_Settings, Wgl_Elementor_Helper};
class Wgl_Carousel extends Widget_Base
{
public function get_name() {
return 'wgl-carousel';
}
public function get_title() {
return esc_html__('WGL Carousel', 'unicoach-core');
}
public function get_icon() {
return 'wgl-carousel';
}
public function get_script_depends() {
return ['slick'];
}
public function get_categories() {
return ['wgl-extensions'];
}
protected function register_controls()
{
$self = new REPEATER();
$this->start_controls_section('wgl_carousel_section',
['label' => esc_html__('Carousel Settings' , 'unicoach-core')]
);
$self->add_control(
'content',
[
'label' => esc_html__('Content', 'unicoach-core'),
'type' => Controls_Manager::SELECT2,
'options' => Wgl_Elementor_Helper::get_instance()->get_elementor_templates(),
]
);
$this->add_control(
'content_repeater',
[
'label' => esc_html__('Templates', 'unicoach-core'),
'type' => Controls_Manager::REPEATER,
'description' => esc_html__('Slider content is a template which you can choose from Elementor library. Each template will be a slider content', 'unicoach-core'),
'fields' => $self->get_controls(),
'title_field' => esc_html__('Template:', 'unicoach-core') . ' {{{ content }}}'
]
);
$this->add_control(
'slide_to_show',
[
'label' => esc_html__('Columns Amount', 'unicoach-core'),
'type' => Controls_Manager::SELECT,
'options' => [
'1' => esc_html__('1 / One', 'unicoach-core'),
'2' => esc_html__('2 / Two', 'unicoach-core'),
'3' => esc_html__('3 / Three', 'unicoach-core'),
'4' => esc_html__('4 / Four', 'unicoach-core'),
'5' => esc_html__('5 / Five', 'unicoach-core'),
'6' => esc_html__('6 / Six', 'unicoach-core'),
],
'default' => '1',
]
);
$this->add_control(
'speed',
[
'label' => esc_html__('Animation Speed', 'unicoach-core'),
'type' => Controls_Manager::NUMBER,
'min' => 1,
'default' => '3000',
]
);
$this->add_control(
'autoplay',
[
'label' => esc_html__('Autoplay', 'unicoach-core'),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_html__('On', 'unicoach-core'),
'label_off' => esc_html__('Off', 'unicoach-core'),
'default' => 'yes',
]
);
$this->add_control(
'autoplay_speed',
[
'label' => esc_html__('Autoplay Speed', 'unicoach-core'),
'type' => Controls_Manager::NUMBER,
'condition' => ['autoplay' => 'yes'],
'min' => 1,
'default' => '3000',
]
);
$this->add_control(
'slides_to_scroll',
[
'label' => esc_html__('Slide One Item per time', 'unicoach-core'),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_html__('On', 'unicoach-core'),
'label_off' => esc_html__('Off', 'unicoach-core'),
]
);
$this->add_control(
'infinite',
[
'label' => esc_html__('Infinite loop sliding', 'unicoach-core'),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_html__('On', 'unicoach-core'),
'label_off' => esc_html__('Off', 'unicoach-core'),
]
);
$this->add_control(
'adaptive_height',
[
'label' => esc_html__('Adaptive Height', 'unicoach-core'),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_html__('On', 'unicoach-core'),
'label_off' => esc_html__('Off', 'unicoach-core'),
]
);
$this->add_control(
'fade_animation',
[
'label' => esc_html__('Fade Animation', 'unicoach-core'),
'type' => Controls_Manager::SWITCHER,
'condition' => ['slide_to_show' => '1'],
'label_on' => esc_html__('On', 'unicoach-core'),
'label_off' => esc_html__('Off', 'unicoach-core'),
]
);
$this->end_controls_section();
$this->start_controls_section(
'navigation_section',
['label' => esc_html__('Navigation', 'unicoach-core')]
);
$this->add_control(
'h_pag_controls',
[
'label' => esc_html__('Pagination Controls', 'unicoach-core'),
'type' => Controls_Manager::HEADING,
'separator' => 'after',
]
);
$this->add_control(
'use_pagination',
[
'label' => esc_html__('Add Pagination control', 'unicoach-core'),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_html__('On', 'unicoach-core'),
'label_off' => esc_html__('Off', 'unicoach-core'),
'default' => 'yes'
]
);
$this->add_control(
'pag_type',
[
'label' => esc_html__('Pagination Type', 'unicoach-core'),
'type' => 'wgl-radio-image',
'condition' => ['use_pagination' => 'yes'],
'options' => [
'circle' => [
'title'=> esc_html__('Circle', 'unicoach-core'),
'image' => WGL_ELEMENTOR_ADDONS_URL . 'assets/img/wgl_elementor_addon/icons/pag_circle.png',
],
'circle_border' => [
'title'=> esc_html__('Empty Circle', 'unicoach-core'),
'image' => WGL_ELEMENTOR_ADDONS_URL . 'assets/img/wgl_elementor_addon/icons/pag_circle_border.png',
],
'square' => [
'title'=> esc_html__('Square', 'unicoach-core'),
'image' => WGL_ELEMENTOR_ADDONS_URL . 'assets/img/wgl_elementor_addon/icons/pag_square.png',
],
'square_border' => [
'title'=> esc_html__('Empty Square', 'unicoach-core'),
'image' => WGL_ELEMENTOR_ADDONS_URL . 'assets/img/wgl_elementor_addon/icons/pag_square_border.png',
],
'line' => [
'title'=> esc_html__('Line', 'unicoach-core'),
'image' => WGL_ELEMENTOR_ADDONS_URL . 'assets/img/wgl_elementor_addon/icons/pag_line.png',
],
'line_circle' => [
'title'=> esc_html__('Line - Circle', 'unicoach-core'),
'image' => WGL_ELEMENTOR_ADDONS_URL . 'assets/img/wgl_elementor_addon/icons/pag_circle.png',
],
],
'default' => 'circle',
]
);
$this->add_control(
'pag_align',
[
'label' => esc_html__('Pagination Aligning', 'unicoach-core'),
'type' => Controls_Manager::SLIDER,
'condition' => ['use_pagination' => 'yes'],
'size_units' => ['%'],
'range' => [
'%' => ['min' => 0, 'max' => 100],
],
'default' => ['size' => 50, 'unit' => '%'],
'selectors' => [
'{{WRAPPER}} .slick-dots' => 'margin-left: {{SIZE}}%; transform: translateX(-{{SIZE}}%);',
],
]
);
$this->add_control(
'pag_offset',
[
'label' => esc_html__('Pagination Top Offset', 'unicoach-core'),
'type' => Controls_Manager::SLIDER,
'condition' => ['use_pagination' => 'yes'],
'size_units' => ['px'],
'range' => [
'px' => ['min' => 0, 'max' => 1000, 'step' => 5 ],
],
'selectors' => [
'{{WRAPPER}} .wgl-carousel .slick-dots' => 'margin-top: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_control(
'custom_pag_color',
[
'label' => esc_html__('Custom Pagination Color', 'unicoach-core'),
'type' => Controls_Manager::SWITCHER,
'condition' => ['use_pagination' => 'yes'],
'label_on' => esc_html__('On', 'unicoach-core'),
'label_off' => esc_html__('Off', 'unicoach-core'),
]
);
$this->add_control(
'pag_color',
[
'label' => esc_html__('Pagination Color', 'unicoach-core'),
'type' => Controls_Manager::COLOR,
'condition' => ['custom_pag_color' => 'yes'],
'dynamic' => ['active' => true],
'default' => Unicoach_Globals::get_primary_color(),
'selectors' => [
'{{WRAPPER}} .pagination_circle .slick-dots li button, {{WRAPPER}} .pagination_square .slick-dots li button, {{WRAPPER}} .pagination_line .slick-dots li button:before' => 'background: {{VALUE}}',
],
]
);
$this->add_control(
'hr_prev_next',
['type' => Controls_Manager::DIVIDER]
);
$this->add_control(
'divider_4',
[
'label' => esc_html__('Prev/Next Buttons', 'unicoach-core'),
'type' => Controls_Manager::HEADING,
]
);
$this->add_control(
'use_prev_next',
[
'label' => esc_html__('Add Prev/Next buttons', 'unicoach-core'),
'type' => Controls_Manager::SWITCHER,
]
);
$this->add_control(
'custom_prev_next_offset',
[
'label' => esc_html__('Custom offset', 'unicoach-core'),
'type' => Controls_Manager::SWITCHER,
'condition' => ['use_prev_next!' => ''],
'label_on' => esc_html__('On', 'unicoach-core'),
'label_off' => esc_html__('Off', 'unicoach-core'),
]
);
$this->add_control(
'prev_next_offset',
[
'label' => esc_html__('Buttons Top Offset', 'unicoach-core'),
'type' => Controls_Manager::SLIDER,
'condition' => ['use_prev_next!' => ''],
'size_units' => ['%'],
'range' => [
'%' => ['min' => 0, 'max' => 1000],
],
'default' => ['size' => 50, 'unit' => '%'],
'selectors' => [
'{{WRAPPER}} .wgl-carousel .slick-next, {{WRAPPER}} .wgl-carousel .slick-prev' => 'top: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_control(
'custom_prev_next_color',
[
'label' => esc_html__('Customize Colors', 'unicoach-core'),
'type' => Controls_Manager::SWITCHER,
'condition' => ['use_prev_next!' => ''],
]
);
$this->add_control(
'prev_next_color',
[
'label' => esc_html__('Prev/Next Buttons Color', 'unicoach-core'),
'type' => Controls_Manager::COLOR,
'condition' => ['custom_prev_next_color' => 'yes'],
'dynamic' => ['active' => true],
'default' => Unicoach_Globals::get_primary_color(),
]
);
$this->add_control(
'prev_next_bg_color',
[
'label' => esc_html__('Buttons Background Color', 'unicoach-core'),
'type' => Controls_Manager::COLOR,
'dynamic' => ['active' => true],
'condition' => ['custom_prev_next_color' => 'yes'],
'default' => '#ffffff',
]
);
$this->end_controls_section();
$this->start_controls_section(
'responsive_section',
['label' => esc_html__('Responsive', 'unicoach-core')]
);
$this->add_control(
'custom_resp',
[
'label' => esc_html__('Customize Responsive', 'unicoach-core'),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_html__('On', 'unicoach-core'),
'label_off' => esc_html__('Off', 'unicoach-core'),
]
);
$this->add_control(
'heading_desktop',
[
'label' => esc_html__('Desktop Settings', 'unicoach-core'),
'type' => Controls_Manager::HEADING,
'condition' => ['custom_resp' => 'yes'],
'separator' => 'after',
]
);
$this->add_control(
'resp_medium',
[
'label' => esc_html__('Desktop Screen Breakpoint', 'unicoach-core'),
'type' => Controls_Manager::NUMBER,
'condition' => ['custom_resp' => 'yes'],
'min' => 1,
'default' => '1025',
]
);
$this->add_control(
'resp_medium_slides',
[
'label' => esc_html__('Slides to show', 'unicoach-core'),
'type' => Controls_Manager::NUMBER,
'condition' => ['custom_resp' => 'yes'],
'min' => 1,
]
);
$this->add_control(
'heading_tablet',
[
'label' => esc_html__('Tablet Settings', 'unicoach-core'),
'type' => Controls_Manager::HEADING,
'condition' => ['custom_resp' => 'yes'],
'separator' => 'after',
]
);
$this->add_control(
'resp_tablets',
[
'label' => esc_html__('Tablet Screen Breakpoint', 'unicoach-core'),
'type' => Controls_Manager::NUMBER,
'condition' => ['custom_resp' => 'yes'],
'min' => 1,
'default' => '800',
]
);
$this->add_control(
'resp_tablets_slides',
[
'label' => esc_html__('Slides to show', 'unicoach-core'),
'type' => Controls_Manager::NUMBER,
'condition' => ['custom_resp' => 'yes'],
'min' => 1,
]
);
$this->add_control(
'heading_mobile',
[
'label' => esc_html__('Mobile Settings', 'unicoach-core'),
'type' => Controls_Manager::HEADING,
'condition' => ['custom_resp' => 'yes'],
'separator' => 'after',
]
);
$this->add_control(
'resp_mobile',
[
'label' => esc_html__('Mobile Screen Breakpoint', 'unicoach-core'),
'type' => Controls_Manager::NUMBER,
'condition' => ['custom_resp' => 'yes'],
'min' => 1,
'default' => '480',
]
);
$this->add_control(
'resp_mobile_slides',
[
'label' => esc_html__('Slides to show', 'unicoach-core'),
'type' => Controls_Manager::NUMBER,
'condition' => ['custom_resp' => 'yes'],
'min' => 1,
]
);
$this->end_controls_section();
}
protected function render()
{
$atts = $this->get_settings_for_display();
extract($atts);
$content = [];
foreach ($content_repeater as $template) {
array_push($content, $template['content']);
}
echo Wgl_Carousel_Settings::init($atts, $content, true);
}
}