get_block_editor_settings( array $custom_settings, WP_Block_Editor_Context $block_editor_context ): array
- Since
- 5.8.0
- Source
wp-includes/block-editor.php:489
Compatibility
- WordPress
- since 5.8.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$custom_settingsarray- Custom settings to use with the given editor type.
$block_editor_contextWP_Block_Editor_Context- The current block editor context.
Return value
array- The contextualized block editor settings.
Performance profile
How much work a call to get_block_editor_settings() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Expensive
- Scaling
- Constant
- Instructions
- 174–260
- Plugin surface
- 2 hooks
- Called by
- 1
Reaches an outbound HTTP request via wp_remote_get().
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 355.
Third-party callbacks on 'block_editor_settings_all', 'block_editor_settings' run inside this call, and their cost is not bounded by anything here.
1 place in core call this, so the cost is paid more often than your own code shows.
What it touches
- optionoption read or write
get_option()called directly - hookthird-party callbacks
apply_filters()called directly - cacheobject cache
wp_cache_get()one call below get_block_editor_settings() - httpoutbound HTTP request
wp_remote_get()one call below get_block_editor_settings() - serializeserialisation
maybe_unserialize()one call below get_block_editor_settings()
Further down the call graph this can also reach query and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 1 distinct outcome
One number would be a lie: the work depends on which branch runs. These are every distinct cost get_block_editor_settings() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
array_keys() && !wp_theme_has_theme_json() && $actual_css === "" && !isset($value) | 174–260 | get_default_block_editor_settings(), get_allowed_block_types(), get_block_categories(), allowedBlockTypes(), ::WP_Block_Type_Registry(), ->get_all_registered(), array_keys(), wp_theme_has_theme_json(), wp_get_global_stylesheet(), get_block_editor_theme_styles(), array_merge(), wp_get_global_settings(), _wp_get_iframed_editor_assets(), wp_is_block_theme(), current_theme_supports(), get_option(), get_option(), get_option(), get_option(), get_option(), get_option(), get_option(), get_option(), size(), wp_get_post_content_block_attributes(), current_user_can(), apply_filters() |
This body has more branch combinations than are worth enumerating, so the table covers the outcomes found first rather than every one that exists.
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 355 | 174–260 | 30 | |
| 8.5 | 355 | 174–260 | 30 | |
| 8.4 | 355 | 174–260 | 30 | |
| 8.3 | 355 | 174–260 | 30 | |
| 8.2 | 355 | 174–260 | 30 | |
| 8.1 | 355 | 174–260 | 30 | 12 fewer instructions than PHP 7.4 |
| 7.4 | 367 | 174–262 | 30 |
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Hooks and filters fired · 2
2 hooks fire while get_block_editor_settings() runs, in this order:
- apply_filters( block_editor_settings_all )filterline 671 (+182 into the body)
Filters the settings to pass to the block editor for all editor type.
- do_action( block_editor_settings )filter_deprecatedline 685 (+196 into the body)
Filters the settings to pass to the block editor.
Uses · 19
- get_default_block_editor_settings()Returns the default block editor settings.
- get_allowed_block_types()Gets the list of allowed block types to use in the block editor.
- get_block_categories()Returns all the categories for block types that will be shown in the block editor.
- get_block_bindings_supported_attributes()Retrieves the list of block attributes supported by block bindings.
- wp_get_global_stylesheet()Returns the stylesheet resulting of merging core, theme, and user data.
- wp_theme_has_theme_json()Checks whether a theme or its parent has a theme.json file.
- get_block_editor_theme_styles()Creates an array of theme styles to load into the block editor.
- wp_get_global_settings()Gets the settings resulting of merging core, theme, and user data.
- _wp_get_iframed_editor_assets()Collect the block editor assets that need to be loaded into the editor's iframe.
- wp_is_block_theme()Returns whether the active theme is a block-based theme or not.
- current_theme_supports()Checks a theme's support for a given feature.
- get_option()Retrieves an option value based on an option name.
Show all 19
- get_avatar_url()Retrieves the avatar URL.
- wp_get_post_content_block_attributes()Retrieves Post Content block attributes from the current post template.
- current_user_can()Returns whether the current user has the specified capability.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- apply_filters_deprecated()Fires functions attached to a deprecated filter hook.
- WP_Block_Type_Registry::get_instance()::get_all_registered()
- WP_Block_Type_Registry::get_instance()Utility method to retrieve the main instance of the class.
Used by · 1
- WP_Customize_Widgets::enqueue_scripts()Enqueues scripts and styles for Customizer panel and export data to JavaScript.
Source code
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; } } if ( wp_theme_has_theme_json() ) { $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; } /* * 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, ); } else { // If there is no `theme.json` file, ensure base layout styles are still available. $block_classes = array( 'css' => 'base-layout-styles', '__unstableType' => 'base-layout', 'isGlobalStyles' => true, ); $actual_css = wp_get_global_stylesheet( array( $block_classes['css'] ) ); if ( '' !== $actual_css ) { $block_classes['css'] = $actual_css; $global_styles[] = $block_classes; } } $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'];Changelog
Introduced in 5.8.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.9.7 tag, from
src/wp-includes/block-editor.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.