Last active
August 23, 2018 13:52
-
-
Save lgladdy/ab1a866ca3077b617e074cf9a749d82d to your computer and use it in GitHub Desktop.
Add zurb foundation widescreen/responsive-embed code to gutenberg video blocks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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