Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kylephillips/9939c47caf43e6ad055a8e9e12a9dbfb to your computer and use it in GitHub Desktop.
Save kylephillips/9939c47caf43e6ad055a8e9e12a9dbfb to your computer and use it in GitHub Desktop.
Apply a JS filter to the allowed blocks in wp-block-animations plugin
/**
* In this example, we're adding a custom "acf/carousel" block to the array of supported block types for block animations
* We've added this JS file to the script dependencies required by the plugin, using the wp_block_animations_script_dependencies hook.
* Additionally, when enqueueing this file, we've added `wp-hooks` as a dependency to ensure the global object is available
*/
wp.hooks.addFilter(
'wp_block_animations_allowed_blocks',
'allowed_blocks',
addCustomBlockAnimations
);
function addCustomBlockAnimations(allowedBlocks)
{
allowedBlocks.push('acf/carousel');
return allowedBlocks;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment