block-embedpress.php
31 lines
| 1 | <?php |
| 2 | // Exit if accessed directly. |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | exit; |
| 5 | } |
| 6 | /** |
| 7 | * It renders gutenberg block of embedpress on the frontend |
| 8 | * @param array $attributes |
| 9 | */ |
| 10 | function embedpress_render_block($attributes){ |
| 11 | if ( !empty( $attributes['embedHTML']) ) { |
| 12 | $embed = apply_filters( 'embedpress_gutenberg_embed', $attributes['embedHTML'], $attributes ); |
| 13 | $aligns = [ |
| 14 | 'left' => 'alignleft', |
| 15 | 'right' => 'alignright', |
| 16 | 'wide' => 'alignwide', |
| 17 | 'full' => 'alignfull' |
| 18 | ]; |
| 19 | $alignment = isset($attributes['align']) && isset($aligns[$attributes['align']])?$aligns[$attributes['align']]:''; |
| 20 | ob_start(); |
| 21 | ?> |
| 22 | <div class="embedpress-gutenberg-wrapper <?php echo esc_attr($alignment) ?>"> |
| 23 | <div class="wp-block-embed__wrapper"> |
| 24 | <?php echo $embed; ?> |
| 25 | </div> |
| 26 | </div> |
| 27 | <?php |
| 28 | return ob_get_clean(); |
| 29 | } |
| 30 | } |
| 31 |