Created
June 21, 2022 21:09
-
-
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
This file contains 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
/** | |
* 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