PluginProbe
bBlocks – Essential Gutenberg Blocks & Patterns Collection / trunk
bBlocks – Essential Gutenberg Blocks & Patterns Collection vtrunk
2.1.6 2.1.5 2.1.4 2.1.3 2.1.2 2.1.1 2.1.0 2.0.43 2.0.42 2.0.41 2.0.40 2.0.39 2.0.38 trunk 1.0 1.1 1.2 1.3 1.4 1.5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 All 106 releases
b-blocks / build / gif / render.php

render.php in bBlocks – Essential Gutenberg Blocks & Patterns Collection trunk, at build/gif/render.php

41 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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>