| 1 |
<?php |
| 2 |
$prefix = 'bBlocksInfoBox'; |
| 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( 'bBlocksInfoBoxStyle' ) ) { |
| 10 |
function bBlocksInfoBoxStyle($attributes, $id, $prefix){ |
| 11 |
extract( $attributes ); |
| 12 |
|
| 13 |
$mainSl = "#$id"; |
| 14 |
$infoBoxSl = "$mainSl .$prefix"; |
| 15 |
|
| 16 |
$infoBoxStyle = new BBlocksStyleGenerator(); |
| 17 |
$infoBoxStyle::addStyle( "$mainSl", [ |
| 18 |
'text-align' => $infoBoxAlign |
| 19 |
] ); |
| 20 |
$infoBoxStyle::addStyle( "$infoBoxSl", [ |
| 21 |
'text-align' => $textAlign, |
| 22 |
'width' => '0px' === $width || '0%' === $width || '0em' === $width ? '100%' : $width, |
| 23 |
GetCSS::getBackgroundCSS( $background ) => '', |
| 24 |
'padding' => GetCSS::getSpaceCSS( $padding ), |
| 25 |
GetCSS::getBorderCSS( $border ) => '', |
| 26 |
'box-shadow' => GetCSS::getShadowCSS( $shadow ) |
| 27 |
] ); |
| 28 |
$infoBoxStyle::addStyle( "$infoBoxSl .infoBoxIcon", [ |
| 29 |
'margin' => GetCSS::getSpaceCSS( $iconMargin ) |
| 30 |
] ); |
| 31 |
$infoBoxStyle::addStyle( "$infoBoxSl .infoBoxIcon i", [ |
| 32 |
GetCSS::getIconCSS( $icon ) => '' |
| 33 |
] ); |
| 34 |
$infoBoxStyle::addStyle( "$infoBoxSl .infoBoxTitle", [ |
| 35 |
'color' => $titleColor, |
| 36 |
'margin' => GetCSS::getSpaceCSS( $titleMargin ) |
| 37 |
] ); |
| 38 |
$infoBoxStyle::addStyle( "$infoBoxSl .infoBoxDescription", [ |
| 39 |
'color' => $descColor, |
| 40 |
'margin' => GetCSS::getSpaceCSS( $descMargin ) |
| 41 |
] ); |
| 42 |
$infoBoxStyle::addStyle( "$infoBoxSl .infoBoxButton", [ |
| 43 |
GetCSS::getColorsCSS( $btnColors ) => '', |
| 44 |
'padding' => GetCSS::getSpaceCSS( $btnPadding ), |
| 45 |
GetCSS::getBorderCSS( $btnBorder ) => '' |
| 46 |
] ); |
| 47 |
$infoBoxStyle::addStyle( "$infoBoxSl .infoBoxButton:hover", [ |
| 48 |
GetCSS::getColorsCSS( $btnHovColors ) => '' |
| 49 |
] ); |
| 50 |
|
| 51 |
return GetCSS::getTypoCSS( '', $titleTypo )['googleFontLink'] . |
| 52 |
GetCSS::getTypoCSS( '', $descTypo )['googleFontLink'] . |
| 53 |
GetCSS::getTypoCSS( '', $btnTypo )['googleFontLink'] . |
| 54 |
GetCSS::getTypoCSS( "$infoBoxSl .infoBoxTitle", $titleTypo )['styles'] . |
| 55 |
GetCSS::getTypoCSS( "$infoBoxSl .infoBoxDescription", $descTypo )['styles'] . |
| 56 |
GetCSS::getTypoCSS( "$infoBoxSl .infoBoxButton", $btnTypo )['styles'] . |
| 57 |
$infoBoxStyle::renderStyle(); |
| 58 |
} |
| 59 |
} |
| 60 |
|
| 61 |
extract( $attributes ); |
| 62 |
|
| 63 |
$btnTab = $isLinkNewTab ? '_blank' : ''; |
| 64 |
?> |
| 65 |
<div |
| 66 |
<?php // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- get_block_wrapper_attributes() is properly escaped ?> |
| 67 |
<?php echo get_block_wrapper_attributes( [ 'class' => $planClass ] ); ?> |
| 68 |
id='<?php echo esc_attr( $id ); ?>' |
| 69 |
> |
| 70 |
<style> |
| 71 |
<?php echo esc_html( bBlocksInfoBoxStyle( $attributes, $id, $prefix ) ); ?> |
| 72 |
</style> |
| 73 |
|
| 74 |
<div class='bBlocksInfoBox'> |
| 75 |
<?php echo $isIcon && $icon['class'] ? "<div class='infoBoxIcon'><i class='". esc_html( $icon['class'] ) ."'></i></div>" : ''; ?> |
| 76 |
<?php echo $title ? "<h3 class='infoBoxTitle'>". wp_kses_post( $title ) ."</h3>" : ''; ?> |
| 77 |
<?php echo $isDesc && $desc ? "<p class='infoBoxDescription'>". wp_kses_post( $desc ) ."</p>" : ''; ?> |
| 78 |
<?php echo $isBtn && $btn ? "<a href='". esc_url( $btnLink ) ."' class='infoBoxButton' target='". esc_attr( $btnTab ) ."' rel='noreferrer noopener'>". wp_kses_post( $btn ) ."</a>" : ''; ?> |
| 79 |
</div> |
| 80 |
</div> |