How to dequeue specific core block styles from the editor? #72034
Replies: 1 comment
|
The frontend half works because Fix: swap the editor half to function themeslug_remove_core_block_styles_from_editor() {
if ( ! is_admin() ) {
return; // enqueue_block_assets also fires on the frontend — avoid double-handling
}
$handles = themeslug_get_block_styles_to_remove();
foreach ( $handles as $handle ) {
wp_dequeue_style( $handle );
}
}
add_action( 'enqueue_block_assets', 'themeslug_remove_core_block_styles_from_editor', PHP_INT_MAX );Your |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi there.
I'm trying to remove a specific list of default block styles from both the front end and the block/site editor in my block theme.
I've been successful on the front end, but I can't get the same approach to work in the editor. The styles, specifically from
wp-block-library, are always present, and I can only find methods to remove all core styles, not specific ones.Environment
6.8.38.4.10Code I'm Using
Here is the full code I am currently using, which includes forcing separate asset loading and using
enqueue_block_editor_assetswith the latest possible priority:Despite these attempts, the styles persist in the editor. Am I missing a step, or is there a different, more modern approach to selectively removing core block styles from the editor context?
Any help would be appreciated!
All reactions