Changeset 56047
- Timestamp:
- 06/27/2023 12:21:12 AM (18 months ago)
- Location:
- trunk/src/wp-includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/block-editor.php
r56030 r56047 288 288 * @access private 289 289 * 290 * @global string $pagenow The filename of the current screen. 290 * @global string $pagenow The filename of the current screen. 291 * @global WP_Styles $wp_styles The WP_Styles current instance. 292 * @global WP_Scripts $wp_scripts The WP_Scripts current instance. 291 293 * 292 294 * @return array { … … 298 300 */ 299 301 function _wp_get_iframed_editor_assets() { 300 global $pagenow, $editor_styles; 301 302 $script_handles = array( 303 'wp-polyfill', 304 ); 305 $style_handles = array( 306 'wp-edit-blocks', 307 ); 308 309 if ( 310 current_theme_supports( 'wp-block-styles' ) && 311 ( ! is_array( $editor_styles ) || count( $editor_styles ) === 0 ) 312 ) { 313 $style_handles[] = 'wp-block-library-theme'; 314 } 315 316 if ( 'widgets.php' === $pagenow || 'customize.php' === $pagenow ) { 317 $style_handles[] = 'wp-widgets'; 318 $style_handles[] = 'wp-edit-widgets'; 319 } 302 global $wp_styles, $wp_scripts, $pagenow; 303 304 // Keep track of the styles and scripts instance to restore later. 305 $current_wp_styles = $wp_styles; 306 $current_wp_scripts = $wp_scripts; 307 308 // Create new instances to collect the assets. 309 $wp_styles = new WP_Styles(); 310 $wp_scripts = new WP_Scripts(); 311 312 /* 313 * Register all currently registered styles and scripts. The actions that 314 * follow enqueue assets, but don't necessarily register them. 315 */ 316 $wp_styles->registered = $current_wp_styles->registered; 317 $wp_scripts->registered = $current_wp_scripts->registered; 318 319 /* 320 * We generally do not need reset styles for the iframed editor. 321 * However, if it's a classic theme, margins will be added to every block, 322 * which is reset specifically for list items, so classic themes rely on 323 * these reset styles. 324 */ 325 $wp_styles->done = 326 wp_theme_has_theme_json() ? array( 'wp-reset-editor-styles' ) : array(); 327 328 wp_enqueue_script( 'wp-polyfill' ); 329 // Enqueue the `editorStyle` handles for all core block, and dependencies. 330 wp_enqueue_style( 'wp-edit-blocks' ); 331 332 if ( 'site-editor.php' === $pagenow ) { 333 wp_enqueue_style( 'wp-edit-site' ); 334 } 335 336 if ( current_theme_supports( 'wp-block-styles' ) ) { 337 wp_enqueue_style( 'wp-block-library-theme' ); 338 } 339 340 /* 341 * We don't want to load EDITOR scripts in the iframe, only enqueue 342 * front-end assets for the content. 343 */ 344 add_filter( 'should_load_block_editor_scripts_and_styles', '__return_false' ); 345 do_action( 'enqueue_block_assets' ); 346 remove_filter( 'should_load_block_editor_scripts_and_styles', '__return_false' ); 320 347 321 348 $block_registry = WP_Block_Type_Registry::get_instance(); 322 349 350 /* 351 * Additionally, do enqueue `editorStyle` assets for all blocks, which 352 * contains editor-only styling for blocks (editor content). 353 */ 323 354 foreach ( $block_registry->get_all_registered() as $block_type ) { 324 $style_handles = array_merge( 325 $style_handles, 326 $block_type->style_handles, 327 $block_type->editor_style_handles 328 ); 329 330 $script_handles = array_merge( 331 $script_handles, 332 $block_type->script_handles 333 ); 334 } 335 336 $style_handles = array_unique( $style_handles ); 337 $done = wp_styles()->done; 355 if ( isset( $block_type->editor_style_handles ) && is_array( $block_type->editor_style_handles ) ) { 356 foreach ( $block_type->editor_style_handles as $style_handle ) { 357 wp_enqueue_style( $style_handle ); 358 } 359 } 360 } 338 361 339 362 ob_start(); 340 341 // We do not need reset styles for the iframed editor. 342 wp_styles()->done = array( 'wp-reset-editor-styles' ); 343 wp_styles()->do_items( $style_handles ); 344 wp_styles()->done = $done; 345 363 wp_print_styles(); 346 364 $styles = ob_get_clean(); 347 365 348 $script_handles = array_unique( $script_handles );349 $done = wp_scripts()->done;350 351 366 ob_start(); 352 353 wp_scripts()->done = array(); 354 wp_scripts()->do_items( $script_handles ); 355 wp_scripts()->done = $done; 356 367 wp_print_head_scripts(); 368 wp_print_footer_scripts(); 357 369 $scripts = ob_get_clean(); 370 371 // Restore the original instances. 372 $wp_styles = $current_wp_styles; 373 $wp_scripts = $current_wp_scripts; 358 374 359 375 return array( -
trunk/src/wp-includes/script-loader.php
r56008 r56047 1630 1630 'wp-block-editor-content', 1631 1631 "/wp-includes/css/dist/block-editor/content$suffix.css", 1632 array( )1632 array( 'wp-components' ) 1633 1633 ); 1634 1634
Note: See TracChangeset
for help on using the changeset viewer.