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