| Conditions | 9 |
| Paths | 80 |
| Total Lines | 44 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 24 | function jetpack_gif_block_render( $attr ) { |
||
| 25 | $padding_top = isset( $attr['paddingTop'] ) ? $attr['paddingTop'] : 0; |
||
| 26 | $style = 'padding-top:' . $padding_top; |
||
| 27 | $giphy_url = isset( $attr['giphyUrl'] ) |
||
| 28 | ? Jetpack_Gutenberg::validate_block_embed_url( $attr['giphyUrl'], array( 'giphy.com' ) ) |
||
| 29 | : null; |
||
| 30 | $search_text = isset( $attr['searchText'] ) ? $attr['searchText'] : ''; |
||
| 31 | $caption = isset( $attr['caption'] ) ? $attr['caption'] : null; |
||
| 32 | |||
| 33 | if ( ! $giphy_url ) { |
||
|
|
|||
| 34 | return null; |
||
| 35 | } |
||
| 36 | |||
| 37 | $classes = Jetpack_Gutenberg::block_classes( 'gif', $attr ); |
||
| 38 | |||
| 39 | $placeholder = sprintf( '<a href="%s">%s</a>', esc_url( $giphy_url ), esc_attr( $search_text ) ); |
||
| 40 | |||
| 41 | ob_start(); |
||
| 42 | ?> |
||
| 43 | <div class="<?php echo esc_attr( $classes ); ?>"> |
||
| 44 | <figure> |
||
| 45 | <?php if ( class_exists( 'Jetpack_AMP_Support' ) && Jetpack_AMP_Support::is_amp_request() ) : ?> |
||
| 46 | <amp-iframe src="<?php echo esc_url( $giphy_url ); ?>" width="100" height="<?php echo absint( $padding_top ); ?>" sandbox="allow-scripts allow-same-origin" layout="responsive"> |
||
| 47 | <div placeholder> |
||
| 48 | <?php echo wp_kses_post( $placeholder ); ?> |
||
| 49 | </div> |
||
| 50 | </amp-iframe> |
||
| 51 | <?php else : ?> |
||
| 52 | <div class="wp-block-jetpack-gif-wrapper" style="<?php echo esc_attr( $style ); ?>"> |
||
| 53 | <iframe src="<?php echo esc_url( $giphy_url ); ?>" title="<?php echo esc_attr( $search_text ); ?>"></iframe> |
||
| 54 | </div> |
||
| 55 | <?php endif; ?> |
||
| 56 | <?php if ( $caption ) : ?> |
||
| 57 | <figcaption class="wp-block-jetpack-gif-caption gallery-caption"><?php echo wp_kses_post( $caption ); ?></figcaption> |
||
| 58 | <?php endif; ?> |
||
| 59 | </figure> |
||
| 60 | </div> |
||
| 61 | <?php |
||
| 62 | $html = ob_get_clean(); |
||
| 63 | |||
| 64 | Jetpack_Gutenberg::load_assets_as_required( 'gif' ); |
||
| 65 | |||
| 66 | return $html; |
||
| 67 | } |
||
| 68 |
In PHP, under loose comparison (like
==, or!=, orswitchconditions), values of different types might be equal.For
stringvalues, the empty string''is a special case, in particular the following results might be unexpected: