block_editor_settings_allfilter-hookWP 5.8.0

Allows changing block editor settings for all editor types.

This filter intercepts the $editor_settings array before the editor uses it and can change any setting, such as the upload size, enabled or disabled UI elements, default styles, and more.

Editor behavior can be precisely configured based on context (a regular post, page, or custom post type) using the WP_Block_Editor_Context object, which contains information about the current editor context.

Introduced in WP 5.8. Before that, the deprecated block_editor_settings hook was used.

Usage

add_filter( 'block_editor_settings_all', 'wp_kama_block_editor_settings_all_filter', 10, 2 );

/**
 * Function for `block_editor_settings_all` filter-hook.
 * 
 * @param array                   $editor_settings      Default editor settings.
 * @param WP_Block_Editor_Context $block_editor_context The current block editor context.
 *
 * @return array
 */
function wp_kama_block_editor_settings_all_filter( $editor_settings, $block_editor_context ){
	// filter...
	return $editor_settings;
}
$editor_settings(array)

Editor settings array.

Complete field list (WP 6.8):

$settings = [
	'__experimentalAdditionalBlockPatternCategories' => [], // Additional block pattern categories that can be added to the editor.
	'__experimentalAdditionalBlockPatterns'          => [], // Additional block patterns registered in the editor.
	'__experimentalDashboardLink'                    => 'http://pbnwp.loc/wp-admin/', // Dashboard link used in the Site Editor.
	'__experimentalDiscussionSettings'               => [], // Discussion and comment settings for the editor.
	'__experimentalFeatures'                         => [], // New block, theme, and related feature settings from theme.json.
	'__unstableGalleryWithImageBlocks'               => true, // Enables the new gallery type where each image is an individual Image block.
	'__unstableIsBlockBasedTheme'                    => true, // Whether a block theme based on theme.json and block templates is active.
	'__unstableResolvedAssets'                       => [], // Automatically resolved assets passed to the editor.
	'alignWide'                 => false, // Whether blocks can use wide and full alignment.
	'allowedBlockTypes'         => true, // Allowed blocks: true for all, false for none, or an array of specific blocks.
	'allowedMimeTypes'          => [], // File types allowed for upload.
	'autosaveInterval'          => 60, // Autosave interval in seconds.
	'availableTemplates'        => [], // Post templates available for the current post.
	'blockCategories'           => [], // Block categories displayed in the editor.
	'bodyPlaceholder'           => 'Type / to choose a block', // Placeholder in the main content editing field.
	'canUpdateBlockBindings'    => true, // Whether block data bindings can be updated.
	'colors'                    => [], // Color palette available to blocks.
	'defaultEditorStyles'       => [], // Default styles applied to the editor.
	'defaultTemplatePartAreas'  => [], // Default template-part areas.
	'disableCustomColors'       => true, // Disable custom color selection.
	'disableCustomFontSizes'    => true, // Disable custom font sizes.
	'disableCustomGradients'    => true, // Disable custom gradients.
	'disableCustomSpacingSizes' => true, // Disable custom spacing sizes.
	'disableLayoutStyles'       => false, // Disable automatic layout CSS.
	'disablePostFormats'        => true, // Disable post format selection.
	'enableCustomLineHeight'    => false, // Allow custom line-height settings.
	'enableCustomSpacing'       => true, // Allow custom padding and margin settings.
	'enableCustomUnits'         => [], // Units available for input, such as px, em, and %.
	'fontSizes'                 => [], // Predefined font sizes.
	'gradients'                 => [], // Predefined gradients.
	'imageDefaultSize'          => 'large', // Default image size when inserting images.
	'imageDimensions'           => [], // Image dimensions available for resizing.
	'imageEditing'              => true, // Enable or disable image editing.
	'imageSizes'                => [], // All available image sizes.
	'isRTL'                     => false, // Whether the interface uses right-to-left direction.
	'localAutosaveInterval'     => 15, // Browser-based local autosave interval in seconds.
	'maxUploadFileSize'         => 1536000, // Maximum uploaded file size in bytes.
	'postContentAttributes'     => [], // Attributes passed to the content block container.
	'postLock'                  => [], // Information about another user locking the post for editing.
	'postLockUtils'             => [], // Functions and settings related to post locking.
	'richEditingEnabled'        => true, // Whether the visual rich-text editor is enabled.
	'spacingSizes'              => [], // Predefined spacing sizes.
	'styles'                    => [], // All applicable theme, theme.json, custom, and other styles.
	'supportsLayout'            => true, // Support for editor layout features.
	'supportsTemplateMode'      => true, // Enable template editing support.
	'titlePlaceholder'          => 'Add title', // Placeholder in the post title field.

	// Additional settings
	'__experimentalBlockDirectory'           => true, // Enable installation of blocks from the WordPress block directory.
	'__experimentalGlobalStylesBaseStyles'   => [], // Base global styles from theme.json.
	'__unstableHasCustomAppender'            => false, // Control display of a custom block inserter button.
	'blockInspectorTabs'                     => [ 'default' => true ], // Control block inspector tabs such as settings and styles.
	'canLockBlocks'                          => true, // Whether blocks can be locked against moving or removal.
	'capabilities'                           => [], // Current user capabilities, such as publishing or editing.
	'clearBlockSelection'                    => false, // Internally clear block selection during certain actions.
	'codeEditingEnabled'                     => true, // Whether the user can use HTML code editing mode.
	'enableOpenverseMediaCategory'           => true, // Enable the Openverse tab in the media browser.
	'generateAnchors'                        => true, // Automatically generate HTML anchors for blocks such as headings.
	'isPreviewMode'                          => false, // Whether the editor is in preview mode.
	'locale'                                 => 'en_US', // Current user locale, for example en_US.
	'maxWidth'                               => 610, // Maximum block container width, usually defined by the theme.
	'onNavigateToEntityRecord'               => null, // JavaScript callback invoked when navigating to another entity such as a post or page.
	'postsPerPage'                           => 10, // Number of posts displayed per page, for example in drop-down lists.
	'readOnly'                               => false, // Whether the editor is read-only, for example when another user has locked the post.
	'widgetTypesToHideFromLegacyWidgetBlock' => [], // Widget types hidden from the Legacy Widget block.
];
$block_editor_context(WP_Block_Editor_Context)

Current editor context, including information about the post and editor type. See WP_Block_Editor_Context.

Example object:

WP_Block_Editor_Context Object (
	[name] => core/edit-site
	[post] =>
)

Examples

#1 Demo: changing editor settings

add_filter( 'block_editor_settings_all', 'remove_block_editor_styles', 10, 2 );

/**
 * @param array                   $settings The block editor settings.
 * @param WP_Block_Editor_Context $context  The context of the block editor.
 */
function remove_block_editor_styles( $settings, $context ): array {
	// Site Editor on the Appearance > Editor admin page: /wp-admin/site-editor.php
	if( $context->name === 'core/edit-site' ){
		$settings['styles'] = []; // Clear Site Editor styles
		$settings['disableLayoutStyles'] = 1; // Disable Site Editor layout styles
	}

	// Block editor on a post editing page: /wp-admin/post.php
	if( $context->name === 'core/edit-post' ){
		if( $context->post->post_type === 'my_custom_type' ){
			$settings['allowedBlockTypes'] = false; // Disable all blocks
		}
		$settings['canLockBlocks'] = false; // Disable block locking
		$settings['disablePostFormats'] = false;
	}

	return $settings;
}

Changelog

Since 5.8.0 Introduced.

Where the hook is called

get_block_editor_settings()
block_editor_settings_all
wp-includes/block-editor.php 645
$editor_settings = apply_filters( 'block_editor_settings_all', $editor_settings, $block_editor_context );

Where the hook is used in WordPress

wp-includes/block-supports/duotone.php 57
add_filter( 'block_editor_settings_all', array( 'WP_Duotone', 'add_editor_settings' ), 10 );