Skip to content

Commit

Permalink
Remove legacy logic for __unstableResolvedAssets (WordPress#51100)
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal authored and sethrubenstein committed Jul 13, 2023
1 parent fe1a85a commit 851a07b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 81 deletions.
79 changes: 0 additions & 79 deletions lib/compat/wordpress-6.2/script-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,89 +64,10 @@ static function () use ( $style ) {
);
}

/**
* Sets the content assets for the block editor.
*
* Note for core merge: see inline comment on what's been updated.
*/
function gutenberg_resolve_assets_override() {
global $pagenow;

$script_handles = array(
'wp-polyfill',
);
// Note for core merge: only 'wp-edit-blocks' should be in this array.
$style_handles = array(
'wp-edit-blocks',
);

if ( current_theme_supports( 'wp-block-styles' ) ) {
$style_handles[] = 'wp-block-library-theme';
}

if ( 'widgets.php' === $pagenow || 'customize.php' === $pagenow ) {
$style_handles[] = 'wp-widgets';
$style_handles[] = 'wp-edit-widgets';
}

$block_registry = WP_Block_Type_Registry::get_instance();

foreach ( $block_registry->get_all_registered() as $block_type ) {
// In older WordPress versions, like 6.0, these properties are not defined.
if ( isset( $block_type->style_handles ) && is_array( $block_type->style_handles ) ) {
$style_handles = array_merge( $style_handles, $block_type->style_handles );
}

if ( isset( $block_type->editor_style_handles ) && is_array( $block_type->editor_style_handles ) ) {
$style_handles = array_merge( $style_handles, $block_type->editor_style_handles );
}

if ( isset( $block_type->script_handles ) && is_array( $block_type->script_handles ) ) {
$script_handles = array_merge( $script_handles, $block_type->script_handles );
}
}

$style_handles = array_unique( $style_handles );
$done = wp_styles()->done;

ob_start();

// We do not need reset styles for the iframed editor.
wp_styles()->done = array( 'wp-reset-editor-styles' );
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();

// Generate font @font-face styles.
if ( function_exists( 'wp_print_fonts' ) ) {
ob_start();
wp_print_fonts( true );
$styles .= ob_get_clean();
}

return array(
'styles' => $styles,
'scripts' => $scripts,
);
}

add_filter(
'block_editor_settings_all',
function( $settings ) {
// We must override what core is passing now.
$settings['__unstableResolvedAssets'] = gutenberg_resolve_assets_override();
$settings['__unstableIsBlockBasedTheme'] = wp_is_block_theme();
return $settings;
},
Expand Down
3 changes: 1 addition & 2 deletions lib/compat/wordpress-6.3/script-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,5 @@ function( $settings ) {
// We must override what core is passing now.
$settings['__unstableResolvedAssets'] = _gutenberg_get_iframed_editor_assets();
return $settings;
},
100
}
);

0 comments on commit 851a07b

Please sign in to comment.