PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.16.0
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.16.0
2.16.0 2.15.0 2.14.0 2.13.0 2.13.1 2.12.0 2.11.1 2.11.0 2.10.0 2.9.0 2.7.4 2.7.5 2.7.6 2.7.7 2.8.0 2.8.1 2.9.1 trunk 1.0 1.0-beta1 1.0-beta2 1.0-beta3 1.0.1 1.0.2 1.0.3 All 83 releases
← All changes | includes/blocks/carousel/block.php +569 -27 2.9.1 → 2.16.0 View file →
@@ -1,21 +1,29 @@
1 1 <?php
2 2 namespace ABlocks\Blocks\Carousel;
3 3
4 +if ( ! defined( 'ABSPATH' ) ) {
5 + exit;
6 +}
7 +
4 8 use ABlocks\Classes\BlockBaseAbstract;
5 9 use ABlocks\Classes\CssGenerator;
10 +use ABlocks\Classes\CssGeneratorV2;
6 11 use ABlocks\Controls\Alignment;
7 12 use ABlocks\Controls\Range;
8 13 use ABlocks\Controls\Dimensions;
9 14 use ABlocks\Controls\Border;
15 +use ABlocks\Controls\Color;
16 +use ABlocks\Controls\BoxShadow;
10 17
11 18
19 +
12 20 class Block extends BlockBaseAbstract {
13 21 protected $block_name = 'carousel';
14 22 protected $style_depends = [ 'ablocks-swiper-style' ];
15 23 protected $script_depends = [ 'ablocks-swiper-script' ];
16 24
17 - public function build_css( $attributes ) {
25 + public function build_css_v1( $attributes ) {
18 26
19 27 $css_generator = new CssGenerator( $attributes );
20 28
21 29 $css_generator->add_class_styles(
@@ -22,14 +30,38 @@
22 30 '{{WRAPPER}} .ablocks-carousel-swiper .swiper-wrapper',
23 31 $this->get_carousel_css( $attributes ),
24 32 $this->get_carousel_css( $attributes, 'Tablet' ),
25 33 $this->get_carousel_css( $attributes, 'Mobile' ),
34 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) {
35 + return $this->get_carousel_css( $attributes, $device );
36 + } )
26 37 );
27 38 $css_generator->add_class_styles(
39 + '{{WRAPPER}} .ablocks-carousel-swiper > .swiper-wrapper > .swiper-slide',
40 + $this->get_slide_css( $attributes ),
41 + $this->get_slide_css( $attributes, 'Tablet' ),
42 + $this->get_slide_css( $attributes, 'Mobile' ),
43 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) {
44 + return $this->get_slide_css( $attributes, $device );
45 + } )
46 + );
47 + $css_generator->add_class_styles(
48 + '{{WRAPPER}} .ablocks-carousel-swiper > .swiper-wrapper > .swiper-slide-active',
49 + $this->get_active_slide_css( $attributes ),
50 + $this->get_active_slide_css( $attributes, 'Tablet' ),
51 + $this->get_active_slide_css( $attributes, 'Mobile' ),
52 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) {
53 + return $this->get_active_slide_css( $attributes, $device );
54 + } )
55 + );
56 + $css_generator->add_class_styles(
28 57 '{{WRAPPER}} .ablocks-carousel-navigation__button',
29 58 $this->get_navigation_button_css( $attributes ),
30 59 $this->get_navigation_button_css( $attributes, 'Tablet' ),
31 60 $this->get_navigation_button_css( $attributes, 'Mobile' ),
61 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) {
62 + return $this->get_navigation_button_css( $attributes, $device );
63 + } )
32 64 );
33 65 $css_generator->add_class_styles(
34 66 '{{WRAPPER}} .ablocks-carousel-navigation__button--next',
35 67 $this->get_navigation_next_button_css( $attributes ),
@@ -34,8 +66,11 @@
34 66 '{{WRAPPER}} .ablocks-carousel-navigation__button--next',
35 67 $this->get_navigation_next_button_css( $attributes ),
36 68 $this->get_navigation_next_button_css( $attributes, 'Tablet' ),
37 69 $this->get_navigation_next_button_css( $attributes, 'Mobile' ),
70 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) {
71 + return $this->get_navigation_next_button_css( $attributes, $device );
72 + } )
38 73 );
39 74 $css_generator->add_class_styles(
40 75 '{{WRAPPER}} .ablocks-carousel-navigation__button--prev',
41 76 $this->get_navigation_prev_button_css( $attributes ),
@@ -40,8 +75,11 @@
40 75 '{{WRAPPER}} .ablocks-carousel-navigation__button--prev',
41 76 $this->get_navigation_prev_button_css( $attributes ),
42 77 $this->get_navigation_prev_button_css( $attributes, 'Tablet' ),
43 78 $this->get_navigation_prev_button_css( $attributes, 'Mobile' ),
79 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) {
80 + return $this->get_navigation_prev_button_css( $attributes, $device );
81 + } )
44 82 );
45 83 $css_generator->add_class_styles(
46 84 '{{WRAPPER}} .ablocks-carousel-navigation__button .ablocks-icon-wrap',
47 85 $this->get_navigation_icon_css( $attributes ),
@@ -46,44 +84,252 @@
46 84 '{{WRAPPER}} .ablocks-carousel-navigation__button .ablocks-icon-wrap',
47 85 $this->get_navigation_icon_css( $attributes ),
48 86 $this->get_navigation_icon_css( $attributes, 'Tablet' ),
49 87 $this->get_navigation_icon_css( $attributes, 'Mobile' ),
88 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) {
89 + return $this->get_navigation_icon_css( $attributes, $device );
90 + } )
50 91 );
92 +
51 93 $css_generator->add_class_styles(
94 + '{{WRAPPER}} .ablocks-carousel-pagination',
95 + $this->get_pagination_parent_css( $attributes ),
96 + $this->get_pagination_parent_css( $attributes, 'Tablet' ),
97 + $this->get_pagination_parent_css( $attributes, 'Mobile' ),
98 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) {
99 + return $this->get_pagination_parent_css( $attributes, $device );
100 + } )
101 + );
102 + $css_generator->add_class_styles(
52 103 '{{WRAPPER}} .swiper-pagination-bullet',
53 104 $this->get_pagination_color_css( $attributes ),
54 105 $this->get_pagination_color_css( $attributes, 'Tablet' ),
55 - $this->get_pagination_color_css( $attributes, 'Mobile' )
106 + $this->get_pagination_color_css( $attributes, 'Mobile' ),
107 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) {
108 + return $this->get_pagination_color_css( $attributes, $device );
109 + } )
56 110 );
111 + $css_generator->add_class_styles(
112 + '{{WRAPPER}} .swiper-pagination-bullet:hover',
113 + $this->get_pagination_color_hover_css( $attributes ),
114 + $this->get_pagination_color_hover_css( $attributes, 'Tablet' ),
115 + $this->get_pagination_color_hover_css( $attributes, 'Mobile' ),
116 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) {
117 + return $this->get_pagination_color_hover_css( $attributes, $device );
118 + } )
119 + );
57 120
58 121 $css_generator->add_class_styles(
59 122 '{{WRAPPER}} .swiper-pagination-bullet.swiper-pagination-bullet-active',
60 123 $this->get_pagination_active_color_css( $attributes ),
61 124 $this->get_pagination_active_color_css( $attributes, 'Tablet' ),
62 - $this->get_pagination_active_color_css( $attributes, 'Mobile' )
125 + $this->get_pagination_active_color_css( $attributes, 'Mobile' ),
126 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) {
127 + return $this->get_pagination_active_color_css( $attributes, $device );
128 + } )
63 129 );
130 + $css_generator->add_class_styles(
131 + '{{WRAPPER}} .swiper-pagination-bullet.swiper-pagination-bullet-active:hover',
132 + $this->get_pagination_active_color_hover_css( $attributes ),
133 + $this->get_pagination_active_color_hover_css( $attributes, 'Tablet' ),
134 + $this->get_pagination_active_color_hover_css( $attributes, 'Mobile' ),
135 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) {
136 + return $this->get_pagination_active_color_hover_css( $attributes, $device );
137 + } )
138 + );
64 139
65 140 $css_generator->add_class_styles(
66 141 '{{WRAPPER}} .ablocks-carousel-navigation__button .ablocks-svg-icon',
67 142 $this->get_navigation_icon_svg_css( $attributes ),
68 143 $this->get_navigation_icon_svg_css( $attributes, 'Tablet' ),
69 - $this->get_navigation_icon_svg_css( $attributes, 'Mobile' )
144 + $this->get_navigation_icon_svg_css( $attributes, 'Mobile' ),
145 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) {
146 + return $this->get_navigation_icon_svg_css( $attributes, $device );
147 + } )
70 148 );
71 149 $css_generator->add_class_styles(
72 150 '{{WRAPPER}} .ablocks-carousel-navigation__button .ablocks-svg-icon:hover',
73 151 $this->get_navigation_icon_svg_hover_css( $attributes ),
74 152 $this->get_navigation_icon_svg_hover_css( $attributes, 'Tablet' ),
75 - $this->get_navigation_icon_svg_hover_css( $attributes, 'Mobile' )
153 + $this->get_navigation_icon_svg_hover_css( $attributes, 'Mobile' ),
154 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) {
155 + return $this->get_navigation_icon_svg_hover_css( $attributes, $device );
156 + } )
76 157 );
77 158 return $css_generator->generate_css();
78 159 }
79 160
161 + public function build_css_v2( $attributes ) {
162 +
163 + $css_generator = new CssGeneratorV2( $attributes, $this->block_name );
164 +
165 + $css_generator->add_class_styles(
166 + '{{WRAPPER}} .ablocks-carousel-swiper .swiper-wrapper',
167 + $this->get_carousel_css( $attributes ),
168 + $this->get_carousel_css( $attributes, 'Tablet' ),
169 + $this->get_carousel_css( $attributes, 'Mobile' ),
170 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) {
171 + return $this->get_carousel_css( $attributes, $device );
172 + } )
173 + );
174 + $css_generator->add_class_styles(
175 + '{{WRAPPER}} .ablocks-carousel-swiper > .swiper-wrapper > .swiper-slide',
176 + $this->get_slide_css( $attributes ),
177 + $this->get_slide_css( $attributes, 'Tablet' ),
178 + $this->get_slide_css( $attributes, 'Mobile' ),
179 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) {
180 + return $this->get_slide_css( $attributes, $device );
181 + } )
182 + );
183 + $css_generator->add_class_styles(
184 + '{{WRAPPER}} .ablocks-carousel-swiper > .swiper-wrapper > .swiper-slide-active',
185 + $this->get_active_slide_css( $attributes ),
186 + $this->get_active_slide_css( $attributes, 'Tablet' ),
187 + $this->get_active_slide_css( $attributes, 'Mobile' ),
188 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) {
189 + return $this->get_active_slide_css( $attributes, $device );
190 + } )
191 + );
192 + $css_generator->add_class_styles(
193 + '{{WRAPPER}} .ablocks-carousel-navigation__button',
194 + $this->get_navigation_button_css( $attributes ),
195 + $this->get_navigation_button_css( $attributes, 'Tablet' ),
196 + $this->get_navigation_button_css( $attributes, 'Mobile' ),
197 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) {
198 + return $this->get_navigation_button_css( $attributes, $device );
199 + } )
200 + );
201 + $css_generator->add_class_styles(
202 + '{{WRAPPER}} .ablocks-carousel-navigation__button--next',
203 + $this->get_navigation_next_button_css( $attributes ),
204 + $this->get_navigation_next_button_css( $attributes, 'Tablet' ),
205 + $this->get_navigation_next_button_css( $attributes, 'Mobile' ),
206 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) {
207 + return $this->get_navigation_next_button_css( $attributes, $device );
208 + } )
209 + );
210 + $css_generator->add_class_styles(
211 + '{{WRAPPER}} .ablocks-carousel-navigation__button--prev',
212 + $this->get_navigation_prev_button_css( $attributes ),
213 + $this->get_navigation_prev_button_css( $attributes, 'Tablet' ),
214 + $this->get_navigation_prev_button_css( $attributes, 'Mobile' ),
215 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) {
216 + return $this->get_navigation_prev_button_css( $attributes, $device );
217 + } )
218 + );
219 + $css_generator->add_class_styles(
220 + '{{WRAPPER}} .ablocks-carousel-navigation__button .ablocks-icon-wrap',
221 + $this->get_navigation_icon_css( $attributes ),
222 + $this->get_navigation_icon_css( $attributes, 'Tablet' ),
223 + $this->get_navigation_icon_css( $attributes, 'Mobile' ),
224 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) {
225 + return $this->get_navigation_icon_css( $attributes, $device );
226 + } )
227 + );
228 +
229 + $css_generator->add_class_styles(
230 + '{{WRAPPER}} .ablocks-carousel-pagination',
231 + $this->get_pagination_parent_css( $attributes ),
232 + $this->get_pagination_parent_css( $attributes, 'Tablet' ),
233 + $this->get_pagination_parent_css( $attributes, 'Mobile' ),
234 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) {
235 + return $this->get_pagination_parent_css( $attributes, $device );
236 + } )
237 + );
238 + $css_generator->add_class_styles(
239 + '{{WRAPPER}} .swiper-pagination-bullet',
240 + $this->get_pagination_color_css( $attributes ),
241 + $this->get_pagination_color_css( $attributes, 'Tablet' ),
242 + $this->get_pagination_color_css( $attributes, 'Mobile' ),
243 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) {
244 + return $this->get_pagination_color_css( $attributes, $device );
245 + } )
246 + );
247 + $css_generator->add_class_styles(
248 + '{{WRAPPER}} .swiper-pagination-bullet:hover',
249 + $this->get_pagination_color_hover_css( $attributes ),
250 + $this->get_pagination_color_hover_css( $attributes, 'Tablet' ),
251 + $this->get_pagination_color_hover_css( $attributes, 'Mobile' ),
252 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) {
253 + return $this->get_pagination_color_hover_css( $attributes, $device );
254 + } )
255 + );
256 +
257 + $css_generator->add_class_styles(
258 + '{{WRAPPER}} .swiper-pagination-bullet.swiper-pagination-bullet-active',
259 + $this->get_pagination_active_color_css( $attributes ),
260 + $this->get_pagination_active_color_css( $attributes, 'Tablet' ),
261 + $this->get_pagination_active_color_css( $attributes, 'Mobile' ),
262 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) {
263 + return $this->get_pagination_active_color_css( $attributes, $device );
264 + } )
265 + );
266 + $css_generator->add_class_styles(
267 + '{{WRAPPER}} .swiper-pagination-bullet.swiper-pagination-bullet-active:hover',
268 + $this->get_pagination_active_color_hover_css( $attributes ),
269 + $this->get_pagination_active_color_hover_css( $attributes, 'Tablet' ),
270 + $this->get_pagination_active_color_hover_css( $attributes, 'Mobile' ),
271 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) {
272 + return $this->get_pagination_active_color_hover_css( $attributes, $device );
273 + } )
274 + );
275 +
276 + $css_generator->add_class_styles(
277 + '{{WRAPPER}} .ablocks-carousel-navigation__button .ablocks-svg-icon',
278 + $this->get_navigation_icon_svg_css( $attributes ),
279 + $this->get_navigation_icon_svg_css( $attributes, 'Tablet' ),
280 + $this->get_navigation_icon_svg_css( $attributes, 'Mobile' ),
281 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) {
282 + return $this->get_navigation_icon_svg_css( $attributes, $device );
283 + } )
284 + );
285 + $css_generator->add_class_styles(
286 + '{{WRAPPER}} .ablocks-carousel-navigation__button .ablocks-svg-icon:hover',
287 + $this->get_navigation_icon_svg_hover_css( $attributes ),
288 + $this->get_navigation_icon_svg_hover_css( $attributes, 'Tablet' ),
289 + $this->get_navigation_icon_svg_hover_css( $attributes, 'Mobile' ),
290 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) {
291 + return $this->get_navigation_icon_svg_hover_css( $attributes, $device );
292 + } )
293 + );
294 + return $css_generator->generate_css();
295 + }
296 + public function build_css( $attributes ) {
297 + if ( isset( $attributes['blockVersion'] ) && (int) $attributes['blockVersion'] === 2 ) {
298 + return $this->build_css_v2( $attributes );
299 + }
300 + return $this->build_css_v1( $attributes );
301 + }
302 +
80 303 public function get_carousel_css( $attributes, $device = '' ) {
81 304 $carousel_css = [];
82 - if ( ! empty( $attributes['verticalAlignment'] ) ) {
83 - $carousel_css['align-items'] = $attributes['verticalAlignment'];
305 + // Temporary approch instead of attribute migration. Might remove it in future
306 + $verticalAlign = isset( $attributes['verticalAlign'][ 'value' . $device ] ) ? $attributes['verticalAlign'][ 'value' . $device ] : '';
307 + if (
308 + ! isset( $attributes['verticalAlign'] )
309 + || (
310 + $attributes['verticalAlignment'] !== '' && $attributes['verticalAlignment'] !== 'center'
311 + )
312 + ) {
313 + $attributes['verticalAlign'][ 'value' . $device ] = $attributes['verticalAlignment'];
314 + $attributes['verticalAlignment'] = '';
315 + } elseif (
316 + $attributes['verticalAlignment'] !== '' && $attributes['verticalAlignment'] === 'center'
317 + ) {
318 + $attributes['verticalAlignment'] = '';
84 319 }
320 + // Temporary approch instead of attribute migration. Might remove it in future
85 321
322 + if ( ! empty( $attributes['verticalAlign'][ 'value' . $device ] ) ) {
323 + $carousel_css['align-items'] = $attributes['verticalAlign'][ 'value' . $device ];
324 + }
325 +
326 + // Room below the track for the offset active slide (wrapper is content-box).
327 + $offset = $this->get_active_slide_offset( $attributes, $device );
328 + if ( '' !== $offset ) {
329 + $carousel_css['padding-bottom'] = $offset;
330 + }
331 +
86 332 return array_merge(
87 333 Range::get_css([
88 334 'attributeValue' => $attributes['carouselHeight'],
89 335 'attribute_object_key' => 'value',
@@ -106,9 +352,9 @@
106 352 Range::get_css([
107 353 'attributeValue' => $attributes['navigationIconPositionY'],
108 354 'attribute_object_key' => 'value',
109 355 'defaultValue' => 50,
110 - 'isResponsive' => false,
356 + 'isResponsive' => true,
111 357 'hasUnit' => true,
112 358 'unitDefaultValue' => '%',
113 359 'property' => 'top',
114 360 'device' => $device,
@@ -126,9 +372,9 @@
126 372 'attributeValue' => $attributes['navigationIconPositionPrevX'],
127 373 'attribute_object_key' => 'value',
128 374 'defaultValue' => -3,
129 375 'hasUnit' => true,
130 - 'isResponsive' => false,
376 + 'isResponsive' => true,
131 377 'unitDefaultValue' => '%',
132 378 'property' => 'left',
133 379 'device' => $device,
134 380 ]),
@@ -143,9 +389,9 @@
143 389 Range::get_css([
144 390 'attributeValue' => $attributes['navigationIconPositionNextX'],
145 391 'attribute_object_key' => 'value',
146 392 'defaultValue' => -3,
147 - 'isResponsive' => false,
393 + 'isResponsive' => true,
148 394 'hasUnit' => true,
149 395 'unitDefaultValue' => '%',
150 396 'property' => 'right',
151 397 'device' => $device,
@@ -157,13 +403,8 @@
157 403
158 404 public function get_navigation_icon_css( $attributes, $device = '' ) {
159 405 $navigation_icon_css = [];
160 406
161 - if ( isset( $attributes['navigationIconSize'][ 'value' . $device ] ) ) {
162 - $unit = isset( $attributes['navigationIconSize'][ 'valueUnit' . $device ] ) ? $attributes['navigationIconSize'][ 'valueUnit' . $device ] : 'px';
163 - $navigation_icon_css['font-size'] = $attributes['navigationIconSize'][ 'value' . $device ] . $unit;
164 - }
165 -
166 407 return array_merge(
167 408 Range::get_css([
168 409 'attributeValue' => $attributes['navigationIconSize'],
169 410 'attribute_object_key' => 'value',
@@ -171,8 +412,9 @@
171 412 'isResponsive' => true,
172 413 'hasUnit' => true,
173 414 'unitDefaultValue' => 'px',
174 415 'property' => 'font-size',
416 + 'device' => $device,
175 417 ]),
176 418 $navigation_icon_css,
177 419 );
178 420 }
@@ -180,26 +422,27 @@
180 422
181 423 public function get_navigation_icon_svg_css( $attributes, $device = '' ) {
182 424 $navigation_icon_svg_css = [];
183 425 if ( isset( $attributes['navigationIconColor'] ) ) {
184 - $navigation_icon_svg_css['fill'] = $attributes['navigationIconColor'];
426 + $navigation_icon_svg_css['fill'] = Color::get_css( isset( $attributes['navigationIconColor'] ) ? $attributes['navigationIconColor'] : '' );
185 427 };
186 428 if ( isset( $attributes['navigationIconBgColor'] ) ) {
187 - $navigation_icon_svg_css['background-color'] = $attributes['navigationIconBgColor'];
429 + $navigation_icon_svg_css['background-color'] = Color::get_css( isset( $attributes['navigationIconBgColor'] ) ? $attributes['navigationIconBgColor'] : '' );
188 430 };
189 431 return array_merge(
190 432 $navigation_icon_svg_css,
191 - Dimensions::get_css( $attributes['navigationIconPadding'], 'padding', $device ),
433 + Dimensions::get_css( $this->with_custom_device_dimension_keys( $attributes['navigationIconPadding'], $device ), 'padding', $device ),
192 434 Border::get_css( $attributes['navigationIconBorder'], '', $device ),
435 + BoxShadow::get_css( $attributes['navigationIconBoxShadow'], $device ),
193 436 );
194 437 }
195 438 public function get_navigation_icon_svg_hover_css( $attributes, $device = '' ) {
196 439 $navigation_icon_svg_hover_css = [];
197 440 if ( isset( $attributes['navigationIconColorH'] ) ) {
198 - $navigation_icon_svg_hover_css['fill'] = $attributes['navigationIconColorH'];
441 + $navigation_icon_svg_hover_css['fill'] = Color::get_css( isset( $attributes['navigationIconColorH'] ) ? $attributes['navigationIconColorH'] : '' );
199 442 };
200 443 if ( isset( $attributes['navigationIconBgColorH'] ) ) {
201 - $navigation_icon_svg_hover_css['background-color'] = $attributes['navigationIconBgColorH'];
444 + $navigation_icon_svg_hover_css['background-color'] = Color::get_css( isset( $attributes['navigationIconBgColorH'] ) ? $attributes['navigationIconBgColorH'] : '' );
202 445 };
203 446 return array_merge(
204 447 Range::get_css([
205 448 'attributeValue' => $attributes['navigationIconTransition'],
@@ -210,26 +453,325 @@
210 453 'device' => $device,
211 454 ]),
212 455 $navigation_icon_svg_hover_css,
213 456 Border::get_hover_css( $attributes['navigationIconBorder'], '', $device ),
457 + BoxShadow::get_hover_css( $attributes['navigationIconBoxShadow'], '', $device ),
214 458 );
215 459 }
216 460
217 - public function get_pagination_color_css( $attributes ) {
461 + public function get_pagination_parent_css( $attributes, $device = '' ) {
462 + return array_merge(
463 + Range::get_css([
464 + 'attributeValue' => $attributes['paginationPositionX'],
465 + 'attribute_object_key' => 'value',
466 + 'defaultValue' => 47,
467 + 'isResponsive' => true,
468 + 'hasUnit' => true,
469 + 'unitDefaultValue' => '%',
470 + 'property' => 'left',
471 + 'device' => $device,
472 + ]),
473 + Range::get_css([
474 + 'attributeValue' => $attributes['paginationPositionY'],
475 + 'attribute_object_key' => 'value',
476 + 'defaultValue' => 100,
477 + 'isResponsive' => true,
478 + 'hasUnit' => true,
479 + 'unitDefaultValue' => '%',
480 + 'property' => 'top',
481 + 'device' => $device,
482 + ]),
483 + );
484 + }
485 + public function get_pagination_color_css( $attributes, $device = '' ) {
218 486 $pagination_color_css = [];
487 + $type = isset( $attributes['paginationType'] ) ? $attributes['paginationType'] : 'default';
488 + $pagination_color_css = [];
219 489 if ( isset( $attributes['paginationColor'] ) ) {
220 - $pagination_color_css['background-color'] = $attributes['paginationColor'];
490 + $color = Color::get_css( $attributes['paginationColor'] );
491 + if ( $type === 'default' ) {
492 + $pagination_color_css['background-color'] = $color;
493 + } elseif ( $type === 'border1' || $type === 'border3' ) {
494 + $pagination_color_css['border-color'] = $color;
495 + $pagination_color_css['background-color'] = 'transparent';
496 + } elseif ( $type === 'border2' ) {
497 + $pagination_color_css['background-color'] = $color;
498 + $pagination_color_css['border-color'] = $color;
499 + }
500 + }
501 + if ( $type === 'border3' ) {
502 + $dims = $this->get_ellipse_dims( $attributes['paginationSize'], $device );
503 + $pagination_color_css['width'] = $dims['width'];
504 + $pagination_color_css['height'] = $dims['height'];
505 + $pagination_color_css['border-radius'] = '9999px';
506 + }
507 + return array_merge(
508 + $pagination_color_css,
509 + ( $type === 'border3' ? [] : Range::get_css([
510 + 'attributeValue' => $attributes['paginationSize'],
511 + 'attribute_object_key' => 'value',
512 + 'defaultValue' => 8,
513 + 'isResponsive' => true,
514 + 'hasUnit' => true,
515 + 'unitDefaultValue' => 'px',
516 + 'property' => 'width',
517 + 'device' => $device,
518 + ]) ),
519 + ( $type === 'border3' ? [] : Range::get_css([
520 + 'attributeValue' => $attributes['paginationSize'],
521 + 'attribute_object_key' => 'value',
522 + 'defaultValue' => 8,
523 + 'isResponsive' => true,
524 + 'hasUnit' => true,
525 + 'unitDefaultValue' => 'px',
526 + 'property' => 'height',
527 + 'device' => $device,
528 + ]) ),
529 + Border::get_css( $attributes['paginationBorder'], '', $device ),
530 + );
531 + }
532 + public function get_pagination_color_hover_css( $attributes, $device = '' ) {
533 + $pagination_color_css = [];
534 + if ( isset( $attributes['paginationHoverColor'] ) ) {
535 + $pagination_color_css['background-color'] = $attributes['paginationHoverColor'];
221 536 };
222 - return $pagination_color_css;
537 + $type = isset( $attributes['paginationType'] ) ? $attributes['paginationType'] : 'default';
538 + $pagination_color_css = [];
539 + if ( isset( $attributes['paginationHoverColor'] ) ) {
540 + $color = Color::get_css( $attributes['paginationHoverColor'] );
541 + if ( $type === 'default' ) {
542 + $pagination_color_css['background-color'] = $color;
543 + } elseif ( $type === 'border1' || $type === 'border3' ) {
544 + $pagination_color_css['border-color'] = $color;
545 + $pagination_color_css['background-color'] = $color;
546 + } elseif ( $type === 'border2' ) {
547 + $pagination_color_css['background-color'] = 'transparent';
548 + $pagination_color_css['border-color'] = $color;
549 + }
550 + }
551 + if ( $type === 'border3' ) {
552 + $dims = $this->get_ellipse_dims( $attributes['paginationHoverSize'], $device );
553 + $pagination_color_css['width'] = $dims['width'];
554 + $pagination_color_css['height'] = $dims['height'];
555 + $pagination_color_css['border-radius'] = '9999px';
556 + }
557 + return array_merge(
558 + $pagination_color_css,
559 + ( $type === 'border3' ? [] : Range::get_css([
560 + 'attributeValue' => $attributes['paginationHoverSize'],
561 + 'attribute_object_key' => 'value',
562 + 'defaultValue' => 8,
563 + 'isResponsive' => true,
564 + 'hasUnit' => true,
565 + 'unitDefaultValue' => 'px',
566 + 'property' => 'width',
567 + 'device' => $device,
568 + ]) ),
569 + ( $type === 'border3' ? [] : Range::get_css([
570 + 'attributeValue' => $attributes['paginationHoverSize'],
571 + 'attribute_object_key' => 'value',
572 + 'defaultValue' => 8,
573 + 'isResponsive' => true,
574 + 'hasUnit' => true,
575 + 'unitDefaultValue' => 'px',
576 + 'property' => 'height',
577 + 'device' => $device,
578 + ]) ),
579 + Border::get_hover_css( $attributes['paginationBorder'], '', $device ),
580 + );
223 581 }
224 582
225 - public function get_pagination_active_color_css( $attributes ) {
583 + public function get_pagination_active_color_css( $attributes, $device = '' ) {
226 584 $pagination_active_color_css = [];
585 + $type = isset( $attributes['paginationType'] ) ? $attributes['paginationType'] : 'default';
586 + $pagination_active_color_css = [];
227 587 if ( isset( $attributes['paginationActiveColor'] ) ) {
228 - $pagination_active_color_css['background-color'] = $attributes['paginationActiveColor'];
229 - };
230 - return $pagination_active_color_css;
588 + $color = Color::get_css( $attributes['paginationActiveColor'] );
589 + if ( $type === 'default' ) {
590 + $pagination_active_color_css['background-color'] = $color;
591 + } elseif ( $type === 'border1' || $type === 'border3' ) {
592 + $pagination_active_color_css['background-color'] = $color;
593 + $pagination_active_color_css['border-color'] = $color;
594 + } elseif ( $type === 'border2' ) {
595 + $pagination_active_color_css['border-color'] = $color;
596 + $pagination_active_color_css['background-color'] = 'transparent';
597 + }
598 + }
599 + if ( $type === 'border3' ) {
600 + $dims = $this->get_ellipse_dims( $attributes['paginationActiveSize'], $device );
601 + $pagination_active_color_css['width'] = $dims['width'];
602 + $pagination_active_color_css['height'] = $dims['height'];
603 + $pagination_active_color_css['border-radius'] = '9999px';
604 + }
605 + return array_merge(
606 + $pagination_active_color_css,
607 + ( $type === 'border3' ? [] : Range::get_css([
608 + 'attributeValue' => $attributes['paginationActiveSize'],
609 + 'attribute_object_key' => 'value',
610 + 'defaultValue' => 8,
611 + 'isResponsive' => true,
612 + 'hasUnit' => true,
613 + 'unitDefaultValue' => 'px',
614 + 'property' => 'width',
615 + 'device' => $device,
616 + ]) ),
617 + ( $type === 'border3' ? [] : Range::get_css([
618 + 'attributeValue' => $attributes['paginationActiveSize'],
619 + 'attribute_object_key' => 'value',
620 + 'defaultValue' => 8,
621 + 'isResponsive' => true,
622 + 'hasUnit' => true,
623 + 'unitDefaultValue' => 'px',
624 + 'property' => 'height',
625 + 'device' => $device,
626 + ]) ),
627 + Border::get_css( $attributes['activePaginationBorder'], '', $device ),
628 + $this->get_pagination_active_width_css( $attributes, $device ),
629 + );
231 630 }
631 + public function get_pagination_active_color_hover_css( $attributes, $device = '' ) {
632 + $pagination_active_color_css = [];
633 + $type = isset( $attributes['paginationType'] ) ? $attributes['paginationType'] : 'default';
634 + $pagination_active_color_css = [];
635 + if ( isset( $attributes['paginationActiveHoverColor'] ) ) {
636 + $color = Color::get_css( $attributes['paginationActiveHoverColor'] );
637 + if ( $type === 'default' ) {
638 + $pagination_active_color_css['background-color'] = $color;
639 + } elseif ( $type === 'border1' || $type === 'border3' ) {
640 + $pagination_active_color_css['border-color'] = $color;
641 + $pagination_active_color_css['background-color'] = 'transparent';
642 + } elseif ( $type === 'border2' ) {
643 + $pagination_active_color_css['background-color'] = $color;
644 + $pagination_active_color_css['border-color'] = $color;
645 + }
646 + }
647 + if ( $type === 'border3' ) {
648 + $dims = $this->get_ellipse_dims( $attributes['paginationActiveHoverSize'], $device );
649 + $pagination_active_color_css['width'] = $dims['width'];
650 + $pagination_active_color_css['height'] = $dims['height'];
651 + $pagination_active_color_css['border-radius'] = '9999px';
652 + }
232 653
654 + return array_merge(
655 + $pagination_active_color_css,
656 + ( $type === 'border3' ? [] : Range::get_css([
657 + 'attributeValue' => $attributes['paginationActiveHoverSize'],
658 + 'attribute_object_key' => 'value',
659 + 'defaultValue' => 8,
660 + 'isResponsive' => true,
661 + 'hasUnit' => true,
662 + 'unitDefaultValue' => 'px',
663 + 'property' => 'width',
664 + 'device' => $device,
665 + ]) ),
666 + ( $type === 'border3' ? [] : Range::get_css([
667 + 'attributeValue' => $attributes['paginationActiveHoverSize'],
668 + 'attribute_object_key' => 'value',
669 + 'defaultValue' => 8,
670 + 'isResponsive' => true,
671 + 'hasUnit' => true,
672 + 'unitDefaultValue' => 'px',
673 + 'property' => 'height',
674 + 'device' => $device,
675 + ]) ),
676 + Border::get_hover_css( $attributes['activePaginationBorder'], '', $device ),
677 + $this->get_pagination_active_width_css( $attributes, $device ),
678 + );
679 + }
680 +
681 + /**
682 + * Active-slide offset for a device ('' when unused). Only centered Slide
683 + * carousels use it; an explicit 0 is kept so it can override a wider
684 + * device. Mirrors getActiveSlideOffset() in styling.js.
685 + */
686 + public function get_active_slide_offset( $attributes, $device = '' ) {
687 + if (
688 + ( $attributes['effect'] ?? 'slide' ) !== 'slide'
689 + || empty( $attributes['centeredSlides'] )
690 + ) {
691 + return '';
692 + }
693 + $css = Range::get_css([
694 + 'attributeValue' => $attributes['activeSlideOffset'] ?? '',
695 + 'isResponsive' => true,
696 + 'hasUnit' => true,
697 + 'unitDefaultValue' => 'px',
698 + 'property' => 'offset',
699 + 'device' => $device,
700 + ]);
701 + return $css['offset'] ?? '';
702 + }
703 +
704 + public function get_slide_css( $attributes, $device = '' ) {
705 + return '' !== $this->get_active_slide_offset( $attributes, $device )
706 + ? [ 'transition' => 'transform 0.4s ease' ]
707 + : [];
708 + }
709 +
710 + public function get_active_slide_css( $attributes, $device = '' ) {
711 + $offset = $this->get_active_slide_offset( $attributes, $device );
712 + return '' !== $offset ? [ 'transform' => 'translateY(' . $offset . ')' ] : [];
713 + }
714 +
715 + // Pill-shaped active bullet: own width, height stays the Active Size.
716 + private function get_pagination_active_width_css( $attributes, $device = '' ) {
717 + if ( ( $attributes['paginationType'] ?? 'default' ) !== 'default' ) {
718 + return [];
719 + }
720 + $css = Range::get_css([
721 + 'attributeValue' => $attributes['paginationActiveWidth'] ?? '',
722 + 'isResponsive' => true,
723 + 'hasUnit' => true,
724 + 'unitDefaultValue' => 'px',
725 + 'property' => 'width',
726 + 'device' => $device,
727 + ]);
728 + if ( empty( $css['width'] ) ) {
729 + return [];
730 + }
731 + return [
732 + 'width' => $css['width'],
733 + 'border-radius' => '9999px',
734 + 'transition' => 'width 0.3s ease',
735 + ];
736 + }
737 +
738 + /**
739 + * Dimensions only knows the Tablet/Mobile members, so a custom breakpoint
740 + * suffix (or the generator's probe suffix) reads keys that were never
741 + * stored and raises "Undefined array key" notices. Seed those members as
742 + * unset; stored values still win, so the emitted CSS is unchanged.
743 + */
744 + private function with_custom_device_dimension_keys( $value, $device ) {
745 + if ( ! is_array( $value ) || in_array( $device, [ '', 'Tablet', 'Mobile' ], true ) ) {
746 + return $value;
747 + }
748 + return array_merge(
749 + [
750 + 'isLinked' . $device => false,
751 + 'common' . $device => '',
752 + 'top' . $device => '',
753 + 'right' . $device => '',
754 + 'bottom' . $device => '',
755 + 'left' . $device => '',
756 + ],
757 + $value
758 + );
759 + }
760 +
761 + private function get_ellipse_dims( $sizeAttr, $device = '', $default = 8, $ratio = 1.8 ) {
762 + $vKey = 'value' . $device;
763 + $uKey = 'valueUnit' . $device;
764 +
765 + $v = isset( $sizeAttr[ $vKey ] ) ? floatval( $sizeAttr[ $vKey ] )
766 + : ( isset( $sizeAttr['value'] ) ? floatval( $sizeAttr['value'] ) : $default );
767 + $u = isset( $sizeAttr[ $uKey ] ) ? $sizeAttr[ $uKey ]
768 + : ( isset( $sizeAttr['valueUnit'] ) ? $sizeAttr['valueUnit'] : 'px' );
769 +
770 + return [
771 + 'height' => $v . $u,
772 + 'width' => ( $v * $ratio ) . $u,
773 + ];
774 + }
233 775
234 776
235 777 }