Skip to content

Commit

Permalink
Check for unset/non-array values in block_type asset handles (#46488)
Browse files Browse the repository at this point in the history
  • Loading branch information
noahtallen committed Dec 14, 2022
1 parent 39c97c0 commit 6120d12
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions lib/compat/wordpress-6.2/script-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,18 @@ function gutenberg_resolve_assets_override() {
$block_registry = WP_Block_Type_Registry::get_instance();

foreach ( $block_registry->get_all_registered() as $block_type ) {
$style_handles = array_merge(
$style_handles,
$block_type->style_handles,
$block_type->editor_style_handles
);

$script_handles = array_merge(
$script_handles,
$block_type->script_handles
);
// 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 );
Expand Down

0 comments on commit 6120d12

Please sign in to comment.