Action hook 'enqueue_block_assets'

in WP Core File wp-includes/block-editor.php at line 340

Description

Collect the block editor assets that need to be loaded into the editor's iframe. The block editor assets. } / 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.

Occurrences

Filename Line Number
wp-includes/block-editor.php 340
wp-includes/script-loader.php 2447

PHP Doc

/**
 * Collect the block editor assets that need to be loaded into the editor's iframe.
 *
 * @since 6.0.0
 * @access private
 *
 * @global WP_Styles  $wp_styles  The WP_Styles current instance.
 * @global WP_Scripts $wp_scripts The WP_Scripts current instance.
 *
 * @return array {
 *     The block editor assets.
 *
 *     @type string|false $styles  String containing the HTML for styles.
 *     @type string|false $scripts String containing the HTML for scripts.
 * }
 */
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.
	 */