Skip to content

Instantly share code, notes, and snippets.

@lgladdy
Last active Aug 23, 2018
Embed
What would you like to do?
Add zurb foundation widescreen/responsive-embed code to gutenberg video blocks.
function foundation_gutenberg_wrappers()
{
if (defined('WP_DEBUG') && WP_DEBUG) {
$gutenberg_file = '/js/raw/gutenberg.js?no_cache=' . time();
} else {
$gutenberg_file = '/js/raw/gutenberg.js';
}
wp_enqueue_script('foundation-gutenberg-extensions', get_template_directory_uri() . $gutenberg_file, array('wp-blocks'));
}
add_action('enqueue_block_editor_assets', 'foundation_gutenberg_wrappers');
wp.hooks.addFilter('blocks.getSaveElement', 'foundation/add-foundation-wrappers', addFoundationWrappers)
function addFoundationWrappers(element, blockType, attributes) {
if ($.inArray(blockType.name, ['core-embed/vimeo', 'core-embed/youtube', 'core-embed/video']) !== -1) {
element.props.className += ' widescreen responsive-embed';
return element;
}
return element;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment