Skip to content

Commit

Permalink
Check for empty parsed Nav blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
getdave committed Nov 23, 2021
1 parent d15df93 commit cdaaf5e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/block-library/src/navigation/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,11 @@ function block_core_navigation_get_fallback() {

// Prefer using the first non-empty Navigation as fallback if available.
if ( $navigation_post ) {
$fallback_blocks = block_core_navigation_normalize_parsed_blocks( parse_blocks( $navigation_post->post_content ) );
$maybe_fallback = block_core_navigation_normalize_parsed_blocks( parse_blocks( $navigation_post->post_content ) );

// Normalizing blocks may result in an empty array of blocks if they were all `null` blocks.
// In this case default to the (Page List) fallback.
$fallback_blocks = ! empty( $maybe_fallback ) ? $maybe_fallback : $fallback_blocks;
}

return $fallback_blocks;
Expand Down

0 comments on commit cdaaf5e

Please sign in to comment.