At this point, I’ve dove into the WordPress block editor and removed a few blocks. In this post, I’ll be diving into some block settings that the editor provides.
Blocks settings are located within the Panel and have different styles depending on the type of block. You can change the text color, background color, font size, style of your image (even “rounded”), and much more depending on what block is chosen.
You can disable certain settings but I’d prefer a filter allowing only certain settings to be enabled. Something like we have for allowing only certain block types. I haven’t found anything yet but there is a way to alter and disable the colors and typography settings. For now I’m just disabling them which also disables the respective panel section.
// disable custom font sizes add_theme_support( 'disable-custom-font-sizes' ); // disable font sizes add_theme_support( 'editor-font-sizes', array() ); // disable custom solid colors add_theme_support( 'disable-custom-colors' ); // disable solid color palette add_theme_support( 'editor-color-palette', array() ); // disable custom gradients add_theme_support( 'disable-custom-gradients' ); // disable gradients palette add_theme_support( 'editor-gradient-presets', array() );
Here’s a helpful article about adding or removing block styles that does so by adding a js file to the editor and filtering it from there. This isn’t where want to spend my time right now but I would like to remove that weird rounded image setting. Maybe another time.
When you search for blocks not only does it allow you to search theme blocks but you can also add new blocks (think plugins). This makes it very easy to add new blocks and without careful consideration, this could quickly clutter up your collection of blocks and your site.
Since we are only allowing certain blocks disabling this makes sense. Please note that you can still install blocks via the plugins screen.
// remove block directory remove_action( 'enqueue_block_editor_assets', 'wp_enqueue_editor_block_directory_assets' ); remove_action( 'enqueue_block_editor_assets', 'gutenberg_enqueue_block_editor_assets_block_directory' );
The editor contains combinations of blocks that include placeholder content or as the official docs put it “predefined block layouts, ready to insert and tweak”.
We’ve already disabled most of our blocks so while this could be helpful for certain projects I think custom blocks will negate the need for this. Plus these are blocks, once again, defined by WordPress, not our design.
// disable block patterns remove_theme_support( 'core-block-patterns' );
So far so good
I’m feeling pretty optimistic about what I’ve discovered (thanks internet and WP docs!) and it has given me some faith that this new editor may just work. I think the next step is to poke around a bit more and use what I have. I want to get comfortable with the editor and make sure this is a good solution before adding anything extra. I’ll update this post if I find anything else worth mentioning.