wp_add_iframed_editor_assets_html()
Inject the block editor assets that need to be loaded into the editor’s iframe as an inline script.
Source
File: wp-includes/script-loader.php
function wp_add_iframed_editor_assets_html() { $script_handles = array(); $style_handles = array( 'wp-block-editor', 'wp-block-library', 'wp-block-library-theme', 'wp-edit-blocks', ); $block_registry = WP_Block_Type_Registry::get_instance(); foreach ( $block_registry->get_all_registered() as $block_type ) { if ( ! empty( $block_type->style ) ) { $style_handles[] = $block_type->style; } if ( ! empty( $block_type->editor_style ) ) { $style_handles[] = $block_type->editor_style; } if ( ! empty( $block_type->script ) ) { $script_handles[] = $block_type->script; } } $style_handles = array_unique( $style_handles ); $done = wp_styles()->done; ob_start(); wp_styles()->done = array(); wp_styles()->do_items( $style_handles ); wp_styles()->done = $done; $styles = ob_get_clean(); $script_handles = array_unique( $script_handles ); $done = wp_scripts()->done; ob_start(); wp_scripts()->done = array(); wp_scripts()->do_items( $script_handles ); wp_scripts()->done = $done; $scripts = ob_get_clean(); $editor_assets = wp_json_encode( array( 'styles' => $styles, 'scripts' => $scripts, ) ); echo "<script>window.__editorAssets = $editor_assets</script>"; }
Changelog
Version | Description |
---|---|
5.8.0 | Introduced. |
© 2003–2021 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_add_iframed_editor_assets_html