Title: _wp_get_iframed_editor_assets
Published: May 25, 2022
Last modified: August 20, 2026

---

# _wp_get_iframed_editor_assets(): array

## In this article

 * [Return](https://developer.wordpress.org/reference/functions/_wp_get_iframed_editor_assets/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/_wp_get_iframed_editor_assets/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/_wp_get_iframed_editor_assets/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/_wp_get_iframed_editor_assets/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/_wp_get_iframed_editor_assets/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/_wp_get_iframed_editor_assets/?output_format=md#wp--skip-link--target)

This function’s access is marked private. This means it is not intended for use 
by plugin or theme developers, only by core. It is listed here for completeness.

Collect the block editor assets that need to be loaded into the editor’s iframe.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/_wp_get_iframed_editor_assets/?output_format=md#return)󠁿

 array The block editor assets.

 * `styles` string|false
 * String containing the HTML for styles.
 * `scripts` string|false
 * String containing the HTML for scripts.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/_wp_get_iframed_editor_assets/?output_format=md#source)󠁿

    ```php
    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();
    	$scripts = ob_get_clean();

    	// Restore the original instances.
    	$wp_styles  = $current_wp_styles;
    	$wp_scripts = $current_wp_scripts;

    	return array(
    		'styles'  => $styles,
    		'scripts' => $scripts,
    	);
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/block-editor.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/block-editor.php#L301)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/block-editor.php#L301-L391)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/_wp_get_iframed_editor_assets/?output_format=md#hooks)󠁿

 [do_action( ‘enqueue_block_assets’ )](https://developer.wordpress.org/reference/hooks/enqueue_block_assets/)

Fires after enqueuing block assets for both editor and front-end.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/_wp_get_iframed_editor_assets/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_print_font_faces_from_style_variations()](https://developer.wordpress.org/reference/functions/wp_print_font_faces_from_style_variations/)`wp-includes/fonts.php` |

Generates and prints font-face styles defined in the theme style variations.

  | 
| [wp_print_font_faces()](https://developer.wordpress.org/reference/functions/wp_print_font_faces/)`wp-includes/fonts.php` |

Generates and prints font-face styles for given fonts or theme.json fonts.

  | 
| [wp_theme_has_theme_json()](https://developer.wordpress.org/reference/functions/wp_theme_has_theme_json/)`wp-includes/global-styles-and-settings.php` |

Checks whether a theme or its parent has a theme.json file.

  | 
| [WP_Block_Type_Registry::get_instance()](https://developer.wordpress.org/reference/classes/wp_block_type_registry/get_instance/)`wp-includes/class-wp-block-type-registry.php` |

Utility method to retrieve the main instance of the class.

  | 
| [WP_Styles::__construct()](https://developer.wordpress.org/reference/classes/wp_styles/__construct/)`wp-includes/class-wp-styles.php` |

Constructor.

  | 
| [wp_print_styles()](https://developer.wordpress.org/reference/functions/wp_print_styles/)`wp-includes/functions.wp-styles.php` |

Displays styles that are in the $handles queue.

  | 
| [has_action()](https://developer.wordpress.org/reference/functions/has_action/)`wp-includes/plugin.php` |

Checks if any action has been registered for a hook.

  | 
| [remove_action()](https://developer.wordpress.org/reference/functions/remove_action/)`wp-includes/plugin.php` |

Removes a callback function from an action hook.

  | 
| [WP_Scripts::__construct()](https://developer.wordpress.org/reference/classes/wp_scripts/__construct/)`wp-includes/class-wp-scripts.php` |

Constructor.

  | 
| [wp_print_head_scripts()](https://developer.wordpress.org/reference/functions/wp_print_head_scripts/)`wp-includes/script-loader.php` |

Prints the script queue in the HTML head on the front end.

  | 
| [wp_print_footer_scripts()](https://developer.wordpress.org/reference/functions/wp_print_footer_scripts/)`wp-includes/script-loader.php` |

Hooks to print the scripts and styles in the footer.

  | 
| [current_theme_supports()](https://developer.wordpress.org/reference/functions/current_theme_supports/)`wp-includes/theme.php` |

Checks a theme’s support for a given feature.

  | 
| [wp_enqueue_script()](https://developer.wordpress.org/reference/functions/wp_enqueue_script/)`wp-includes/functions.wp-scripts.php` |

Enqueues a script.

  | 
| [wp_enqueue_style()](https://developer.wordpress.org/reference/functions/wp_enqueue_style/)`wp-includes/functions.wp-styles.php` |

Enqueues a CSS stylesheet.

  | 
| [add_filter()](https://developer.wordpress.org/reference/functions/add_filter/)`wp-includes/plugin.php` |

Adds a callback function to a filter hook.

  | 
| [do_action()](https://developer.wordpress.org/reference/functions/do_action/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to an action hook.

  | 
| [remove_filter()](https://developer.wordpress.org/reference/functions/remove_filter/)`wp-includes/plugin.php` |

Removes a callback function from a filter hook.

  | 
| [add_action()](https://developer.wordpress.org/reference/functions/add_action/)`wp-includes/plugin.php` |

Adds a callback function to an action hook.

  |

[Show 13 more](https://developer.wordpress.org/reference/functions/_wp_get_iframed_editor_assets/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/_wp_get_iframed_editor_assets/?output_format=md#)

| Used by | Description | 
| [get_block_editor_settings()](https://developer.wordpress.org/reference/functions/get_block_editor_settings/)`wp-includes/block-editor.php` |

Returns the contextualized block editor settings for a selected editor context.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/_wp_get_iframed_editor_assets/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.0.0](https://developer.wordpress.org/reference/since/6.0.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2F_wp_get_iframed_editor_assets%2F)
before being able to contribute a note or feedback.