| 1 |
<?php |
| 2 |
$prefix = 'bBlocksPriceLists'; |
| 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( 'bBlocksPriceListsStyle' ) ) { |
| 10 |
function bBlocksPriceListsStyle($attributes, $id, $prefix){ |
| 11 |
extract( $attributes ); |
| 12 |
|
| 13 |
$mainSl = "#$id"; |
| 14 |
$priceListsSl = "$mainSl .$prefix"; |
| 15 |
$gPriceSl = "$priceListsSl .priceItem"; |
| 16 |
|
| 17 |
$priceListsStyle = new BBlocksStyleGenerator(); |
| 18 |
$priceListsStyle::addStyle( "$priceListsSl", [ |
| 19 |
'grid-gap' => "$rowGap $columnGap" |
| 20 |
] ); |
| 21 |
$priceListsStyle::addStyle( "$gPriceSl", [ |
| 22 |
'text-align' => $textAlign, |
| 23 |
'padding' => GetCSS::getSpaceCSS( $padding ) |
| 24 |
] ); |
| 25 |
$priceListsStyle::addStyle( "$gPriceSl .productImage", [ |
| 26 |
'margin' => GetCSS::getSpaceCSS( $imgMargin ) |
| 27 |
] ); |
| 28 |
$priceListsStyle::addStyle( "$gPriceSl .productName", [ |
| 29 |
'margin' => GetCSS::getSpaceCSS( $nameMargin ) |
| 30 |
] ); |
| 31 |
$priceListsStyle::addStyle( "$gPriceSl .productDescription", [ |
| 32 |
'margin' => GetCSS::getSpaceCSS( $descMargin ) |
| 33 |
] ); |
| 34 |
|
| 35 |
$childCSS = ""; |
| 36 |
foreach ( $products as $index => $product ) { |
| 37 |
extract( $product ); |
| 38 |
$priceSl = "$mainSl #priceItem-$index"; |
| 39 |
|
| 40 |
$backgroundStyle = GetCSS::getBackgroundCSS( $background ); |
| 41 |
$imgBorderStyle = GetCSS::getBorderCSS( $imgBorder ); |
| 42 |
$separatorStyle = GetCSS::getSeparatorCSS( $separator ); |
| 43 |
|
| 44 |
$childCSS .= " |
| 45 |
$priceSl{ $backgroundStyle } |
| 46 |
$priceSl .productImage{ $imgBorderStyle } |
| 47 |
$priceSl .productName{ color: $nameColor; } |
| 48 |
$priceSl .productDescription{ color: $descColor; } |
| 49 |
$priceSl .productPrice{ color: $priceColor; } |
| 50 |
$priceSl .productSeparator{ $separatorStyle } |
| 51 |
"; |
| 52 |
} |
| 53 |
|
| 54 |
return GetCSS::getTypoCSS( '', $nameTypo )['googleFontLink'] . |
| 55 |
GetCSS::getTypoCSS( '', $descTypo )['googleFontLink'] . |
| 56 |
GetCSS::getTypoCSS( '', $priceTypo )['googleFontLink'] . |
| 57 |
GetCSS::getTypoCSS( "$gPriceSl .productName", $nameTypo )['styles'] . |
| 58 |
GetCSS::getTypoCSS( "$gPriceSl .productDescription", $descTypo )['styles'] . |
| 59 |
GetCSS::getTypoCSS( "$gPriceSl .productPrice", $priceTypo )['styles'] . |
| 60 |
$priceListsStyle::renderStyle() . |
| 61 |
$childCSS; |
| 62 |
} |
| 63 |
} |
| 64 |
|
| 65 |
extract( $attributes ); |
| 66 |
?> |
| 67 |
<div |
| 68 |
<?php // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- get_block_wrapper_attributes() is properly escaped ?> |
| 69 |
<?php echo get_block_wrapper_attributes( [ 'class' => $planClass ] ); ?> |
| 70 |
id='<?php echo esc_attr( $id ); ?>' |
| 71 |
> |
| 72 |
<style><?php echo esc_html( bBlocksPriceListsStyle( $attributes, $id, $prefix ) ); ?></style> |
| 73 |
|
| 74 |
<div class='<?php echo esc_attr( $prefix ); ?> <?php echo esc_attr( $layout ?? 'vertical' ); ?> columns-<?php echo esc_attr( $columns['desktop'] ); ?> columns-tablet-<?php echo esc_attr( $columns['tablet'] ); ?> columns-mobile-<?php echo esc_attr( $columns['mobile'] ); ?>'> |
| 75 |
<?php foreach ( $products as $index => $product ) { |
| 76 |
extract( $product ); ?> |
| 77 |
|
| 78 |
<div class='priceItem' id='priceItem-<?php echo esc_attr( $index ); ?>'> |
| 79 |
<?php echo $img['url'] ? "<img class='productImage' src='". esc_url( $img['url'] ) ."' alt='". esc_attr( $img['alt'] ) ."' />" : ''; ?> |
| 80 |
|
| 81 |
<div class='productDetails'> |
| 82 |
<h4 class='productName'><?php echo wp_kses_post( $name ); ?></h4> |
| 83 |
|
| 84 |
<?php echo $isDesc ? "<p class='productDescription'>". wp_kses_post( $desc ) ."</p>" : ''; ?> |
| 85 |
|
| 86 |
<span class='productPrice'><?php echo wp_kses_post( $price ); ?></span> |
| 87 |
</div> |
| 88 |
|
| 89 |
<?php echo $isSep ? "<span class='productSeparator'></span>" : ''; ?> |
| 90 |
</div> |
| 91 |
<?php } ?> |
| 92 |
</div> |
| 93 |
</div> |