_wp_get_iframed_editor_assets(): array
- Since
- 6.0.0
- Source
wp-includes/block-editor.php:301
Compatibility
- WordPress
- since 6.0.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 block editor assets.
$stylesstring|falseString containing the HTML for styles.$scriptsstring|falseString containing the HTML for scripts.
Performance profile
How much work a call to _wp_get_iframed_editor_assets() 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
- Light
- Scaling
- Scales with input
- Instructions
- 82–95
- Plugin surface
- 1 hook
- Called by
- 1
Touches nothing outside its own arguments.
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 110.
Third-party callbacks on 'enqueue_block_assets' 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
do_action()called directly
Further down the call graph this can also reach option, cache, serialize, transient and query. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 8 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost _wp_get_iframed_editor_assets() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!current_theme_supports() | 82–84 | wp_theme_has_theme_json(), wp_enqueue_script(), wp_enqueue_style(), current_theme_supports(), add_filter(), do_action(), remove_filter(), ::WP_Block_Type_Registry(), ->get_all_registered(), has_action(), ob_start(), wp_print_styles(), wp_print_font_faces(), wp_print_font_faces_from_style_variations(), ob_get_clean(), ob_start(), wp_print_head_scripts(), wp_print_footer_scripts(), ob_get_clean() |
current_theme_supports() | 85–87 | wp_theme_has_theme_json(), wp_enqueue_script(), wp_enqueue_style(), current_theme_supports(), wp_enqueue_style(), add_filter(), do_action(), remove_filter(), ::WP_Block_Type_Registry(), ->get_all_registered(), has_action(), ob_start(), wp_print_styles(), wp_print_font_faces(), wp_print_font_faces_from_style_variations(), ob_get_clean(), ob_start(), wp_print_head_scripts(), wp_print_footer_scripts(), ob_get_clean() |
!current_theme_supports() | 86–88 | wp_theme_has_theme_json(), wp_enqueue_script(), wp_enqueue_style(), current_theme_supports(), add_filter(), do_action(), remove_filter(), ::WP_Block_Type_Registry(), ->get_all_registered(), has_action(), ob_start(), wp_print_styles(), wp_print_font_faces(), wp_print_font_faces_from_style_variations(), ob_get_clean(), add_action(), ob_start(), wp_print_head_scripts(), wp_print_footer_scripts(), ob_get_clean() |
!current_theme_supports() | 86–88 | wp_theme_has_theme_json(), wp_enqueue_script(), wp_enqueue_style(), current_theme_supports(), add_filter(), do_action(), remove_filter(), ::WP_Block_Type_Registry(), ->get_all_registered(), has_action(), remove_action(), ob_start(), wp_print_styles(), wp_print_font_faces(), wp_print_font_faces_from_style_variations(), ob_get_clean(), ob_start(), wp_print_head_scripts(), wp_print_footer_scripts(), ob_get_clean() |
current_theme_supports() | 89–91 | wp_theme_has_theme_json(), wp_enqueue_script(), wp_enqueue_style(), current_theme_supports(), wp_enqueue_style(), add_filter(), do_action(), remove_filter(), ::WP_Block_Type_Registry(), ->get_all_registered(), has_action(), ob_start(), wp_print_styles(), wp_print_font_faces(), wp_print_font_faces_from_style_variations(), ob_get_clean(), add_action(), ob_start(), wp_print_head_scripts(), wp_print_footer_scripts(), ob_get_clean() |
current_theme_supports() | 89–91 | wp_theme_has_theme_json(), wp_enqueue_script(), wp_enqueue_style(), current_theme_supports(), wp_enqueue_style(), add_filter(), do_action(), remove_filter(), ::WP_Block_Type_Registry(), ->get_all_registered(), has_action(), remove_action(), ob_start(), wp_print_styles(), wp_print_font_faces(), wp_print_font_faces_from_style_variations(), ob_get_clean(), ob_start(), wp_print_head_scripts(), wp_print_footer_scripts(), ob_get_clean() |
!current_theme_supports() | 90–92 | wp_theme_has_theme_json(), wp_enqueue_script(), wp_enqueue_style(), current_theme_supports(), add_filter(), do_action(), remove_filter(), ::WP_Block_Type_Registry(), ->get_all_registered(), has_action(), remove_action(), ob_start(), wp_print_styles(), wp_print_font_faces(), wp_print_font_faces_from_style_variations(), ob_get_clean(), add_action(), ob_start(), wp_print_head_scripts(), wp_print_footer_scripts(), ob_get_clean() |
current_theme_supports() | 93–95 | wp_theme_has_theme_json(), wp_enqueue_script(), wp_enqueue_style(), current_theme_supports(), wp_enqueue_style(), add_filter(), do_action(), remove_filter(), ::WP_Block_Type_Registry(), ->get_all_registered(), has_action(), remove_action(), ob_start(), wp_print_styles(), wp_print_font_faces(), wp_print_font_faces_from_style_variations(), ob_get_clean(), add_action(), ob_start(), wp_print_head_scripts(), wp_print_footer_scripts(), ob_get_clean() |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 110 instructions, 82–95 executed per call, 10 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_get_iframed_editor_assets() runs, in this order:
- do_action( enqueue_block_assets )actionline 342 (+41 into the body)
Fires after enqueuing block assets for both editor and front-end.
Uses · 18
- wp_theme_has_theme_json()Checks whether a theme or its parent has a theme.json file.
- wp_enqueue_script()Enqueues a script.
- wp_enqueue_style()Enqueues a CSS stylesheet.
- current_theme_supports()Checks a theme's support for a given feature.
- add_filter()Adds a callback function to a filter hook.
- do_action()Calls the callback functions that have been added to an action hook.
- remove_filter()Removes a callback function from a filter hook.
- has_action()Checks if any action has been registered for a hook.
- remove_action()Removes a callback function from an action hook.
- wp_print_styles()Displays styles that are in the $handles queue.
- wp_print_font_faces()Generates and prints font-face styles for given fonts or theme.json fonts.
- wp_print_font_faces_from_style_variations()Generates and prints font-face styles defined the the theme style variations.
Show all 18
- add_action()Adds a callback function to an action hook.
- wp_print_head_scripts()Prints the script queue in the HTML head on the front end.
- wp_print_footer_scripts()Hooks to print the scripts and styles in the footer.
- WP_Styles::__construct()Constructor.
- WP_Scripts::__construct()Constructor.
- WP_Block_Type_Registry::get_instance()Utility method to retrieve the main instance of the class.
Used by · 1
- get_block_editor_settings()Returns the contextualized block editor settings for a selected editor context.
Source code
function _wp_get_iframed_editor_assets() { global $wp_styles, $wp_scripts; // Keep track of the styles and scripts instance to restore later. $current_wp_styles = $wp_styles; $current_wp_scripts = $wp_scripts; // Create new instances to collect the assets. $wp_styles = new WP_Styles(); $wp_scripts = new WP_Scripts(); /* * Register all currently registered styles and scripts. The actions that * follow enqueue assets, but don't necessarily register them. */ $wp_styles->registered = $current_wp_styles->registered; $wp_scripts->registered = $current_wp_scripts->registered; /* * We generally do not need reset styles for the iframed editor. * However, if it's a classic theme, margins will be added to every block, * which is reset specifically for list items, so classic themes rely on * these reset styles. */ $wp_styles->done = wp_theme_has_theme_json() ? array( 'wp-reset-editor-styles' ) : array(); wp_enqueue_script( 'wp-polyfill' ); // Enqueue the `editorStyle` handles for all core block, and dependencies. wp_enqueue_style( 'wp-edit-blocks' ); if ( current_theme_supports( 'wp-block-styles' ) ) { wp_enqueue_style( 'wp-block-library-theme' ); } /* * We don't want to load EDITOR scripts in the iframe, only enqueue * front-end assets for the content. */ add_filter( 'should_load_block_editor_scripts_and_styles', '__return_false' ); /** This action is documented in wp-includes/script-loader.php */ do_action( 'enqueue_block_assets' ); remove_filter( 'should_load_block_editor_scripts_and_styles', '__return_false' ); $block_registry = WP_Block_Type_Registry::get_instance(); /* * Additionally, do enqueue `editorStyle` assets for all blocks, which * contains editor-only styling for blocks (editor content). */ foreach ( $block_registry->get_all_registered() as $block_type ) { if ( isset( $block_type->editor_style_handles ) && is_array( $block_type->editor_style_handles ) ) { foreach ( $block_type->editor_style_handles as $style_handle ) { wp_enqueue_style( $style_handle ); } } } /** * Remove the deprecated `print_emoji_styles` handler. * It avoids breaking style generation with a deprecation message. */ $has_emoji_styles = has_action( 'wp_print_styles', 'print_emoji_styles' ); if ( $has_emoji_styles ) { remove_action( 'wp_print_styles', 'print_emoji_styles' ); } ob_start(); wp_print_styles(); wp_print_font_faces(); wp_print_font_faces_from_style_variations(); $styles = ob_get_clean(); if ( $has_emoji_styles ) { add_action( 'wp_print_styles', 'print_emoji_styles' ); } ob_start(); wp_print_head_scripts(); wp_print_footer_scripts();Changelog
Introduced in 6.0.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.0.4 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.