| 1 |
<?php |
| 2 |
$prefix = 'bBlocksGif'; |
| 3 |
$id = wp_unique_id( "$prefix-" ); |
| 4 |
$planClass = BBlocks\Inc\Utils::isPro() ? 'pro' : 'free'; |
| 5 |
|
| 6 |
// Generate Styles |
| 7 |
if( !function_exists( 'bBlocksGifStyle' ) ) { |
| 8 |
function bBlocksGifStyle($attributes, $id, $prefix){ |
| 9 |
extract( $attributes ); |
| 10 |
|
| 11 |
$mainSl = "#$id"; |
| 12 |
$gifSl = "$mainSl .$prefix"; |
| 13 |
|
| 14 |
$gifW = '0px' === $gifWidth || '0%' === $gifWidth || '0em' === $gifWidth ? 'auto' : $gifWidth; |
| 15 |
|
| 16 |
$gifCSS = "$gifSl{ |
| 17 |
text-align: $gifAlign; |
| 18 |
} |
| 19 |
$gifSl figure{ |
| 20 |
width: $gifW; |
| 21 |
}"; |
| 22 |
|
| 23 |
return $gifCSS; |
| 24 |
} |
| 25 |
} |
| 26 |
|
| 27 |
extract( $attributes ); |
| 28 |
?> |
| 29 |
<div |
| 30 |
<?php // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- get_block_wrapper_attributes() is properly escaped ?> |
| 31 |
<?php echo get_block_wrapper_attributes( [ 'class' => $planClass ] ); ?> |
| 32 |
id='<?php echo esc_attr( $id ); ?>' |
| 33 |
> |
| 34 |
<style><?php echo esc_html( bBlocksGifStyle( $attributes, $id, $prefix ) ); ?></style> |
| 35 |
|
| 36 |
<div class='<?php echo esc_attr( $prefix ); ?>'> |
| 37 |
<figure> |
| 38 |
<?php echo !empty( $gif ) ? "<img src='". esc_url( $gif['images']['original']['url'] ?? '' ) ."' alt='". esc_attr( $gif['title'] ?? '' ) ."' />" : ''; ?> |
| 39 |
</figure> |
| 40 |
</div> |
| 41 |
</div> |