Title: get_block_editor_settings
Published: July 20, 2021
Last modified: August 20, 2026

---

# get_block_editor_settings( array $custom_settings, WP_Block_Editor_Context $block_editor_context ): array

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/get_block_editor_settings/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/get_block_editor_settings/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/get_block_editor_settings/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/get_block_editor_settings/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/get_block_editor_settings/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/get_block_editor_settings/?output_format=md#changelog)

Returns the contextualized block editor settings for a selected editor context.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/get_block_editor_settings/?output_format=md#parameters)󠁿

 `$custom_settings`arrayrequired

Custom settings to use with the given editor type.

`$block_editor_context`[WP_Block_Editor_Context](https://developer.wordpress.org/reference/classes/wp_block_editor_context/)
required

The current block editor context.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/get_block_editor_settings/?output_format=md#return)󠁿

 array The contextualized block editor settings.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/get_block_editor_settings/?output_format=md#source)󠁿

    ```php
    function get_block_editor_settings( array $custom_settings, $block_editor_context ) {
    	$editor_settings = array_merge(
    		get_default_block_editor_settings(),
    		array(
    			'allowedBlockTypes' => get_allowed_block_types( $block_editor_context ),
    			'blockCategories'   => get_block_categories( $block_editor_context ),
    		),
    		$custom_settings
    	);

    	$editor_settings['__experimentalBlockBindingsSupportedAttributes'] = array();
    	foreach ( array_keys( WP_Block_Type_Registry::get_instance()->get_all_registered() ) as $block_type ) {
    		$supported_block_attributes = get_block_bindings_supported_attributes( $block_type );
    		if ( ! empty( $supported_block_attributes ) ) {
    			$editor_settings['__experimentalBlockBindingsSupportedAttributes'][ $block_type ] = $supported_block_attributes;
    		}
    	}

    	$global_styles = array();
    	$presets       = array(
    		array(
    			'css'            => 'variables',
    			'__unstableType' => 'presets',
    			'isGlobalStyles' => true,
    		),
    		array(
    			'css'            => 'presets',
    			'__unstableType' => 'presets',
    			'isGlobalStyles' => true,
    		),
    	);
    	foreach ( $presets as $preset_style ) {
    		$actual_css = wp_get_global_stylesheet( array( $preset_style['css'] ) );
    		if ( '' !== $actual_css ) {
    			$preset_style['css'] = $actual_css;
    			$global_styles[]     = $preset_style;
    		}
    	}

    	$block_classes = array(
    		'css'            => 'styles',
    		'__unstableType' => 'theme',
    		'isGlobalStyles' => true,
    	);
    	$actual_css    = wp_get_global_stylesheet( array( $block_classes['css'] ) );
    	if ( '' !== $actual_css ) {
    		$block_classes['css'] = $actual_css;
    		$global_styles[]      = $block_classes;
    	}

    	// Get any additional css from the customizer and add it before global styles custom CSS.
    	$global_styles[] = array(
    		'css'            => wp_get_custom_css(),
    		'__unstableType' => 'user',
    		'isGlobalStyles' => false,
    	);

    	/*
    	 * Add the custom CSS as a separate stylesheet so any invalid CSS
    	 * entered by users does not break other global styles.
    	 */
    	$global_styles[] = array(
    		'css'            => wp_get_global_stylesheet( array( 'custom-css' ) ),
    		'__unstableType' => 'user',
    		'isGlobalStyles' => true,
    	);

    	$editor_settings['styles'] = array_merge( $global_styles, get_block_editor_theme_styles() );

    	$editor_settings['__experimentalFeatures'] = wp_get_global_settings();
    	// These settings may need to be updated based on data coming from theme.json sources.
    	if ( isset( $editor_settings['__experimentalFeatures']['color']['palette'] ) ) {
    		$colors_by_origin          = $editor_settings['__experimentalFeatures']['color']['palette'];
    		$editor_settings['colors'] = $colors_by_origin['custom'] ?? $colors_by_origin['theme'] ?? $colors_by_origin['default'];
    	}
    	if ( isset( $editor_settings['__experimentalFeatures']['color']['gradients'] ) ) {
    		$gradients_by_origin          = $editor_settings['__experimentalFeatures']['color']['gradients'];
    		$editor_settings['gradients'] = $gradients_by_origin['custom'] ?? $gradients_by_origin['theme'] ?? $gradients_by_origin['default'];
    	}
    	if ( isset( $editor_settings['__experimentalFeatures']['typography']['fontSizes'] ) ) {
    		$font_sizes_by_origin         = $editor_settings['__experimentalFeatures']['typography']['fontSizes'];
    		$editor_settings['fontSizes'] = $font_sizes_by_origin['custom'] ?? $font_sizes_by_origin['theme'] ?? $font_sizes_by_origin['default'];
    	}
    	if ( isset( $editor_settings['__experimentalFeatures']['color']['custom'] ) ) {
    		$editor_settings['disableCustomColors'] = ! $editor_settings['__experimentalFeatures']['color']['custom'];
    		unset( $editor_settings['__experimentalFeatures']['color']['custom'] );
    	}
    	if ( isset( $editor_settings['__experimentalFeatures']['color']['customGradient'] ) ) {
    		$editor_settings['disableCustomGradients'] = ! $editor_settings['__experimentalFeatures']['color']['customGradient'];
    		unset( $editor_settings['__experimentalFeatures']['color']['customGradient'] );
    	}
    	if ( isset( $editor_settings['__experimentalFeatures']['typography']['customFontSize'] ) ) {
    		$editor_settings['disableCustomFontSizes'] = ! $editor_settings['__experimentalFeatures']['typography']['customFontSize'];
    		unset( $editor_settings['__experimentalFeatures']['typography']['customFontSize'] );
    	}
    	if ( isset( $editor_settings['__experimentalFeatures']['typography']['lineHeight'] ) ) {
    		$editor_settings['enableCustomLineHeight'] = $editor_settings['__experimentalFeatures']['typography']['lineHeight'];
    		unset( $editor_settings['__experimentalFeatures']['typography']['lineHeight'] );
    	}
    	if ( isset( $editor_settings['__experimentalFeatures']['spacing']['units'] ) ) {
    		$editor_settings['enableCustomUnits'] = $editor_settings['__experimentalFeatures']['spacing']['units'];
    		unset( $editor_settings['__experimentalFeatures']['spacing']['units'] );
    	}
    	if ( isset( $editor_settings['__experimentalFeatures']['spacing']['padding'] ) ) {
    		$editor_settings['enableCustomSpacing'] = $editor_settings['__experimentalFeatures']['spacing']['padding'];
    		unset( $editor_settings['__experimentalFeatures']['spacing']['padding'] );
    	}
    	if ( isset( $editor_settings['__experimentalFeatures']['spacing']['customSpacingSize'] ) ) {
    		$editor_settings['disableCustomSpacingSizes'] = ! $editor_settings['__experimentalFeatures']['spacing']['customSpacingSize'];
    		unset( $editor_settings['__experimentalFeatures']['spacing']['customSpacingSize'] );
    	}

    	if ( isset( $editor_settings['__experimentalFeatures']['spacing']['spacingSizes'] ) ) {
    		$spacing_sizes_by_origin         = $editor_settings['__experimentalFeatures']['spacing']['spacingSizes'];
    		$editor_settings['spacingSizes'] = $spacing_sizes_by_origin['custom'] ?? $spacing_sizes_by_origin['theme'] ?? $spacing_sizes_by_origin['default'];
    	}

    	$editor_settings['__unstableResolvedAssets']         = _wp_get_iframed_editor_assets();
    	$editor_settings['__unstableIsBlockBasedTheme']      = wp_is_block_theme();
    	$editor_settings['localAutosaveInterval']            = 15;
    	$editor_settings['disableLayoutStyles']              = current_theme_supports( 'disable-layout-styles' );
    	$editor_settings['__experimentalDiscussionSettings'] = array(
    		'commentOrder'         => get_option( 'comment_order' ),
    		'commentsPerPage'      => get_option( 'comments_per_page' ),
    		'defaultCommentsPage'  => get_option( 'default_comments_page' ),
    		'pageComments'         => get_option( 'page_comments' ),
    		'threadComments'       => get_option( 'thread_comments' ),
    		'threadCommentsDepth'  => get_option( 'thread_comments_depth' ),
    		'defaultCommentStatus' => get_option( 'default_comment_status' ),
    		'avatarURL'            => get_avatar_url(
    			'',
    			array(
    				'size'          => 96,
    				'force_default' => true,
    				'default'       => get_option( 'avatar_default' ),
    			)
    		),
    	);

    	$post_content_block_attributes = wp_get_post_content_block_attributes();

    	if ( isset( $post_content_block_attributes ) ) {
    		$editor_settings['postContentAttributes'] = $post_content_block_attributes;
    	}

    	$editor_settings['canUpdateBlockBindings'] = current_user_can( 'edit_block_binding', $block_editor_context );

    	/**
    	 * Filters the settings to pass to the block editor for all editor type.
    	 *
    	 * @since 5.8.0
    	 *
    	 * @param array                   $editor_settings      Default editor settings.
    	 * @param WP_Block_Editor_Context $block_editor_context The current block editor context.
    	 */
    	$editor_settings = apply_filters( 'block_editor_settings_all', $editor_settings, $block_editor_context );

    	if ( ! empty( $block_editor_context->post ) ) {
    		$post = $block_editor_context->post;

    		/**
    		 * Filters the settings to pass to the block editor.
    		 *
    		 * @since 5.0.0
    		 * @deprecated 5.8.0 Use the 'block_editor_settings_all' filter instead.
    		 *
    		 * @param array   $editor_settings Default editor settings.
    		 * @param WP_Post $post            Post being edited.
    		 */
    		$editor_settings = apply_filters_deprecated( 'block_editor_settings', array( $editor_settings, $post ), '5.8.0', 'block_editor_settings_all' );
    	}

    	$editor_settings['canEditCSS'] = current_user_can( 'edit_css' );

    	return $editor_settings;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/block-editor.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/block-editor.php#L490)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/block-editor.php#L490-L665)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/get_block_editor_settings/?output_format=md#hooks)󠁿

 [apply_filters_deprecated( ‘block_editor_settings’, array $editor_settings, WP_Post $post )](https://developer.wordpress.org/reference/hooks/block_editor_settings/)

Filters the settings to pass to the block editor.

 [apply_filters( ‘block_editor_settings_all’, array $editor_settings, WP_Block_Editor_Context $block_editor_context )](https://developer.wordpress.org/reference/hooks/block_editor_settings_all/)

Filters the settings to pass to the block editor for all editor type.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/get_block_editor_settings/?output_format=md#related)󠁿

| Uses | Description | 
| [get_block_bindings_supported_attributes()](https://developer.wordpress.org/reference/functions/get_block_bindings_supported_attributes/)`wp-includes/block-bindings.php` |

Retrieves the list of block attributes supported by block bindings.

  | 
| [wp_get_post_content_block_attributes()](https://developer.wordpress.org/reference/functions/wp_get_post_content_block_attributes/)`wp-includes/block-editor.php` |

Retrieves Post Content block attributes from the current post template.

  | 
| [_wp_get_iframed_editor_assets()](https://developer.wordpress.org/reference/functions/_wp_get_iframed_editor_assets/)`wp-includes/block-editor.php` |

Collect the block editor assets that need to be loaded into the editor’s iframe.

  | 
| [wp_get_global_stylesheet()](https://developer.wordpress.org/reference/functions/wp_get_global_stylesheet/)`wp-includes/global-styles-and-settings.php` |

Returns the stylesheet resulting of merging core, theme, and user data.

  | 
| [wp_get_global_settings()](https://developer.wordpress.org/reference/functions/wp_get_global_settings/)`wp-includes/global-styles-and-settings.php` |

Gets the settings resulting of merging core, theme, and user data.

  | 
| [wp_is_block_theme()](https://developer.wordpress.org/reference/functions/wp_is_block_theme/)`wp-includes/theme.php` |

Returns whether the active theme is a block-based theme or not.

  | 
| [get_block_editor_theme_styles()](https://developer.wordpress.org/reference/functions/get_block_editor_theme_styles/)`wp-includes/block-editor.php` |

Creates an array of theme styles to load into the block editor.

  | 
| [get_default_block_editor_settings()](https://developer.wordpress.org/reference/functions/get_default_block_editor_settings/)`wp-includes/block-editor.php` |

Returns the default block editor settings.

  | 
| [get_allowed_block_types()](https://developer.wordpress.org/reference/functions/get_allowed_block_types/)`wp-includes/block-editor.php` |

Gets the list of allowed block types to use in the block editor.

  | 
| [WP_Block_Type_Registry::get_instance()](https://developer.wordpress.org/reference/classes/wp_block_type_registry/get_instance/)`wp-includes/class-wp-block-type-registry.php` |

Utility method to retrieve the main instance of the class.

  | 
| [get_block_categories()](https://developer.wordpress.org/reference/functions/get_block_categories/)`wp-includes/block-editor.php` |

Returns all the categories for block types that will be shown in the block editor.

  | 
| [wp_get_custom_css()](https://developer.wordpress.org/reference/functions/wp_get_custom_css/)`wp-includes/theme.php` |

Fetches the saved Custom CSS content for rendering.

  | 
| [apply_filters_deprecated()](https://developer.wordpress.org/reference/functions/apply_filters_deprecated/)`wp-includes/plugin.php` |

Fires functions attached to a deprecated filter hook.

  | 
| [get_avatar_url()](https://developer.wordpress.org/reference/functions/get_avatar_url/)`wp-includes/link-template.php` |

Retrieves the avatar URL.

  | 
| [current_user_can()](https://developer.wordpress.org/reference/functions/current_user_can/)`wp-includes/capabilities.php` |

Returns whether the current user has the specified capability.

  | 
| [current_theme_supports()](https://developer.wordpress.org/reference/functions/current_theme_supports/)`wp-includes/theme.php` |

Checks a theme’s support for a given feature.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  | 
| [get_option()](https://developer.wordpress.org/reference/functions/get_option/)`wp-includes/option.php` |

Retrieves an option value based on an option name.

  |

[Show 13 more](https://developer.wordpress.org/reference/functions/get_block_editor_settings/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/get_block_editor_settings/?output_format=md#)

| Used by | Description | 
| [WP_Customize_Widgets::enqueue_scripts()](https://developer.wordpress.org/reference/classes/wp_customize_widgets/enqueue_scripts/)`wp-includes/class-wp-customize-widgets.php` |

Enqueues scripts and styles for Customizer panel and export data to JavaScript.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/get_block_editor_settings/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.8.0](https://developer.wordpress.org/reference/since/5.8.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_block_editor_settings%2F)
before being able to contribute a note or feedback.