Created
September 7, 2022 07:41
-
-
Save herbie4/03239b343845f36ca61fe7a97d30400e to your computer and use it in GitHub Desktop.
gutenberg deactivate individual block styles
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
/* | |
first enqueue a javascript file | |
place it in the childtheme dir | |
*/ | |
function hhdev_enqueue_assets() { | |
wp_enqueue_script( | |
'hhdev-remove-block-styles', | |
get_stylesheet_directory_uri().'/remove-block-styles.js', | |
array( 'wp-blocks', 'wp-dom-ready', 'wp-edit-post' ), | |
filemtime( get_stylesheet_directory_uri().'/remove-block-styles.js' ), | |
true | |
); | |
} | |
add_action( 'enqueue_block_editor_assets', 'hhdev_enqueue_assets', 11 ); | |
/* | |
add this in the javascript file | |
change the blocks names as needed | |
*/ | |
wp.domReady( function() { | |
wp.blocks.unregisterBlockStyle( | |
'core/image', | |
'editorskit-diagonal' | |
); | |
wp.blocks.unregisterBlockStyle( | |
'core/image', | |
'editorskit-inverted-diagonal' | |
); | |
wp.blocks.unregisterBlockStyle( | |
'core/cover', | |
'editorskit-diagonal' | |
); | |
wp.blocks.unregisterBlockStyle( | |
'core/cover', | |
'editorskit-inverted-diagonal' | |
); | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment