Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fatal error by checking if block_type asset properties are set #46488

Merged
merged 7 commits into from
Dec 14, 2022
Merged
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 ) ) {
array_merge( $style_handles, $block_type->style_handles );
noahtallen marked this conversation as resolved.
Show resolved Hide resolved
}

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

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

$style_handles = array_unique( $style_handles );
Expand Down