Wrap or annotate what a Benecaster block renders
Every block in the Blocks & Widgets Library renders by running the Benecaster shortcode it stands for. benecaster_blocks_block_render receives that HTML with the block’s name, its attributes and the exact shortcode, so you can wrap or annotate one kind of block — here, giving every Episode Player a wrapper your theme can style.
Only while the add-on is active. The block also saves its shortcode, and with the add-on removed that renders without reaching this filter. For a change that must survive removal, use the shortcode’s own output filter.
An empty $html means the shortcode rendered nothing for this viewer. Leave it empty rather than wrapping nothing.
Code
<?php
// Give every Episode Player block a wrapper your theme can style.
add_filter( 'benecaster_blocks_block_render', function ( string $html, string $block_name, array $attributes, string $shortcode ): string {
if ( 'benecaster/episode-player' !== $block_name || '' === $html ) {
return $html;
}
return '<div class="my-theme-player">' . $html . '</div>';
}, 10, 4 );
Hooks Used
Need this built rather than just documented? See our services →