| | |
| | | <?php |
| | | namespace JVBase\blocks; |
| | | |
| | | use JVBase\blocks\CustomBlocks; |
| | | if (!defined('ABSPATH')) { |
| | | exit; |
| | | } |
| | |
| | | */ |
| | | public function render($attributes, $content): string |
| | | { |
| | | |
| | | // Extract attributes with defaults |
| | | $poster_id = $attributes['posterId'] ?? 0; |
| | | $video_sources = $attributes['videoSources'] ?? []; |
| | |
| | | "uploadDate": "'.$date.'" |
| | | } |
| | | </script> |
| | | <div class="wrap"> |
| | | <div class="wrap abs edges"> |
| | | <div class="video-container">'; |
| | | $html .= '<video'; |
| | | $html .= ' muted loop playsinline autoplay'; |
| | |
| | | } |
| | | |
| | | $html .= '</video>'; |
| | | $html .= '</div></div><div class="inner-wrap"></div></section>'; |
| | | |
| | | $inner_content = $this->extractInnerContent($content); |
| | | $html .= '</div></div><div class="inner-wrap">'.$inner_content.'</div></section>'; |
| | | |
| | | return $html; |
| | | } |
| | | |
| | | /** |
| | | * Extract inner content from the saved block content |
| | | * Removes the wrapper div and returns just the inner blocks HTML |
| | | */ |
| | | protected function extractInnerContent(string $content): string |
| | | { |
| | | if (empty($content)) { |
| | | return ''; |
| | | } |
| | | |
| | | // Remove the placeholder wrapper div |
| | | $content = preg_replace('/<div[^>]*class="[^"]*video-cover-wrapper-placeholder[^"]*"[^>]*>/', '', $content, 1); |
| | | $content = preg_replace('/<\/div>\s*$/', '', $content, 1); |
| | | |
| | | return trim($content); |
| | | } |
| | | } |