Conditions | 9 |
Paths | 160 |
Total Lines | 41 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
24 | function jetpack_gif_block_render( $attr ) { |
||
25 | $align = isset( $attr['align'] ) ? $attr['align'] : 'center'; |
||
26 | $padding_top = isset( $attr['paddingTop'] ) ? $attr['paddingTop'] : 0; |
||
27 | $style = 'padding-top:' . $padding_top; |
||
28 | $giphy_url = isset( $attr['giphyUrl'] ) ? $attr['giphyUrl'] : null; |
||
29 | $search_text = isset( $attr['searchText'] ) ? $attr['searchText'] : ''; |
||
30 | $caption = isset( $attr['caption'] ) ? $attr['caption'] : null; |
||
31 | |||
32 | if ( ! $giphy_url ) { |
||
33 | return null; |
||
34 | } |
||
35 | |||
36 | $classes = array( |
||
37 | 'wp-block-jetpack-gif', |
||
38 | 'align' . $align, |
||
39 | ); |
||
40 | if ( isset( $attr['className'] ) ) { |
||
41 | array_push( $classes, $attr['className'] ); |
||
42 | } |
||
43 | |||
44 | ob_start(); |
||
45 | ?> |
||
46 | <div class="<?php echo esc_attr( implode( $classes, ' ' ) ); ?>"> |
||
47 | <figure> |
||
48 | <div class="wp-block-jetpack-gif-wrapper" style="<?php echo esc_attr( $style ); ?>"> |
||
49 | <iframe src="<?php echo esc_url( $giphy_url ); ?>" |
||
50 | title="<?php echo esc_attr( $search_text ); ?>"></iframe> |
||
51 | </div> |
||
52 | <?php if ( $caption ) : ?> |
||
53 | <figcaption |
||
54 | class="wp-block-jetpack-gif-caption gallery-caption"><?php echo wp_kses_post( $caption ); ?></figcaption> |
||
55 | <?php endif; ?> |
||
56 | </figure> |
||
57 | </div> |
||
58 | <?php |
||
59 | $html = ob_get_clean(); |
||
60 | |||
61 | Jetpack_Gutenberg::load_assets_as_required( 'gif' ); |
||
62 | |||
63 | return $html; |
||
64 | } |
||
65 |