get_default_block_editor_settings(): array
- Since
- 5.8.0
- Source
wp-includes/block-editor.php:155
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.
Return value
array- The default block editor settings.
Performance profile
How much work a call to get_default_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
- Heavy
- Scaling
- Scales with input
- Instructions
- 88–108
- Plugin surface
- 1 hook
- Called by
- 1
Reads or writes the filesystem via file_exists().
The body loops, so the work grows with how much data it finds.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 127.
Third-party callbacks on 'image_size_names_choose' 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
- hookthird-party callbacks
apply_filters()called directly - optionoption read or write
get_option()called directly - filesystemfilesystem access
file_exists()called directly - cacheobject cache
wp_cache_get()one call below get_default_block_editor_settings() - serializeserialisation
maybe_unserialize()one call below get_default_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 · 6 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost get_default_block_editor_settings() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!current_user_can() | 88–95 | current_user_can(), __(), __(), __(), __(), thumbnail(), get_option(), array_keys(), wp_get_registered_image_subsizes(), get_theme_support(), get_allowed_mime_types(), get_default_block_categories(), is_rtl(), admin_url(), get_classic_theme_supports_block_editor_settings() |
!current_user_can() && !file_exists() | 92–99 | current_user_can(), __(), __(), __(), __(), thumbnail(), get_option(), array_keys(), wp_get_registered_image_subsizes(), file_exists(), get_theme_support(), get_allowed_mime_types(), get_default_block_categories(), is_rtl(), admin_url(), get_classic_theme_supports_block_editor_settings() |
current_user_can() | 92–100 | current_user_can(), wp_max_upload_size(), __(), __(), __(), __(), thumbnail(), get_option(), array_keys(), wp_get_registered_image_subsizes(), get_theme_support(), get_allowed_mime_types(), get_default_block_categories(), is_rtl(), admin_url(), get_classic_theme_supports_block_editor_settings() |
!current_user_can() && file_exists() | 96–103 | current_user_can(), __(), __(), __(), __(), thumbnail(), get_option(), array_keys(), wp_get_registered_image_subsizes(), file_exists(), file_get_contents(), get_theme_support(), get_allowed_mime_types(), get_default_block_categories(), is_rtl(), admin_url(), get_classic_theme_supports_block_editor_settings() |
current_user_can() && !file_exists() | 96–104 | current_user_can(), wp_max_upload_size(), __(), __(), __(), __(), thumbnail(), get_option(), array_keys(), wp_get_registered_image_subsizes(), file_exists(), get_theme_support(), get_allowed_mime_types(), get_default_block_categories(), is_rtl(), admin_url(), get_classic_theme_supports_block_editor_settings() |
current_user_can() && file_exists() | 100–108 | current_user_can(), wp_max_upload_size(), __(), __(), __(), __(), thumbnail(), get_option(), array_keys(), wp_get_registered_image_subsizes(), file_exists(), file_get_contents(), get_theme_support(), get_allowed_mime_types(), get_default_block_categories(), is_rtl(), admin_url(), get_classic_theme_supports_block_editor_settings() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 127 | 88–108 | 13 | |
| 8.5 | 127 | 88–108 | 13 | |
| 8.4 | 127 | 88–108 | 13 | 3 fewer instructions than PHP 8.3 |
| 8.3 | 130 | 91–111 | 13 | |
| 8.2 | 130 | 91–111 | 13 | |
| 8.1 | 130 | 91–111 | 13 | |
| 7.4 | 130 | 91–111 | 13 |
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 · 1
One hook fires while get_default_block_editor_settings() runs, in this order:
- apply_filters( image_size_names_choose )filterline 168 (+13 into the body)
Filters the names and labels of the default image sizes.
Uses · 12
- current_user_can()Returns whether the current user has the specified capability.
- wp_max_upload_size()Determines the maximum upload size allowed in php.ini.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- __()Retrieves the translation of $text.
- get_option()Retrieves an option value based on an option name.
- wp_get_registered_image_subsizes()Returns a normalized list of all currently registered image sub-sizes.
- get_theme_support()Gets the theme support arguments passed when registering that support.
- get_allowed_mime_types()Retrieves the list of allowed mime types and file extensions.
- get_default_block_categories()Returns the list of default categories for block types.
- is_rtl()Determines whether the current locale is right-to-left (RTL).
- admin_url()Retrieves the URL to the admin area for the current site.
- get_classic_theme_supports_block_editor_settings()Returns the classic theme supports settings for block editor.
Used by · 1
- get_block_editor_settings()Returns the contextualized block editor settings for a selected editor context.
Source code
function get_default_block_editor_settings() { // Media settings. // wp_max_upload_size() can be expensive, so only call it when relevant for the current user. $max_upload_size = 0; if ( current_user_can( 'upload_files' ) ) { $max_upload_size = wp_max_upload_size(); if ( ! $max_upload_size ) { $max_upload_size = 0; } } /** This filter is documented in wp-admin/includes/media.php */ $image_size_names = apply_filters( 'image_size_names_choose', array( 'thumbnail' => __( 'Thumbnail' ), 'medium' => __( 'Medium' ), 'large' => __( 'Large' ), 'full' => __( 'Full Size' ), ) ); $available_image_sizes = array(); foreach ( $image_size_names as $image_size_slug => $image_size_name ) { $available_image_sizes[] = array( 'slug' => $image_size_slug, 'name' => $image_size_name, ); } $default_size = get_option( 'image_default_size', 'large' ); $image_default_size = in_array( $default_size, array_keys( $image_size_names ), true ) ? $default_size : 'large'; $image_dimensions = array(); $all_sizes = wp_get_registered_image_subsizes(); foreach ( $available_image_sizes as $size ) { $key = $size['slug']; if ( isset( $all_sizes[ $key ] ) ) { $image_dimensions[ $key ] = $all_sizes[ $key ]; } } // These styles are used if the "no theme styles" options is triggered or on // themes without their own editor styles. $default_editor_styles_file = ABSPATH . WPINC . '/css/dist/block-editor/default-editor-styles.css'; static $default_editor_styles_file_contents = false; if ( ! $default_editor_styles_file_contents && file_exists( $default_editor_styles_file ) ) { $default_editor_styles_file_contents = file_get_contents( $default_editor_styles_file ); } $default_editor_styles = array(); if ( $default_editor_styles_file_contents ) { $default_editor_styles = array( array( 'css' => $default_editor_styles_file_contents ), ); } $editor_settings = array( 'alignWide' => get_theme_support( 'align-wide' ), 'allowedBlockTypes' => true, 'allowedMimeTypes' => get_allowed_mime_types(), 'defaultEditorStyles' => $default_editor_styles, 'blockCategories' => get_default_block_categories(), 'isRTL' => is_rtl(), 'imageDefaultSize' => $image_default_size, 'imageDimensions' => $image_dimensions, 'imageEditing' => true, 'imageSizes' => $available_image_sizes, 'maxUploadFileSize' => $max_upload_size, '__experimentalDashboardLink' => admin_url( '/' ), // The following flag is required to enable the new Gallery block format on the mobile apps in 5.9. '__unstableGalleryWithImageBlocks' => true, ); $theme_settings = get_classic_theme_supports_block_editor_settings(); foreach ( $theme_settings as $key => $value ) { $editor_settings[ $key ] = $value; }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.