PluginProbe ʕ •ᴥ•ʔ
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz / trunk
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz vtrunk
2.12.5 2.12.4 2.12.3 2.12.2 2.12.1 2.12.0 2.11.1 2.11.0 2.10.1 2.10.0 2.9.1 2.9.0 2.8.2 2.8.1 2.7.0 2.7.1 2.8.0 trunk 0.0.10 0.0.11 0.0.12 0.0.13 0.0.2 0.0.3 0.0.4 0.0.5 0.0.6 0.0.7 0.0.8 0.0.9 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.1.0 1.1.1 1.1.2 1.10.0 1.10.1 1.11.0 1.12.0 1.12.1 1.12.2 1.12.3 1.13.0 1.13.1 1.13.2 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.5.0 1.5.1 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.8.0 1.9.0 1.9.1 2.0.0 2.0.1 2.0.2 2.1.0 2.1.1 2.2.0 2.2.1 2.2.2 2.3.0 2.4.0 2.5.0 2.5.2 2.6.0
sureforms / modules / gutenberg / classes / class-spec-block-helper.php
sureforms / modules / gutenberg / classes Last commit date
class-spec-block-config.php 2 years ago class-spec-block-helper.php 1 year ago class-spec-block-js.php 2 years ago class-spec-block-loader.php 2 years ago class-spec-filesystem.php 2 months ago class-spec-gb-helper.php 11 months ago class-spec-init-blocks.php 5 months ago class-spec-spectra-compatibility.php 5 months ago
class-spec-block-helper.php
1249 lines
1 <?php
2 /**
3 * Sureforms Block Helper.
4 *
5 * @package Sureforms
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit; // Exit if accessed directly.
10 }
11
12 if ( ! class_exists( 'Spec_Block_Helper' ) ) {
13
14 /**
15 * Class Spec_Block_Helper.
16 */
17 class Spec_Block_Helper {
18 /**
19 * Get Icon Block CSS
20 *
21 * @since 0.0.1
22 * @param array $attr The block attributes.
23 * @param string $id The selector ID.
24 * @return array The Widget List.
25 */
26 public static function get_icon_css( $attr, $id ) {
27
28 $defaults = Spec_Gb_Helper::$block_list['srfm/icon']['attributes'];
29
30 $attr = array_merge( $defaults, $attr );
31
32 $icon_width = Spec_Gb_Helper::get_css_value( $attr['iconSize'], $attr['iconSizeUnit'] );
33 $transformation = Spec_Gb_Helper::get_css_value( $attr['rotation'], $attr['rotationUnit'] );
34 $background = 'classic' === $attr['iconBackgroundColorType'] ? $attr['iconBackgroundColor'] : $attr['iconBackgroundGradientColor'];
35 $hover_background = 'classic' === $attr['iconHoverBackgroundColorType'] ? $attr['iconHoverBackgroundColor'] : $attr['iconHoverBackgroundGradientColor'];
36
37 $drop_shadow_properties = [
38 'horizontal' => $attr['iconShadowHOffset'],
39 'vertical' => $attr['iconShadowVOffset'],
40 'blur' => $attr['iconShadowBlur'],
41 'color' => $attr['iconShadowColor'],
42 ];
43 $drop_shadow = Spec_Gb_Helper::generate_shadow_css( $drop_shadow_properties );
44
45 $box_shadow_properties = [
46 'horizontal' => $attr['iconBoxShadowHOffset'],
47 'vertical' => $attr['iconBoxShadowVOffset'],
48 'blur' => $attr['iconBoxShadowBlur'],
49 'spread' => $attr['iconBoxShadowSpread'],
50 'color' => $attr['iconBoxShadowColor'],
51 'position' => $attr['iconBoxShadowPosition'],
52 ];
53
54 $box_shadow_hover_properties = [
55 'horizontal' => $attr['iconBoxShadowHOffsetHover'],
56 'vertical' => $attr['iconBoxShadowVOffsetHover'],
57 'blur' => $attr['iconBoxShadowBlurHover'],
58 'spread' => $attr['iconBoxShadowSpreadHover'],
59 'color' => $attr['iconBoxShadowColorHover'],
60 'position' => $attr['iconBoxShadowPositionHover'],
61 'alt_color' => $attr['iconBoxShadowColor'],
62 ];
63
64 $box_shadow = Spec_Gb_Helper::generate_shadow_css( $box_shadow_properties );
65 $box_shadow_hover_css = Spec_Gb_Helper::generate_shadow_css( $box_shadow_hover_properties );
66
67 $t_selectors = [];
68 $m_selectors = [];
69
70 $selectors['.uagb-icon-wrapper'] = [
71 'text-align' => $attr['align'],
72 ];
73 $selectors['.uagb-icon-wrapper .uagb-svg-wrapper a'] = [
74 'display' => 'contents',
75 ];
76 $selectors['.uagb-icon-wrapper svg'] = [
77 'width' => $icon_width,
78 'height' => $icon_width,
79 'transform' => "rotate($transformation)",
80 'box-sizing' => 'content-box',
81 'fill' => $attr['iconColor'],
82 'filter' => $drop_shadow ? "drop-shadow( $drop_shadow )" : '',
83 ];
84 $selectors['.uagb-icon-wrapper .uagb-svg-wrapper:hover svg'] = [
85 'fill' => $attr['iconHoverColor'],
86 ];
87 $selectors['.uagb-icon-wrapper .uagb-svg-wrapper'] = array_merge(
88 [
89 'display' => 'inline-flex',
90 'background' => $background,
91 // padding.
92 'padding-top' => Spec_Gb_Helper::get_css_value( $attr['iconTopPadding'], $attr['iconPaddingUnit'] ),
93 'padding-right' => Spec_Gb_Helper::get_css_value( $attr['iconRightPadding'], $attr['iconPaddingUnit'] ),
94 'padding-bottom' => Spec_Gb_Helper::get_css_value( $attr['iconBottomPadding'], $attr['iconPaddingUnit'] ),
95 'padding-left' => Spec_Gb_Helper::get_css_value( $attr['iconLeftPadding'], $attr['iconPaddingUnit'] ),
96 // margin.
97 'margin-top' => Spec_Gb_Helper::get_css_value( $attr['iconTopMargin'], $attr['iconMarginUnit'] ),
98 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['iconRightMargin'], $attr['iconMarginUnit'] ),
99 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['iconBottomMargin'], $attr['iconMarginUnit'] ),
100 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['iconLeftMargin'], $attr['iconMarginUnit'] ),
101 // border.
102 'border-style' => $attr['iconBorderStyle'],
103 'border-color' => $attr['iconBorderColor'],
104 'box-shadow' => $box_shadow,
105 ],
106 self::generate_border_css( $attr, 'icon' )
107 );
108 $selectors['.uagb-icon-wrapper .uagb-svg-wrapper:hover'] = [
109 'border-color' => $attr['iconBorderHColor'],
110 'background' => $hover_background,
111 ];
112
113 // If using separate box shadow hover settings, then generate CSS for it.
114 if ( $attr['useSeparateBoxShadows'] ) {
115 $selectors['.uagb-icon-wrapper .uagb-svg-wrapper:hover'] = [
116 'box-shadow' => $box_shadow_hover_css,
117 'border-color' => $attr['iconBorderHColor'],
118 'background' => $hover_background,
119 ];
120
121 };
122
123 // Generates css for tablet devices.
124 $t_icon_width = Spec_Gb_Helper::get_css_value( $attr['iconSizeTablet'], $attr['iconSizeUnit'] );
125 $t_selectors['.uagb-icon-wrapper'] = [
126 'text-align' => $attr['alignTablet'],
127 ];
128 $t_selectors['.uagb-icon-wrapper svg'] = [
129 'width' => $t_icon_width,
130 'height' => $t_icon_width,
131 ];
132 $t_selectors['.uagb-icon-wrapper .uagb-svg-wrapper'] = array_merge(
133 [
134 'display' => 'inline-flex',
135 'padding-top' => Spec_Gb_Helper::get_css_value( $attr['iconTopTabletPadding'], $attr['iconTabletPaddingUnit'] ),
136 'padding-right' => Spec_Gb_Helper::get_css_value( $attr['iconRightTabletPadding'], $attr['iconTabletPaddingUnit'] ),
137 'padding-bottom' => Spec_Gb_Helper::get_css_value( $attr['iconBottomTabletPadding'], $attr['iconTabletPaddingUnit'] ),
138 'padding-left' => Spec_Gb_Helper::get_css_value( $attr['iconLeftTabletPadding'], $attr['iconTabletPaddingUnit'] ),
139 'margin-top' => Spec_Gb_Helper::get_css_value( $attr['iconTopTabletMargin'], $attr['iconTabletMarginUnit'] ),
140 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['iconRightTabletMargin'], $attr['iconTabletMarginUnit'] ),
141 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['iconBottomTabletMargin'], $attr['iconTabletMarginUnit'] ),
142 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['iconLeftTabletMargin'], $attr['iconTabletMarginUnit'] ),
143 ],
144 self::generate_border_css( $attr, 'icon', 'tablet' )
145 );
146
147 // Generates css for mobile devices.
148 $m_icon_width = Spec_Gb_Helper::get_css_value( $attr['iconSizeMobile'], $attr['iconSizeUnit'] );
149 $m_selectors['.uagb-icon-wrapper'] = [
150 'text-align' => $attr['alignMobile'],
151 ];
152 $m_selectors['.uagb-icon-wrapper svg'] = [
153 'width' => $m_icon_width,
154 'height' => $m_icon_width,
155 ];
156 $m_selectors['.uagb-icon-wrapper .uagb-svg-wrapper'] = array_merge(
157 [
158 'display' => 'inline-flex',
159 'padding-top' => Spec_Gb_Helper::get_css_value( $attr['iconTopMobilePadding'], $attr['iconMobilePaddingUnit'] ),
160 'padding-right' => Spec_Gb_Helper::get_css_value( $attr['iconRightMobilePadding'], $attr['iconMobilePaddingUnit'] ),
161 'padding-bottom' => Spec_Gb_Helper::get_css_value( $attr['iconBottomMobilePadding'], $attr['iconMobilePaddingUnit'] ),
162 'padding-left' => Spec_Gb_Helper::get_css_value( $attr['iconLeftMobilePadding'], $attr['iconMobilePaddingUnit'] ),
163 'margin-top' => Spec_Gb_Helper::get_css_value( $attr['iconTopMobileMargin'], $attr['iconMobileMarginUnit'] ),
164 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['iconRightMobileMargin'], $attr['iconMobileMarginUnit'] ),
165 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['iconBottomMobileMargin'], $attr['iconMobileMarginUnit'] ),
166 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['iconLeftMobileMargin'], $attr['iconMobileMarginUnit'] ),
167 ],
168 self::generate_border_css( $attr, 'icon', 'mobile' )
169 );
170
171 $combined_selectors = [
172 'desktop' => $selectors,
173 'tablet' => $t_selectors,
174 'mobile' => $m_selectors,
175 ];
176
177 return Spec_Gb_Helper::generate_all_css( $combined_selectors, ' .uagb-block-' . $id );
178 }
179
180 /**
181 * Get Image Block CSS
182 *
183 * @since 0.0.1
184 * @param array $attr The block attributes.
185 * @param string $id The selector ID.
186 * @return array The Widget List.
187 */
188 public static function get_image_css( $attr, $id ) {
189
190 $defaults = Spec_Gb_Helper::$block_list['srfm/image']['attributes'];
191
192 $attr = array_merge( $defaults, $attr );
193
194 $m_selectors = [];
195 $t_selectors = [];
196
197 $image_border_css = self::generate_border_css( $attr, 'image' );
198 $image_border_css_tablet = self::generate_border_css( $attr, 'image', 'tablet' );
199 $image_border_css_mobile = self::generate_border_css( $attr, 'image', 'mobile' );
200 $overlay_border_css = self::generate_border_css( $attr, 'overlay' );
201 $overlay_border_css_tablet = self::generate_border_css( $attr, 'overlay', 'tablet' );
202 $overlay_border_css_mobile = self::generate_border_css( $attr, 'overlay', 'mobile' );
203
204 $width_tablet = '' !== $attr['widthTablet'] ? $attr['widthTablet'] . 'px' : $attr['width'] . 'px';
205 $width_mobile = '' !== $attr['widthMobile'] ? $attr['widthMobile'] . 'px' : $width_tablet;
206
207 $height_tablet = '' !== $attr['heightTablet'] ? $attr['heightTablet'] . 'px' : $attr['height'] . 'px';
208 $height_mobile = '' !== $attr['heightMobile'] ? $attr['heightMobile'] . 'px' : $height_tablet;
209
210 $align = '';
211 $align_tablet = '';
212 $align_mobile = '';
213
214 switch ( $attr['align'] ) {
215 case 'left':
216 $align = 'flex-start';
217 break;
218 case 'right':
219 $align = 'flex-end';
220 break;
221 case 'center':
222 $align = 'center';
223 break;
224 }
225
226 switch ( $attr['alignTablet'] ) {
227 case 'left':
228 $align_tablet = 'flex-start';
229 break;
230 case 'right':
231 $align_tablet = 'flex-end';
232 break;
233 case 'center':
234 $align_tablet = 'center';
235 break;
236 }
237
238 switch ( $attr['alignMobile'] ) {
239 case 'left':
240 $align_mobile = 'flex-start';
241 break;
242 case 'right':
243 $align_mobile = 'flex-end';
244 break;
245 case 'center':
246 $align_mobile = 'center';
247 break;
248 }
249
250 $box_shadow_properties = [
251 'horizontal' => $attr['imageBoxShadowHOffset'],
252 'vertical' => $attr['imageBoxShadowVOffset'],
253 'blur' => $attr['imageBoxShadowBlur'],
254 'spread' => $attr['imageBoxShadowSpread'],
255 'color' => $attr['imageBoxShadowColor'],
256 'position' => $attr['imageBoxShadowPosition'],
257 ];
258 $box_shadow_hover_properties = [
259 'horizontal' => $attr['imageBoxShadowHOffsetHover'],
260 'vertical' => $attr['imageBoxShadowVOffsetHover'],
261 'blur' => $attr['imageBoxShadowBlurHover'],
262 'spread' => $attr['imageBoxShadowSpreadHover'],
263 'color' => $attr['imageBoxShadowColorHover'],
264 'position' => $attr['imageBoxShadowPositionHover'],
265 'alt_color' => $attr['imageBoxShadowColor'],
266 ];
267
268 $box_shadow_css = Spec_Gb_Helper::generate_shadow_css( $box_shadow_properties );
269 $box_shadow_hover_css = Spec_Gb_Helper::generate_shadow_css( $box_shadow_hover_properties );
270
271 $selectors = [
272 '.wp-block-uagb-image' => [
273 'margin-top' => Spec_Gb_Helper::get_css_value( $attr['imageTopMargin'], $attr['imageMarginUnit'] ),
274 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['imageRightMargin'], $attr['imageMarginUnit'] ),
275 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['imageBottomMargin'], $attr['imageMarginUnit'] ),
276 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['imageLeftMargin'], $attr['imageMarginUnit'] ),
277 'text-align' => $attr['align'],
278 'justify-content' => $align,
279 'align-self' => $align,
280 ],
281 ' .wp-block-uagb-image__figure' => [
282 'align-items' => $align,
283 ],
284 '.wp-block-uagb-image--layout-default figure img' => array_merge(
285 [
286 'box-shadow' => $box_shadow_css,
287 ],
288 $image_border_css
289 ),
290 '.wp-block-uagb-image .wp-block-uagb-image__figure img:hover' => [
291 'border-color' => $attr['imageBorderHColor'],
292 ],
293 '.wp-block-uagb-image .wp-block-uagb-image__figure figcaption' => [
294 'color' => $attr['captionColor'],
295 'margin-top' => Spec_Gb_Helper::get_css_value( $attr['captionTopMargin'], $attr['captionMarginUnit'] ),
296 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['captionRightMargin'], $attr['captionMarginUnit'] ),
297 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['captionBottomMargin'], $attr['captionMarginUnit'] ),
298 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['captionLeftMargin'], $attr['captionMarginUnit'] ),
299 'text-align' => $attr['captionAlign'],
300 ],
301 '.wp-block-uagb-image .wp-block-uagb-image__figure figcaption a' => [
302 'color' => $attr['captionColor'],
303 ],
304 // overlay.
305 '.wp-block-uagb-image--layout-overlay figure img' => array_merge(
306 [
307 'box-shadow' => $box_shadow_css,
308 ],
309 $image_border_css
310 ),
311 '.wp-block-uagb-image--layout-overlay .wp-block-uagb-image--layout-overlay__color-wrapper' => array_merge(
312 [
313 'background' => $attr['overlayBackground'],
314 'opacity' => $attr['overlayOpacity'],
315 ],
316 $image_border_css
317 ),
318 '.wp-block-uagb-image--layout-overlay .wp-block-uagb-image--layout-overlay__color-wrapper:hover' => [
319 'border-color' => $attr['imageBorderHColor'],
320 ],
321 '.wp-block-uagb-image--layout-overlay .wp-block-uagb-image--layout-overlay__inner' => array_merge(
322 $overlay_border_css,
323 [
324 'left' => Spec_Gb_Helper::get_css_value( $attr['overlayPositionFromEdge'], $attr['overlayPositionFromEdgeUnit'] ),
325 'right' => Spec_Gb_Helper::get_css_value( $attr['overlayPositionFromEdge'], $attr['overlayPositionFromEdgeUnit'] ),
326 'top' => Spec_Gb_Helper::get_css_value( $attr['overlayPositionFromEdge'], $attr['overlayPositionFromEdgeUnit'] ),
327 'bottom' => Spec_Gb_Helper::get_css_value( $attr['overlayPositionFromEdge'], $attr['overlayPositionFromEdgeUnit'] ),
328 ]
329 ),
330 '.wp-block-uagb-image--layout-overlay .wp-block-uagb-image--layout-overlay__inner .uagb-image-heading' => [
331 'color' => $attr['headingColor'],
332 'margin-top' => Spec_Gb_Helper::get_css_value( $attr['headingTopMargin'], $attr['headingMarginUnit'] ),
333 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['headingRightMargin'], $attr['headingMarginUnit'] ),
334 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['headingBottomMargin'], $attr['headingMarginUnit'] ),
335 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['headingLeftMargin'], $attr['headingMarginUnit'] ),
336 'opacity' => 'always' === $attr['headingShowOn'] ? 1 : 0,
337 ],
338 '.wp-block-uagb-image--layout-overlay .wp-block-uagb-image--layout-overlay__inner .uagb-image-heading a' => [
339 'color' => $attr['headingColor'],
340 ],
341 '.wp-block-uagb-image--layout-overlay .wp-block-uagb-image--layout-overlay__inner .uagb-image-caption' => [
342 'opacity' => 'always' === $attr['captionShowOn'] ? 1 : 0,
343 ],
344 '.wp-block-uagb-image--layout-overlay .wp-block-uagb-image__figure:hover .wp-block-uagb-image--layout-overlay__inner' => [
345 'border-color' => $attr['overlayBorderHColor'],
346 ],
347 '.wp-block-uagb-image--layout-overlay .wp-block-uagb-image__figure:hover .wp-block-uagb-image--layout-overlay__color-wrapper' => [
348 'opacity' => $attr['overlayHoverOpacity'],
349 ],
350 // separator.
351 '.wp-block-uagb-image .wp-block-uagb-image--layout-overlay__inner .uagb-image-separator' => [
352 'width' => Spec_Gb_Helper::get_css_value( $attr['separatorWidth'], $attr['separatorWidthType'] ),
353 'border-top-width' => Spec_Gb_Helper::get_css_value( $attr['separatorThickness'], $attr['separatorThicknessUnit'] ),
354 'border-top-color' => $attr['separatorColor'],
355 'border-top-style' => $attr['separatorStyle'],
356 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['separatorBottomMargin'], $attr['separatorMarginUnit'] ),
357 'margin-top' => Spec_Gb_Helper::get_css_value( $attr['separatorTopMargin'], $attr['separatorMarginUnit'] ),
358 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['separatorLeftMargin'], $attr['separatorMarginUnit'] ),
359 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['separatorRightMargin'], $attr['separatorMarginUnit'] ),
360 'opacity' => 'always' === $attr['separatorShowOn'] ? 1 : 0,
361 ],
362 ];
363
364 $selectors['.wp-block-uagb-image .wp-block-uagb-image__figure img'] = [
365 'object-fit' => $attr['objectFit'],
366 'width' => $attr['width'] . 'px',
367 'height' => 'auto',
368 ];
369 if ( $attr['customHeightSetDesktop'] ) {
370 $selectors['.wp-block-uagb-image .wp-block-uagb-image__figure img']['height'] = $attr['height'] . 'px';
371 }
372
373 if ( 'hover' === $attr['headingShowOn'] ) {
374 $selectors['.wp-block-uagb-image .wp-block-uagb-image__figure:hover .wp-block-uagb-image--layout-overlay__inner .uagb-image-heading'] = [
375 'opacity' => 1,
376 ];
377 }
378 if ( 'hover' === $attr['captionShowOn'] ) {
379 $selectors['.wp-block-uagb-image .wp-block-uagb-image__figure:hover .wp-block-uagb-image--layout-overlay__inner .uagb-image-caption'] = [
380 'opacity' => 1,
381 ];
382 }
383 if ( 'hover' === $attr['separatorShowOn'] ) {
384 $selectors['.wp-block-uagb-image .wp-block-uagb-image__figure:hover .wp-block-uagb-image--layout-overlay__inner .uagb-image-separator'] = [
385 'opacity' => 1,
386 ];
387 }
388
389 // If using separate box shadow hover settings, then generate CSS for it.
390 if ( $attr['useSeparateBoxShadows'] ) {
391 $selectors['.wp-block-uagb-image--layout-default figure img:hover'] = [
392 'box-shadow' => $box_shadow_hover_css,
393 ];
394
395 $selectors['.wp-block-uagb-image--layout-overlay figure img:hover'] = [
396 'box-shadow' => $box_shadow_hover_css,
397 ];
398
399 };
400
401 if ( 'none' !== $attr['maskShape'] ) {
402 $image_path = SRFM_URL . 'assets/images/masks/' . $attr['maskShape'] . '.svg';
403 if ( 'custom' === $attr['maskShape'] ) {
404 $image_path = $attr['maskCustomShape']['url'];
405 }
406 if ( ! empty( $image_path ) ) {
407 $selectors[ '.wp-block-uagb-image .wp-block-uagb-image__figure img, .uagb-block-' . $id . ' .wp-block-uagb-image--layout-overlay__color-wrapper' ] = [
408 'mask-image' => 'url(' . $image_path . ')',
409 '-webkit-mask-image' => 'url(' . $image_path . ')',
410 'mask-size' => $attr['maskSize'],
411 '-webkit-mask-size' => $attr['maskSize'],
412 'mask-repeat' => $attr['maskRepeat'],
413 '-webkit-mask-repeat' => $attr['maskRepeat'],
414 'mask-position' => $attr['maskPosition'],
415 '-webkit-mask-position' => $attr['maskPosition'],
416 ];
417 }
418 }
419
420 // tablet.
421 $t_selectors['.wp-block-uagb-image--layout-default figure img'] = $image_border_css_tablet;
422 $t_selectors['.wp-block-uagb-image--layout-overlay figure img'] = $image_border_css_tablet;
423 $t_selectors['.wp-block-uagb-image .wp-block-uagb-image__figure img'] = [
424 'width' => Spec_Gb_Helper::get_css_value( $attr['widthTablet'], 'px' ),
425 ];
426 $t_selectors['.wp-block-uagb-image'] = [
427 'margin-top' => Spec_Gb_Helper::get_css_value( $attr['imageTopMarginTablet'], $attr['imageMarginUnitTablet'] ),
428 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['imageRightMarginTablet'], $attr['imageMarginUnitTablet'] ),
429 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['imageBottomMarginTablet'], $attr['imageMarginUnitTablet'] ),
430 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['imageLeftMarginTablet'], $attr['imageMarginUnitTablet'] ),
431 'text-align' => $attr['alignTablet'],
432 'justify-content' => $align_tablet,
433 'align-self' => $align_tablet,
434 ];
435 $t_selectors[' .wp-block-uagb-image__figure'] = [
436 'align-items' => $align_tablet,
437 ];
438 $t_selectors['.wp-block-uagb-image .wp-block-uagb-image__figure figcaption'] = [
439 'margin-top' => Spec_Gb_Helper::get_css_value( $attr['captionTopMarginTablet'], $attr['captionMarginUnitTablet'] ),
440 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['captionRightMarginTablet'], $attr['captionMarginUnitTablet'] ),
441 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['captionBottomMarginTablet'], $attr['captionMarginUnitTablet'] ),
442 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['captionLeftMarginTablet'], $attr['captionMarginUnitTablet'] ),
443 ];
444 $t_selectors['.wp-block-uagb-image--layout-overlay .wp-block-uagb-image--layout-overlay__inner'] = $overlay_border_css_tablet;
445 $t_selectors['.wp-block-uagb-image .wp-block-uagb-image--layout-overlay__inner .uagb-image-heading'] = [
446 'margin-top' => Spec_Gb_Helper::get_css_value( $attr['headingTopMarginTablet'], $attr['headingMarginUnitTablet'] ),
447 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['headingRightMarginTablet'], $attr['headingMarginUnitTablet'] ),
448 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['headingBottomMarginTablet'], $attr['headingMarginUnitTablet'] ),
449 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['headingLeftMarginTablet'], $attr['headingMarginUnitTablet'] ),
450 ];
451 $t_selectors['.wp-block-uagb-image .wp-block-uagb-image--layout-overlay__inner .uagb-image-separator'] = [
452 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['separatorBottomMarginTablet'], $attr['separatorMarginUnitTablet'] ),
453 'margin-top' => Spec_Gb_Helper::get_css_value( $attr['separatorTopMarginTablet'], $attr['separatorMarginUnitTablet'] ),
454 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['separatorLeftMarginTablet'], $attr['separatorMarginUnitTablet'] ),
455 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['separatorRightMarginTablet'], $attr['separatorMarginUnitTablet'] ),
456 ];
457
458 $t_selectors['.wp-block-uagb-image .wp-block-uagb-image__figure img'] = [
459 'object-fit' => $attr['objectFitTablet'],
460 'width' => $width_tablet,
461 'height' => 'auto',
462 ];
463
464 if ( $attr['customHeightSetTablet'] ) {
465 $t_selectors['.wp-block-uagb-image .wp-block-uagb-image__figure img']['height'] = $height_tablet;
466 }
467
468 // mobile.
469 $m_selectors['.wp-block-uagb-image--layout-default figure img'] = $image_border_css_mobile;
470 $m_selectors['.wp-block-uagb-image--layout-overlay figure img'] = $image_border_css_mobile;
471 $m_selectors['.wp-block-uagb-image .wp-block-uagb-image__figure img'] = [
472 'width' => Spec_Gb_Helper::get_css_value( $attr['widthMobile'], 'px' ),
473 ];
474 $m_selectors['.wp-block-uagb-image'] = [
475 'margin-top' => Spec_Gb_Helper::get_css_value( $attr['imageTopMarginMobile'], $attr['imageMarginUnitMobile'] ),
476 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['imageRightMarginMobile'], $attr['imageMarginUnitMobile'] ),
477 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['imageBottomMarginMobile'], $attr['imageMarginUnitMobile'] ),
478 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['imageLeftMarginMobile'], $attr['imageMarginUnitMobile'] ),
479 'text-align' => $attr['alignMobile'],
480 'justify-content' => $align_mobile,
481 'align-self' => $align_mobile,
482 ];
483 $m_selectors[' .wp-block-uagb-image__figure'] = [
484 'align-items' => $align_mobile,
485 ];
486 $m_selectors['.wp-block-uagb-image .wp-block-uagb-image__figure figcaption'] = [
487 'margin-top' => Spec_Gb_Helper::get_css_value( $attr['captionTopMarginMobile'], $attr['captionMarginUnitMobile'] ),
488 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['captionRightMarginMobile'], $attr['captionMarginUnitMobile'] ),
489 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['captionBottomMarginMobile'], $attr['captionMarginUnitMobile'] ),
490 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['captionLeftMarginMobile'], $attr['captionMarginUnitMobile'] ),
491 ];
492
493 $m_selectors['.wp-block-uagb-image .wp-block-uagb-image--layout-overlay__inner .uagb-image-heading'] = [
494 'margin-top' => Spec_Gb_Helper::get_css_value( $attr['headingTopMarginMobile'], $attr['headingMarginUnitMobile'] ),
495 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['headingRightMarginMobile'], $attr['headingMarginUnitMobile'] ),
496 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['headingBottomMarginMobile'], $attr['headingMarginUnitMobile'] ),
497 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['headingLeftMarginMobile'], $attr['headingMarginUnitMobile'] ),
498 ];
499 $m_selectors['.wp-block-uagb-image--layout-overlay .wp-block-uagb-image--layout-overlay__inner'] = $overlay_border_css_mobile;
500 $m_selectors['.wp-block-uagb-image .wp-block-uagb-image--layout-overlay__inner .uagb-image-separator'] = [
501 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['separatorBottomMarginMobile'], $attr['separatorMarginUnitMobile'] ),
502 'margin-top' => Spec_Gb_Helper::get_css_value( $attr['separatorTopMarginMobile'], $attr['separatorMarginUnitMobile'] ),
503 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['separatorLeftMarginMobile'], $attr['separatorMarginUnitMobile'] ),
504 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['separatorRightMarginMobile'], $attr['separatorMarginUnitMobile'] ),
505 ];
506
507 $m_selectors['.wp-block-uagb-image .wp-block-uagb-image__figure img'] = [
508 'object-fit' => $attr['objectFitMobile'],
509 'width' => $width_mobile,
510 'height' => 'auto',
511 ];
512
513 if ( $attr['customHeightSetMobile'] ) {
514 $m_selectors['.wp-block-uagb-image .wp-block-uagb-image__figure img']['height'] = $height_mobile;
515 }
516
517 $combined_selectors = [
518 'desktop' => $selectors,
519 'tablet' => $t_selectors,
520 'mobile' => $m_selectors,
521 ];
522
523 $combined_selectors = Spec_Gb_Helper::get_typography_css( $attr, 'heading', '.wp-block-uagb-image--layout-overlay .wp-block-uagb-image--layout-overlay__inner .uagb-image-heading', $combined_selectors );
524 $combined_selectors = Spec_Gb_Helper::get_typography_css( $attr, 'caption', '.wp-block-uagb-image .wp-block-uagb-image__figure figcaption', $combined_selectors );
525
526 return Spec_Gb_Helper::generate_all_css( $combined_selectors, ' .uagb-block-' . $id );
527 }
528
529 /**
530 * Get Heading Block CSS
531 *
532 * @since 0.0.1
533 * @param array $attr The block attributes.
534 * @param string $id The selector ID.
535 * @return array The Widget List.
536 */
537 public static function get_advanced_heading_css( $attr, $id ) {
538 $defaults = Spec_Gb_Helper::$block_list['srfm/advanced-heading']['attributes'];
539
540 $attr = array_merge( $defaults, $attr );
541
542 $t_selectors = [];
543 $m_selectors = [];
544 $selectors = [];
545
546 $high_light_border_css = self::generate_border_css( $attr, 'highLight' );
547 $high_light_border_css_tablet = self::generate_border_css( $attr, 'highLight', 'tablet' );
548 $high_light_border_css_mobile = self::generate_border_css( $attr, 'highLight', 'mobile' );
549
550 $selectors = [
551 '.wp-block-uagb-advanced-heading .uagb-heading-text' => [
552 'color' => $attr['headingColor'],
553 ],
554 '.wp-block-uagb-advanced-heading ' => [
555 'background' => 'classic' === $attr['blockBackgroundType'] ? $attr['blockBackground'] : $attr['blockGradientBackground'],
556 'text-align' => $attr['headingAlign'],
557 'margin-top' => Spec_Gb_Helper::get_css_value(
558 $attr['blockTopMargin'],
559 $attr['blockMarginUnit']
560 ),
561 'margin-right' => Spec_Gb_Helper::get_css_value(
562 $attr['blockRightMargin'],
563 $attr['blockMarginUnit']
564 ),
565 'margin-bottom' => Spec_Gb_Helper::get_css_value(
566 $attr['blockBottomMargin'],
567 $attr['blockMarginUnit']
568 ),
569 'margin-left' => Spec_Gb_Helper::get_css_value(
570 $attr['blockLeftMargin'],
571 $attr['blockMarginUnit']
572 ),
573 'padding-top' => Spec_Gb_Helper::get_css_value(
574 $attr['blockTopPadding'],
575 $attr['blockPaddingUnit']
576 ),
577 'padding-right' => Spec_Gb_Helper::get_css_value(
578 $attr['blockRightPadding'],
579 $attr['blockPaddingUnit']
580 ),
581 'padding-bottom' => Spec_Gb_Helper::get_css_value(
582 $attr['blockBottomPadding'],
583 $attr['blockPaddingUnit']
584 ),
585 'padding-left' => Spec_Gb_Helper::get_css_value(
586 $attr['blockLeftPadding'],
587 $attr['blockPaddingUnit']
588 ),
589 ],
590 '.wp-block-uagb-advanced-heading a' => [
591 'color' => $attr['linkColor'],
592 ],
593 '.wp-block-uagb-advanced-heading a:hover' => [
594 'color' => $attr['linkHColor'],
595 ],
596 '.wp-block-uagb-advanced-heading .uagb-desc-text' => [
597 'color' => $attr['subHeadingColor'],
598 'margin-bottom' => Spec_Gb_Helper::get_css_value(
599 $attr['subHeadSpace'],
600 'px'
601 ),
602 ],
603 '.wp-block-uagb-advanced-heading .srfm-highlight' => array_merge(
604 [
605 'background' => $attr['highLightBackground'],
606 'color' => $attr['highLightColor'],
607 '-webkit-text-fill-color' => $attr['highLightColor'],
608 'font-family' => $attr['highLightFontFamily'],
609 'font-style' => $attr['highLightFontStyle'],
610 'text-decoration' => $attr['highLightDecoration'],
611 'text-transform' => $attr['highLightTransform'],
612 'font-weight' => $attr['highLightFontWeight'],
613 'font-size' => Spec_Gb_Helper::get_css_value( $attr['highLightFontSize'], $attr['highLightFontSizeType'] ),
614 'line-height' => Spec_Gb_Helper::get_css_value( $attr['highLightLineHeight'], $attr['highLightLineHeightType'] ),
615 'padding-top' => Spec_Gb_Helper::get_css_value(
616 $attr['highLightTopPadding'],
617 $attr['highLightPaddingUnit']
618 ),
619 'padding-right' => Spec_Gb_Helper::get_css_value(
620 $attr['highLightRightPadding'],
621 $attr['highLightPaddingUnit']
622 ),
623 'padding-bottom' => Spec_Gb_Helper::get_css_value(
624 $attr['highLightBottomPadding'],
625 $attr['highLightPaddingUnit']
626 ),
627 'padding-left' => Spec_Gb_Helper::get_css_value(
628 $attr['highLightLeftPadding'],
629 $attr['highLightPaddingUnit']
630 ),
631
632 ],
633 $high_light_border_css
634 ),
635 '.wp-block-uagb-advanced-heading .srfm-highlight:hover' => [
636 'border-color' => $attr['highLightBorderHColor'],
637 ],
638 ];
639
640 $heading_text_shadow_color = ( ! empty( $attr['headShadowColor'] ) ? Spec_Gb_Helper::get_css_value( $attr['headShadowHOffset'], 'px' ) . ' ' . Spec_Gb_Helper::get_css_value( $attr['headShadowVOffset'], 'px' ) . ' ' . Spec_Gb_Helper::get_css_value( $attr['headShadowBlur'], 'px' ) . ' ' . $attr['headShadowColor'] : '' );
641
642 if ( 'gradient' === $attr['headingColorType'] ) {
643 $selectors['.wp-block-uagb-advanced-heading .uagb-heading-text'] = array_merge(
644 $selectors['.wp-block-uagb-advanced-heading .uagb-heading-text'],
645 [
646 'background' => $attr['headingGradientColor'],
647 '-webkit-background-clip' => 'text',
648 '-webkit-text-fill-color' => 'transparent',
649 'filter' => 'drop-shadow( ' . $heading_text_shadow_color . ' )',
650 ]
651 );
652 $selectors['.wp-block-uagb-advanced-heading a'] = array_merge(
653 $selectors['.wp-block-uagb-advanced-heading a'],
654 [
655 '-webkit-text-fill-color' => $attr['linkColor'],
656 ]
657 );
658 $selectors['.wp-block-uagb-advanced-heading a:hover'] = array_merge(
659 $selectors['.wp-block-uagb-advanced-heading a:hover'],
660 [
661 '-webkit-text-fill-color' => $attr['linkHColor'],
662 ]
663 );
664 } else {
665 $selectors['.wp-block-uagb-advanced-heading .uagb-heading-text'] = array_merge(
666 $selectors['.wp-block-uagb-advanced-heading .uagb-heading-text'],
667 [
668 'text-shadow' => $heading_text_shadow_color,
669 ]
670 );
671 }
672
673 // Text Selection & highlight.
674 $highlight_selection_text = [
675 'color' => $attr['highLightColor'],
676 'background' => $attr['highLightBackground'],
677 '-webkit-text-fill-color' => $attr['highLightColor'],
678 ];
679
680 $selectors['.wp-block-uagb-advanced-heading .srfm-highlight::-moz-selection'] = $highlight_selection_text;
681 $selectors['.wp-block-uagb-advanced-heading .srfm-highlight::selection'] = $highlight_selection_text;
682
683 $separator_style = isset( $attr['separatorStyle'] ) ? $attr['separatorStyle'] : '';
684
685 if ( 'none' !== $separator_style ) {
686 $selectors['.wp-block-uagb-advanced-heading .uagb-separator'] = [
687 'border-top-style' => $attr['separatorStyle'],
688 'border-top-width' => Spec_Gb_Helper::get_css_value(
689 $attr['separatorHeight'],
690 $attr['separatorHeightType']
691 ),
692 'width' => Spec_Gb_Helper::get_css_value(
693 $attr['separatorWidth'],
694 $attr['separatorWidthType']
695 ),
696 'border-color' => $attr['separatorColor'],
697 'margin-bottom' => Spec_Gb_Helper::get_css_value(
698 $attr['separatorSpace'],
699 $attr['separatorSpaceType']
700 ),
701 ];
702 $t_selectors['.wp-block-uagb-advanced-heading .uagb-separator'] = [
703 'width' => Spec_Gb_Helper::get_css_value(
704 $attr['separatorWidthTablet'],
705 $attr['separatorWidthType']
706 ),
707 'margin-bottom' => Spec_Gb_Helper::get_css_value(
708 $attr['separatorSpaceTablet'],
709 $attr['separatorSpaceType']
710 ),
711 ];
712 $m_selectors['.wp-block-uagb-advanced-heading .uagb-separator'] = [
713 'width' => Spec_Gb_Helper::get_css_value(
714 $attr['separatorWidthMobile'],
715 $attr['separatorWidthType']
716 ),
717 'margin-bottom' => Spec_Gb_Helper::get_css_value(
718 $attr['separatorSpaceMobile'],
719 $attr['separatorSpaceType']
720 ),
721 ];
722 }
723 $t_selectors['.wp-block-uagb-advanced-heading '] = [
724 'text-align' => $attr['headingAlignTablet'],
725 'padding-top' => Spec_Gb_Helper::get_css_value( $attr['blockTopPaddingTablet'], $attr['blockPaddingUnitTablet'] ),
726 'padding-right' => Spec_Gb_Helper::get_css_value( $attr['blockRightPaddingTablet'], $attr['blockPaddingUnitTablet'] ),
727 'padding-bottom' => Spec_Gb_Helper::get_css_value( $attr['blockBottomPaddingTablet'], $attr['blockPaddingUnitTablet'] ),
728 'padding-left' => Spec_Gb_Helper::get_css_value( $attr['blockLeftPaddingTablet'], $attr['blockPaddingUnitTablet'] ),
729 'margin-top' => Spec_Gb_Helper::get_css_value( $attr['blockTopMarginTablet'], $attr['blockMarginUnitTablet'] ),
730 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['blockRightMarginTablet'], $attr['blockMarginUnitTablet'] ),
731 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['blockBottomMarginTablet'], $attr['blockMarginUnitTablet'] ),
732 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['blockLeftMarginTablet'], $attr['blockMarginUnitTablet'] ),
733 ];
734
735 $t_selectors['.wp-block-uagb-advanced-heading .srfm-highlight'] = array_merge(
736 [
737 'padding-top' => Spec_Gb_Helper::get_css_value( $attr['highLightTopPaddingTablet'], $attr['highLightPaddingUnitTablet'] ),
738 'padding-right' => Spec_Gb_Helper::get_css_value( $attr['highLightRightPaddingTablet'], $attr['highLightPaddingUnitTablet'] ),
739 'padding-bottom' => Spec_Gb_Helper::get_css_value( $attr['highLightBottomPaddingTablet'], $attr['highLightPaddingUnitTablet'] ),
740 'padding-left' => Spec_Gb_Helper::get_css_value( $attr['highLightLeftPaddingTablet'], $attr['highLightPaddingUnitTablet'] ),
741 ],
742 $high_light_border_css_tablet
743 );
744
745 $m_selectors['.wp-block-uagb-advanced-heading '] = [
746 'text-align' => $attr['headingAlignMobile'],
747 'padding-top' => Spec_Gb_Helper::get_css_value( $attr['blockTopPaddingMobile'], $attr['blockPaddingUnitMobile'] ),
748 'padding-right' => Spec_Gb_Helper::get_css_value( $attr['blockRightPaddingMobile'], $attr['blockPaddingUnitMobile'] ),
749 'padding-bottom' => Spec_Gb_Helper::get_css_value( $attr['blockBottomPaddingMobile'], $attr['blockPaddingUnitMobile'] ),
750 'padding-left' => Spec_Gb_Helper::get_css_value( $attr['blockLeftPaddingMobile'], $attr['blockPaddingUnitMobile'] ),
751 'margin-top' => Spec_Gb_Helper::get_css_value( $attr['blockTopMarginMobile'], $attr['blockMarginUnitMobile'] ),
752 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['blockRightMarginMobile'], $attr['blockMarginUnitMobile'] ),
753 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['blockBottomMarginMobile'], $attr['blockMarginUnitMobile'] ),
754 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['blockLeftMarginMobile'], $attr['blockMarginUnitMobile'] ),
755 ];
756 $m_selectors['.wp-block-uagb-advanced-heading .srfm-highlight'] = array_merge(
757 [
758 'padding-top' => Spec_Gb_Helper::get_css_value( $attr['highLightTopPaddingMobile'], $attr['highLightPaddingUnitMobile'] ),
759 'padding-right' => Spec_Gb_Helper::get_css_value( $attr['highLightRightPaddingMobile'], $attr['highLightPaddingUnitMobile'] ),
760 'padding-bottom' => Spec_Gb_Helper::get_css_value( $attr['highLightBottomPaddingMobile'], $attr['highLightPaddingUnitMobile'] ),
761 'padding-left' => Spec_Gb_Helper::get_css_value( $attr['highLightLeftPaddingMobile'], $attr['highLightPaddingUnitMobile'] ),
762 ],
763 $high_light_border_css_mobile
764 );
765
766 $t_selectors['.wp-block-uagb-advanced-heading .uagb-desc-text'] = [
767 'margin-bottom' => Spec_Gb_Helper::get_css_value(
768 $attr['subHeadSpaceTablet'],
769 $attr['subHeadSpaceType']
770 ),
771 ];
772 $m_selectors['.wp-block-uagb-advanced-heading .uagb-desc-text'] = [
773 'margin-bottom' => Spec_Gb_Helper::get_css_value(
774 $attr['subHeadSpaceMobile'],
775 $attr['subHeadSpaceType']
776 ),
777 ];
778 if ( $attr['headingDescToggle'] || 'none' !== $attr['separatorStyle'] ) {
779 $selectors[' .uagb-heading-text'] = [
780 'margin-bottom' => Spec_Gb_Helper::get_css_value(
781 $attr['headSpace'],
782 'px'
783 ),
784 ];
785 $t_selectors[' .uagb-heading-text'] = [
786 'margin-bottom' => Spec_Gb_Helper::get_css_value(
787 $attr['headSpaceTablet'],
788 $attr['headSpaceType']
789 ),
790 ];
791 $m_selectors[' .uagb-heading-text'] = [
792 'margin-bottom' => Spec_Gb_Helper::get_css_value(
793 $attr['headSpaceMobile'],
794 $attr['headSpaceType']
795 ),
796 ];
797 }
798
799 $combined_selectors = Spec_Gb_Helper::get_combined_selectors(
800 'advanced-heading',
801 [
802 'desktop' => $selectors,
803 'tablet' => $t_selectors,
804 'mobile' => $m_selectors,
805 ],
806 $attr
807 );
808
809 $combined_selectors = Spec_Gb_Helper::get_typography_css( $attr, 'head', ' .uagb-heading-text', $combined_selectors );
810 $combined_selectors = Spec_Gb_Helper::get_typography_css( $attr, 'subHead', ' .uagb-desc-text', $combined_selectors );
811 $combined_selectors = Spec_Gb_Helper::get_typography_css( $attr, 'highLight', '.wp-block-uagb-advanced-heading .srfm-highlight', $combined_selectors );
812
813 return Spec_Gb_Helper::generate_all_css( $combined_selectors, ' .uagb-block-' . $id );
814
815 }
816
817
818 /**
819 * Get Separator Block CSS
820 *
821 * @since 0.0.1
822 * @param array $attr The block attributes.
823 * @param string $id The selector ID.
824 * @return array The Widget List.
825 */
826 public static function get_separator_css( $attr, $id ) {
827
828 $defaults = Spec_Gb_Helper::$block_list['srfm/separator']['attributes'];
829
830 $attr = array_merge( $defaults, $attr );
831
832 $t_selectors = [];
833 $m_selectors = [];
834 $selectors = [];
835 $border_size = '100%';
836
837 $border_css = [
838 '-webkit-mask-size' => ( Spec_Gb_Helper::get_css_value( $attr['separatorSize'], $attr['separatorSizeType'] ) . ' ' . $border_size ),
839 'border-top-width' => Spec_Gb_Helper::get_css_value( $attr['separatorBorderHeight'], $attr['separatorBorderHeightUnit'] ),
840 'width' => Spec_Gb_Helper::get_css_value( $attr['separatorWidth'], $attr['separatorWidthType'] ),
841 'border-top-color' => $attr['separatorColor'],
842 'border-top-style' => $attr['separatorStyle'],
843 ];
844
845 $border_style = [];
846 $icon_spacing_style = [];
847
848 if ( 'none' === $attr['elementType'] ) {
849 $border_style['.wp-block-uagb-separator:not(.wp-block-uagb-separator--text):not(.wp-block-uagb-separator--icon) .wp-block-uagb-separator__inner'] = $border_css;
850
851 } else {
852 $align_css = Spec_Gb_Helper::alignment_css( $attr['separatorAlign'] );
853 $border_style = [
854 '.wp-block-uagb-separator .wp-block-uagb-separator__inner' => array_merge(
855 [
856 'width' => Spec_Gb_Helper::get_css_value( $attr['separatorWidth'], $attr['separatorWidthType'] ),
857
858 ],
859 $align_css
860 ),
861 ];
862 $border_style['.wp-block-uagb-separator--text .wp-block-uagb-separator__inner::before'] = $border_css;
863 $border_style['.wp-block-uagb-separator--icon .wp-block-uagb-separator__inner::before'] = $border_css;
864 $border_style['.wp-block-uagb-separator--text .wp-block-uagb-separator__inner::after'] = $border_css;
865 $border_style['.wp-block-uagb-separator--icon .wp-block-uagb-separator__inner::after'] = $border_css;
866
867 if ( 'left' === $attr['elementPosition'] ) {
868 $icon_spacing_style['.wp-block-uagb-separator .wp-block-uagb-separator__inner .wp-block-uagb-separator-element'] = [
869 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['elementSpacing'], $attr['elementSpacingUnit'] ),
870 ];
871 $border_style['.wp-block-uagb-separator--text .wp-block-uagb-separator__inner::before'] = [
872 'display' => 'none',
873 ];
874 $border_style['.wp-block-uagb-separator--icon .wp-block-uagb-separator__inner::before'] = [
875 'display' => 'none',
876 ];
877 }
878 if ( 'right' === $attr['elementPosition'] ) {
879 $icon_spacing_style['.wp-block-uagb-separator .wp-block-uagb-separator__inner .wp-block-uagb-separator-element'] = [
880 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['elementSpacing'], $attr['elementSpacingUnit'] ),
881 ];
882 $border_style['.wp-block-uagb-separator--text .wp-block-uagb-separator__inner::after'] = [
883 'display' => 'none',
884 ];
885 $border_style['.wp-block-uagb-separator--icon .wp-block-uagb-separator__inner::after'] = [
886 'display' => 'none',
887 ];
888 }
889 if ( 'center' === $attr['elementPosition'] ) {
890 $icon_spacing_style['.wp-block-uagb-separator .wp-block-uagb-separator__inner .wp-block-uagb-separator-element'] = [
891 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['elementSpacing'], $attr['elementSpacingUnit'] ),
892 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['elementSpacing'], $attr['elementSpacingUnit'] ),
893 ];
894 }
895 }
896
897 $selectors = [
898 '.wp-block-uagb-separator.uagb-block .wp-block-uagb-separator-wrapper' => [
899 'margin-top' => Spec_Gb_Helper::get_css_value( $attr['blockTopMargin'], $attr['blockMarginUnit'] ),
900 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['blockRightMargin'], $attr['blockMarginUnit'] ),
901 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['blockBottomMargin'], $attr['blockMarginUnit'] ),
902 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['blockLeftMargin'], $attr['blockMarginUnit'] ),
903 'padding-top' => Spec_Gb_Helper::get_css_value( $attr['blockTopPadding'], $attr['blockPaddingUnit'] ),
904 'padding-right' => Spec_Gb_Helper::get_css_value( $attr['blockRightPadding'], $attr['blockPaddingUnit'] ),
905 'padding-bottom' => Spec_Gb_Helper::get_css_value( $attr['blockBottomPadding'], $attr['blockPaddingUnit'] ),
906 'padding-left' => Spec_Gb_Helper::get_css_value( $attr['blockLeftPadding'], $attr['blockPaddingUnit'] ),
907 'text-align' => $attr['separatorAlign'],
908 ],
909 '.wp-block-uagb-separator--text .wp-block-uagb-separator-element .uagb-html-tag' => [
910 'font-family' => $attr['elementTextFontFamily'],
911 'font-style' => $attr['elementTextFontStyle'],
912 'text-decoration' => $attr['elementTextDecoration'],
913 'text-transform' => $attr['elementTextTransform'],
914 'font-weight' => $attr['elementTextFontWeight'],
915 'color' => $attr['elementColor'],
916 'font-size' => Spec_Gb_Helper::get_css_value( $attr['elementTextFontSize'], $attr['elementTextFontSizeType'] ),
917 'line-height' => Spec_Gb_Helper::get_css_value( $attr['elementTextLineHeight'], $attr['elementTextLineHeightType'] ),
918 'letter-spacing' => Spec_Gb_Helper::get_css_value( $attr['elementTextLetterSpacing'], $attr['elementTextLetterSpacingType'] ),
919 ],
920 '.wp-block-uagb-separator--icon .wp-block-uagb-separator-element svg' => [
921 'font-size' => Spec_Gb_Helper::get_css_value( $attr['elementIconWidth'], $attr['elementIconWidthType'] ),
922 'width' => Spec_Gb_Helper::get_css_value( $attr['elementIconWidth'], $attr['elementIconWidthType'] ),
923 'height' => Spec_Gb_Helper::get_css_value( $attr['elementIconWidth'], $attr['elementIconWidthType'] ),
924 'line-height' => Spec_Gb_Helper::get_css_value( $attr['elementIconWidth'], $attr['elementIconWidthType'] ),
925 'color' => $attr['elementColor'],
926 'fill' => $attr['elementColor'],
927 ],
928 ];
929 $selectors = array_merge( $selectors, $border_style, $icon_spacing_style );
930
931 // Tablet.
932 $border_css_tablet = [
933 '-webkit-mask-size' => ( Spec_Gb_Helper::get_css_value( $attr['separatorSizeTablet'], $attr['separatorSizeType'] ) . ' ' . $border_size ),
934 'border-top-width' => Spec_Gb_Helper::get_css_value( $attr['separatorBorderHeightTablet'], $attr['separatorBorderHeightUnit'] ),
935 'width' => Spec_Gb_Helper::get_css_value( $attr['separatorWidthTablet'], $attr['separatorWidthType'] ),
936 'border-top-color' => $attr['separatorColor'],
937 'border-top-style' => $attr['separatorStyle'],
938 ];
939
940 $border_style_tablet = [];
941 $icon_spacing_style_tablet = [];
942 if ( 'none' === $attr['elementType'] ) {
943 $border_style_tablet['.wp-block-uagb-separator:not(.wp-block-uagb-separator--text):not(.wp-block-uagb-separator--icon) .wp-block-uagb-separator__inner'] = $border_css_tablet;
944
945 } else {
946 $align_css = Spec_Gb_Helper::alignment_css( $attr['separatorAlignTablet'] );
947 $border_style_tablet = [
948 '.wp-block-uagb-separator .wp-block-uagb-separator__inner' => array_merge(
949 [
950 'width' => Spec_Gb_Helper::get_css_value( $attr['separatorWidthTablet'], $attr['separatorWidthType'] ),
951
952 ],
953 $align_css
954 ),
955 ];
956 $border_style_tablet['.wp-block-uagb-separator--text .wp-block-uagb-separator__inner::before'] = $border_css_tablet;
957 $border_style_tablet['.wp-block-uagb-separator--icon .wp-block-uagb-separator__inner::before'] = $border_css_tablet;
958 $border_style_tablet['.wp-block-uagb-separator--text .wp-block-uagb-separator__inner::after'] = $border_css_tablet;
959 $border_style_tablet['.wp-block-uagb-separator--icon .wp-block-uagb-separator__inner::after'] = $border_css_tablet;
960 if ( 'left' === $attr['elementPosition'] ) {
961 $icon_spacing_style_tablet['.wp-block-uagb-separator .wp-block-uagb-separator__inner .wp-block-uagb-separator-element'] = [
962 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['elementSpacingTablet'], $attr['elementSpacingUnit'] ),
963 ];
964 $border_style_tablet['.wp-block-uagb-separator--text .wp-block-uagb-separator__inner::before'] = [
965 'display' => 'none',
966 ];
967 $border_style_tablet['.wp-block-uagb-separator--icon .wp-block-uagb-separator__inner::before'] = [
968 'display' => 'none',
969 ];
970 }
971 if ( 'center' === $attr['elementPosition'] ) {
972 $icon_spacing_style_tablet['.wp-block-uagb-separator .wp-block-uagb-separator__inner .wp-block-uagb-separator-element'] = [
973 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['elementSpacingTablet'], $attr['elementSpacingUnit'] ),
974 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['elementSpacingTablet'], $attr['elementSpacingUnit'] ),
975 ];
976 }
977 if ( 'right' === $attr['elementPosition'] ) {
978 $icon_spacing_style_tablet['.wp-block-uagb-separator .wp-block-uagb-separator__inner .wp-block-uagb-separator-element'] = [
979 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['elementSpacingTablet'], $attr['elementSpacingUnit'] ),
980 ];
981 $border_style_tablet['.wp-block-uagb-separator--text .wp-block-uagb-separator__inner::after'] = [
982 'display' => 'none',
983 ];
984 $border_style_tablet['.wp-block-uagb-separator--icon .wp-block-uagb-separator__inner::after'] = [
985 'display' => 'none',
986 ];
987 }
988 }
989 $t_selectors = [
990 '.wp-block-uagb-separator.uagb-block .wp-block-uagb-separator-wrapper' => [
991 'margin-top' => Spec_Gb_Helper::get_css_value( $attr['blockTopMarginTablet'], $attr['blockMarginUnit'] ),
992 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['blockRightMarginTablet'], $attr['blockMarginUnit'] ),
993 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['blockBottomMarginTablet'], $attr['blockMarginUnit'] ),
994 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['blockLeftMarginTablet'], $attr['blockMarginUnit'] ),
995 'padding-top' => Spec_Gb_Helper::get_css_value( $attr['blockTopPaddingTablet'], $attr['blockPaddingUnit'] ),
996 'padding-right' => Spec_Gb_Helper::get_css_value( $attr['blockRightPaddingTablet'], $attr['blockPaddingUnit'] ),
997 'padding-bottom' => Spec_Gb_Helper::get_css_value( $attr['blockBottomPaddingTablet'], $attr['blockPaddingUnit'] ),
998 'padding-left' => Spec_Gb_Helper::get_css_value( $attr['blockLeftPaddingTablet'], $attr['blockPaddingUnit'] ),
999 'text-align' => $attr['separatorAlignTablet'],
1000 ],
1001 '.wp-block-uagb-separator--text .wp-block-uagb-separator-element .uagb-html-tag' => [
1002 'font-family' => $attr['elementTextFontFamily'],
1003 'font-style' => $attr['elementTextFontStyle'],
1004 'text-decoration' => $attr['elementTextDecoration'],
1005 'text-transform' => $attr['elementTextTransform'],
1006 'font-weight' => $attr['elementTextFontWeight'],
1007 'color' => $attr['elementColor'],
1008 'margin-bottom' => 'initial',
1009 'font-size' => Spec_Gb_Helper::get_css_value( $attr['elementTextFontSizeTablet'], $attr['elementTextFontSizeType'] ),
1010 'line-height' => Spec_Gb_Helper::get_css_value( $attr['elementTextLineHeightTablet'], $attr['elementTextLineHeightType'] ),
1011 'letter-spacing' => Spec_Gb_Helper::get_css_value( $attr['elementTextLetterSpacingTablet'], $attr['elementTextLetterSpacingType'] ),
1012 ],
1013 '.wp-block-uagb-separator--icon .wp-block-uagb-separator-element svg' => [
1014 'font-size' => Spec_Gb_Helper::get_css_value( $attr['elementIconWidthTablet'], $attr['elementIconWidthType'] ),
1015 'width' => Spec_Gb_Helper::get_css_value( $attr['elementIconWidthTablet'], $attr['elementIconWidthType'] ),
1016 'height' => Spec_Gb_Helper::get_css_value( $attr['elementIconWidthTablet'], $attr['elementIconWidthType'] ),
1017 'line-height' => Spec_Gb_Helper::get_css_value( $attr['elementIconWidthTablet'], $attr ['elementIconWidthType'] ),
1018 'color' => $attr['elementColor'],
1019 'fill' => $attr['elementColor'],
1020 ],
1021 ];
1022
1023 $t_selectors = array_merge( $t_selectors, $border_style_tablet, $icon_spacing_style_tablet );
1024
1025 // Mobile.
1026 $border_css_mobile = [
1027 '-webkit-mask-size' => ( Spec_Gb_Helper::get_css_value( $attr['separatorSizeMobile'], $attr['separatorSizeType'] ) . ' ' . $border_size ),
1028 'border-top-width' => Spec_Gb_Helper::get_css_value( $attr['separatorBorderHeightMobile'], $attr['separatorBorderHeightUnit'] ),
1029 'width' => Spec_Gb_Helper::get_css_value( $attr['separatorWidthMobile'], $attr['separatorWidthType'] ),
1030 'border-top-color' => $attr['separatorColor'],
1031 'border-top-style' => $attr['separatorStyle'],
1032 ];
1033 $border_style_mobile = [];
1034 $icon_spacing_style_mobile = [];
1035 if ( 'none' === $attr['elementType'] ) {
1036 $border_style_mobile['.wp-block-uagb-separator:not(.wp-block-uagb-separator--text):not(.wp-block-uagb-separator--icon) .wp-block-uagb-separator__inner'] = $border_css_mobile;
1037
1038 } else {
1039 $align_css = Spec_Gb_Helper::alignment_css( $attr['separatorAlignMobile'] );
1040 $border_style_mobile = [
1041 '.wp-block-uagb-separator .wp-block-uagb-separator__inner' => array_merge(
1042 [
1043 'width' => Spec_Gb_Helper::get_css_value( $attr['separatorWidthMobile'], $attr['separatorWidthType'] ),
1044
1045 ],
1046 $align_css
1047 ),
1048 ];
1049 $border_style_mobile['.wp-block-uagb-separator--text .wp-block-uagb-separator__inner::before'] = $border_css_mobile;
1050 $border_style_mobile['.wp-block-uagb-separator--icon .wp-block-uagb-separator__inner::before'] = $border_css_mobile;
1051 $border_style_mobile['.wp-block-uagb-separator--text .wp-block-uagb-separator__inner::after'] = $border_css_mobile;
1052 $border_style_mobile['.wp-block-uagb-separator--icon .wp-block-uagb-separator__inner::after'] = $border_css_mobile;
1053 if ( 'left' === $attr['elementPosition'] ) {
1054 $icon_spacing_style_mobile['.wp-block-uagb-separator .wp-block-uagb-separator__inner .wp-block-uagb-separator-element'] = [
1055 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['elementSpacingMobile'], $attr['elementSpacingUnit'] ),
1056
1057 ];
1058 $border_style_mobile['.wp-block-uagb-separator--text .wp-block-uagb-separator__inner::before'] = [
1059 'display' => 'none',
1060 ];
1061 $border_style_mobile['.wp-block-uagb-separator--icon .wp-block-uagb-separator__inner::before'] = [
1062 'display' => 'none',
1063 ];
1064 }
1065 if ( 'center' === $attr['elementPosition'] ) {
1066 $icon_spacing_style_mobile['.wp-block-uagb-separator .wp-block-uagb-separator__inner .wp-block-uagb-separator-element'] = [
1067 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['elementSpacingMobile'], $attr['elementSpacingUnit'] ),
1068 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['elementSpacingMobile'], $attr['elementSpacingUnit'] ),
1069 ];
1070 }
1071 if ( 'right' === $attr['elementPosition'] ) {
1072 $icon_spacing_style_mobile['.wp-block-uagb-separator .wp-block-uagb-separator__inner .wp-block-uagb-separator-element'] = [
1073 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['elementSpacingMobile'], $attr['elementSpacingUnit'] ),
1074 ];
1075 $border_style_mobile['.wp-block-uagb-separator--text .wp-block-uagb-separator__inner::after'] = [
1076 'display' => 'none',
1077 ];
1078 $border_style_mobile['.wp-block-uagb-separator--icon .wp-block-uagb-separator__inner::after'] = [
1079 'display' => 'none',
1080 ];
1081 }
1082 }
1083 $m_selectors = [
1084 '.wp-block-uagb-separator.uagb-block .wp-block-uagb-separator-wrapper' => [
1085 'margin-top' => Spec_Gb_Helper::get_css_value( $attr['blockTopMarginMobile'], $attr['blockMarginUnit'] ),
1086 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['blockRightMarginMobile'], $attr['blockMarginUnit'] ),
1087 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['blockBottomMarginMobile'], $attr['blockMarginUnit'] ),
1088 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['blockLeftMarginMobile'], $attr['blockMarginUnit'] ),
1089 'padding-top' => Spec_Gb_Helper::get_css_value( $attr['blockTopPaddingMobile'], $attr['blockPaddingUnit'] ),
1090 'padding-right' => Spec_Gb_Helper::get_css_value( $attr['blockRightPaddingMobile'], $attr['blockPaddingUnit'] ),
1091 'padding-bottom' => Spec_Gb_Helper::get_css_value( $attr['blockBottomPaddingMobile'], $attr['blockPaddingUnit'] ),
1092 'padding-left' => Spec_Gb_Helper::get_css_value( $attr['blockLeftPaddingMobile'], $attr['blockPaddingUnit'] ),
1093 'text-align' => $attr['separatorAlignMobile'],
1094 ],
1095 '.wp-block-uagb-separator--text .wp-block-uagb-separator-element .uagb-html-tag' => [
1096 'font-family' => $attr['elementTextFontFamily'],
1097 'font-style' => $attr['elementTextFontStyle'],
1098 'text-decoration' => $attr['elementTextDecoration'],
1099 'text-transform' => $attr['elementTextTransform'],
1100 'font-weight' => $attr['elementTextFontWeight'],
1101 'color' => $attr['elementColor'],
1102 'margin-bottom' => 'initial',
1103 'font-size' => Spec_Gb_Helper::get_css_value( $attr['elementTextFontSizeMobile'], $attr['elementTextFontSizeType'] ),
1104 'line-height' => Spec_Gb_Helper::get_css_value( $attr['elementTextLineHeightMobile'], $attr['elementTextLineHeightType'] ),
1105 'letter-spacing' => Spec_Gb_Helper::get_css_value( $attr['elementTextLetterSpacingMobile'], $attr['elementTextLetterSpacingType'] ),
1106 ],
1107 '.wp-block-uagb-separator--icon .wp-block-uagb-separator-element svg' => [
1108 'font-size' => Spec_Gb_Helper::get_css_value( $attr['elementIconWidthMobile'], $attr['elementIconWidthType'] ),
1109 'width' => Spec_Gb_Helper::get_css_value( $attr['elementIconWidthMobile'], $attr['elementIconWidthType'] ),
1110 'height' => Spec_Gb_Helper::get_css_value( $attr['elementIconWidthMobile'], $attr['elementIconWidthType'] ),
1111 'line-height' => Spec_Gb_Helper::get_css_value( $attr['elementIconWidthMobile'], $attr ['elementIconWidthType'] ),
1112 'color' => $attr['elementColor'],
1113 'fill' => $attr['elementColor'],
1114 ],
1115 ];
1116 $m_selectors = array_merge( $m_selectors, $border_style_mobile, $icon_spacing_style_mobile );
1117
1118 $combined_selectors = [
1119 'desktop' => $selectors,
1120 'tablet' => $t_selectors,
1121 'mobile' => $m_selectors,
1122 ];
1123 return Spec_Gb_Helper::generate_all_css( $combined_selectors, ' .uagb-block-' . $id );
1124 }
1125
1126 /**
1127 * Border CSS generation Function.
1128 *
1129 * @since 0.0.1
1130 * @param array $attr Attribute List.
1131 * @param string $prefix Attribuate prefix .
1132 * @param string $device Responsive.
1133 * @return array border css array.
1134 */
1135 public static function generate_border_css( $attr, $prefix, $device = 'desktop' ) {
1136 $gen_border_css = [];
1137 if ( 'tablet' === $device ) {
1138 if ( 'none' !== $attr[ $prefix . 'BorderStyle' ] ) {
1139 $gen_border_css['border-top-width'] = self::get_css_value( $attr[ $prefix . 'BorderTopWidthTablet' ], 'px' );
1140 $gen_border_css['border-left-width'] = self::get_css_value( $attr[ $prefix . 'BorderLeftWidthTablet' ], 'px' );
1141 $gen_border_css['border-right-width'] = self::get_css_value( $attr[ $prefix . 'BorderRightWidthTablet' ], 'px' );
1142 $gen_border_css['border-bottom-width'] = self::get_css_value( $attr[ $prefix . 'BorderBottomWidthTablet' ], 'px' );
1143 }
1144 $gen_border_unit_tablet = isset( $attr[ $prefix . 'BorderRadiusUnitTablet' ] ) ? $attr[ $prefix . 'BorderRadiusUnitTablet' ] : 'px';
1145 $gen_border_css['border-top-left-radius'] = self::get_css_value( $attr[ $prefix . 'BorderTopLeftRadiusTablet' ], $gen_border_unit_tablet );
1146 $gen_border_css['border-top-right-radius'] = self::get_css_value( $attr[ $prefix . 'BorderTopRightRadiusTablet' ], $gen_border_unit_tablet );
1147 $gen_border_css['border-bottom-left-radius'] = self::get_css_value( $attr[ $prefix . 'BorderBottomLeftRadiusTablet' ], $gen_border_unit_tablet );
1148 $gen_border_css['border-bottom-right-radius'] = self::get_css_value( $attr[ $prefix . 'BorderBottomRightRadiusTablet' ], $gen_border_unit_tablet );
1149 } elseif ( 'mobile' === $device ) {
1150 if ( 'none' !== $attr[ $prefix . 'BorderStyle' ] ) {
1151 $gen_border_css['border-top-width'] = self::get_css_value( $attr[ $prefix . 'BorderTopWidthMobile' ], 'px' );
1152 $gen_border_css['border-left-width'] = self::get_css_value( $attr[ $prefix . 'BorderLeftWidthMobile' ], 'px' );
1153 $gen_border_css['border-right-width'] = self::get_css_value( $attr[ $prefix . 'BorderRightWidthMobile' ], 'px' );
1154 $gen_border_css['border-bottom-width'] = self::get_css_value( $attr[ $prefix . 'BorderBottomWidthMobile' ], 'px' );
1155 }
1156 $gen_border_unit_mobile = isset( $attr[ $prefix . 'BorderTopLeftRadiusMobile' ] ) ? $attr[ $prefix . 'BorderTopLeftRadiusMobile' ] : 'px';
1157 $gen_border_css['border-top-left-radius'] = self::get_css_value( $attr[ $prefix . 'BorderTopLeftRadiusMobile' ], $gen_border_unit_mobile );
1158 $gen_border_css['border-top-right-radius'] = self::get_css_value( $attr[ $prefix . 'BorderTopRightRadiusMobile' ], $gen_border_unit_mobile );
1159 $gen_border_css['border-bottom-left-radius'] = self::get_css_value( $attr[ $prefix . 'BorderBottomLeftRadiusMobile' ], $gen_border_unit_mobile );
1160 $gen_border_css['border-bottom-right-radius'] = self::get_css_value( $attr[ $prefix . 'BorderBottomRightRadiusMobile' ], $gen_border_unit_mobile );
1161 } else {
1162 if ( 'none' !== $attr[ $prefix . 'BorderStyle' ] ) {
1163 $gen_border_css['border-top-width'] = self::get_css_value( $attr[ $prefix . 'BorderTopWidth' ], 'px' );
1164 $gen_border_css['border-left-width'] = self::get_css_value( $attr[ $prefix . 'BorderLeftWidth' ], 'px' );
1165 $gen_border_css['border-right-width'] = self::get_css_value( $attr[ $prefix . 'BorderRightWidth' ], 'px' );
1166 $gen_border_css['border-bottom-width'] = self::get_css_value( $attr[ $prefix . 'BorderBottomWidth' ], 'px' );
1167 }
1168 $gen_border_unit = isset( $attr[ $prefix . 'BorderRadiusUnit' ] ) ? $attr[ $prefix . 'BorderRadiusUnit' ] : 'px';
1169 $gen_border_css['border-top-left-radius'] = self::get_css_value( $attr[ $prefix . 'BorderTopLeftRadius' ], $gen_border_unit );
1170 $gen_border_css['border-top-right-radius'] = self::get_css_value( $attr[ $prefix . 'BorderTopRightRadius' ], $gen_border_unit );
1171 $gen_border_css['border-bottom-left-radius'] = self::get_css_value( $attr[ $prefix . 'BorderBottomLeftRadius' ], $gen_border_unit );
1172 $gen_border_css['border-bottom-right-radius'] = self::get_css_value( $attr[ $prefix . 'BorderBottomRightRadius' ], $gen_border_unit );
1173 }
1174 $border_style = $attr[ $prefix . 'BorderStyle' ];
1175 $border_color = $attr[ $prefix . 'BorderColor' ];
1176 $gen_border_css['border-style'] = $border_style;
1177 $gen_border_css['border-color'] = $border_color;
1178 return $gen_border_css;
1179 }
1180
1181 /**
1182 * Get CSS value
1183 *
1184 * Syntax:
1185 *
1186 * get_css_value( VALUE, UNIT );
1187 *
1188 * E.g.
1189 *
1190 * get_css_value( VALUE, 'em' );
1191 *
1192 * @param string $value CSS value.
1193 * @param string $unit CSS unit.
1194 * @since 0.0.1
1195 */
1196 public static function get_css_value( $value = '', $unit = '' ) {
1197
1198 if ( '' === $value ) {
1199 return $value;
1200 }
1201
1202 $css_val = '';
1203
1204 if ( isset( $value ) ) {
1205 $css_val = esc_attr( $value ) . $unit;
1206 }
1207
1208 return $css_val;
1209 }
1210
1211 /**
1212 * Deprecated Border CSS generation Function.
1213 *
1214 * @since 0.0.1
1215 * @param array $current_css Current style list.
1216 * @param string $border_width Border Width.
1217 * @param string $border_radius Border Radius.
1218 * @param string $border_color Border Color.
1219 * @param string $border_style Border Style.
1220 */
1221 public static function generate_deprecated_border_css( $current_css, $border_width, $border_radius, $border_color = '', $border_style = '' ) {
1222 $gen_border_css = [];
1223 if ( is_numeric( $border_width ) ) {
1224 $gen_border_css['border-top-width'] = self::get_css_value( $border_width, 'px' );
1225 $gen_border_css['border-left-width'] = self::get_css_value( $border_width, 'px' );
1226 $gen_border_css['border-right-width'] = self::get_css_value( $border_width, 'px' );
1227 $gen_border_css['border-bottom-width'] = self::get_css_value( $border_width, 'px' );
1228 }
1229
1230 if ( is_numeric( $border_radius ) ) {
1231 $gen_border_css['border-top-left-radius'] = self::get_css_value( $border_radius, 'px' );
1232 $gen_border_css['border-top-right-radius'] = self::get_css_value( $border_radius, 'px' );
1233 $gen_border_css['border-bottom-left-radius'] = self::get_css_value( $border_radius, 'px' );
1234 $gen_border_css['border-bottom-right-radius'] = self::get_css_value( $border_radius, 'px' );
1235 }
1236
1237 if ( $border_color ) {
1238 $gen_border_css['border-color'] = $border_color;
1239 }
1240
1241 if ( $border_style ) {
1242 $gen_border_css['border-style'] = $border_style;
1243 }
1244 return wp_parse_args( $gen_border_css, $current_css );
1245 }
1246
1247 }
1248 }
1249