wppaste
WordPress

get_default_block_editor_settings(): array

Since
5.8.0
Source
wp-includes/block-editor.php:155
Returns the default block editor settings.

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

Reads or writes the filesystem via file_exists().

Scaling
Scales with input

The body loops, so the work grows with how much data it finds.

Instructions
88–108

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 127.

Plugin surface
1 hook

Third-party callbacks on 'image_size_names_choose' run inside this call, and their cost is not bounded by anything here.

Called by
1

1 place in core call this, so the cost is paid more often than your own code shows.

What it touches

  • hookthird-party callbacksapply_filters()called directly
  • optionoption read or writeget_option()called directly
  • filesystemfilesystem accessfile_exists()called directly
  • cacheobject cachewp_cache_get()one call below get_default_block_editor_settings()
  • serializeserialisationmaybe_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.

WhenInstructionsCalls it makes
!current_user_can()88–95current_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–99current_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–100current_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–103current_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–104current_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–108current_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

PHPCompiledExecutedBranchesNotes
8.6-dev12788–10813
8.512788–10813
8.412788–108133 fewer instructions than PHP 8.3
8.313091–11113
8.213091–11113
8.113091–11113
7.413091–11113

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:

  1. apply_filters( image_size_names_choose )filterline 168 (+13 into the body)

    Filters the names and labels of the default image sizes.

Uses · 12

Used by · 1

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.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 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.