| @@ -1,0 +1,38 @@ | ||
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace ABlocks\Blocks\ModalPanel; | |
| 4 | + | |
| 5 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 6 | + exit; | |
| 7 | +} | |
| 8 | + | |
| 9 | +use ABlocks\Classes\BlockBaseAbstract; | |
| 10 | +use ABlocks\Classes\CssGenerator; | |
| 11 | + | |
| 12 | +class Block extends BlockBaseAbstract { | |
| 13 | + protected $parent_block_name = 'modal'; | |
| 14 | + protected $block_name = 'modal-panel'; | |
| 15 | + | |
| 16 | + public function __construct() { | |
| 17 | + parent::__construct(); | |
| 18 | + add_filter( 'ablocks/get_render_block_content', [ $this, 'render_static_block_content' ], 10, 3 ); | |
| 19 | + } | |
| 20 | + | |
| 21 | + public function build_css( $attributes ) { | |
| 22 | + $css_generator = new CssGenerator( $attributes ); | |
| 23 | + return $css_generator->generate_css(); | |
| 24 | + } | |
| 25 | + | |
| 26 | + public function render_static_block_content( $content, $attributes, $block_instance ) { | |
| 27 | + if ( $block_instance->name === $this->namespace . '/' . $this->block_name ) { | |
| 28 | + return preg_replace( | |
| 29 | + '/<div\s+class="ablocks-block-modal---panel-wrap"(?![^>]*style=)/i', | |
| 30 | + '<div class="ablocks-block-modal---panel-wrap" style="opacity:0;visibility:hidden;"', | |
| 31 | + $content | |
| 32 | + ); | |
| 33 | + } | |
| 34 | + return $content; | |
| 35 | + } | |
| 36 | + | |
| 37 | + | |
| 38 | +} | |