Changeset 53160 for trunk/src/wp-includes/script-loader.php
- Timestamp:
- 04/12/2022 03:59:47 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/script-loader.php
r53140 r53160 2885 2885 2886 2886 /** 2887 * Inject the block editor assets that need to be loaded into the editor's iframe as an inline script.2888 *2889 * @since 5.8.02890 *2891 * @global string $pagenow The filename of the current screen.2892 */2893 function wp_add_iframed_editor_assets_html() {2894 global $pagenow;2895 2896 if ( ! wp_should_load_block_editor_scripts_and_styles() ) {2897 return;2898 }2899 2900 $script_handles = array();2901 $style_handles = array(2902 'wp-block-editor',2903 'wp-block-library',2904 'wp-block-library-theme',2905 'wp-edit-blocks',2906 );2907 2908 if ( 'widgets.php' === $pagenow || 'customize.php' === $pagenow ) {2909 $style_handles[] = 'wp-widgets';2910 $style_handles[] = 'wp-edit-widgets';2911 }2912 2913 $block_registry = WP_Block_Type_Registry::get_instance();2914 2915 foreach ( $block_registry->get_all_registered() as $block_type ) {2916 if ( ! empty( $block_type->style ) ) {2917 $style_handles[] = $block_type->style;2918 }2919 2920 if ( ! empty( $block_type->editor_style ) ) {2921 $style_handles[] = $block_type->editor_style;2922 }2923 2924 if ( ! empty( $block_type->script ) ) {2925 $script_handles[] = $block_type->script;2926 }2927 }2928 2929 $style_handles = array_unique( $style_handles );2930 $done = wp_styles()->done;2931 2932 ob_start();2933 2934 // We do not need reset styles for the iframed editor.2935 wp_styles()->done = array( 'wp-reset-editor-styles' );2936 wp_styles()->do_items( $style_handles );2937 wp_styles()->done = $done;2938 2939 $styles = ob_get_clean();2940 2941 $script_handles = array_unique( $script_handles );2942 $done = wp_scripts()->done;2943 2944 ob_start();2945 2946 wp_scripts()->done = array();2947 wp_scripts()->do_items( $script_handles );2948 wp_scripts()->done = $done;2949 2950 $scripts = ob_get_clean();2951 2952 $editor_assets = wp_json_encode(2953 array(2954 'styles' => $styles,2955 'scripts' => $scripts,2956 )2957 );2958 2959 echo "<script>window.__editorAssets = $editor_assets</script>";2960 }2961 2962 /**2963 2887 * Function that enqueues the CSS Custom Properties coming from theme.json. 2964 2888 *
Note: See TracChangeset
for help on using the changeset viewer.