Skip to content

Instantly share code, notes, and snippets.

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 herbie4/03239b343845f36ca61fe7a97d30400e to your computer and use it in GitHub Desktop.
Save herbie4/03239b343845f36ca61fe7a97d30400e to your computer and use it in GitHub Desktop.
gutenberg deactivate individual block styles
/*
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