| 1 |
<?php |
| 2 |
namespace UiCoreElements; |
| 3 |
use Elementor\Controls_Manager; |
| 4 |
use UiCoreElements\UiCoreWidget; |
| 5 |
use UiCoreElements\Utils\Carousel_Trait; |
| 6 |
use UiCoreElements\Utils\Testimonial_Trait; |
| 7 |
use UiCoreElements\Utils\Animation_Trait; |
| 8 |
use UiCoreElements\Utils\Item_Style_Component; |
| 9 |
|
| 10 |
defined('ABSPATH') || exit(); |
| 11 |
|
| 12 |
/** |
| 13 |
* Testimonial Carousel |
| 14 |
* |
| 15 |
* @author Lucas Marini Falbo <lucas@uicore.co> |
| 16 |
* @since 1.0.1 |
| 17 |
*/ |
| 18 |
|
| 19 |
class TestimonialCarousel extends UiCoreWidget |
| 20 |
{ |
| 21 |
|
| 22 |
use Carousel_Trait; |
| 23 |
use Testimonial_Trait; |
| 24 |
use Animation_Trait; |
| 25 |
use Item_Style_Component; |
| 26 |
|
| 27 |
public function get_name() |
| 28 |
{ |
| 29 |
return 'uicore-testimonial-carousel'; |
| 30 |
} |
| 31 |
public function get_title() |
| 32 |
{ |
| 33 |
return esc_html__('Testimonial Carousel', 'uicore-elements'); |
| 34 |
} |
| 35 |
public function get_icon() |
| 36 |
{ |
| 37 |
return 'eicon-testimonial ui-e-widget'; |
| 38 |
} |
| 39 |
public function get_categories() |
| 40 |
{ |
| 41 |
return ['uicore']; |
| 42 |
} |
| 43 |
public function get_keywords() |
| 44 |
{ |
| 45 |
return ['testimonial', 'review', 'services', 'cards', 'box', 'client', 'carousel']; |
| 46 |
} |
| 47 |
public function get_styles() |
| 48 |
{ |
| 49 |
$styles = [ |
| 50 |
'testimonial-carousel', |
| 51 |
'animation', // hover animations |
| 52 |
'entrance', // entrance basic style |
| 53 |
]; |
| 54 |
if(!class_exists('\UiCore\Core') && !class_exists('\UiCoreAnimate\Base')){ |
| 55 |
$styles['e-animations'] = [ // entrance animations |
| 56 |
'external' => true, |
| 57 |
]; |
| 58 |
} |
| 59 |
return $styles; |
| 60 |
} |
| 61 |
public function get_scripts() |
| 62 |
{ |
| 63 |
$scripts = [ |
| 64 |
'utils/global-testimonial' => [ |
| 65 |
'condition' => [ |
| 66 |
'layout' => 'layout_5' |
| 67 |
] |
| 68 |
] |
| 69 |
]; |
| 70 |
return array_merge($scripts, $this->TRAIT_get_scripts()); |
| 71 |
} |
| 72 |
protected function register_controls() |
| 73 |
{ |
| 74 |
|
| 75 |
$this->TRAIT_register_testimonial_repeater_controls('Testimonial Carousel Items'); // Repeater Controls |
| 76 |
|
| 77 |
// Additional Carousel Controls |
| 78 |
$this->start_controls_section( |
| 79 |
'section_review_additional_settings', |
| 80 |
[ |
| 81 |
'label' => __('Additional Settings', 'uicore-elements'), |
| 82 |
'tab' => Controls_Manager::TAB_CONTENT, |
| 83 |
] |
| 84 |
); |
| 85 |
|
| 86 |
$this->TRAIT_register_specific_testimonial_controls('layout'); |
| 87 |
$this->TRAIT_register_carousel_additional_controls(); // Carousel Additionals |
| 88 |
$this->TRAIT_register_testimonial_additional_controls(); // Testimonial Additionals |
| 89 |
|
| 90 |
$this->end_controls_section(); |
| 91 |
|
| 92 |
$this->start_controls_section( |
| 93 |
'section_carousel_settings', |
| 94 |
[ |
| 95 |
'label' => __('Carousel Settings', 'uicore-elements'), |
| 96 |
] |
| 97 |
); |
| 98 |
|
| 99 |
$this->TRAIT_register_carousel_settings_controls(); // Carousel settings |
| 100 |
|
| 101 |
$this->end_controls_section(); |
| 102 |
|
| 103 |
$this->TRAIT_register_navigation_controls(); // Navigation settings |
| 104 |
|
| 105 |
$this->start_controls_section( |
| 106 |
'section_style_review_items', |
| 107 |
[ |
| 108 |
'label' => esc_html__( 'Items', 'uicore-elements' ), |
| 109 |
'tab' => Controls_Manager::TAB_STYLE, |
| 110 |
] |
| 111 |
); |
| 112 |
|
| 113 |
// move it to specific controls |
| 114 |
$this->add_control( |
| 115 |
'item_gap', |
| 116 |
[ |
| 117 |
'label' => esc_html__( 'Inner Content Spacing', 'uicore-elements' ), |
| 118 |
'type' => Controls_Manager::SLIDER, |
| 119 |
'size_units' => [ 'px', '%', 'em' ], |
| 120 |
'range' => [ |
| 121 |
'px' => [ |
| 122 |
'min' => 0, |
| 123 |
'max' => 50, |
| 124 |
'step' => 1, |
| 125 |
], |
| 126 |
'%' => [ |
| 127 |
'min' => 0, |
| 128 |
'max' => 100, |
| 129 |
], |
| 130 |
], |
| 131 |
'default' => [ |
| 132 |
'unit' => 'px', |
| 133 |
'size' => 15, |
| 134 |
], |
| 135 |
'selectors' => [ |
| 136 |
'{{WRAPPER}} .ui-e-testimonial-flex' => 'margin-bottom: {{SIZE}}{{UNIT}};', |
| 137 |
], |
| 138 |
'conditions' => [ |
| 139 |
'relation' => 'and', |
| 140 |
'terms' => [ |
| 141 |
[ |
| 142 |
'name' => 'image_inline', |
| 143 |
'operator' => '===', |
| 144 |
'value' => 'yes', |
| 145 |
], |
| 146 |
[ |
| 147 |
'name' => 'layout', |
| 148 |
'operator' => 'in', |
| 149 |
'value' => ['layout_2'], |
| 150 |
], |
| 151 |
], |
| 152 |
], |
| 153 |
] |
| 154 |
); |
| 155 |
$this->TRAIT_register_all_item_style_controls(); |
| 156 |
|
| 157 |
$this->end_controls_section(); |
| 158 |
|
| 159 |
$this->TRAIT_register_style_controls(); // All Testimonial components styles |
| 160 |
$this->TRAIT_register_navigation_style_controls(); // Carousel Navigation Styles |
| 161 |
|
| 162 |
$this->start_controls_section( |
| 163 |
'section_style_animations', |
| 164 |
[ |
| 165 |
'label' => __('Animations', 'uicore-elements'), |
| 166 |
'tab' => Controls_Manager::TAB_STYLE, |
| 167 |
] |
| 168 |
); |
| 169 |
|
| 170 |
$this->TRAIT_register_testimonial_animation_controls(); |
| 171 |
|
| 172 |
$this->end_controls_section(); |
| 173 |
|
| 174 |
// We need to set border radius as variable to use item radius on other components on swiper elements |
| 175 |
$this->update_control('item_border_radius', [ |
| 176 |
'selectors' => [ |
| 177 |
'{{WRAPPER}} .ui-e-item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 178 |
'{{WRAPPER}}' => '--ui-e-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' |
| 179 |
], |
| 180 |
]); |
| 181 |
} |
| 182 |
public function render() |
| 183 |
{ |
| 184 |
$settings = $this->get_settings_for_display(); |
| 185 |
?> |
| 186 |
<div class="ui-e-carousel swiper"> |
| 187 |
<div class='swiper-wrapper'> |
| 188 |
<?php |
| 189 |
foreach ( $settings['review_items'] as $index => $item ) : |
| 190 |
$this->TRAIT_render_review_item($item, $settings['layout']); |
| 191 |
endforeach; |
| 192 |
?> |
| 193 |
</div> |
| 194 |
<?php $this->TRAIT_render_carousel_navigations(); ?> |
| 195 |
</div> |
| 196 |
<?php |
| 197 |
} |
| 198 |
} |
| 199 |
\Elementor\Plugin::instance()->widgets_manager->register(new TestimonialCarousel()); |