| 1 |
<?php |
| 2 |
$prefix = 'bBlocksMailto'; |
| 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( 'bBlocksMailtoStyle' ) ) { |
| 10 |
function bBlocksMailtoStyle($attributes, $id, $prefix){ |
| 11 |
extract( $attributes ); |
| 12 |
|
| 13 |
$mailToSl = "#$id .$prefix"; |
| 14 |
|
| 15 |
$mailtoStyle = new BBlocksStyleGenerator(); |
| 16 |
$mailtoStyle::addStyle( "$mailToSl", [ |
| 17 |
'text-align' => $mailtoAlign |
| 18 |
] ); |
| 19 |
$mailtoStyle::addStyle( "$mailToSl a.mailtoButton", [ |
| 20 |
GetCSS::getColorsCSS( $btnColors ) => '', |
| 21 |
'padding' => GetCSS::getSpaceCSS( $btnPadding ), |
| 22 |
GetCSS::getBorderCSS( $btnBorder ) => '', |
| 23 |
'box-shadow' => '0px 5px 20px 0px '. $btnColors['bg'] |
| 24 |
] ); |
| 25 |
$mailtoStyle::addStyle( "$mailToSl a.mailtoButton:hover", [ |
| 26 |
GetCSS::getColorsCSS( $btnHovColors ) => '', |
| 27 |
'box-shadow' => '0px 5px 20px 0px '. $btnHovColors['bg'] |
| 28 |
] ); |
| 29 |
|
| 30 |
return GetCSS::getTypoCSS( '', $btnTypo )['googleFontLink'] . |
| 31 |
GetCSS::getTypoCSS( "$mailToSl a.mailtoButton", $btnTypo )['styles'] . |
| 32 |
$mailtoStyle::renderStyle(); |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
extract( $attributes ); |
| 37 |
?> |
| 38 |
<div |
| 39 |
<?php // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- get_block_wrapper_attributes() is properly escaped ?> |
| 40 |
<?php echo get_block_wrapper_attributes( [ 'class' => $planClass ] ); ?> |
| 41 |
id='<?php echo esc_attr( $id ); ?>' |
| 42 |
> |
| 43 |
<style> |
| 44 |
<?php echo esc_html( bBlocksMailtoStyle( $attributes, $id, $prefix ) ); ?> |
| 45 |
</style> |
| 46 |
|
| 47 |
<div class='<?php echo esc_attr( $prefix ); ?>'> |
| 48 |
<a href='<?php echo 'mailto:' . esc_attr( sanitize_email( $receiverMail ) ); ?>' class='mailtoui mailtoButton'> |
| 49 |
<?php echo 'left' === $iconPosition && $icon['class'] ? "<i class='". esc_html( $icon['class'] ) ."'></i>" : ''; ?> |
| 50 |
|
| 51 |
<span><?php echo wp_kses_post( $btn ); ?></span> |
| 52 |
|
| 53 |
<?php echo 'right' === $iconPosition && $icon['class'] ? "<i class='". esc_html( $icon['class'] ) ."'></i>" : ''; ?> |
| 54 |
</a> |
| 55 |
</div> |
| 56 |
</div> |