wp_use_widgets_block_editor(): bool
- Since
- 5.8.0
- Source
wp-includes/widgets.php:1910
Description
Defaults to true unless a theme has removed support for widgets-block-editor or a plugin has filtered the return value of this function.
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
bool- Whether to use the block editor to manage widgets.
Performance profile
How much work a call to wp_use_widgets_block_editor() 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
- Trivial
- Scaling
- Constant
- Instructions
- 8
- Plugin surface
- 1 hook
- Called by
- 6
Touches nothing outside its own arguments.
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5. The body compiles to 8.
Third-party callbacks on 'use_widgets_block_editor' run inside this call, and their cost is not bounded by anything here.
6 places 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
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 wp_use_widgets_block_editor() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 8 | get_theme_support(), apply_filters() |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 8 instructions, 8 executed per call, 0 branches. The work does not change between versions.
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 wp_use_widgets_block_editor() runs, in this order:
- apply_filters( use_widgets_block_editor )filterline 1918 (+8 into the body)
Filters whether to use the block editor to manage widgets.
Uses · 2
- apply_filters()Calls the callback functions that have been added to a filter hook.
- get_theme_support()Gets the theme support arguments passed when registering that support.
Used by · 6
- WP_Customize_Widgets::customize_register()Registers Customizer settings and controls for all sidebars and widgets.
- WP_Customize_Widgets::enqueue_scripts()Enqueues scripts and styles for Customizer panel and export data to JavaScript.
- WP_Customize_Widgets::sanitize_widget_instance()Sanitizes a widget instance.
- WP_Customize_Widgets::sanitize_widget_js_instance()Converts a widget instance into JSON-representable format.
- WP_Customize_Widgets::should_load_block_editor_scripts_and_styles()Tells the script loader to load the scripts and styles of custom blocks if the widgets block editor is enabled.
- wp_set_up_cross_origin_isolation()Enables cross-origin isolation in the block editor.
Source code
function wp_use_widgets_block_editor() { /** * Filters whether to use the block editor to manage widgets. * * @since 5.8.0 * * @param bool $use_widgets_block_editor Whether to use the block editor to manage widgets. */ return apply_filters( 'use_widgets_block_editor', get_theme_support( 'widgets-block-editor' ) );}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 7.1.0 tag, from
src/wp-includes/widgets.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.