Skip to content

Commit

Permalink
Create filter and improve output validity test
Browse files Browse the repository at this point in the history
  • Loading branch information
getdave committed Nov 25, 2021
1 parent 8648ce3 commit a720dbf
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/block-library/src/navigation/index.php
Expand Up @@ -187,6 +187,7 @@ function( $block ) {
* @return array the array of blocks to be used as a fallback.
*/
function block_core_navigation_get_fallback_blocks() {

// Default to a list of Pages.
$fallback_blocks = array(
array(
Expand All @@ -206,7 +207,7 @@ function block_core_navigation_get_fallback_blocks() {
$fallback_blocks = ! empty( $maybe_fallback ) ? $maybe_fallback : $fallback_blocks;
}

return $fallback_blocks;
return apply_filters( 'block_core_navigation_render_fallback', $fallback_blocks );
}

/**
Expand Down Expand Up @@ -298,7 +299,13 @@ function render_block_core_navigation( $attributes, $content, $block ) {

$fallback_blocks = block_core_navigation_get_fallback_blocks();

// Fallback my have been filtered so do basic test for validity.
if ( empty( $fallback_blocks ) || ! is_array( $fallback_blocks ) ) {
return '';
}

$inner_blocks = new WP_Block_List( $fallback_blocks, $attributes );

}

// Restore legacy classnames for submenu positioning.
Expand Down

0 comments on commit a720dbf

Please sign in to comment.