PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 1.5.2
GenerateBlocks v1.5.2
trunk 1.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 2.0.0 2.0.1 2.0.2 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.3.0
generateblocks / includes / generate-css.php
generateblocks / includes Last commit date
class-do-css.php 4 years ago class-dynamic-content.php 4 years ago class-enqueue-css.php 4 years ago class-legacy-attributes.php 4 years ago class-plugin-update.php 5 years ago class-query-loop.php 4 years ago class-render-blocks.php 4 years ago class-rest.php 4 years ago class-settings.php 4 years ago dashboard.php 4 years ago defaults.php 4 years ago functions.php 4 years ago general.php 4 years ago generate-css.php 4 years ago
generate-css.php
1906 lines
1 <?php
2 /**
3 * Output our dynamic CSS.
4 *
5 * @package GenerateBlocks
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit; // Exit if accessed directly.
10 }
11
12 /**
13 * Build the CSS from our block attributes.
14 *
15 * @since 0.1
16 * @param string $content The content we're looking through.
17 *
18 * @return string The dynamic CSS.
19 */
20 function generateblocks_get_dynamic_css( $content = '' ) {
21 if ( ! $content ) {
22 return;
23 }
24
25 $data = generateblocks_get_block_data( $content );
26
27 if ( empty( $data ) ) {
28 return;
29 }
30
31 $blocks_exist = false;
32 $icon_css_added = false;
33 $main_css_data = array();
34 $desktop_css_data = array();
35 $tablet_css_data = array();
36 $tablet_only_css_data = array();
37 $mobile_css_data = array();
38
39 foreach ( $data as $name => $blockData ) {
40 /**
41 * Get our Grid block CSS.
42 *
43 * @since 0.1
44 */
45 if ( 'grid' === $name ) {
46 if ( empty( $blockData ) ) {
47 continue;
48 }
49
50 $blocks_exist = true;
51
52 $css = new GenerateBlocks_Dynamic_CSS();
53 $desktop_css = new GenerateBlocks_Dynamic_CSS();
54 $tablet_css = new GenerateBlocks_Dynamic_CSS();
55 $tablet_only_css = new GenerateBlocks_Dynamic_CSS();
56 $mobile_css = new GenerateBlocks_Dynamic_CSS();
57
58 $css->set_selector( '.gb-grid-wrapper' );
59 $css->add_property( 'display', 'flex' );
60 $css->add_property( 'flex-wrap', 'wrap' );
61
62 $css->set_selector( '.gb-grid-wrapper > .gb-grid-column > .gb-container' );
63 $css->add_property( 'display', 'flex' );
64 $css->add_property( 'flex-direction', 'column' );
65 $css->add_property( 'height', '100%' );
66
67 $css->set_selector( '.gb-grid-column' );
68 $css->add_property( 'box-sizing', 'border-box' );
69
70 $css->set_selector( '.gb-grid-wrapper .wp-block-image' );
71 $css->add_property( 'margin-bottom', '0' );
72
73 foreach ( $blockData as $atts ) {
74 if ( ! isset( $atts['uniqueId'] ) ) {
75 continue;
76 }
77
78 $defaults = generateblocks_get_block_defaults();
79
80 $settings = wp_parse_args(
81 $atts,
82 $defaults['gridContainer']
83 );
84
85 $id = $atts['uniqueId'];
86 $blockVersion = ! empty( $settings['blockVersion'] ) ? $settings['blockVersion'] : 1;
87
88 // Use legacy settings if needed.
89 if ( $blockVersion < 2 ) {
90 $settings = GenerateBlocks_Legacy_Attributes::get_settings( '1.4.0', 'grid', $settings, $atts );
91 }
92
93 $gap_direction = 'left';
94
95 if ( is_rtl() ) {
96 $gap_direction = 'right';
97 }
98
99 // Don't output horizontal gap defaults if we're using global styles.
100 if ( $blockVersion < 2 && isset( $settings['useGlobalStyle'] ) && $settings['useGlobalStyle'] && isset( $settings['globalStyleId'] ) && $settings['globalStyleId'] ) {
101 if ( (string) $settings['horizontalGap'] === (string) $defaults['gridContainer']['horizontalGap'] ) {
102 $settings['horizontalGap'] = '';
103 }
104 }
105
106 $css->set_selector( '.gb-grid-wrapper-' . $id );
107 $css->add_property( 'align-items', $settings['verticalAlignment'] );
108 $css->add_property( 'justify-content', $settings['horizontalAlignment'] );
109
110 if ( $settings['horizontalGap'] ) {
111 $css->add_property( 'margin-' . $gap_direction, '-' . $settings['horizontalGap'] . 'px' );
112 }
113
114 $css->set_selector( '.gb-grid-wrapper-' . $id . ' > .gb-grid-column' );
115 $css->add_property( 'padding-' . $gap_direction, $settings['horizontalGap'], 'px' );
116 $css->add_property( 'padding-bottom', $settings['verticalGap'], 'px' );
117
118 $tablet_css->set_selector( '.gb-grid-wrapper-' . $id );
119
120 if ( 'inherit' !== $settings['verticalAlignmentTablet'] ) {
121 $tablet_css->add_property( 'align-items', $settings['verticalAlignmentTablet'] );
122 }
123
124 if ( 'inherit' !== $settings['horizontalAlignmentTablet'] ) {
125 $tablet_css->add_property( 'justify-content', $settings['horizontalAlignmentTablet'] );
126 }
127
128 if ( $settings['horizontalGapTablet'] ) {
129 $tablet_css->add_property( 'margin-' . $gap_direction, '-' . $settings['horizontalGapTablet'] . 'px' );
130 } elseif ( 0 === $settings['horizontalGapTablet'] ) {
131 $tablet_css->add_property( 'margin-' . $gap_direction, $settings['horizontalGapTablet'] );
132 }
133
134 $tablet_css->set_selector( '.gb-grid-wrapper-' . $id . ' > .gb-grid-column' );
135 $tablet_css->add_property( 'padding-' . $gap_direction, $settings['horizontalGapTablet'], 'px' );
136 $tablet_css->add_property( 'padding-bottom', $settings['verticalGapTablet'], 'px' );
137
138 $mobile_css->set_selector( '.gb-grid-wrapper-' . $id );
139
140 if ( 'inherit' !== $settings['verticalAlignmentMobile'] ) {
141 $mobile_css->add_property( 'align-items', $settings['verticalAlignmentMobile'] );
142 }
143
144 if ( 'inherit' !== $settings['horizontalAlignmentMobile'] ) {
145 $mobile_css->add_property( 'justify-content', $settings['horizontalAlignmentMobile'] );
146 }
147
148 if ( $settings['horizontalGapMobile'] ) {
149 $mobile_css->add_property( 'margin-' . $gap_direction, '-' . $settings['horizontalGapMobile'] . 'px' );
150 } elseif ( 0 === $settings['horizontalGapMobile'] ) {
151 $mobile_css->add_property( 'margin-' . $gap_direction, $settings['horizontalGapMobile'] );
152 }
153
154 $mobile_css->set_selector( '.gb-grid-wrapper-' . $id . ' > .gb-grid-column' );
155 $mobile_css->add_property( 'padding-' . $gap_direction, $settings['horizontalGapMobile'], 'px' );
156 $mobile_css->add_property( 'padding-bottom', $settings['verticalGapMobile'], 'px' );
157
158 /**
159 * Do generateblocks_block_css_data hook
160 *
161 * @since 1.0
162 *
163 * @param string $name The name of our block.
164 * @param array $settings The settings for the current block.
165 * @param object $css Our desktop/main CSS data.
166 * @param object $desktop_css Our desktop only CSS data.
167 * @param object $tablet_css Our tablet CSS data.
168 * @param object $tablet_only_css Our tablet only CSS data.
169 * @param object $mobile_css Our mobile CSS data.
170 */
171 do_action(
172 'generateblocks_block_css_data',
173 $name,
174 $settings,
175 $css,
176 $desktop_css,
177 $tablet_css,
178 $tablet_only_css,
179 $mobile_css
180 );
181 }
182
183 if ( $css->css_output() ) {
184 $main_css_data[] = $css->css_output();
185 }
186
187 if ( $desktop_css->css_output() ) {
188 $desktop_css_data[] = $desktop_css->css_output();
189 }
190
191 if ( $tablet_css->css_output() ) {
192 $tablet_css_data[] = $tablet_css->css_output();
193 }
194
195 if ( $tablet_only_css->css_output() ) {
196 $tablet_only_css_data[] = $tablet_only_css->css_output();
197 }
198
199 if ( $mobile_css->css_output() ) {
200 $mobile_css_data[] = $mobile_css->css_output();
201 }
202 }
203
204 /**
205 * Get our Container block CSS.
206 *
207 * @since 0.1
208 */
209 if ( 'container' === $name ) {
210 if ( empty( $blockData ) ) {
211 continue;
212 }
213
214 $blocks_exist = true;
215
216 $css = new GenerateBlocks_Dynamic_CSS();
217 $desktop_css = new GenerateBlocks_Dynamic_CSS();
218 $tablet_css = new GenerateBlocks_Dynamic_CSS();
219 $tablet_only_css = new GenerateBlocks_Dynamic_CSS();
220 $mobile_css = new GenerateBlocks_Dynamic_CSS();
221
222 $css->set_selector( '.gb-container .wp-block-image img' );
223 $css->add_property( 'vertical-align', 'middle' );
224
225 $css->set_selector( '.gb-container .gb-shape' );
226 $css->add_property( 'position', 'absolute' );
227 $css->add_property( 'overflow', 'hidden' );
228 $css->add_property( 'pointer-events', 'none' );
229 $css->add_property( 'line-height', '0' );
230
231 $css->set_selector( '.gb-container .gb-shape svg' );
232 $css->add_property( 'fill', 'currentColor' );
233
234 foreach ( $blockData as $atts ) {
235 if ( ! isset( $atts['uniqueId'] ) ) {
236 continue;
237 }
238
239 $defaults = generateblocks_get_block_defaults();
240
241 $settings = wp_parse_args(
242 $atts,
243 $defaults['container']
244 );
245
246 $id = $atts['uniqueId'];
247 $blockVersion = ! empty( $settings['blockVersion'] ) ? $settings['blockVersion'] : 1;
248
249 // Use legacy settings if needed.
250 if ( $blockVersion < 2 ) {
251 $settings = GenerateBlocks_Legacy_Attributes::get_settings( '1.4.0', 'container', $settings, $atts );
252 }
253
254 $fontFamily = $settings['fontFamily'];
255
256 if ( $fontFamily && $settings['fontFamilyFallback'] ) {
257 $fontFamily = $fontFamily . ', ' . $settings['fontFamilyFallback'];
258 }
259
260 if ( ! isset( $settings['bgOptions']['selector'] ) ) {
261 $settings['bgOptions']['selector'] = 'element';
262 }
263
264 $containerWidth = $settings['containerWidth'];
265
266 if ( isset( $settings['useGlobalStyle'] ) && $settings['useGlobalStyle'] ) {
267 if ( (string) $containerWidth === (string) $defaults['container']['containerWidth'] ) {
268 $containerWidth = '';
269 }
270 }
271
272 $backgroundImageValue = generateblocks_get_background_image_css( 'image', $settings );
273 $gradientValue = generateblocks_get_background_image_css( 'gradient', $settings );
274 $hasBgImage = generateblocks_has_background_image( $settings );
275
276 $css->set_selector( '.gb-container-' . $id );
277 $css->add_property( 'font-family', $fontFamily );
278 $css->add_property( 'font-size', $settings['fontSize'], $settings['fontSizeUnit'] );
279 $css->add_property( 'font-weight', $settings['fontWeight'] );
280 $css->add_property( 'text-transform', $settings['textTransform'] );
281 $css->add_property( 'margin', array( $settings['marginTop'], $settings['marginRight'], $settings['marginBottom'], $settings['marginLeft'] ), $settings['marginUnit'] );
282
283 if ( 'contained' === $settings['outerContainer'] && ! $settings['isGrid'] ) {
284 if ( ! empty( $containerWidth ) ) {
285 $css->add_property( 'max-width', absint( $containerWidth ), 'px' );
286 $css->add_property( 'margin-left', 'auto' );
287 $css->add_property( 'margin-right', 'auto' );
288 }
289 }
290
291 $css->add_property( 'background-color', generateblocks_hex2rgba( $settings['backgroundColor'], $settings['backgroundColorOpacity'] ) );
292 $css->add_property( 'color', $settings['textColor'] );
293
294 if ( $hasBgImage && 'element' === $settings['bgOptions']['selector'] && $backgroundImageValue ) {
295 if ( ! $settings['bgImageInline'] || ( $settings['bgImageInline'] && 'element' !== $settings['bgOptions']['selector'] ) ) {
296 $css->add_property( 'background-image', $backgroundImageValue );
297 }
298
299 $css->add_property( 'background-repeat', $settings['bgOptions']['repeat'] );
300 $css->add_property( 'background-position', $settings['bgOptions']['position'] );
301 $css->add_property( 'background-size', $settings['bgOptions']['size'] );
302 $css->add_property( 'background-attachment', $settings['bgOptions']['attachment'] );
303 } elseif ( $settings['gradient'] && 'element' === $settings['gradientSelector'] ) {
304 $css->add_property( 'background-image', $gradientValue );
305 }
306
307 if (
308 ( $hasBgImage && 'pseudo-element' === $settings['bgOptions']['selector'] ) ||
309 $settings['zindex'] ||
310 ( $settings['gradient'] && 'pseudo-element' === $settings['gradientSelector'] )
311 ) {
312 $css->add_property( 'position', 'relative' );
313 }
314
315 if (
316 ( $hasBgImage && 'pseudo-element' === $settings['bgOptions']['selector'] ) ||
317 ( $settings['gradient'] && 'pseudo-element' === $settings['gradientSelector'] )
318 ) {
319 $css->add_property( 'overflow', 'hidden' );
320 }
321
322 if ( $settings['zindex'] ) {
323 $css->add_property( 'z-index', $settings['zindex'] );
324 }
325
326 $css->add_property( 'border-radius', array( $settings['borderRadiusTopLeft'], $settings['borderRadiusTopRight'], $settings['borderRadiusBottomRight'], $settings['borderRadiusBottomLeft'] ), $settings['borderRadiusUnit'] );
327 $css->add_property( 'border-width', array( $settings['borderSizeTop'], $settings['borderSizeRight'], $settings['borderSizeBottom'], $settings['borderSizeLeft'] ), 'px' );
328 $css->add_property( 'border-color', generateblocks_hex2rgba( $settings['borderColor'], $settings['borderColorOpacity'] ) );
329 $css->add_property( 'min-height', $settings['minHeight'], $settings['minHeightUnit'] );
330
331 // Set flags so we don't duplicate this CSS in media queries.
332 $usingMinHeightFlex = false;
333 $usingMinHeightInnerWidth = false;
334
335 if ( $settings['minHeight'] && $settings['verticalAlignment'] && ! $settings['isGrid'] ) {
336 $css->add_property( 'display', 'flex' );
337 $css->add_property( 'flex-direction', 'row' );
338 $css->add_property( 'align-items', $settings['verticalAlignment'] );
339
340 $usingMinHeightFlex = true;
341 }
342
343 $css->add_property( 'text-align', $settings['alignment'] );
344
345 $innerZIndex = $settings['innerZindex'];
346
347 $css->set_selector( '.gb-container-' . $id . ':before' );
348
349 if ( $hasBgImage && 'pseudo-element' === $settings['bgOptions']['selector'] ) {
350 $css->add_property( 'content', '""' );
351 $css->add_property( 'background-image', $backgroundImageValue );
352 $css->add_property( 'background-repeat', $settings['bgOptions']['repeat'] );
353 $css->add_property( 'background-position', $settings['bgOptions']['position'] );
354 $css->add_property( 'background-size', $settings['bgOptions']['size'] );
355 $css->add_property( 'background-attachment', $settings['bgOptions']['attachment'] );
356 $css->add_property( 'z-index', '0' );
357 $css->add_property( 'position', 'absolute' );
358 $css->add_property( 'top', '0' );
359 $css->add_property( 'right', '0' );
360 $css->add_property( 'bottom', '0' );
361 $css->add_property( 'left', '0' );
362 $css->add_property( 'transition', 'inherit' );
363 $css->add_property( 'border-radius', array( $settings['borderRadiusTopLeft'], $settings['borderRadiusTopRight'], $settings['borderRadiusBottomRight'], $settings['borderRadiusBottomLeft'] ), $settings['borderRadiusUnit'] );
364
365 if ( isset( $settings['bgOptions']['opacity'] ) && 1 !== $settings['bgOptions']['opacity'] ) {
366 $css->add_property( 'opacity', $settings['bgOptions']['opacity'] );
367 }
368
369 if ( $blockVersion < 2 && ! $innerZIndex ) {
370 $innerZIndex = 1;
371 }
372 }
373
374 if ( $settings['gradient'] && 'pseudo-element' === $settings['gradientSelector'] ) {
375 $css->set_selector( '.gb-container-' . $id . ':after' );
376 $css->add_property( 'content', '""' );
377 $css->add_property( 'background-image', $gradientValue );
378 $css->add_property( 'z-index', '0' );
379 $css->add_property( 'position', 'absolute' );
380 $css->add_property( 'top', '0' );
381 $css->add_property( 'right', '0' );
382 $css->add_property( 'bottom', '0' );
383 $css->add_property( 'left', '0' );
384
385 if ( $blockVersion < 2 && ! $innerZIndex ) {
386 $innerZIndex = 1;
387 }
388 }
389
390 $css->set_selector( '.gb-container-' . $id . ' > .gb-inside-container' );
391 $css->add_property( 'padding', array( $settings['paddingTop'], $settings['paddingRight'], $settings['paddingBottom'], $settings['paddingLeft'] ), $settings['paddingUnit'] );
392
393 if ( 'contained' === $settings['innerContainer'] && ! $settings['isGrid'] ) {
394 if ( ! empty( $containerWidth ) ) {
395 $css->add_property( 'max-width', absint( $containerWidth ), 'px' );
396 $css->add_property( 'margin-left', 'auto' );
397 $css->add_property( 'margin-right', 'auto' );
398 }
399 }
400
401 if ( $usingMinHeightFlex ) {
402 $css->add_property( 'width', '100%' );
403
404 $usingMinHeightInnerWidth = true;
405 }
406
407 if ( $innerZIndex || 0 === $innerZIndex ) {
408 $css->add_property( 'z-index', $innerZIndex );
409 $css->add_property( 'position', 'relative' );
410 }
411
412 $css->set_selector( '.gb-container-' . $id . ' a, .gb-container-' . $id . ' a:visited' );
413 $css->add_property( 'color', $settings['linkColor'] );
414
415 $css->set_selector( '.gb-container-' . $id . ' a:hover' );
416 $css->add_property( 'color', $settings['linkColorHover'] );
417
418 if ( $settings['isGrid'] ) {
419 $css->set_selector( '.gb-grid-wrapper > .gb-grid-column-' . $id );
420 $css->add_property( 'width', $settings['width'], '%' );
421
422 $css->add_property( 'flex-grow', $settings['flexGrow'] );
423 $css->add_property( 'flex-shrink', $settings['flexShrink'] );
424
425 if ( is_numeric( $settings['flexBasis'] ) ) {
426 $css->add_property( 'flex-basis', $settings['flexBasis'], $settings['flexBasisUnit'] );
427 } else {
428 $css->add_property( 'flex-basis', $settings['flexBasis'] );
429 }
430 }
431
432 if ( $settings['removeVerticalGap'] ) {
433 $desktop_css->set_selector( '.gb-grid-wrapper > div.gb-grid-column-' . $id );
434 $desktop_css->add_property( 'padding-bottom', '0' );
435 }
436
437 $css->set_selector( '.gb-grid-wrapper > .gb-grid-column-' . $id . ' > .gb-container' );
438 $css->add_property( 'justify-content', $settings['verticalAlignment'] );
439
440 if ( ! empty( $settings['shapeDividers'] ) ) {
441 $css->set_selector( '.gb-container-' . $id );
442 $css->add_property( 'position', 'relative' );
443
444 $default_styles = generateblocks_get_default_styles();
445
446 foreach ( (array) $settings['shapeDividers'] as $index => $options ) {
447 $shapeNumber = $index + 1;
448
449 $shapeOptions = wp_parse_args(
450 $options,
451 $default_styles['container']['shapeDividers']
452 );
453
454 $shapeTransforms = array();
455
456 if ( 'top' === $shapeOptions['location'] ) {
457 $shapeTransforms[] = 'scaleY(-1)';
458 }
459
460 if ( $shapeOptions['flipHorizontally'] ) {
461 $shapeTransforms[] = 'scaleX(-1)';
462 }
463
464 $css->set_selector( '.gb-container-' . $id . ' > .gb-shapes .gb-shape-' . $shapeNumber );
465 $css->add_property( 'color', generateblocks_hex2rgba( $shapeOptions['color'], $shapeOptions['colorOpacity'] ) );
466 $css->add_property( 'z-index', $shapeOptions['zindex'] );
467
468 if ( 'top' === $shapeOptions['location'] || 'bottom' === $shapeOptions['location'] ) {
469 $css->add_property( 'left', '0' );
470 $css->add_property( 'right', '0' );
471 }
472
473 if ( 'bottom' === $shapeOptions['location'] ) {
474 $css->add_property( 'bottom', '-1px' );
475 }
476
477 if ( 'top' === $shapeOptions['location'] ) {
478 $css->add_property( 'top', '-1px' );
479 }
480
481 if ( ! empty( $shapeTransforms ) ) {
482 $css->add_property( 'transform', implode( ' ', $shapeTransforms ) );
483 }
484
485 $shapeWidth = $shapeOptions['width'] . '%';
486
487 if ( 100 === (int) $shapeOptions['width'] ) {
488 $shapeWidth = 'calc(' . $shapeWidth . ' + 1.3px)';
489 }
490
491 $css->set_selector( '.gb-container-' . $id . ' > .gb-shapes .gb-shape-' . $shapeNumber . ' svg' );
492 $css->add_property( 'height', $shapeOptions['height'], 'px' );
493 $css->add_property( 'width', $shapeWidth );
494
495 if ( 'top' === $shapeOptions['location'] || 'bottom' === $shapeOptions['location'] ) {
496 $css->add_property( 'position', 'relative' );
497 $css->add_property( 'left', '50%' );
498 $css->add_property( 'transform', 'translateX(-50%)' );
499 $css->add_property( 'min-width', '100%' );
500 }
501 }
502 }
503
504 $tablet_css->set_selector( '.gb-container-' . $id );
505 $tablet_css->add_property( 'font-size', $settings['fontSizeTablet'], $settings['fontSizeUnit'] );
506 $tablet_css->add_property( 'margin', array( $settings['marginTopTablet'], $settings['marginRightTablet'], $settings['marginBottomTablet'], $settings['marginLeftTablet'] ), $settings['marginUnit'] );
507 $tablet_css->add_property( 'border-radius', array( $settings['borderRadiusTopLeftTablet'], $settings['borderRadiusTopRightTablet'], $settings['borderRadiusBottomRightTablet'], $settings['borderRadiusBottomLeftTablet'] ), $settings['borderRadiusUnit'] );
508 $tablet_css->add_property( 'border-width', array( $settings['borderSizeTopTablet'], $settings['borderSizeRightTablet'], $settings['borderSizeBottomTablet'], $settings['borderSizeLeftTablet'] ), 'px' );
509 $tablet_css->add_property( 'min-height', $settings['minHeightTablet'], $settings['minHeightUnitTablet'] );
510
511 if ( ! $settings['isGrid'] ) {
512 if ( ! $usingMinHeightFlex && $settings['minHeightTablet'] && 'inherit' !== $settings['verticalAlignmentTablet'] ) {
513 $tablet_css->add_property( 'display', 'flex' );
514 $tablet_css->add_property( 'flex-direction', 'row' );
515
516 $usingMinHeightFlex = true;
517 }
518
519 if ( $usingMinHeightFlex && 'inherit' !== $settings['verticalAlignmentTablet'] ) {
520 $tablet_css->add_property( 'align-items', $settings['verticalAlignmentTablet'] );
521 }
522 }
523
524 $tablet_css->add_property( 'text-align', $settings['alignmentTablet'] );
525
526 $tablet_css->set_selector( '.gb-container-' . $id . ' > .gb-inside-container' );
527 $tablet_css->add_property( 'padding', array( $settings['paddingTopTablet'], $settings['paddingRightTablet'], $settings['paddingBottomTablet'], $settings['paddingLeftTablet'] ), $settings['paddingUnit'] );
528
529 $usingMinHeightInnerWidthBoxSizing = false;
530
531 if ( ! $settings['isGrid'] ) {
532 // Needs 100% width if it's a flex item.
533 if ( ! $usingMinHeightInnerWidth && $settings['minHeightTablet'] && 'inherit' !== $settings['verticalAlignmentTablet'] ) {
534 $tablet_css->add_property( 'width', '100%' );
535
536 $usingMinHeightInnerWidth = true;
537 } elseif ( $usingMinHeightInnerWidth ) {
538 if ( 'contained' === $settings['innerContainer'] && ! $settings['isGrid'] ) {
539 $tablet_css->add_property( 'box-sizing', 'border-box' );
540
541 $usingMinHeightInnerWidthBoxSizing = true;
542 }
543 }
544 }
545
546 $tablet_css->set_selector( '.gb-grid-wrapper > .gb-grid-column-' . $id );
547
548 if ( ! $settings['autoWidthTablet'] ) {
549 $tablet_css->add_property( 'width', $settings['widthTablet'], '%' );
550 } else {
551 $tablet_css->add_property( 'width', 'auto' );
552 }
553
554 $tablet_css->add_property( 'flex-grow', $settings['flexGrowTablet'] );
555 $tablet_css->add_property( 'flex-shrink', $settings['flexShrinkTablet'] );
556
557 if ( is_numeric( $settings['flexBasisTablet'] ) ) {
558 $tablet_css->add_property( 'flex-basis', $settings['flexBasisTablet'], $settings['flexBasisUnit'] );
559 } else {
560 $tablet_css->add_property( 'flex-basis', $settings['flexBasisTablet'] );
561 }
562
563 if ( $settings['isGrid'] ) {
564 $tablet_css->add_property( 'order', $settings['orderTablet'] );
565 }
566
567 if ( $settings['removeVerticalGapTablet'] ) {
568 $tablet_only_css->set_selector( '.gb-grid-wrapper > div.gb-grid-column-' . $id );
569 $tablet_only_css->add_property( 'padding-bottom', '0' );
570 }
571
572 $tablet_css->set_selector( '.gb-grid-wrapper > .gb-grid-column-' . $id . ' > .gb-container' );
573
574 if ( 'inherit' !== $settings['verticalAlignmentTablet'] ) {
575 $tablet_css->add_property( 'justify-content', $settings['verticalAlignmentTablet'] );
576 }
577
578 if ( $hasBgImage && 'pseudo-element' === $settings['bgOptions']['selector'] ) {
579 $tablet_css->set_selector( '.gb-container-' . $id . ':before' );
580 $tablet_css->add_property( 'border-radius', array( $settings['borderRadiusTopLeftTablet'], $settings['borderRadiusTopRightTablet'], $settings['borderRadiusBottomRightTablet'], $settings['borderRadiusBottomLeftTablet'] ), $settings['borderRadiusUnit'] );
581 }
582
583 if ( ! empty( $settings['shapeDividers'] ) ) {
584 $default_styles = generateblocks_get_default_styles();
585
586 foreach ( (array) $settings['shapeDividers'] as $index => $options ) {
587 $shapeNumber = $index + 1;
588
589 $shapeOptions = wp_parse_args(
590 $options,
591 $default_styles['container']['shapeDividers']
592 );
593
594 $tablet_css->set_selector( '.gb-container-' . $id . ' > .gb-shapes .gb-shape-' . $shapeNumber . ' svg' );
595 $tablet_css->add_property( 'height', $shapeOptions['heightTablet'], 'px' );
596 $tablet_css->add_property( 'width', $shapeOptions['widthTablet'], '%' );
597 }
598 }
599
600 $mobile_css->set_selector( '.gb-container-' . $id );
601 $mobile_css->add_property( 'font-size', $settings['fontSizeMobile'], $settings['fontSizeUnit'] );
602 $mobile_css->add_property( 'margin', array( $settings['marginTopMobile'], $settings['marginRightMobile'], $settings['marginBottomMobile'], $settings['marginLeftMobile'] ), $settings['marginUnit'] );
603 $mobile_css->add_property( 'border-radius', array( $settings['borderRadiusTopLeftMobile'], $settings['borderRadiusTopRightMobile'], $settings['borderRadiusBottomRightMobile'], $settings['borderRadiusBottomLeftMobile'] ), $settings['borderRadiusUnit'] );
604 $mobile_css->add_property( 'border-width', array( $settings['borderSizeTopMobile'], $settings['borderSizeRightMobile'], $settings['borderSizeBottomMobile'], $settings['borderSizeLeftMobile'] ), 'px' );
605 $mobile_css->add_property( 'min-height', $settings['minHeightMobile'], $settings['minHeightUnitMobile'] );
606
607 if ( ! $settings['isGrid'] ) {
608 if ( ! $usingMinHeightFlex && $settings['minHeightMobile'] && 'inherit' !== $settings['verticalAlignmentMobile'] ) {
609 $mobile_css->add_property( 'display', 'flex' );
610 $mobile_css->add_property( 'flex-direction', 'row' );
611
612 $usingMinHeightFlex = true;
613 }
614
615 if ( $usingMinHeightFlex && 'inherit' !== $settings['verticalAlignmentMobile'] ) {
616 $mobile_css->add_property( 'align-items', $settings['verticalAlignmentMobile'] );
617 }
618 }
619
620 $mobile_css->add_property( 'text-align', $settings['alignmentMobile'] );
621
622 $mobile_css->set_selector( '.gb-container-' . $id . ' > .gb-inside-container' );
623 $mobile_css->add_property( 'padding', array( $settings['paddingTopMobile'], $settings['paddingRightMobile'], $settings['paddingBottomMobile'], $settings['paddingLeftMobile'] ), $settings['paddingUnit'] );
624
625 if ( ! $settings['isGrid'] ) {
626 // Needs 100% width if it's a flex item.
627 if ( ! $usingMinHeightInnerWidth && $settings['minHeightMobile'] && 'inherit' !== $settings['verticalAlignmentMobile'] ) {
628 $mobile_css->add_property( 'width', '100%' );
629 } elseif ( $usingMinHeightInnerWidth && ! $usingMinHeightInnerWidthBoxSizing ) {
630 if ( 'contained' === $settings['innerContainer'] && ! $settings['isGrid'] ) {
631 $mobile_css->add_property( 'box-sizing', 'border-box' );
632 }
633 }
634 }
635
636 $mobile_css->set_selector( '.gb-grid-wrapper > .gb-grid-column-' . $id );
637
638 if ( ! $settings['autoWidthMobile'] ) {
639 $mobile_css->add_property( 'width', $settings['widthMobile'], '%' );
640 }
641
642 if ( $settings['autoWidthMobile'] ) {
643 $mobile_css->add_property( 'width', 'auto' );
644 }
645
646 $mobile_css->add_property( 'flex-grow', $settings['flexGrowMobile'] );
647 $mobile_css->add_property( 'flex-shrink', $settings['flexShrinkMobile'] );
648
649 if ( is_numeric( $settings['flexBasisMobile'] ) ) {
650 $mobile_css->add_property( 'flex-basis', $settings['flexBasisMobile'], $settings['flexBasisUnit'] );
651 } else {
652 $mobile_css->add_property( 'flex-basis', $settings['flexBasisMobile'] );
653 }
654
655 if ( $settings['isGrid'] ) {
656 $mobile_css->add_property( 'order', $settings['orderMobile'] );
657 }
658
659 if ( $settings['removeVerticalGapMobile'] ) {
660 $mobile_css->set_selector( '.gb-grid-wrapper > div.gb-grid-column-' . $id );
661 $mobile_css->add_property( 'padding-bottom', '0' );
662 }
663
664 $mobile_css->set_selector( '.gb-grid-wrapper > .gb-grid-column-' . $id . ' > .gb-container' );
665
666 if ( 'inherit' !== $settings['verticalAlignmentMobile'] ) {
667 $mobile_css->add_property( 'justify-content', $settings['verticalAlignmentMobile'] );
668 }
669
670 if ( $hasBgImage && 'pseudo-element' === $settings['bgOptions']['selector'] ) {
671 $mobile_css->set_selector( '.gb-container-' . $id . ':before' );
672 $mobile_css->add_property( 'border-radius', array( $settings['borderRadiusTopLeftMobile'], $settings['borderRadiusTopRightMobile'], $settings['borderRadiusBottomRightMobile'], $settings['borderRadiusBottomLeftMobile'] ), $settings['borderRadiusUnit'] );
673 }
674
675 if ( ! empty( $settings['shapeDividers'] ) ) {
676 $default_styles = generateblocks_get_default_styles();
677
678 foreach ( (array) $settings['shapeDividers'] as $index => $options ) {
679 $shapeNumber = $index + 1;
680
681 $shapeOptions = wp_parse_args(
682 $options,
683 $default_styles['container']['shapeDividers']
684 );
685
686 $mobile_css->set_selector( '.gb-container-' . $id . ' > .gb-shapes .gb-shape-' . $shapeNumber . ' svg' );
687 $mobile_css->add_property( 'height', $shapeOptions['heightMobile'], 'px' );
688 $mobile_css->add_property( 'width', $shapeOptions['widthMobile'], '%' );
689 }
690 }
691
692 if ( $hasBgImage && 'fixed' === $settings['bgOptions']['attachment'] ) {
693 if ( 'element' === $settings['bgOptions']['selector'] ) {
694 $mobile_css->set_selector( '.gb-container-' . $id );
695 }
696
697 if ( 'pseudo-element' === $settings['bgOptions']['selector'] ) {
698 $mobile_css->set_selector( '.gb-container-' . $id . ':before' );
699 }
700
701 $mobile_css->add_property( 'background-attachment', 'initial' );
702 }
703
704 /**
705 * Do generateblocks_block_css_data hook
706 *
707 * @since 1.0
708 *
709 * @param string $name The name of our block.
710 * @param array $settings The settings for the current block.
711 * @param object $css Our desktop/main CSS data.
712 * @param object $desktop_css Our desktop only CSS data.
713 * @param object $tablet_css Our tablet CSS data.
714 * @param object $tablet_only_css Our tablet only CSS data.
715 * @param object $mobile_css Our mobile CSS data.
716 */
717 do_action(
718 'generateblocks_block_css_data',
719 $name,
720 $settings,
721 $css,
722 $desktop_css,
723 $tablet_css,
724 $tablet_only_css,
725 $mobile_css
726 );
727 }
728
729 if ( $css->css_output() ) {
730 $main_css_data[] = $css->css_output();
731 }
732
733 if ( $desktop_css->css_output() ) {
734 $desktop_css_data[] = $desktop_css->css_output();
735 }
736
737 if ( $tablet_css->css_output() ) {
738 $tablet_css_data[] = $tablet_css->css_output();
739 }
740
741 if ( $tablet_only_css->css_output() ) {
742 $tablet_only_css_data[] = $tablet_only_css->css_output();
743 }
744
745 if ( $mobile_css->css_output() ) {
746 $mobile_css_data[] = $mobile_css->css_output();
747 }
748 }
749
750 /**
751 * Get our Button Container block CSS.
752 *
753 * @since 0.1
754 */
755 if ( 'button-container' === $name ) {
756 if ( empty( $blockData ) ) {
757 continue;
758 }
759
760 $blocks_exist = true;
761
762 $css = new GenerateBlocks_Dynamic_CSS();
763 $desktop_css = new GenerateBlocks_Dynamic_CSS();
764 $tablet_css = new GenerateBlocks_Dynamic_CSS();
765 $tablet_only_css = new GenerateBlocks_Dynamic_CSS();
766 $mobile_css = new GenerateBlocks_Dynamic_CSS();
767
768 $css->set_selector( '.gb-button-wrapper' );
769 $css->add_property( 'display', 'flex' );
770 $css->add_property( 'flex-wrap', 'wrap' );
771 $css->add_property( 'align-items', 'flex-start' );
772 $css->add_property( 'justify-content', 'flex-start' );
773 $css->add_property( 'clear', 'both' );
774
775 foreach ( $blockData as $atts ) {
776 if ( ! isset( $atts['uniqueId'] ) ) {
777 continue;
778 }
779
780 $defaults = generateblocks_get_block_defaults();
781
782 $settings = wp_parse_args(
783 $atts,
784 $defaults['buttonContainer']
785 );
786
787 $id = $atts['uniqueId'];
788 $blockVersion = ! empty( $settings['blockVersion'] ) ? $settings['blockVersion'] : 1;
789
790 $css->set_selector( '.gb-button-wrapper-' . $id );
791 $css->add_property( 'margin', array( $settings['marginTop'], $settings['marginRight'], $settings['marginBottom'], $settings['marginLeft'] ), $settings['marginUnit'] );
792 $css->add_property( 'justify-content', generateblocks_get_flexbox_alignment( $settings['alignment'] ) );
793
794 $stack_desktop = $desktop_css;
795 $stack_tablet_only = $tablet_only_css;
796
797 if ( $blockVersion < 2 ) {
798 $stack_desktop = $css;
799 $stack_tablet_only = $tablet_css;
800 }
801
802 if ( $settings['stack'] ) {
803 $stack_desktop->set_selector( '.gb-button-wrapper-' . $id );
804 $stack_desktop->add_property( 'flex-direction', 'column' );
805 $stack_desktop->add_property( 'align-items', generateblocks_get_flexbox_alignment( $settings['alignment'] ) );
806 }
807
808 if ( $settings['fillHorizontalSpace'] ) {
809 $stack_desktop->set_selector( '.gb-button-wrapper-' . $id . ' > .gb-button' );
810 $stack_desktop->add_property( 'flex', '1' );
811 }
812
813 if ( $settings['stack'] && $settings['fillHorizontalSpace'] ) {
814 $stack_desktop->add_property( 'width', '100%' );
815 $stack_desktop->add_property( 'box-sizing', 'border-box' );
816 }
817
818 $tablet_css->set_selector( '.gb-button-wrapper-' . $id );
819 $tablet_css->add_property( 'margin', array( $settings['marginTopTablet'], $settings['marginRightTablet'], $settings['marginBottomTablet'], $settings['marginLeftTablet'] ), $settings['marginUnit'] );
820 $tablet_css->add_property( 'justify-content', generateblocks_get_flexbox_alignment( $settings['alignmentTablet'] ) );
821
822 if ( $settings['stackTablet'] ) {
823 $stack_tablet_only->set_selector( '.gb-button-wrapper-' . $id );
824 $stack_tablet_only->add_property( 'flex-direction', 'column' );
825 $stack_tablet_only->add_property( 'align-items', generateblocks_get_flexbox_alignment( $settings['alignmentTablet'] ) );
826 }
827
828 if ( $settings['fillHorizontalSpaceTablet'] ) {
829 $stack_tablet_only->set_selector( '.gb-button-wrapper-' . $id . ' > .gb-button' );
830 $stack_tablet_only->add_property( 'flex', '1' );
831 }
832
833 if ( $settings['stackTablet'] && $settings['fillHorizontalSpaceTablet'] ) {
834 $stack_tablet_only->add_property( 'width', '100%' );
835 $stack_tablet_only->add_property( 'box-sizing', 'border-box' );
836 }
837
838 $mobile_css->set_selector( '.gb-button-wrapper-' . $id );
839 $mobile_css->add_property( 'margin', array( $settings['marginTopMobile'], $settings['marginRightMobile'], $settings['marginBottomMobile'], $settings['marginLeftMobile'] ), $settings['marginUnit'] );
840 $mobile_css->add_property( 'justify-content', generateblocks_get_flexbox_alignment( $settings['alignmentMobile'] ) );
841
842 if ( $settings['stackMobile'] ) {
843 $mobile_css->add_property( 'flex-direction', 'column' );
844 $mobile_css->add_property( 'align-items', generateblocks_get_flexbox_alignment( $settings['alignmentMobile'] ) );
845 }
846
847 if ( $settings['fillHorizontalSpaceMobile'] ) {
848 $mobile_css->set_selector( '.gb-button-wrapper-' . $id . ' > .gb-button' );
849 $mobile_css->add_property( 'flex', '1' );
850 }
851
852 if ( $settings['stackMobile'] && $settings['fillHorizontalSpaceMobile'] ) {
853 $mobile_css->add_property( 'width', '100%' );
854 $mobile_css->add_property( 'box-sizing', 'border-box' );
855 }
856
857 /**
858 * Do generateblocks_block_css_data hook
859 *
860 * @since 1.0
861 *
862 * @param string $name The name of our block.
863 * @param array $settings The settings for the current block.
864 * @param object $css Our desktop/main CSS data.
865 * @param object $desktop_css Our desktop only CSS data.
866 * @param object $tablet_css Our tablet CSS data.
867 * @param object $tablet_only_css Our tablet only CSS data.
868 * @param object $mobile_css Our mobile CSS data.
869 */
870 do_action(
871 'generateblocks_block_css_data',
872 $name,
873 $settings,
874 $css,
875 $desktop_css,
876 $tablet_css,
877 $tablet_only_css,
878 $mobile_css
879 );
880 }
881
882 if ( $css->css_output() ) {
883 $main_css_data[] = $css->css_output();
884 }
885
886 if ( $desktop_css->css_output() ) {
887 $desktop_css_data[] = $desktop_css->css_output();
888 }
889
890 if ( $tablet_css->css_output() ) {
891 $tablet_css_data[] = $tablet_css->css_output();
892 }
893
894 if ( $tablet_only_css->css_output() ) {
895 $tablet_only_css_data[] = $tablet_only_css->css_output();
896 }
897
898 if ( $mobile_css->css_output() ) {
899 $mobile_css_data[] = $mobile_css->css_output();
900 }
901 }
902
903 /**
904 * Get our Button block CSS.
905 *
906 * @since 0.1
907 */
908 if ( 'button' === $name ) {
909 if ( empty( $blockData ) ) {
910 continue;
911 }
912
913 $blocks_exist = true;
914
915 $css = new GenerateBlocks_Dynamic_CSS();
916 $desktop_css = new GenerateBlocks_Dynamic_CSS();
917 $tablet_css = new GenerateBlocks_Dynamic_CSS();
918 $tablet_only_css = new GenerateBlocks_Dynamic_CSS();
919 $mobile_css = new GenerateBlocks_Dynamic_CSS();
920
921 if ( ! $icon_css_added ) {
922 $css->set_selector( '.gb-icon' );
923 $css->add_property( 'display', 'inline-flex' );
924 $css->add_property( 'line-height', '0' );
925
926 $css->set_selector( '.gb-icon svg' );
927 $css->add_property( 'height', '1em' );
928 $css->add_property( 'width', '1em' );
929 $css->add_property( 'fill', 'currentColor' );
930
931 $icon_css_added = true;
932 }
933
934 $css->set_selector( '.gb-button-wrapper .gb-button' );
935 $css->add_property( 'display', 'inline-flex' );
936 $css->add_property( 'align-items', 'center' );
937 $css->add_property( 'justify-content', 'center' );
938 $css->add_property( 'text-align', 'center' );
939 $css->add_property( 'text-decoration', 'none' );
940 $css->add_property( 'transition', '.2s background-color ease-in-out, .2s color ease-in-out, .2s border-color ease-in-out, .2s opacity ease-in-out, .2s box-shadow ease-in-out' );
941
942 $css->set_selector( '.gb-button-wrapper .gb-button .gb-icon' );
943 $css->add_property( 'align-items', 'center' );
944
945 foreach ( $blockData as $atts ) {
946 if ( ! isset( $atts['uniqueId'] ) ) {
947 continue;
948 }
949
950 $defaults = generateblocks_get_block_defaults();
951
952 $settings = wp_parse_args(
953 $atts,
954 $defaults['button']
955 );
956
957 $id = $atts['uniqueId'];
958 $blockVersion = ! empty( $settings['blockVersion'] ) ? $settings['blockVersion'] : 1;
959
960 // Use legacy settings if needed.
961 if ( $blockVersion < 2 ) {
962 $settings = GenerateBlocks_Legacy_Attributes::get_settings( '1.4.0', 'button', $settings, $atts );
963 }
964
965 $selector = 'a.gb-button-' . $id;
966
967 if ( isset( $atts['hasUrl'] ) && ! $atts['hasUrl'] ) {
968 $selector = '.gb-button-' . $id;
969 }
970
971 // Back-compatibility for when icon held a value.
972 if ( $settings['icon'] ) {
973 $settings['hasIcon'] = true;
974 }
975
976 $fontFamily = $settings['fontFamily'];
977
978 if ( $fontFamily && $settings['fontFamilyFallback'] ) {
979 $fontFamily = $fontFamily . ', ' . $settings['fontFamilyFallback'];
980 }
981
982 $gradientColorStopOneValue = '';
983 $gradientColorStopTwoValue = '';
984
985 if ( $settings['gradient'] ) {
986 if ( $settings['gradientColorOne'] && '' !== $settings['gradientColorStopOne'] ) {
987 $gradientColorStopOneValue = ' ' . $settings['gradientColorStopOne'] . '%';
988 }
989
990 if ( $settings['gradientColorTwo'] && '' !== $settings['gradientColorStopTwo'] ) {
991 $gradientColorStopTwoValue = ' ' . $settings['gradientColorStopTwo'] . '%';
992 }
993 }
994
995 $css->set_selector( '.gb-button-wrapper ' . $selector . ',.gb-button-wrapper ' . $selector . ':visited' );
996 $css->add_property( 'background-color', generateblocks_hex2rgba( $settings['backgroundColor'], $settings['backgroundColorOpacity'] ) );
997 $css->add_property( 'color', $settings['textColor'] );
998
999 if ( $settings['gradient'] ) {
1000 $css->add_property( 'background-image', 'linear-gradient(' . $settings['gradientDirection'] . 'deg, ' . generateblocks_hex2rgba( $settings['gradientColorOne'], $settings['gradientColorOneOpacity'] ) . $gradientColorStopOneValue . ', ' . generateblocks_hex2rgba( $settings['gradientColorTwo'], $settings['gradientColorTwoOpacity'] ) . $gradientColorStopTwoValue . ')' );
1001 }
1002
1003 $css->add_property( 'font-family', $fontFamily );
1004 $css->add_property( 'font-size', $settings['fontSize'], $settings['fontSizeUnit'] );
1005 $css->add_property( 'font-weight', $settings['fontWeight'] );
1006 $css->add_property( 'text-transform', $settings['textTransform'] );
1007 $css->add_property( 'letter-spacing', $settings['letterSpacing'], 'em' );
1008 $css->add_property( 'padding', array( $settings['paddingTop'], $settings['paddingRight'], $settings['paddingBottom'], $settings['paddingLeft'] ), $settings['paddingUnit'] );
1009 $css->add_property( 'border-radius', array( $settings['borderRadiusTopLeft'], $settings['borderRadiusTopRight'], $settings['borderRadiusBottomRight'], $settings['borderRadiusBottomLeft'] ), $settings['borderRadiusUnit'] );
1010 $css->add_property( 'margin', array( $settings['marginTop'], $settings['marginRight'], $settings['marginBottom'], $settings['marginLeft'] ), $settings['marginUnit'] );
1011 $css->add_property( 'border-width', array( $settings['borderSizeTop'], $settings['borderSizeRight'], $settings['borderSizeBottom'], $settings['borderSizeLeft'] ), 'px' );
1012 $css->add_property( 'border-color', generateblocks_hex2rgba( $settings['borderColor'], $settings['borderColorOpacity'] ) );
1013 $css->add_property( 'text-transform', $settings['textTransform'] );
1014
1015 if ( $settings['hasIcon'] ) {
1016 $css->add_property( 'display', 'inline-flex' );
1017 $css->add_property( 'align-items', 'center' );
1018 }
1019
1020 $css->set_selector( '.gb-button-wrapper ' . $selector . ':hover,.gb-button-wrapper ' . $selector . ':active,.gb-button-wrapper ' . $selector . ':focus' );
1021 $css->add_property( 'background-color', generateblocks_hex2rgba( $settings['backgroundColorHover'], $settings['backgroundColorHoverOpacity'] ) );
1022 $css->add_property( 'color', $settings['textColorHover'] );
1023 $css->add_property( 'border-color', generateblocks_hex2rgba( $settings['borderColorHover'], $settings['borderColorHoverOpacity'] ) );
1024
1025 $css->set_selector( '.gb-button-wrapper ' . $selector . '.gb-button__current, .gb-button-wrapper ' . $selector . '.gb-button__current:visited' );
1026 $css->add_property( 'background-color', $settings['backgroundColorCurrent'] );
1027 $css->add_property( 'color', $settings['textColorCurrent'] );
1028 $css->add_property( 'border-color', $settings['borderColorCurrent'] );
1029
1030 if ( $settings['hasIcon'] ) {
1031 $css->set_selector( $selector . ' .gb-icon' );
1032 $css->add_property( 'font-size', $settings['iconSize'], $settings['iconSizeUnit'] );
1033
1034 if ( ! $settings['removeText'] ) {
1035 $css->add_property( 'padding', array( $settings['iconPaddingTop'], $settings['iconPaddingRight'], $settings['iconPaddingBottom'], $settings['iconPaddingLeft'] ), $settings['iconPaddingUnit'] );
1036 }
1037 }
1038
1039 $tablet_css->set_selector( '.gb-button-wrapper ' . $selector );
1040 $tablet_css->add_property( 'font-size', $settings['fontSizeTablet'], $settings['fontSizeUnit'] );
1041 $tablet_css->add_property( 'letter-spacing', $settings['letterSpacingTablet'], 'em' );
1042 $tablet_css->add_property( 'padding', array( $settings['paddingTopTablet'], $settings['paddingRightTablet'], $settings['paddingBottomTablet'], $settings['paddingLeftTablet'] ), $settings['paddingUnit'] );
1043 $tablet_css->add_property( 'border-radius', array( $settings['borderRadiusTopLeftTablet'], $settings['borderRadiusTopRightTablet'], $settings['borderRadiusBottomRightTablet'], $settings['borderRadiusBottomLeftTablet'] ), $settings['borderRadiusUnit'] );
1044 $tablet_css->add_property( 'margin', array( $settings['marginTopTablet'], $settings['marginRightTablet'], $settings['marginBottomTablet'], $settings['marginLeftTablet'] ), $settings['marginUnit'] );
1045 $tablet_css->add_property( 'border-width', array( $settings['borderSizeTopTablet'], $settings['borderSizeRightTablet'], $settings['borderSizeBottomTablet'], $settings['borderSizeLeftTablet'] ), 'px' );
1046
1047 if ( $settings['hasIcon'] ) {
1048 $tablet_css->set_selector( $selector . ' .gb-icon' );
1049 $tablet_css->add_property( 'font-size', $settings['iconSizeTablet'], $settings['iconSizeUnit'] );
1050
1051 if ( ! $settings['removeText'] ) {
1052 $tablet_css->add_property( 'padding', array( $settings['iconPaddingTopTablet'], $settings['iconPaddingRightTablet'], $settings['iconPaddingBottomTablet'], $settings['iconPaddingLeftTablet'] ), $settings['iconPaddingUnit'] );
1053 }
1054 }
1055
1056 $mobile_css->set_selector( '.gb-button-wrapper ' . $selector );
1057 $mobile_css->add_property( 'font-size', $settings['fontSizeMobile'], $settings['fontSizeUnit'] );
1058 $mobile_css->add_property( 'letter-spacing', $settings['letterSpacingMobile'], 'em' );
1059 $mobile_css->add_property( 'padding', array( $settings['paddingTopMobile'], $settings['paddingRightMobile'], $settings['paddingBottomMobile'], $settings['paddingLeftMobile'] ), $settings['paddingUnit'] );
1060 $mobile_css->add_property( 'border-radius', array( $settings['borderRadiusTopLeftMobile'], $settings['borderRadiusTopRightMobile'], $settings['borderRadiusBottomRightMobile'], $settings['borderRadiusBottomLeftMobile'] ), $settings['borderRadiusUnit'] );
1061 $mobile_css->add_property( 'margin', array( $settings['marginTopMobile'], $settings['marginRightMobile'], $settings['marginBottomMobile'], $settings['marginLeftMobile'] ), $settings['marginUnit'] );
1062 $mobile_css->add_property( 'border-width', array( $settings['borderSizeTopMobile'], $settings['borderSizeRightMobile'], $settings['borderSizeBottomMobile'], $settings['borderSizeLeftMobile'] ), 'px' );
1063
1064 if ( $settings['hasIcon'] ) {
1065 $mobile_css->set_selector( $selector . ' .gb-icon' );
1066 $mobile_css->add_property( 'font-size', $settings['iconSizeMobile'], $settings['iconSizeUnit'] );
1067
1068 if ( ! $settings['removeText'] ) {
1069 $mobile_css->add_property( 'padding', array( $settings['iconPaddingTopMobile'], $settings['iconPaddingRightMobile'], $settings['iconPaddingBottomMobile'], $settings['iconPaddingLeftMobile'] ), $settings['iconPaddingUnit'] );
1070 }
1071 }
1072
1073 /**
1074 * Do generateblocks_block_css_data hook
1075 *
1076 * @since 1.0
1077 *
1078 * @param string $name The name of our block.
1079 * @param array $settings The settings for the current block.
1080 * @param object $css Our desktop/main CSS data.
1081 * @param object $desktop_css Our desktop only CSS data.
1082 * @param object $tablet_css Our tablet CSS data.
1083 * @param object $tablet_only_css Our tablet only CSS data.
1084 * @param object $mobile_css Our mobile CSS data.
1085 */
1086 do_action(
1087 'generateblocks_block_css_data',
1088 $name,
1089 $settings,
1090 $css,
1091 $desktop_css,
1092 $tablet_css,
1093 $tablet_only_css,
1094 $mobile_css
1095 );
1096 }
1097
1098 if ( $css->css_output() ) {
1099 $main_css_data[] = $css->css_output();
1100 }
1101
1102 if ( $desktop_css->css_output() ) {
1103 $desktop_css_data[] = $desktop_css->css_output();
1104 }
1105
1106 if ( $tablet_css->css_output() ) {
1107 $tablet_css_data[] = $tablet_css->css_output();
1108 }
1109
1110 if ( $tablet_only_css->css_output() ) {
1111 $tablet_only_css_data[] = $tablet_only_css->css_output();
1112 }
1113
1114 if ( $mobile_css->css_output() ) {
1115 $mobile_css_data[] = $mobile_css->css_output();
1116 }
1117 }
1118
1119 /**
1120 * Get our Headline block CSS.
1121 *
1122 * @since 0.1
1123 */
1124 if ( 'headline' === $name ) {
1125 if ( empty( $blockData ) ) {
1126 continue;
1127 }
1128
1129 $blocks_exist = true;
1130
1131 $css = new GenerateBlocks_Dynamic_CSS();
1132 $desktop_css = new GenerateBlocks_Dynamic_CSS();
1133 $tablet_css = new GenerateBlocks_Dynamic_CSS();
1134 $tablet_only_css = new GenerateBlocks_Dynamic_CSS();
1135 $mobile_css = new GenerateBlocks_Dynamic_CSS();
1136
1137 if ( ! $icon_css_added ) {
1138 $css->set_selector( '.gb-icon' );
1139 $css->add_property( 'display', 'inline-flex' );
1140 $css->add_property( 'line-height', '0' );
1141
1142 $css->set_selector( '.gb-icon svg' );
1143 $css->add_property( 'height', '1em' );
1144 $css->add_property( 'width', '1em' );
1145 $css->add_property( 'fill', 'currentColor' );
1146
1147 $icon_css_added = true;
1148 }
1149
1150 $css->set_selector( '.gb-highlight' );
1151 $css->add_property( 'background', 'none' );
1152 $css->add_property( 'color', 'unset' );
1153
1154 foreach ( $blockData as $atts ) {
1155 if ( ! isset( $atts['uniqueId'] ) ) {
1156 continue;
1157 }
1158
1159 $defaults = generateblocks_get_block_defaults();
1160
1161 $settings = wp_parse_args(
1162 $atts,
1163 $defaults['headline']
1164 );
1165
1166 $id = $atts['uniqueId'];
1167
1168 $selector = '.gb-headline-' . $id;
1169
1170 if ( apply_filters( 'generateblocks_headline_selector_tagname', true, $atts ) ) {
1171 $selector = $settings['element'] . $selector;
1172 }
1173
1174 // Back-compatibility for when icon held a value.
1175 if ( $settings['icon'] ) {
1176 $settings['hasIcon'] = true;
1177 }
1178
1179 $fontFamily = $settings['fontFamily'];
1180
1181 if ( $fontFamily && $settings['fontFamilyFallback'] ) {
1182 $fontFamily = $fontFamily . ', ' . $settings['fontFamilyFallback'];
1183 }
1184
1185 if ( ! isset( $atts['hasWrapper'] ) ) {
1186 $css->set_selector( $selector );
1187 $css->add_property( 'font-family', $fontFamily );
1188 $css->add_property( 'text-align', $settings['alignment'] );
1189 $css->add_property( 'color', $settings['textColor'] );
1190 $css->add_property( 'background-color', generateblocks_hex2rgba( $settings['backgroundColor'], $settings['backgroundColorOpacity'] ) );
1191 $css->add_property( 'font-size', $settings['fontSize'], $settings['fontSizeUnit'] );
1192 $css->add_property( 'font-weight', $settings['fontWeight'] );
1193 $css->add_property( 'text-transform', $settings['textTransform'] );
1194 $css->add_property( 'line-height', $settings['lineHeight'], $settings['lineHeightUnit'] );
1195 $css->add_property( 'letter-spacing', $settings['letterSpacing'], 'em' );
1196 $css->add_property( 'padding', array( $settings['paddingTop'], $settings['paddingRight'], $settings['paddingBottom'], $settings['paddingLeft'] ), $settings['paddingUnit'] );
1197 $css->add_property( 'margin', array( $settings['marginTop'], $settings['marginRight'], $settings['marginBottom'], $settings['marginLeft'] ), $settings['marginUnit'] );
1198 $css->add_property( 'border-radius', array( $settings['borderRadiusTopLeft'], $settings['borderRadiusTopRight'], $settings['borderRadiusBottomRight'], $settings['borderRadiusBottomLeft'] ), $settings['borderRadiusUnit'] );
1199 $css->add_property( 'border-width', array( $settings['borderSizeTop'], $settings['borderSizeRight'], $settings['borderSizeBottom'], $settings['borderSizeLeft'] ), 'px' );
1200 $css->add_property( 'border-color', generateblocks_hex2rgba( $settings['borderColor'], $settings['borderColorOpacity'] ) );
1201
1202 if ( $settings['inlineWidth'] ) {
1203 if ( $settings['hasIcon'] ) {
1204 $css->add_property( 'display', 'inline-flex' );
1205 } else {
1206 $css->add_property( 'display', 'inline-block' );
1207 }
1208 }
1209
1210 if ( $settings['hasIcon'] ) {
1211 if ( ! $settings['inlineWidth'] ) {
1212 $css->add_property( 'display', 'flex' );
1213 }
1214
1215 if ( 'above' === $settings['iconLocation'] ) {
1216 $css->add_property( 'text-align', $settings['alignment'] );
1217 } else {
1218 $css->add_property( 'justify-content', generateblocks_get_flexbox_alignment( $settings['alignment'] ) );
1219 }
1220
1221 if ( 'inline' === $settings['iconLocation'] ) {
1222 $css->add_property( 'align-items', generateblocks_get_flexbox_alignment( $settings['iconVerticalAlignment'] ) );
1223 }
1224
1225 if ( 'above' === $settings['iconLocation'] ) {
1226 $css->add_property( 'flex-direction', 'column' );
1227 }
1228 }
1229
1230 $css->set_selector( $selector . ' a' );
1231 $css->add_property( 'color', $settings['linkColor'] );
1232
1233 $css->set_selector( $selector . ' a:hover' );
1234 $css->add_property( 'color', $settings['linkColorHover'] );
1235
1236 if ( $settings['hasIcon'] ) {
1237 $css->set_selector( $selector . ' .gb-icon' );
1238 $css->add_property( 'color', generateblocks_hex2rgba( $settings['iconColor'], $settings['iconColorOpacity'] ) );
1239
1240 if ( ! $settings['removeText'] ) {
1241 $css->add_property( 'padding', array( $settings['iconPaddingTop'], $settings['iconPaddingRight'], $settings['iconPaddingBottom'], $settings['iconPaddingLeft'] ), $settings['iconPaddingUnit'] );
1242 }
1243
1244 if ( 'above' === $settings['iconLocation'] ) {
1245 $css->add_property( 'display', 'inline' );
1246 }
1247
1248 $css->set_selector( $selector . ' .gb-icon svg' );
1249 $css->add_property( 'width', $settings['iconSize'], $settings['iconSizeUnit'] );
1250 $css->add_property( 'height', $settings['iconSize'], $settings['iconSizeUnit'] );
1251 }
1252
1253 if ( $settings['highlightTextColor'] ) {
1254 $css->set_selector( $selector . ' .gb-highlight' );
1255 $css->add_property( 'color', $settings['highlightTextColor'] );
1256 }
1257
1258 $tablet_css->set_selector( $selector );
1259 $tablet_css->add_property( 'text-align', $settings['alignmentTablet'] );
1260 $tablet_css->add_property( 'font-size', $settings['fontSizeTablet'], $settings['fontSizeUnit'] );
1261 $tablet_css->add_property( 'line-height', $settings['lineHeightTablet'], $settings['lineHeightUnit'] );
1262 $tablet_css->add_property( 'letter-spacing', $settings['letterSpacingTablet'], 'em' );
1263 $tablet_css->add_property( 'margin', array( $settings['marginTopTablet'], $settings['marginRightTablet'], $settings['marginBottomTablet'], $settings['marginLeftTablet'] ), $settings['marginUnit'] );
1264 $tablet_css->add_property( 'padding', array( $settings['paddingTopTablet'], $settings['paddingRightTablet'], $settings['paddingBottomTablet'], $settings['paddingLeftTablet'] ), $settings['paddingUnit'] );
1265 $tablet_css->add_property( 'border-radius', array( $settings['borderRadiusTopLeftTablet'], $settings['borderRadiusTopRightTablet'], $settings['borderRadiusBottomRightTablet'], $settings['borderRadiusBottomLeftTablet'] ), $settings['borderRadiusUnit'] );
1266 $tablet_css->add_property( 'border-width', array( $settings['borderSizeTopTablet'], $settings['borderSizeRightTablet'], $settings['borderSizeBottomTablet'], $settings['borderSizeLeftTablet'] ), 'px' );
1267
1268 if ( $settings['inlineWidthTablet'] ) {
1269 if ( $settings['hasIcon'] ) {
1270 $tablet_css->add_property( 'display', 'inline-flex' );
1271 } else {
1272 $tablet_css->add_property( 'display', 'inline-block' );
1273 }
1274 }
1275
1276 if ( $settings['hasIcon'] ) {
1277 $tablet_css->add_property( 'justify-content', generateblocks_get_flexbox_alignment( $settings['alignmentTablet'] ) );
1278
1279 if ( 'inline' === $settings['iconLocationTablet'] ) {
1280 $tablet_css->add_property( 'align-items', generateblocks_get_flexbox_alignment( $settings['iconVerticalAlignmentTablet'] ) );
1281 }
1282
1283 if ( 'above' === $settings['iconLocationTablet'] ) {
1284 $tablet_css->add_property( 'flex-direction', 'column' );
1285 }
1286
1287 $tablet_css->set_selector( $selector . ' .gb-icon' );
1288
1289 if ( ! $settings['removeText'] ) {
1290 $tablet_css->add_property( 'padding', array( $settings['iconPaddingTopTablet'], $settings['iconPaddingRightTablet'], $settings['iconPaddingBottomTablet'], $settings['iconPaddingLeftTablet'] ), $settings['iconPaddingUnit'] );
1291 }
1292
1293 if ( 'above' === $settings['iconLocationTablet'] || ( 'above' === $settings['iconLocation'] && '' == $settings['iconLocationTablet'] ) ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
1294 $tablet_css->add_property( 'align-self', generateblocks_get_flexbox_alignment( $settings['alignmentTablet'] ) );
1295 }
1296
1297 if ( 'above' === $settings['iconLocationTablet'] ) {
1298 $tablet_css->add_property( 'display', 'inline' );
1299 }
1300
1301 $tablet_css->set_selector( $selector . ' .gb-icon svg' );
1302 $tablet_css->add_property( 'width', $settings['iconSizeTablet'], $settings['iconSizeUnit'] );
1303 $tablet_css->add_property( 'height', $settings['iconSizeTablet'], $settings['iconSizeUnit'] );
1304 }
1305
1306 $mobile_css->set_selector( $selector );
1307 $mobile_css->add_property( 'text-align', $settings['alignmentMobile'] );
1308 $mobile_css->add_property( 'font-size', $settings['fontSizeMobile'], $settings['fontSizeUnit'] );
1309 $mobile_css->add_property( 'line-height', $settings['lineHeightMobile'], $settings['lineHeightUnit'] );
1310 $mobile_css->add_property( 'letter-spacing', $settings['letterSpacingMobile'], 'em' );
1311 $mobile_css->add_property( 'margin', array( $settings['marginTopMobile'], $settings['marginRightMobile'], $settings['marginBottomMobile'], $settings['marginLeftMobile'] ), $settings['marginUnit'] );
1312 $mobile_css->add_property( 'padding', array( $settings['paddingTopMobile'], $settings['paddingRightMobile'], $settings['paddingBottomMobile'], $settings['paddingLeftMobile'] ), $settings['paddingUnit'] );
1313 $mobile_css->add_property( 'border-radius', array( $settings['borderRadiusTopLeftMobile'], $settings['borderRadiusTopRightMobile'], $settings['borderRadiusBottomRightMobile'], $settings['borderRadiusBottomLeftMobile'] ), $settings['borderRadiusUnit'] );
1314 $mobile_css->add_property( 'border-width', array( $settings['borderSizeTopMobile'], $settings['borderSizeRightMobile'], $settings['borderSizeBottomMobile'], $settings['borderSizeLeftMobile'] ), 'px' );
1315
1316 if ( $settings['inlineWidthMobile'] ) {
1317 if ( $settings['hasIcon'] ) {
1318 $mobile_css->add_property( 'display', 'inline-flex' );
1319 } else {
1320 $mobile_css->add_property( 'display', 'inline-block' );
1321 }
1322 }
1323
1324 if ( $settings['hasIcon'] ) {
1325 $mobile_css->add_property( 'justify-content', generateblocks_get_flexbox_alignment( $settings['alignmentMobile'] ) );
1326
1327 if ( 'inline' === $settings['iconLocationMobile'] ) {
1328 $mobile_css->add_property( 'align-items', generateblocks_get_flexbox_alignment( $settings['iconVerticalAlignmentMobile'] ) );
1329 }
1330
1331 if ( 'above' === $settings['iconLocationMobile'] ) {
1332 $mobile_css->add_property( 'flex-direction', 'column' );
1333 }
1334
1335 $mobile_css->set_selector( $selector . ' .gb-icon' );
1336
1337 if ( ! $settings['removeText'] ) {
1338 $mobile_css->add_property( 'padding', array( $settings['iconPaddingTopMobile'], $settings['iconPaddingRightMobile'], $settings['iconPaddingBottomMobile'], $settings['iconPaddingLeftMobile'] ), $settings['iconPaddingUnit'] );
1339 }
1340
1341 if ( 'above' === $settings['iconLocationMobile'] || ( 'above' === $settings['iconLocation'] && '' == $settings['iconLocationMobile'] ) ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
1342 $mobile_css->add_property( 'align-self', generateblocks_get_flexbox_alignment( $settings['alignmentMobile'] ) );
1343 }
1344
1345 if ( 'above' === $settings['iconLocationMobile'] ) {
1346 $mobile_css->add_property( 'display', 'inline' );
1347 }
1348
1349 $mobile_css->set_selector( $selector . ' .gb-icon svg' );
1350 $mobile_css->add_property( 'width', $settings['iconSizeMobile'], $settings['iconSizeUnit'] );
1351 $mobile_css->add_property( 'height', $settings['iconSizeMobile'], $settings['iconSizeUnit'] );
1352 }
1353 } else {
1354 // The below CSS is for users using the old headline wrapper.
1355 $css->set_selector( '.gb-headline-wrapper' );
1356 $css->add_property( 'display', 'flex' );
1357
1358 $css->set_selector( '.gb-headline-wrapper > .gb-headline' );
1359 $css->add_property( 'margin', '0' );
1360 $css->add_property( 'padding', '0' );
1361
1362 $css->set_selector( '.gb-headline-' . $id );
1363 $css->add_property( 'font-family', $fontFamily );
1364 $css->add_property( 'text-align', $settings['alignment'] );
1365 $css->add_property( 'color', $settings['textColor'] );
1366
1367 if ( ! $settings['hasIcon'] ) {
1368 $css->add_property( 'background-color', generateblocks_hex2rgba( $settings['backgroundColor'], $settings['backgroundColorOpacity'] ) );
1369
1370 if ( $settings['inlineWidth'] ) {
1371 $css->add_property( 'display', 'inline-block' );
1372 }
1373
1374 $css->add_property( 'border-width', array( $settings['borderSizeTop'], $settings['borderSizeRight'], $settings['borderSizeBottom'], $settings['borderSizeLeft'] ), 'px' );
1375 $css->add_property( 'border-color', generateblocks_hex2rgba( $settings['borderColor'], $settings['borderColorOpacity'] ) );
1376 }
1377
1378 $css->add_property( 'font-size', $settings['fontSize'], $settings['fontSizeUnit'] );
1379 $css->add_property( 'font-weight', $settings['fontWeight'] );
1380 $css->add_property( 'text-transform', $settings['textTransform'] );
1381 $css->add_property( 'line-height', $settings['lineHeight'], $settings['lineHeightUnit'] );
1382 $css->add_property( 'letter-spacing', $settings['letterSpacing'], 'em' );
1383
1384 if ( ! $settings['hasIcon'] ) {
1385 $css->add_property( 'padding', array( $settings['paddingTop'], $settings['paddingRight'], $settings['paddingBottom'], $settings['paddingLeft'] ), $settings['paddingUnit'] );
1386 $css->add_property( 'margin', array( $settings['marginTop'], $settings['marginRight'], $settings['marginBottom'], $settings['marginLeft'] ), $settings['marginUnit'] );
1387
1388 if ( function_exists( 'generate_get_default_fonts' ) && '' === $settings['marginBottom'] ) {
1389 $defaultBlockStyles = generateblocks_get_default_styles();
1390
1391 if ( isset( $defaultBlockStyles['headline'][ $settings['element'] ]['marginBottom'] ) ) {
1392 $css->add_property( 'margin-bottom', $defaultBlockStyles['headline'][ $settings['element'] ]['marginBottom'], $defaultBlockStyles['headline'][ $settings['element'] ]['marginUnit'] );
1393 }
1394 }
1395 }
1396
1397 $css->set_selector( '.gb-headline-' . $id . ' a, .gb-headline-' . $id . ' a:visited' );
1398 $css->add_property( 'color', $settings['linkColor'] );
1399
1400 $css->set_selector( '.gb-headline-' . $id . ' a:hover' );
1401 $css->add_property( 'color', $settings['linkColorHover'] );
1402
1403 if ( $settings['hasIcon'] ) {
1404 $css->set_selector( '.gb-headline-wrapper-' . $id . ' .gb-icon' );
1405
1406 if ( ! $settings['removeText'] ) {
1407 $css->add_property( 'padding', array( $settings['iconPaddingTop'], $settings['iconPaddingRight'], $settings['iconPaddingBottom'], $settings['iconPaddingLeft'] ), $settings['iconPaddingUnit'] );
1408 }
1409
1410 $css->add_property( 'color', generateblocks_hex2rgba( $settings['iconColor'], $settings['iconColorOpacity'] ) );
1411
1412 if ( 'above' === $settings['iconLocation'] ) {
1413 $css->add_property( 'display', 'inline' );
1414 }
1415
1416 $css->set_selector( '.gb-headline-wrapper-' . $id . ' .gb-icon svg' );
1417 $css->add_property( 'width', $settings['iconSize'], $settings['iconSizeUnit'] );
1418 $css->add_property( 'height', $settings['iconSize'], $settings['iconSizeUnit'] );
1419
1420 $css->set_selector( '.gb-headline-wrapper-' . $id );
1421 $css->add_property( 'padding', array( $settings['paddingTop'], $settings['paddingRight'], $settings['paddingBottom'], $settings['paddingLeft'] ), $settings['paddingUnit'] );
1422 $css->add_property( 'margin', array( $settings['marginTop'], $settings['marginRight'], $settings['marginBottom'], $settings['marginLeft'] ), $settings['marginUnit'] );
1423
1424 $defaultBlockStyles = generateblocks_get_default_styles();
1425
1426 if ( '' === $settings['marginBottom'] && ! $settings['removeText'] && isset( $defaultBlockStyles['headline'][ $settings['element'] ]['marginBottom'] ) && is_numeric( $defaultBlockStyles['headline'][ $settings['element'] ]['marginBottom'] ) ) {
1427 $css->add_property( 'margin-bottom', $defaultBlockStyles['headline'][ $settings['element'] ]['marginBottom'], $defaultBlockStyles['headline'][ $settings['element'] ]['marginUnit'] );
1428 }
1429
1430 if ( '' === $settings['fontSize'] && ! $settings['removeText'] && isset( $defaultBlockStyles['headline'][ $settings['element'] ]['fontSize'] ) ) {
1431 $css->add_property( 'font-size', $defaultBlockStyles['headline'][ $settings['element'] ]['fontSize'], $defaultBlockStyles['headline'][ $settings['element'] ]['fontSizeUnit'] );
1432 } else {
1433 $css->add_property( 'font-size', $settings['fontSize'], $settings['fontSizeUnit'] );
1434 }
1435
1436 if ( 'above' === $settings['iconLocation'] ) {
1437 $css->add_property( 'text-align', $settings['alignment'] );
1438 } else {
1439 $css->add_property( 'justify-content', generateblocks_get_flexbox_alignment( $settings['alignment'] ) );
1440 }
1441
1442 if ( $settings['inlineWidth'] ) {
1443 $css->add_property( 'display', 'inline-flex' );
1444 }
1445
1446 if ( 'inline' === $settings['iconLocation'] ) {
1447 $css->add_property( 'align-items', generateblocks_get_flexbox_alignment( $settings['iconVerticalAlignment'] ) );
1448 }
1449
1450 $css->add_property( 'background-color', generateblocks_hex2rgba( $settings['backgroundColor'], $settings['backgroundColorOpacity'] ) );
1451 $css->add_property( 'color', $settings['textColor'] );
1452 $css->add_property( 'border-width', array( $settings['borderSizeTop'], $settings['borderSizeRight'], $settings['borderSizeBottom'], $settings['borderSizeLeft'] ), 'px' );
1453 $css->add_property( 'border-color', generateblocks_hex2rgba( $settings['borderColor'], $settings['borderColorOpacity'] ) );
1454
1455 if ( 'above' === $settings['iconLocation'] ) {
1456 $css->add_property( 'flex-direction', 'column' );
1457 }
1458 }
1459
1460 if ( $settings['highlightTextColor'] ) {
1461 $css->set_selector( '.gb-headline-' . $id . ' .gb-highlight' );
1462 $css->add_property( 'color', $settings['highlightTextColor'] );
1463 }
1464
1465 $tablet_css->set_selector( '.gb-headline-' . $id );
1466 $tablet_css->add_property( 'text-align', $settings['alignmentTablet'] );
1467 $tablet_css->add_property( 'font-size', $settings['fontSizeTablet'], $settings['fontSizeUnit'] );
1468 $tablet_css->add_property( 'line-height', $settings['lineHeightTablet'], $settings['lineHeightUnit'] );
1469 $tablet_css->add_property( 'letter-spacing', $settings['letterSpacingTablet'], 'em' );
1470
1471 if ( ! $settings['hasIcon'] ) {
1472 $tablet_css->add_property( 'margin', array( $settings['marginTopTablet'], $settings['marginRightTablet'], $settings['marginBottomTablet'], $settings['marginLeftTablet'] ), $settings['marginUnit'] );
1473 $tablet_css->add_property( 'padding', array( $settings['paddingTopTablet'], $settings['paddingRightTablet'], $settings['paddingBottomTablet'], $settings['paddingLeftTablet'] ), $settings['paddingUnit'] );
1474 $tablet_css->add_property( 'border-width', array( $settings['borderSizeTopTablet'], $settings['borderSizeRightTablet'], $settings['borderSizeBottomTablet'], $settings['borderSizeLeftTablet'] ), 'px' );
1475
1476 if ( $settings['inlineWidthTablet'] ) {
1477 $tablet_css->add_property( 'display', 'inline-flex' );
1478 }
1479 }
1480
1481 if ( $settings['hasIcon'] ) {
1482 $tablet_css->set_selector( '.gb-headline-wrapper-' . $id . ' .gb-icon' );
1483
1484 if ( ! $settings['removeText'] ) {
1485 $tablet_css->add_property( 'padding', array( $settings['iconPaddingTopTablet'], $settings['iconPaddingRightTablet'], $settings['iconPaddingBottomTablet'], $settings['iconPaddingLeftTablet'] ), $settings['iconPaddingUnit'] );
1486 }
1487
1488 if ( 'above' === $settings['iconLocationTablet'] || ( 'above' === $settings['iconLocation'] && '' == $settings['iconLocationTablet'] ) ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
1489 $tablet_css->add_property( 'align-self', generateblocks_get_flexbox_alignment( $settings['alignmentTablet'] ) );
1490 }
1491
1492 $tablet_css->set_selector( '.gb-headline-wrapper-' . $id . ' .gb-icon svg' );
1493 $tablet_css->add_property( 'width', $settings['iconSizeTablet'], $settings['iconSizeUnit'] );
1494 $tablet_css->add_property( 'height', $settings['iconSizeTablet'], $settings['iconSizeUnit'] );
1495
1496 $tablet_css->set_selector( '.gb-headline-wrapper-' . $id );
1497 $tablet_css->add_property( 'margin', array( $settings['marginTopTablet'], $settings['marginRightTablet'], $settings['marginBottomTablet'], $settings['marginLeftTablet'] ), $settings['marginUnit'] );
1498 $tablet_css->add_property( 'padding', array( $settings['paddingTopTablet'], $settings['paddingRightTablet'], $settings['paddingBottomTablet'], $settings['paddingLeftTablet'] ), $settings['paddingUnit'] );
1499 $tablet_css->add_property( 'border-width', array( $settings['borderSizeTopTablet'], $settings['borderSizeRightTablet'], $settings['borderSizeBottomTablet'], $settings['borderSizeLeftTablet'] ), 'px' );
1500 $tablet_css->add_property( 'justify-content', generateblocks_get_flexbox_alignment( $settings['alignmentTablet'] ) );
1501
1502 $defaultBlockStyles = generateblocks_get_default_styles();
1503
1504 if ( '' === $settings['marginBottomTablet'] && ! $settings['removeText'] && isset( $defaultBlockStyles['headline'][ $settings['element'] ]['marginBottomTablet'] ) && is_numeric( $defaultBlockStyles['headline'][ $settings['element'] ]['marginBottomTablet'] ) ) {
1505 $tablet_css->add_property( 'margin-bottom', $defaultBlockStyles['headline'][ $settings['element'] ]['marginBottomTablet'], $defaultBlockStyles['headline'][ $settings['element'] ]['marginUnit'] );
1506 }
1507
1508 if ( '' === $settings['fontSizeTablet'] && ! $settings['removeText'] && isset( $defaultBlockStyles['headline'][ $settings['element'] ]['fontSizeTablet'] ) ) {
1509 $tablet_css->add_property( 'font-size', $defaultBlockStyles['headline'][ $settings['element'] ]['fontSizeTablet'], $defaultBlockStyles['headline'][ $settings['element'] ]['fontSizeUnit'] );
1510 } else {
1511 $tablet_css->add_property( 'font-size', $settings['fontSizeTablet'], $settings['fontSizeUnit'] );
1512 }
1513
1514 if ( $settings['inlineWidthTablet'] ) {
1515 $tablet_css->add_property( 'display', 'inline-flex' );
1516 }
1517
1518 if ( 'inline' === $settings['iconLocationTablet'] ) {
1519 $tablet_css->add_property( 'align-items', generateblocks_get_flexbox_alignment( $settings['iconVerticalAlignmentTablet'] ) );
1520 }
1521
1522 if ( 'above' === $settings['iconLocationTablet'] ) {
1523 $tablet_css->add_property( 'flex-direction', 'column' );
1524 }
1525 }
1526
1527 $mobile_css->set_selector( '.gb-headline-' . $id );
1528 $mobile_css->add_property( 'text-align', $settings['alignmentMobile'] );
1529 $mobile_css->add_property( 'font-size', $settings['fontSizeMobile'], $settings['fontSizeUnit'] );
1530 $mobile_css->add_property( 'line-height', $settings['lineHeightMobile'], $settings['lineHeightUnit'] );
1531 $mobile_css->add_property( 'letter-spacing', $settings['letterSpacingMobile'], 'em' );
1532
1533 if ( ! $settings['hasIcon'] ) {
1534 $mobile_css->add_property( 'margin', array( $settings['marginTopMobile'], $settings['marginRightMobile'], $settings['marginBottomMobile'], $settings['marginLeftMobile'] ), $settings['marginUnit'] );
1535 $mobile_css->add_property( 'padding', array( $settings['paddingTopMobile'], $settings['paddingRightMobile'], $settings['paddingBottomMobile'], $settings['paddingLeftMobile'] ), $settings['paddingUnit'] );
1536 $mobile_css->add_property( 'border-width', array( $settings['borderSizeTopMobile'], $settings['borderSizeRightMobile'], $settings['borderSizeBottomMobile'], $settings['borderSizeLeftMobile'] ), 'px' );
1537
1538 if ( $settings['inlineWidthMobile'] ) {
1539 $mobile_css->add_property( 'display', 'inline-flex' );
1540 }
1541 }
1542
1543 if ( $settings['hasIcon'] ) {
1544 $mobile_css->set_selector( '.gb-headline-wrapper-' . $id . ' .gb-icon' );
1545
1546 if ( ! $settings['removeText'] ) {
1547 $mobile_css->add_property( 'padding', array( $settings['iconPaddingTopMobile'], $settings['iconPaddingRightMobile'], $settings['iconPaddingBottomMobile'], $settings['iconPaddingLeftMobile'] ), $settings['iconPaddingUnit'] );
1548 }
1549
1550 if ( 'above' === $settings['iconLocationMobile'] || ( 'above' === $settings['iconLocation'] && '' == $settings['iconLocationMobile'] ) || ( 'above' === $settings['iconLocationTablet'] && '' == $settings['iconLocationMobile'] ) ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
1551 $mobile_css->add_property( 'align-self', generateblocks_get_flexbox_alignment( $settings['alignmentMobile'] ) );
1552 }
1553
1554 $mobile_css->set_selector( '.gb-headline-wrapper-' . $id . ' .gb-icon svg' );
1555 $mobile_css->add_property( 'width', $settings['iconSizeMobile'], $settings['iconSizeUnit'] );
1556 $mobile_css->add_property( 'height', $settings['iconSizeMobile'], $settings['iconSizeUnit'] );
1557
1558 $mobile_css->set_selector( '.gb-headline-wrapper-' . $id );
1559 $mobile_css->add_property( 'margin', array( $settings['marginTopMobile'], $settings['marginRightMobile'], $settings['marginBottomMobile'], $settings['marginLeftMobile'] ), $settings['marginUnit'] );
1560 $mobile_css->add_property( 'padding', array( $settings['paddingTopMobile'], $settings['paddingRightMobile'], $settings['paddingBottomMobile'], $settings['paddingLeftMobile'] ), $settings['paddingUnit'] );
1561 $mobile_css->add_property( 'justify-content', generateblocks_get_flexbox_alignment( $settings['alignmentMobile'] ) );
1562
1563 $defaultBlockStyles = generateblocks_get_default_styles();
1564
1565 if ( '' === $settings['marginBottomMobile'] && ! $settings['removeText'] && isset( $defaultBlockStyles['headline'][ $settings['element'] ]['marginBottomMobile'] ) && is_numeric( $defaultBlockStyles['headline'][ $settings['element'] ]['marginBottomMobile'] ) ) {
1566 $mobile_css->add_property( 'margin-bottom', $defaultBlockStyles['headline'][ $settings['element'] ]['marginBottomMobile'], $defaultBlockStyles['headline'][ $settings['element'] ]['marginUnit'] );
1567 }
1568
1569 if ( '' === $settings['fontSizeMobile'] && ! $settings['removeText'] && ! empty( $defaultBlockStyles['headline'][ $settings['element'] ]['fontSizeMobile'] ) ) {
1570 $mobile_css->add_property( 'font-size', $defaultBlockStyles['headline'][ $settings['element'] ]['fontSizeMobile'], $defaultBlockStyles['headline'][ $settings['element'] ]['fontSizeUnit'] );
1571 } else {
1572 $mobile_css->add_property( 'font-size', $settings['fontSizeMobile'], $settings['fontSizeUnit'] );
1573 }
1574
1575 if ( $settings['inlineWidthMobile'] ) {
1576 $mobile_css->add_property( 'display', 'inline-flex' );
1577 }
1578
1579 if ( 'inline' === $settings['iconLocationMobile'] ) {
1580 $mobile_css->add_property( 'align-items', generateblocks_get_flexbox_alignment( $settings['iconVerticalAlignmentMobile'] ) );
1581 }
1582
1583 if ( 'above' === $settings['iconLocationMobile'] ) {
1584 $mobile_css->add_property( 'flex-direction', 'column' );
1585 }
1586 }
1587 }
1588
1589 /**
1590 * Do generateblocks_block_css_data hook
1591 *
1592 * @since 1.0
1593 *
1594 * @param string $name The name of our block.
1595 * @param array $settings The settings for the current block.
1596 * @param object $css Our desktop/main CSS data.
1597 * @param object $desktop_css Our desktop only CSS data.
1598 * @param object $tablet_css Our tablet CSS data.
1599 * @param object $tablet_only_css Our tablet only CSS data.
1600 * @param object $mobile_css Our mobile CSS data.
1601 */
1602 do_action(
1603 'generateblocks_block_css_data',
1604 $name,
1605 $settings,
1606 $css,
1607 $desktop_css,
1608 $tablet_css,
1609 $tablet_only_css,
1610 $mobile_css
1611 );
1612 }
1613
1614 if ( $css->css_output() ) {
1615 $main_css_data[] = $css->css_output();
1616 }
1617
1618 if ( $desktop_css->css_output() ) {
1619 $desktop_css_data[] = $desktop_css->css_output();
1620 }
1621
1622 if ( $tablet_css->css_output() ) {
1623 $tablet_css_data[] = $tablet_css->css_output();
1624 }
1625
1626 if ( $tablet_only_css->css_output() ) {
1627 $tablet_only_css_data[] = $tablet_only_css->css_output();
1628 }
1629
1630 if ( $mobile_css->css_output() ) {
1631 $mobile_css_data[] = $mobile_css->css_output();
1632 }
1633 }
1634
1635 /**
1636 * Get our Image block CSS.
1637 *
1638 * @since 1.5.0
1639 */
1640 if ( 'image' === $name ) {
1641 if ( empty( $blockData ) ) {
1642 continue;
1643 }
1644
1645 $blocks_exist = true;
1646
1647 $css = new GenerateBlocks_Dynamic_CSS();
1648 $desktop_css = new GenerateBlocks_Dynamic_CSS();
1649 $tablet_css = new GenerateBlocks_Dynamic_CSS();
1650 $tablet_only_css = new GenerateBlocks_Dynamic_CSS();
1651 $mobile_css = new GenerateBlocks_Dynamic_CSS();
1652
1653 $css->set_selector( '.gb-block-image img' );
1654 $css->add_property( 'vertical-align', 'middle' );
1655
1656 foreach ( $blockData as $atts ) {
1657 if ( ! isset( $atts['uniqueId'] ) ) {
1658 continue;
1659 }
1660
1661 $defaults = generateblocks_get_block_defaults();
1662
1663 $settings = wp_parse_args(
1664 $atts,
1665 $defaults['image']
1666 );
1667
1668 $id = $atts['uniqueId'];
1669
1670 $css->set_selector( '.gb-block-image-' . $id );
1671 $css->add_property( 'padding', array( $settings['paddingTop'], $settings['paddingRight'], $settings['paddingBottom'], $settings['paddingLeft'] ), $settings['paddingUnit'] );
1672 $css->add_property( 'margin', array( $settings['marginTop'], $settings['marginRight'], $settings['marginBottom'], $settings['marginLeft'] ), $settings['marginUnit'] );
1673
1674 // Set a flag we'll update later if we disable floats.
1675 $disable_float = false;
1676 $has_desktop_float = 'floatLeft' === $settings['alignment'] || 'floatRight' === $settings['alignment'];
1677 $has_tablet_float = 'floatLeft' === $settings['alignmentTablet'] || 'floatRight' === $settings['alignmentTablet'];
1678
1679 if ( $has_desktop_float ) {
1680 $css->add_property( 'float', generateblocks_get_float_alignment( $settings['alignment'] ) );
1681 } else {
1682 $css->add_property( 'text-align', $settings['alignment'] );
1683 }
1684
1685 $css->set_selector( '.gb-image-' . $id );
1686 $css->add_property( 'border-radius', array( $settings['borderRadiusTopLeft'], $settings['borderRadiusTopRight'], $settings['borderRadiusBottomRight'], $settings['borderRadiusBottomLeft'] ), $settings['borderRadiusUnit'] );
1687 $css->add_property( 'border-width', array( $settings['borderSizeTop'], $settings['borderSizeRight'], $settings['borderSizeBottom'], $settings['borderSizeLeft'] ), 'px' );
1688 $css->add_property( 'border-color', $settings['borderColor'] );
1689 $css->add_property( 'width', $settings['width'] );
1690 $css->add_property( 'height', $settings['height'] );
1691 $css->add_property( 'object-fit', $settings['objectFit'] );
1692
1693 $tablet_css->set_selector( '.gb-block-image-' . $id );
1694 $tablet_css->add_property( 'padding', array( $settings['paddingTopTablet'], $settings['paddingRightTablet'], $settings['paddingBottomTablet'], $settings['paddingLeftTablet'] ), $settings['paddingUnit'] );
1695 $tablet_css->add_property( 'margin', array( $settings['marginTopTablet'], $settings['marginRightTablet'], $settings['marginBottomTablet'], $settings['marginLeftTablet'] ), $settings['marginUnit'] );
1696
1697 if ( $has_tablet_float ) {
1698 $tablet_css->add_property( 'float', generateblocks_get_float_alignment( $settings['alignmentTablet'] ) );
1699 } else {
1700 $tablet_css->add_property( 'text-align', $settings['alignmentTablet'] );
1701
1702 if ( $settings['alignmentTablet'] && $has_desktop_float ) {
1703 $tablet_css->add_property( 'float', 'none' );
1704 $disable_float = true;
1705 }
1706 }
1707
1708 $tablet_css->set_selector( '.gb-image-' . $id );
1709 $tablet_css->add_property( 'border-radius', array( $settings['borderRadiusTopLeftTablet'], $settings['borderRadiusTopRightTablet'], $settings['borderRadiusBottomRightTablet'], $settings['borderRadiusBottomLeftTablet'] ), $settings['borderRadiusUnit'] );
1710 $tablet_css->add_property( 'border-width', array( $settings['borderSizeTopTablet'], $settings['borderSizeRightTablet'], $settings['borderSizeBottomTablet'], $settings['borderSizeLeftTablet'] ), 'px' );
1711 $tablet_css->add_property( 'width', $settings['widthTablet'] );
1712 $tablet_css->add_property( 'height', $settings['heightTablet'] );
1713 $tablet_css->add_property( 'object-fit', $settings['objectFitTablet'] );
1714
1715 $mobile_css->set_selector( '.gb-block-image-' . $id );
1716 $mobile_css->add_property( 'padding', array( $settings['paddingTopMobile'], $settings['paddingRightMobile'], $settings['paddingBottomMobile'], $settings['paddingLeftMobile'] ), $settings['paddingUnit'] );
1717 $mobile_css->add_property( 'margin', array( $settings['marginTopMobile'], $settings['marginRightMobile'], $settings['marginBottomMobile'], $settings['marginLeftMobile'] ), $settings['marginUnit'] );
1718
1719 if ( 'floatLeft' === $settings['alignmentMobile'] || 'floatRight' === $settings['alignmentMobile'] ) {
1720 $mobile_css->add_property( 'float', generateblocks_get_float_alignment( $settings['alignmentMobile'] ) );
1721 } else {
1722 $mobile_css->add_property( 'text-align', $settings['alignmentMobile'] );
1723
1724 if (
1725 $settings['alignmentMobile'] &&
1726 ! $disable_float &&
1727 (
1728 $has_desktop_float ||
1729 $has_tablet_float
1730 )
1731 ) {
1732 $mobile_css->add_property( 'float', 'none' );
1733 }
1734 }
1735
1736 $mobile_css->set_selector( '.gb-image-' . $id );
1737 $mobile_css->add_property( 'border-radius', array( $settings['borderRadiusTopLeftMobile'], $settings['borderRadiusTopRightMobile'], $settings['borderRadiusBottomRightMobile'], $settings['borderRadiusBottomLeftMobile'] ), $settings['borderRadiusUnit'] );
1738 $mobile_css->add_property( 'border-width', array( $settings['borderSizeTopMobile'], $settings['borderSizeRightMobile'], $settings['borderSizeBottomMobile'], $settings['borderSizeLeftMobile'] ), 'px' );
1739 $mobile_css->add_property( 'width', $settings['widthMobile'] );
1740 $mobile_css->add_property( 'height', $settings['heightMobile'] );
1741 $mobile_css->add_property( 'object-fit', $settings['objectFitMobile'] );
1742
1743 /**
1744 * Do generateblocks_block_css_data hook
1745 *
1746 * @since 1.0
1747 *
1748 * @param string $name The name of our block.
1749 * @param array $settings The settings for the current block.
1750 * @param object $css Our desktop/main CSS data.
1751 * @param object $desktop_css Our desktop only CSS data.
1752 * @param object $tablet_css Our tablet CSS data.
1753 * @param object $tablet_only_css Our tablet only CSS data.
1754 * @param object $mobile_css Our mobile CSS data.
1755 */
1756 do_action(
1757 'generateblocks_block_css_data',
1758 $name,
1759 $settings,
1760 $css,
1761 $desktop_css,
1762 $tablet_css,
1763 $tablet_only_css,
1764 $mobile_css
1765 );
1766 }
1767
1768 if ( $css->css_output() ) {
1769 $main_css_data[] = $css->css_output();
1770 }
1771
1772 if ( $desktop_css->css_output() ) {
1773 $desktop_css_data[] = $desktop_css->css_output();
1774 }
1775
1776 if ( $tablet_css->css_output() ) {
1777 $tablet_css_data[] = $tablet_css->css_output();
1778 }
1779
1780 if ( $tablet_only_css->css_output() ) {
1781 $tablet_only_css_data[] = $tablet_only_css->css_output();
1782 }
1783
1784 if ( $mobile_css->css_output() ) {
1785 $mobile_css_data[] = $mobile_css->css_output();
1786 }
1787 }
1788 }
1789
1790 if ( ! $blocks_exist ) {
1791 return false;
1792 }
1793
1794 return apply_filters(
1795 'generateblocks_css_device_data',
1796 array(
1797 'main' => $main_css_data,
1798 'desktop' => $desktop_css_data,
1799 'tablet' => $tablet_css_data,
1800 'tablet_only' => $tablet_only_css_data,
1801 'mobile' => $mobile_css_data,
1802 ),
1803 $settings
1804 );
1805 }
1806
1807 /**
1808 * Turn our CSS array into plain CSS.
1809 *
1810 * @since 1.0
1811 *
1812 * @param array $data Our CSS data.
1813 */
1814 function generateblocks_get_parsed_css( $data ) {
1815 $output = '';
1816
1817 foreach ( $data as $device => $selectors ) {
1818 foreach ( $selectors as $selector => $properties ) {
1819 if ( ! count( $properties ) ) {
1820 continue;
1821 }
1822
1823 $temporary_output = $selector . '{';
1824 $elements_added = 0;
1825
1826 foreach ( $properties as $key => $value ) {
1827 if ( empty( $value ) ) {
1828 continue;
1829 }
1830
1831 $elements_added++;
1832 $temporary_output .= $value;
1833 }
1834
1835 $temporary_output .= '}';
1836
1837 if ( $elements_added > 0 ) {
1838 $output .= $temporary_output;
1839 }
1840 }
1841 }
1842
1843 return $output;
1844 }
1845
1846 /**
1847 * Print our CSS for each block.
1848 *
1849 * @since 0.1
1850 */
1851 function generateblocks_get_frontend_block_css() {
1852 if ( ! function_exists( 'has_blocks' ) ) {
1853 return;
1854 }
1855
1856 $content = generateblocks_get_parsed_content();
1857
1858 if ( ! $content ) {
1859 return;
1860 }
1861
1862 $data = generateblocks_get_dynamic_css( $content );
1863
1864 if ( ! $data ) {
1865 return;
1866 }
1867
1868 $css = '';
1869
1870 $css .= generateblocks_get_parsed_css( $data['main'] );
1871
1872 if ( ! empty( $data['desktop'] ) ) {
1873 $css .= sprintf(
1874 '@media %1$s {%2$s}',
1875 generateblocks_get_media_query( 'desktop' ),
1876 generateblocks_get_parsed_css( $data['desktop'] )
1877 );
1878 }
1879
1880 if ( ! empty( $data['tablet'] ) ) {
1881 $css .= sprintf(
1882 '@media %1$s {%2$s}',
1883 generateblocks_get_media_query( 'tablet' ),
1884 generateblocks_get_parsed_css( $data['tablet'] )
1885 );
1886 }
1887
1888 if ( ! empty( $data['tablet_only'] ) ) {
1889 $css .= sprintf(
1890 '@media %1$s {%2$s}',
1891 generateblocks_get_media_query( 'tablet_only' ),
1892 generateblocks_get_parsed_css( $data['tablet_only'] )
1893 );
1894 }
1895
1896 if ( ! empty( $data['mobile'] ) ) {
1897 $css .= sprintf(
1898 '@media %1$s {%2$s}',
1899 generateblocks_get_media_query( 'mobile' ),
1900 generateblocks_get_parsed_css( $data['mobile'] )
1901 );
1902 }
1903
1904 return apply_filters( 'generateblocks_css_output', $css );
1905 }
1906