| 1 |
<?php |
| 2 |
$prefix = 'bBlocksFeatureBoxes'; |
| 3 |
$id = wp_unique_id( "$prefix-" ); |
| 4 |
$planClass = BBlocks\Inc\Utils::isPro() ? 'pro' : 'free'; |
| 5 |
|
| 6 |
use BBlocks\Inc\GetCSS as GetCSS; |
| 7 |
|
| 8 |
// Generate Styles |
| 9 |
if( !function_exists( 'bBlocksFeatureBoxesStyle' ) ) { |
| 10 |
function bBlocksFeatureBoxesStyle($attributes, $id, $prefix){ |
| 11 |
extract( $attributes ); |
| 12 |
|
| 13 |
$mainSl = "#$id"; |
| 14 |
$featureBoxesSl = "$mainSl .$prefix"; |
| 15 |
$gFeatureSl = "$featureBoxesSl .feature"; |
| 16 |
|
| 17 |
$featureBoxesStyle = new BBlocksStyleGenerator(); |
| 18 |
$featureBoxesStyle::addStyle( "$featureBoxesSl", [ |
| 19 |
'grid-gap' => "$rowGap $columnGap" |
| 20 |
] ); |
| 21 |
$featureBoxesStyle::addStyle( "$gFeatureSl", [ |
| 22 |
'text-align' => $textAlign, |
| 23 |
'padding' => GetCSS::getSpaceCSS( $padding ) |
| 24 |
] ); |
| 25 |
$featureBoxesStyle::addStyle( "$gFeatureSl .featureIcon", [ |
| 26 |
'margin' => GetCSS::getSpaceCSS( $iconMargin ) |
| 27 |
] ); |
| 28 |
$featureBoxesStyle::addStyle( "$gFeatureSl .featureTitle", [ |
| 29 |
'margin' => GetCSS::getSpaceCSS( $titleMargin ) |
| 30 |
] ); |
| 31 |
$featureBoxesStyle::addStyle( "$gFeatureSl .featureSeparator", [ |
| 32 |
'margin' => GetCSS::getSpaceCSS( $sepMargin ) |
| 33 |
] ); |
| 34 |
|
| 35 |
$childCSS = ""; |
| 36 |
foreach ( $features as $index => $feature ) { |
| 37 |
extract( $feature ); |
| 38 |
|
| 39 |
$featureSl = "$mainSl #feature-$index"; |
| 40 |
|
| 41 |
$backgroundStyle = GetCSS::getBackgroundCSS($background ); |
| 42 |
$iconStyle = GetCSS::getIconCSS($icon ); |
| 43 |
$separatorStyle = GetCSS::getSeparatorCSS($separator ); |
| 44 |
|
| 45 |
$childCSS .= " |
| 46 |
$featureSl{ $backgroundStyle } |
| 47 |
$featureSl .featureIcon i{ $iconStyle } |
| 48 |
$featureSl .featureIcon img{ width: $iconWidth; } |
| 49 |
$featureSl .featureTitle{ color: $titleColor; } |
| 50 |
$featureSl .featureSeparator{ $separatorStyle } |
| 51 |
$featureSl .featureDescription{ color: $descColor; } |
| 52 |
"; |
| 53 |
} |
| 54 |
|
| 55 |
return GetCSS::getTypoCSS( '', $titleTypo )['googleFontLink'] . |
| 56 |
GetCSS::getTypoCSS( '', $descTypo )['googleFontLink'] . |
| 57 |
GetCSS::getTypoCSS( "$gFeatureSl .featureTitle", $titleTypo )['styles'] . |
| 58 |
GetCSS::getTypoCSS( "$gFeatureSl .featureDescription", $descTypo )['styles'] . |
| 59 |
$featureBoxesStyle::renderStyle() . |
| 60 |
$childCSS; |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
extract( $attributes ); |
| 65 |
?> |
| 66 |
<div |
| 67 |
<?php // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- get_block_wrapper_attributes() is properly escaped ?> |
| 68 |
<?php echo get_block_wrapper_attributes( [ 'class' => $planClass ] ); ?> |
| 69 |
id='<?php echo esc_attr( $id ); ?>' |
| 70 |
> |
| 71 |
<style><?php echo esc_html( bBlocksFeatureBoxesStyle( $attributes, $id, $prefix ) ); ?></style> |
| 72 |
|
| 73 |
<div class='<?php echo esc_attr( $prefix ); ?> columns-<?php echo esc_attr( $columns['desktop'] ); ?> columns-tablet-<?php echo esc_attr( $columns['tablet'] ); ?> columns-mobile-<?php echo esc_attr( $columns['mobile'] ); ?>'> |
| 74 |
<?php foreach ( $features as $index => $feature ) { |
| 75 |
extract( $feature ); ?> |
| 76 |
|
| 77 |
<div class='feature' id='feature-<?php echo esc_attr( $index ); ?>'> |
| 78 |
<div class='featureIcon'> |
| 79 |
<?php echo $isUpIcon ? // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- inline constructed with esc_url/esc_attr below. |
| 80 |
( $upIcon['url'] ? "<img src='". esc_url( $upIcon['url'] ) ."' alt='". esc_attr( $upIcon['alt'] ) ."' />" : '' ) : |
| 81 |
( $icon['class'] ? "<i class='". esc_attr( $icon['class'] ) ."'></i>" : '' ); ?> |
| 82 |
</div> |
| 83 |
|
| 84 |
<div class='featureDetails'> |
| 85 |
<?php echo $isTitle && $title ? "<h4 class='featureTitle'>". wp_kses_post( $title ) ."</h4>" : ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- static wrapper tags with wp_kses_post-escaped content. ?> |
| 86 |
|
| 87 |
<?php echo $isSep ? "<span class='featureSeparator'></span>" : ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- static markup, no user input. ?> |
| 88 |
|
| 89 |
<?php echo $isDesc && $desc ? "<p class='featureDescription'>". wp_kses_post( $desc ) ."</p>" : ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- static wrapper tags with wp_kses_post-escaped content. ?> |
| 90 |
</div> |
| 91 |
</div> |
| 92 |
<?php } ?> |
| 93 |
</div> |
| 94 |
</div> |