This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* @package ogre-consent
|
||||
* @author cleverogre
|
||||
* @copyright 2026 CleverOgre
|
||||
* @license GLP-3.0-or-later
|
||||
* @version 0.0.0
|
||||
* @since 0.0.0
|
||||
*/
|
||||
|
||||
namespace Ogre\Consent\Services;
|
||||
|
||||
use Ogre\Consent\BlockService;
|
||||
use WP_Block;
|
||||
use Override;
|
||||
use WP_HTML_Tag_Processor;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
final class YouTube extends BlockService {
|
||||
|
||||
protected function __construct() {
|
||||
parent::__construct('core/iframe', 'youtube');
|
||||
}
|
||||
|
||||
#[Override]
|
||||
public function render_block(string $block_content, array $block, WP_Block $instance): string
|
||||
{
|
||||
// TODO: Check block iframe type
|
||||
|
||||
$tags = new WP_HTML_Tag_Processor($block_content);
|
||||
|
||||
if ($tags->next_tag('iframe')) {
|
||||
$tags->set_attribute('data-name', $this->name);
|
||||
$src = $tags->get_attribute('src');
|
||||
$tags->remove_attribute('src');
|
||||
$tags->set_attribute('data-src', $src);
|
||||
}
|
||||
|
||||
return $tags->get_updated_html();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
YouTube::instance();
|
||||
Reference in New Issue
Block a user