This commit is contained in:
@@ -10,34 +10,15 @@
|
||||
|
||||
namespace Ogre\Consent\Services;
|
||||
|
||||
use Ogre\Consent\BlockService;
|
||||
use WP_Block;
|
||||
use Override;
|
||||
use WP_HTML_Tag_Processor;
|
||||
use Ogre\Consent as Plugin;
|
||||
use Ogre\Consent\EmbedBlockService;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
final class YouTube extends BlockService {
|
||||
final class YouTube extends EmbedBlockService {
|
||||
|
||||
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();
|
||||
parent::__construct('youtube', Plugin::__('YouTube'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user