Changeset 51003 for trunk/src/wp-includes/script-loader.php
- Timestamp:
- 05/25/2021 02:19:14 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/script-loader.php
r51001 r51003 2663 2663 } 2664 2664 } 2665 2666 /** 2667 * Inject the block editor assets that need to be loaded into the editor's iframe as an inline script. 2668 * 2669 * @since 5.8.0 2670 */ 2671 function wp_add_iframed_editor_assets_html() { 2672 $script_handles = array(); 2673 $style_handles = array( 2674 'wp-block-editor', 2675 'wp-block-library', 2676 'wp-block-library-theme', 2677 'wp-edit-blocks', 2678 ); 2679 2680 $block_registry = WP_Block_Type_Registry::get_instance(); 2681 2682 foreach ( $block_registry->get_all_registered() as $block_type ) { 2683 if ( ! empty( $block_type->style ) ) { 2684 $style_handles[] = $block_type->style; 2685 } 2686 2687 if ( ! empty( $block_type->editor_style ) ) { 2688 $style_handles[] = $block_type->editor_style; 2689 } 2690 2691 if ( ! empty( $block_type->script ) ) { 2692 $script_handles[] = $block_type->script; 2693 } 2694 } 2695 2696 $style_handles = array_unique( $style_handles ); 2697 $done = wp_styles()->done; 2698 2699 ob_start(); 2700 2701 wp_styles()->done = array(); 2702 wp_styles()->do_items( $style_handles ); 2703 wp_styles()->done = $done; 2704 2705 $styles = ob_get_clean(); 2706 2707 $script_handles = array_unique( $script_handles ); 2708 $done = wp_scripts()->done; 2709 2710 ob_start(); 2711 2712 wp_scripts()->done = array(); 2713 wp_scripts()->do_items( $script_handles ); 2714 wp_scripts()->done = $done; 2715 2716 $scripts = ob_get_clean(); 2717 2718 $editor_assets = wp_json_encode( 2719 array( 2720 'styles' => $styles, 2721 'scripts' => $scripts, 2722 ) 2723 ); 2724 2725 echo "<script>window.__editorAssets = $editor_assets</script>"; 2726 }
Note: See TracChangeset
for help on using the changeset viewer.