Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@lgladdy
Last active August 23, 2018 13:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lgladdy/ab1a866ca3077b617e074cf9a749d82d to your computer and use it in GitHub Desktop.
Save lgladdy/ab1a866ca3077b617e074cf9a749d82d to your computer and use it in GitHub Desktop.
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