The block_editor_settings_all WordPress PHP filter allows you to modify the settings passed to the block editor for all editor types.
Usage
add_filter('block_editor_settings_all', 'my_custom_function', 10, 2); function my_custom_function($editor_settings, $block_editor_context) { // your custom code here return $editor_settings; }
Parameters
$editor_settings
(array): Default editor settings.$block_editor_context
(WP_Block_Editor_Context): The current block editor context.
More information
See WordPress Developer Resources: block_editor_settings_all
Examples
Change Color Palette
Customize the color palette for the block editor.
add_filter('block_editor_settings_all', 'my_custom_color_palette', 10, 2); function my_custom_color_palette($editor_settings, $block_editor_context) { $editor_settings['colors'] = array( array( 'name' => __('Red', 'my-theme'), 'slug' => 'red', 'color' => '#FF0000', ), array( 'name' => __('Green', 'my-theme'), 'slug' => 'green', 'color' => '#00FF00', ), ); return $editor_settings; }
Disable Custom Colors
Disable the custom color picker in the block editor.
add_filter('block_editor_settings_all', 'my_disable_custom_colors', 10, 2); function my_disable_custom_colors($editor_settings, $block_editor_context) { $editor_settings['disableCustomColors'] = true; return $editor_settings; }
Enable Custom Line Heights
Enable custom line heights for all blocks in the block editor.
add_filter('block_editor_settings_all', 'my_enable_custom_line_heights', 10, 2); function my_enable_custom_line_heights($editor_settings, $block_editor_context) { $editor_settings['enableCustomLineHeight'] = true; return $editor_settings; }
Enable Custom Spacing
Enable custom spacing (padding and margin) for all blocks in the block editor.
add_filter('block_editor_settings_all', 'my_enable_custom_spacing', 10, 2); function my_enable_custom_spacing($editor_settings, $block_editor_context) { $editor_settings['enableCustomSpacing'] = true; return $editor_settings; }
Change Image Sizes
Customize the image sizes available in the block editor.
add_filter('block_editor_settings_all', 'my_custom_image_sizes', 10, 2); function my_custom_image_sizes($editor_settings, $block_editor_context) { $editor_settings['imageSizes'] = array( array( 'slug' => 'thumbnail', 'name' => __('Thumbnail', 'my-theme'), ), array( 'slug' => 'medium', 'name' => __('Medium', 'my-theme'), ), array( 'slug' => 'large', 'name' => __('Large', 'my-theme'), ), ); return $editor_settings; }