PluginProbe
UiCore Elements – Free widgets and templates for Elementor / 1.3.18
UiCore Elements – Free widgets and templates for Elementor v1.3.18
1.3.18 1.3.17 1.3.16 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.2.0 1.2.1 1.2.2 1.2.3 All 42 releases
← All changes | includes/utils/logo-component.php +475 -450 1.0.0 → 1.3.18 View file →
@@ -1,450 +1,475 @@
1 -<?php
2 -namespace UiCoreElements\Utils;
3 -
4 -use Elementor\Controls_Manager;
5 -use Elementor\Utils;
6 -use Elementor\Repeater;
7 -use Elementor\Group_Control_Image_Size;
8 -use Elementor\Group_Control_Box_Shadow;
9 -use Elementor\Group_Control_Css_Filter;
10 -
11 -defined('ABSPATH') || exit();
12 -
13 -trait Logo_Trait {
14 -
15 - // Settings
16 - function register_logo_repeater_controls($logo)
17 - {
18 - $this->start_controls_section(
19 - 'section_logo',
20 - [
21 - 'label' => __( $logo, 'uicore-elements' ),
22 - 'tab' => Controls_Manager::TAB_CONTENT,
23 - ]
24 - );
25 -
26 - $repeater = new Repeater();
27 - $repeater->add_control(
28 - 'title',
29 - [
30 - 'label' => __( 'Title', 'uicore-elements' ),
31 - 'type' => Controls_Manager::TEXT,
32 - ]
33 - );
34 - $repeater->add_control(
35 - 'image',
36 - [
37 - 'label' => __( 'Logo Image', 'uicore-elements' ),
38 - 'type' => Controls_Manager::MEDIA,
39 - 'default' => [
40 - 'url' => Utils::get_placeholder_image_src(),
41 - ],
42 - ]
43 - );
44 - $repeater->add_control(
45 - 'link',
46 - [
47 - 'label' => __( 'Website URL', 'uicore-elements' ),
48 - 'type' => Controls_Manager::URL,
49 - 'show_external' => false,
50 - 'label_block' => false,
51 - ]
52 - );
53 - $this->add_control(
54 - 'logo_list',
55 - [
56 - 'show_label' => false,
57 - 'type' => Controls_Manager::REPEATER,
58 - 'fields' => $repeater->get_controls(),
59 - 'title_field' => "{{{ title }}}",
60 - 'default' => [
61 - [
62 - 'title' => __( 'Item 1', 'uicore-elements' ),
63 - 'image' => [ 'url' => Utils::get_placeholder_image_src() ]
64 - ],
65 - [
66 - 'title' => __( 'Item 2', 'uicore-elements' ),
67 - 'image' => [ 'url' => Utils::get_placeholder_image_src() ]
68 - ],
69 - [
70 - 'title' => __( 'Item 3', 'uicore-elements' ),
71 - 'image' => [ 'url' => Utils::get_placeholder_image_src() ]
72 - ],
73 - [
74 - 'title' => __( 'Item 4', 'uicore-elements' ),
75 - 'image' => [ 'url' => Utils::get_placeholder_image_src() ]
76 - ],
77 - [
78 - 'title' => __( 'Item 5', 'uicore-elements' ),
79 - 'image' => [ 'url' => Utils::get_placeholder_image_src() ]
80 - ],
81 - [
82 - 'title' => __( 'Item 6', 'uicore-elements' ),
83 - 'image' => [ 'url' => Utils::get_placeholder_image_src() ]
84 - ],
85 - [
86 - 'title' => __( 'Item 7', 'uicore-elements' ),
87 - 'image' => [ 'url' => Utils::get_placeholder_image_src() ]
88 - ],
89 - [
90 - 'title' => __( 'Item 8', 'uicore-elements' ),
91 - 'image' => [ 'url' => Utils::get_placeholder_image_src() ]
92 - ],
93 - ]
94 - ]
95 - );
96 - $this->end_controls_section();
97 - }
98 - function register_logo_adittional_controls($height = true)
99 - {
100 - $this->add_group_control(
101 - Group_Control_Image_Size::get_type(),
102 - [
103 - 'name' => 'thumbnail',
104 - 'default' => 'large',
105 - 'default' => 'medium',
106 - 'exclude' => [
107 - 'custom'
108 - ]
109 - ]
110 - );
111 - if($height){
112 - $this->add_responsive_control(
113 - 'height',
114 - [
115 - 'label' => __( 'Item Height', 'uicore-elements' ),
116 - 'type' => Controls_Manager::SLIDER,
117 - 'size_units' => [ 'px' ],
118 - 'range' => [
119 - 'px' => [
120 - 'max' => 500,
121 - 'min' => 100,
122 - ]
123 - ],
124 - 'selectors' => [
125 - '{{WRAPPER}} .ui-e-item' => 'height: {{SIZE}}{{UNIT}};'
126 - ],
127 - ]
128 - );
129 - }
130 - }
131 -
132 - // Grid Styles
133 - function register_logos_grid_style_controls()
134 - {
135 - $this->start_controls_tabs( 'logos_style' );
136 -
137 - $this->start_controls_tab(
138 - 'tab_logos_style_normal',
139 - [
140 - 'label' => __( 'Normal', 'uicore-elements' ),
141 - ]
142 - );
143 -
144 - $this->add_control(
145 - 'item_bg_color',
146 - [
147 - 'label' => __( 'Background Color', 'uicore-elements' ),
148 - 'type' => Controls_Manager::COLOR,
149 - 'selectors' => [
150 - '{{WRAPPER}} figure' => 'background-color: {{VALUE}};',
151 - ],
152 - ]
153 - );
154 - // Using Group Control Border overlays script border styling
155 - $this->add_control(
156 - 'item_border_type',
157 - [
158 - 'label' => __( 'Border Type', 'bdthemes-element-pack' ),
159 - 'type' => Controls_Manager::SELECT,
160 - 'options' => [
161 - 'none' => __( 'None', 'bdthemes-element-pack' ),
162 - 'solid' => __( 'Solid', 'bdthemes-element-pack' ),
163 - 'double' => __( 'Double', 'bdthemes-element-pack' ),
164 - 'dotted' => __( 'Dotted', 'bdthemes-element-pack' ),
165 - 'dashed' => __( 'Dashed', 'bdthemes-element-pack' ),
166 - 'groove' => __( 'Groove', 'bdthemes-element-pack' ),
167 - ],
168 - 'default' => 'solid',
169 - 'selectors' => [
170 - '{{WRAPPER}} .ui-e-item' => 'border-style: {{VALUE}};',
171 - ],
172 - ]
173 - );
174 - $this->add_responsive_control(
175 - 'item_border_width',
176 - [
177 - 'label' => __( 'Border Width', 'bdthemes-element-pack' ),
178 - 'type' => Controls_Manager::SLIDER,
179 - 'default' => [
180 - 'size' => 2,
181 - ],
182 - 'tablet_default' => [
183 - 'size' => 2,
184 - ],
185 - 'mobile_default' => [
186 - 'size' => 2,
187 - ],
188 - 'range' => [
189 - 'px' => [
190 - 'min' => 0,
191 - 'max' => 50,
192 - ],
193 - ],
194 - 'selectors' => [
195 - '{{WRAPPER}}' => '--ui-e-border-width: {{SIZE}}{{UNIT}};'
196 - ],
197 - 'condition' => [
198 - 'item_border_type!' => 'none',
199 - ]
200 - ]
201 - );
202 - $this->add_control(
203 - 'item_border_color',
204 - [
205 - 'label' => __( 'Border Color', 'bdthemes-element-pack' ),
206 - 'type' => Controls_Manager::COLOR,
207 - 'selectors' => [
208 - '{{WRAPPER}} .ui-e-item' => 'border-color: {{VALUE}};',
209 - ],
210 - 'default' => '#EEE',
211 - 'condition' => [
212 - 'item_border_type!' => 'none',
213 - ]
214 - ]
215 - );
216 - $this->add_responsive_control(
217 - 'item_border_radius',
218 - [
219 - 'label' => __( 'Border Radius', 'uicore-elements' ),
220 - 'type' => Controls_Manager::DIMENSIONS,
221 - 'size_units' => [ 'px', '%' ],
222 - 'default' => [
223 - 'top' => 5,
224 - 'right' => 5,
225 - 'bottom' => 5,
226 - 'left' => 5,
227 - 'unit' => 'px',
228 - 'isLinked' => true,
229 - ],
230 - 'selectors' => [
231 - // each side is used separately by logo-grid script
232 - '{{WRAPPER}}' => '--ui-e-top-radius: {{TOP}}{{UNIT}};
233 - --ui-e-right-radius: {{RIGHT}}{{UNIT}};
234 - --ui-e-left-radius: {{LEFT}}{{UNIT}};
235 - --ui-e-bottom-radius: {{BOTTOM}}{{UNIT}};
236 - --ui-e-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
237 - ],
238 - ]
239 - );
240 - $this->add_responsive_control(
241 - 'item_padding',
242 - [
243 - 'label' => __( 'Padding', 'uicore-elements' ),
244 - 'type' => Controls_Manager::DIMENSIONS,
245 - 'size_units' => [ 'px', 'em', '%' ],
246 - 'default' => [
247 - 'top' => 20,
248 - 'right' => 20,
249 - 'bottom' => 20,
250 - 'left' => 20,
251 - 'unit' => 'px',
252 - 'isLinked' => true,
253 - ],
254 - 'selectors' => [
255 - '{{WRAPPER}} figure' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
256 - ],
257 - ]
258 - );
259 - $this->add_group_control(
260 - Group_Control_Box_Shadow::get_type(),
261 - [
262 - 'name' => 'logos_box_shadow_item',
263 - 'exclude' => [
264 - 'box_shadow_position',
265 - ],
266 - 'selector' => '{{WRAPPER}} .ui-e-item',
267 - 'condition' => [
268 - 'layout' => 'inner-border'
269 - ],
270 - ]
271 - );
272 - $this->add_group_control(
273 - Group_Control_Box_Shadow::get_type(),
274 - [
275 - 'name' => 'logos_box_shadow_wrapper',
276 - 'exclude' => [
277 - 'box_shadow_position',
278 - ],
279 - 'selector' => '{{WRAPPER}} .ui-e-grid',
280 - 'condition' => [
281 - 'layout!' => 'inner-border'
282 - ],
283 - ]
284 - );
285 - $this->register_logos_image_style_controls('normal');
286 - $this->end_controls_tab();
287 -
288 - $this->start_controls_tab(
289 - 'tab_logos_style_hover',
290 - [
291 - 'label' => __( 'Hover', 'uicore-elements' ),
292 - ]
293 - );
294 - $this->add_control(
295 - 'item_bg_hover_color',
296 - [
297 - 'label' => __( 'Background Color', 'uicore-elements' ),
298 - 'type' => Controls_Manager::COLOR,
299 - 'selectors' => [
300 - '{{WRAPPER}} .ui-e-item:hover figure' => 'background-color: {{VALUE}};',
301 - ],
302 - ]
303 - );
304 - $this->add_control(
305 - 'grid_border_hover_color',
306 - [
307 - 'label' => __( 'Border Color', 'uicore-elements' ),
308 - 'type' => Controls_Manager::COLOR,
309 - 'selectors' => [
310 - '{{WRAPPER}} .ui-e-item:hover' => 'border-color: {{VALUE}};',
311 - ],
312 - 'condition' => [
313 - 'item_border_type!' => 'none',
314 - 'layout' => 'inner-border',
315 - ]
316 - ]
317 - );
318 - $this->register_logos_image_style_controls('hover');
319 - $this->end_controls_tab();
320 -
321 - $this->end_controls_tabs();
322 - }
323 - // Logo Image Styles
324 - function register_logos_image_style_controls($state, $active_selector = '.is-selected')
325 - {
326 - if($state == 'normal'){
327 - $this->add_group_control(
328 - Group_Control_Css_Filter::get_type(),
329 - [
330 - 'name' => 'image_css_filters',
331 - 'selector' => '{{WRAPPER}} figure img',
332 - ]
333 - );
334 - $this->add_responsive_control(
335 - 'image_size',
336 - [
337 - 'label' => __( 'Image Size', 'uicore-elements' ),
338 - 'type' => Controls_Manager::SLIDER,
339 - 'size_units' => [ 'px', '%' ],
340 - 'range' => [
341 - 'px' => [
342 - 'min' => 10,
343 - 'max' => 500,
344 - ],
345 - '%' => [
346 - 'min' => 0,
347 - 'max' => 100,
348 - ],
349 - ],
350 - 'selectors' => [
351 - '{{WRAPPER}} img' => 'height: {{SIZE}}{{UNIT}}; width: {{SIZE}}{{UNIT}}; object-fit: contain;'
352 - ],
353 - ]
354 - );
355 - } else if ($state == 'hover'){
356 - $this->add_group_control(
357 - Group_Control_Css_Filter::get_type(),
358 - [
359 - 'name' => 'image_css_filters_hover',
360 - 'selector' => '{{WRAPPER}} figure:hover img',
361 - ]
362 - );
363 - $this->add_control(
364 - 'image_bg_hover_transition',
365 - [
366 - 'label' => __( 'Transition Duration', 'uicore-elements' ),
367 - 'type' => Controls_Manager::SLIDER,
368 - 'range' => [
369 - 'px' => [
370 - 'max' => 3,
371 - 'step' => 0.1,
372 - ],
373 - ],
374 - 'selectors' => [
375 - '{{WRAPPER}} figure img' => 'transition-duration: {{SIZE}}s;',
376 - ],
377 - ]
378 - );
379 - } else if($state == 'active'){
380 - $this->add_group_control(
381 - Group_Control_Css_Filter::get_type(),
382 - [
383 - 'name' => 'image_css_filters_active',
384 - 'selector' => '{{WRAPPER}} '.$active_selector.' figure img',
385 - ]
386 - );
387 - }
388 - }
389 -
390 - // Rendering
391 - function render_logo_figure($data, $size)
392 - {
393 - $image = wp_get_attachment_image_url($data['id'], $size);
394 - $name = isset($data['name']) ? $data['name'] : '';
395 - $desc = isset($data['description']) ? $data['description'] : '';
396 - $alt = $name . ' : ' . $desc;
397 - ?>
398 - <figure class="<?php echo esc_attr($this->get_settings_for_display('logo_hover_animation'));?>">
399 - <?php
400 - if($image) {
401 - echo wp_get_attachment_image(
402 - $data['id'],
403 - $size,
404 - false,
405 - ['alt' => esc_attr( $alt )]
406 - );
407 - } else {
408 - printf(
409 - '<img src="%s" alt="%s">',
410 - Utils::get_placeholder_image_src(),
411 - esc_attr( $alt )
412 - );
413 - }
414 - ?>
415 - </figure>
416 - <?php
417 - }
418 - function render_logo_item()
419 - {
420 - $settings = $this->get_settings_for_display();
421 - $entrance = $settings['animate_items'] == 'ui-e-grid-animate' ? 'elementor-invisible' : '';
422 - $hover = isset($settings['item_hover_animation']) ? $settings['item_hover_animation'] : null;
423 - $animations = sprintf('%s %s', $entrance, $hover);
424 -
425 - foreach ( $settings['logo_list'] as $index => $item ) {
426 -
427 - // Params
428 - $key = 'logo_'.$index;
429 - $tag = 'div ';
430 - $this->add_render_attribute($key, 'class', 'ui-e-item' );
431 -
432 - // Build URL
433 - if (!empty($item['link']['url'])) {
434 - $tag = 'a ';
435 - $this->add_link_attributes($key, $item['link'] );
436 - }
437 - ?>
438 - <div class="ui-e-wrp">
439 - <div class='ui-e-animations-wrp <?php echo esc_attr($animations);?>'>
440 - <div class="ui-e-item-wrp">
441 - <<?php echo esc_html($tag);?> <?php $this->print_render_attribute_string($key); ?>>
442 - <?php $this->render_logo_figure($item['image'], $settings['thumbnail_size']); ?>
443 - </<?php echo esc_html($tag);?>>
444 - </div>
445 - </div>
446 - </div>
447 - <?php
448 - }
449 - }
450 -}
1 +<?php
2 +
3 +namespace UiCoreElements\Utils;
4 +
5 +use Elementor\Controls_Manager;
6 +use Elementor\Utils;
7 +use Elementor\Repeater;
8 +use Elementor\Group_Control_Image_Size;
9 +use Elementor\Group_Control_Box_Shadow;
10 +use Elementor\Group_Control_Css_Filter;
11 +
12 +use UiCoreElements\Utils\Carousel_Trait;
13 +use UiCoreElements\Helper;
14 +
15 +defined('ABSPATH') || exit();
16 +
17 +trait Logo_Trait
18 +{
19 +
20 + use Carousel_Trait;
21 +
22 + // Settings
23 + protected function TRAIT_register_logo_repeater_controls($logo)
24 + {
25 + $this->start_controls_section(
26 + 'section_logo',
27 + [
28 + /* translators: %s: logo name */
29 + 'label' => esc_html(sprintf('%s', $logo), 'uicore-elements'),
30 + 'tab' => Controls_Manager::TAB_CONTENT,
31 + ]
32 + );
33 +
34 + $repeater = new Repeater();
35 + $repeater->add_control(
36 + 'title',
37 + [
38 + 'label' => esc_html__('Title', 'uicore-elements'),
39 + 'type' => Controls_Manager::TEXT,
40 + ]
41 + );
42 + $repeater->add_control(
43 + 'image',
44 + [
45 + 'label' => esc_html__('Logo Image', 'uicore-elements'),
46 + 'type' => Controls_Manager::MEDIA,
47 + 'default' => [
48 + 'url' => Utils::get_placeholder_image_src(),
49 + ],
50 + ]
51 + );
52 + $repeater->add_control(
53 + 'link',
54 + [
55 + 'label' => esc_html__('Website URL', 'uicore-elements'),
56 + 'type' => Controls_Manager::URL,
57 + 'show_external' => false,
58 + 'label_block' => false,
59 + ]
60 + );
61 + $this->add_control(
62 + 'logo_list',
63 + [
64 + 'show_label' => false,
65 + 'type' => Controls_Manager::REPEATER,
66 + 'fields' => $repeater->get_controls(),
67 + 'title_field' => "{{{ title }}}",
68 + 'default' => [
69 + [
70 + 'title' => esc_html__('Item 1', 'uicore-elements'),
71 + 'image' => ['url' => Utils::get_placeholder_image_src()]
72 + ],
73 + [
74 + 'title' => esc_html__('Item 2', 'uicore-elements'),
75 + 'image' => ['url' => Utils::get_placeholder_image_src()]
76 + ],
77 + [
78 + 'title' => esc_html__('Item 3', 'uicore-elements'),
79 + 'image' => ['url' => Utils::get_placeholder_image_src()]
80 + ],
81 + [
82 + 'title' => esc_html__('Item 4', 'uicore-elements'),
83 + 'image' => ['url' => Utils::get_placeholder_image_src()]
84 + ],
85 + [
86 + 'title' => esc_html__('Item 5', 'uicore-elements'),
87 + 'image' => ['url' => Utils::get_placeholder_image_src()]
88 + ],
89 + [
90 + 'title' => esc_html__('Item 6', 'uicore-elements'),
91 + 'image' => ['url' => Utils::get_placeholder_image_src()]
92 + ],
93 + [
94 + 'title' => esc_html__('Item 7', 'uicore-elements'),
95 + 'image' => ['url' => Utils::get_placeholder_image_src()]
96 + ],
97 + [
98 + 'title' => esc_html__('Item 8', 'uicore-elements'),
99 + 'image' => ['url' => Utils::get_placeholder_image_src()]
100 + ],
101 + ]
102 + ]
103 + );
104 + $this->end_controls_section();
105 + }
106 + protected function TRAIT_register_logo_adittional_controls()
107 + {
108 + $this->add_group_control(
109 + Group_Control_Image_Size::get_type(),
110 + [
111 + 'name' => 'thumbnail',
112 + 'default' => 'large',
113 + 'default' => 'medium',
114 + 'exclude' => [
115 + 'custom'
116 + ]
117 + ]
118 + );
119 + $this->add_responsive_control(
120 + 'height',
121 + [
122 + 'label' => esc_html__('Item Height', 'uicore-elements'),
123 + 'type' => Controls_Manager::SLIDER,
124 + 'size_units' => ['px'],
125 + 'range' => [
126 + 'px' => [
127 + 'max' => 500,
128 + 'min' => 100,
129 + ]
130 + ],
131 + 'selectors' => [
132 + '{{WRAPPER}} .ui-e-item' => 'height: {{SIZE}}{{UNIT}};'
133 + ],
134 + ]
135 + );
136 + }
137 +
138 + // Grid Styles
139 + protected function TRAIT_register_logos_grid_style_controls()
140 + {
141 + $this->start_controls_tabs('logos_style');
142 +
143 + $this->start_controls_tab(
144 + 'tab_logos_style_normal',
145 + [
146 + 'label' => esc_html__('Normal', 'uicore-elements'),
147 + ]
148 + );
149 +
150 + $this->add_control(
151 + 'item_bg_color',
152 + [
153 + 'label' => esc_html__('Background Color', 'uicore-elements'),
154 + 'type' => Controls_Manager::COLOR,
155 + 'selectors' => [
156 + '{{WRAPPER}} figure' => 'background-color: {{VALUE}};',
157 + ],
158 + ]
159 + );
160 + // Using Group Control Border overlays script border styling
161 + $this->add_control(
162 + 'item_border_type',
163 + [
164 + 'label' => esc_html__('Border Type', 'uicore-elements'),
165 + 'type' => Controls_Manager::SELECT,
166 + 'options' => [
167 + 'none' => esc_html__('None', 'uicore-elements'),
168 + 'solid' => esc_html__('Solid', 'uicore-elements'),
169 + 'double' => esc_html__('Double', 'uicore-elements'),
170 + 'dotted' => esc_html__('Dotted', 'uicore-elements'),
171 + 'dashed' => esc_html__('Dashed', 'uicore-elements'),
172 + 'groove' => esc_html__('Groove', 'uicore-elements'),
173 + ],
174 + 'default' => 'solid',
175 + 'selectors' => [
176 + '{{WRAPPER}} .ui-e-item' => 'border-style: {{VALUE}};',
177 + ],
178 + ]
179 + );
180 + $this->add_responsive_control(
181 + 'item_border_width',
182 + [
183 + 'label' => esc_html__('Border Width', 'uicore-elements'),
184 + 'type' => Controls_Manager::SLIDER,
185 + 'default' => [
186 + 'size' => 2,
187 + ],
188 + 'tablet_default' => [
189 + 'size' => 2,
190 + ],
191 + 'mobile_default' => [
192 + 'size' => 2,
193 + ],
194 + 'range' => [
195 + 'px' => [
196 + 'min' => 0,
197 + 'max' => 50,
198 + ],
199 + ],
200 + 'selectors' => [
201 + '{{WRAPPER}}' => '--ui-e-border-width: {{SIZE}}{{UNIT}};'
202 + ],
203 + 'condition' => [
204 + 'item_border_type!' => 'none',
205 + ]
206 + ]
207 + );
208 + $this->add_control(
209 + 'item_border_color',
210 + [
211 + 'label' => esc_html__('Border Color', 'uicore-elements'),
212 + 'type' => Controls_Manager::COLOR,
213 + 'selectors' => [
214 + '{{WRAPPER}} .ui-e-item' => 'border-color: {{VALUE}};',
215 + ],
216 + 'default' => '#EEE',
217 + 'condition' => [
218 + 'item_border_type!' => 'none',
219 + ]
220 + ]
221 + );
222 + $this->add_responsive_control(
223 + 'item_border_radius',
224 + [
225 + 'label' => esc_html__('Border Radius', 'uicore-elements'),
226 + 'type' => Controls_Manager::DIMENSIONS,
227 + 'size_units' => ['px', '%'],
228 + 'default' => [
229 + 'top' => 5,
230 + 'right' => 5,
231 + 'bottom' => 5,
232 + 'left' => 5,
233 + 'unit' => 'px',
234 + 'isLinked' => true,
235 + ],
236 + 'selectors' => [
237 + // each side is used separately by logo-grid script
238 + '{{WRAPPER}}' => '--ui-e-top-radius: {{TOP}}{{UNIT}};
239 + --ui-e-right-radius: {{RIGHT}}{{UNIT}};
240 + --ui-e-left-radius: {{LEFT}}{{UNIT}};
241 + --ui-e-bottom-radius: {{BOTTOM}}{{UNIT}};
242 + --ui-e-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
243 + ],
244 + ]
245 + );
246 + $this->add_responsive_control(
247 + 'item_padding',
248 + [
249 + 'label' => esc_html__('Padding', 'uicore-elements'),
250 + 'type' => Controls_Manager::DIMENSIONS,
251 + 'size_units' => ['px', 'em', '%'],
252 + 'default' => [
253 + 'top' => 20,
254 + 'right' => 20,
255 + 'bottom' => 20,
256 + 'left' => 20,
257 + 'unit' => 'px',
258 + 'isLinked' => true,
259 + ],
260 + 'selectors' => [
261 + '{{WRAPPER}} figure' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
262 + ],
263 + ]
264 + );
265 + $this->add_group_control(
266 + Group_Control_Box_Shadow::get_type(),
267 + [
268 + 'name' => 'logos_box_shadow_item',
269 + 'exclude' => [
270 + 'box_shadow_position',
271 + ],
272 + 'selector' => '{{WRAPPER}} .ui-e-item',
273 + 'condition' => [
274 + 'layout' => 'inner-border'
275 + ],
276 + ]
277 + );
278 + $this->add_group_control(
279 + Group_Control_Box_Shadow::get_type(),
280 + [
281 + 'name' => 'logos_box_shadow_wrapper',
282 + 'exclude' => [
283 + 'box_shadow_position',
284 + ],
285 + 'selector' => '{{WRAPPER}} .ui-e-grid',
286 + 'condition' => [
287 + 'layout!' => 'inner-border'
288 + ],
289 + ]
290 + );
291 + $this->TRAIT_register_logos_image_style_controls('normal');
292 + $this->end_controls_tab();
293 +
294 + $this->start_controls_tab(
295 + 'tab_logos_style_hover',
296 + [
297 + 'label' => esc_html__('Hover', 'uicore-elements'),
298 + ]
299 + );
300 + $this->add_control(
301 + 'item_bg_hover_color',
302 + [
303 + 'label' => esc_html__('Background Color', 'uicore-elements'),
304 + 'type' => Controls_Manager::COLOR,
305 + 'selectors' => [
306 + '{{WRAPPER}} .ui-e-item:hover figure' => 'background-color: {{VALUE}};',
307 + ],
308 + ]
309 + );
310 + $this->add_control(
311 + 'grid_border_hover_color',
312 + [
313 + 'label' => esc_html__('Border Color', 'uicore-elements'),
314 + 'type' => Controls_Manager::COLOR,
315 + 'selectors' => [
316 + '{{WRAPPER}} .ui-e-item:hover' => 'border-color: {{VALUE}};',
317 + ],
318 + 'condition' => [
319 + 'item_border_type!' => 'none',
320 + 'layout' => 'inner-border',
321 + ]
322 + ]
323 + );
324 + $this->TRAIT_register_logos_image_style_controls('hover');
325 + $this->end_controls_tab();
326 +
327 + $this->end_controls_tabs();
328 + }
329 + // Logo Image Styles
330 + protected function TRAIT_register_logos_image_style_controls($state)
331 + {
332 + if ($state == 'normal') {
333 + $this->add_group_control(
334 + Group_Control_Css_Filter::get_type(),
335 + [
336 + 'name' => 'image_css_filters',
337 + 'selector' => '{{WRAPPER}} figure img',
338 + ]
339 + );
340 + $this->add_responsive_control(
341 + 'image_size',
342 + [
343 + 'label' => esc_html__('Image Size', 'uicore-elements'),
344 + 'type' => Controls_Manager::SLIDER,
345 + 'size_units' => ['px', '%'],
346 + 'range' => [
347 + 'px' => [
348 + 'min' => 10,
349 + 'max' => 500,
350 + ],
351 + '%' => [
352 + 'min' => 0,
353 + 'max' => 100,
354 + ],
355 + ],
356 + 'selectors' => [
357 + '{{WRAPPER}} img' => 'height: {{SIZE}}{{UNIT}}; width: {{SIZE}}{{UNIT}}; object-fit: contain;'
358 + ],
359 + ]
360 + );
361 + } else if ($state == 'hover') {
362 + $this->add_group_control(
363 + Group_Control_Css_Filter::get_type(),
364 + [
365 + 'name' => 'image_css_filters_hover',
366 + 'selector' => '{{WRAPPER}} figure:hover img',
367 + ]
368 + );
369 + $this->add_control(
370 + 'image_bg_hover_transition',
371 + [
372 + 'label' => esc_html__('Transition Duration', 'uicore-elements'),
373 + 'type' => Controls_Manager::SLIDER,
374 + 'range' => [
375 + 'px' => [
376 + 'max' => 3,
377 + 'step' => 0.1,
378 + ],
379 + ],
380 + 'selectors' => [
381 + '{{WRAPPER}} figure img' => 'transition-duration: {{SIZE}}s;',
382 + ],
383 + ]
384 + );
385 + } else if ($state == 'active') {
386 + $this->add_group_control(
387 + Group_Control_Css_Filter::get_type(),
388 + [
389 + 'name' => 'image_css_filters_active',
390 + 'selector' => '{{WRAPPER}} .is-selected figure img',
391 + ]
392 + );
393 + }
394 + }
395 +
396 + // Rendering
397 + protected function render_logo_figure($data, $size)
398 + {
399 + $image = wp_get_attachment_image_url($data['id'], $size);
400 + $name = isset($data['name']) ? $data['name'] : '';
401 + $desc = isset($data['description']) ? $data['description'] : '';
402 + $alt = $name . ' : ' . $desc;
403 +?>
404 + <figure class="<?php echo esc_attr($this->get_settings_for_display('logo_hover_animation')); ?>">
405 + <?php
406 + if ($image) {
407 + echo wp_get_attachment_image(
408 + $data['id'],
409 + $size,
410 + false,
411 + ['alt' => esc_attr($alt)]
412 + );
413 + } else {
414 + printf(
415 + '<img src="%s" alt="%s">',
416 + esc_url(Utils::get_placeholder_image_src()),
417 + esc_attr($alt)
418 + );
419 + }
420 + ?>
421 + </figure>
422 + <?php
423 + }
424 + protected function TRAIT_render_logo_item()
425 + {
426 + $settings = $this->get_settings_for_display();
427 +
428 + // Get entrance and item hover animation classes
429 + $entrance = $this->is_option('animate_items', 'ui-e-grid-animate') ? 'elementor-invisible' : '';
430 + $hover = isset($settings['item_hover_animation']) ? $settings['item_hover_animation'] : null;
431 + $animations = sprintf('%s %s', $entrance, $hover);
432 +
433 + // Check if any animation that relies on the animation wrapper is set
434 + $has_animation = !empty($entrance) || !empty($hover) || !empty($settings['item_hover_animation']) || !empty($settings['logo_hover_animation']);
435 +
436 + // Build wrapper class
437 + $is_carousel = strpos($this->get_name(), 'carousel') !== false;
438 + $this->add_render_attribute([
439 + 'wrapper' => [
440 + 'class' => $is_carousel ? 'ui-e-wrp swiper-slide' : 'ui-e-wrp',
441 + ],
442 + ]);
443 +
444 + foreach ($settings['logo_list'] as $index => $item) {
445 + $this->render_logo($index, $item, $settings, $has_animation, $animations);
446 + }
447 + }
448 +
449 + protected function render_logo($index, $item, $settings, $has_animation, $animations)
450 + {
451 + // Params
452 + $key = 'logo_' . $index;
453 + $tag = 'div';
454 + $this->add_render_attribute($key, 'class', 'ui-e-item');
455 +
456 + // Build URL
457 + if (!empty($item['link']['url'])) {
458 + $tag = 'a';
459 + $this->add_link_attributes($key, $item['link']);
460 + }
461 + ?>
462 + <div <?php $this->print_render_attribute_string('wrapper'); ?>>
463 + <?php if ($has_animation) : ?>
464 + <div class='ui-e-animations-wrp <?php echo esc_attr($animations); ?>'>
465 + <?php endif; ?>
466 + <<?php echo Helper::esc_tag($tag); ?> <?php $this->print_render_attribute_string($key); ?>>
467 + <?php $this->render_logo_figure($item['image'], $settings['thumbnail_size']); ?>
468 + </<?php echo Helper::esc_tag($tag); ?>>
469 + <?php if ($has_animation) : ?>
470 + </div>
471 + <?php endif; ?>
472 + </div>
473 +<?php
474 + }
475 +}