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

Block Library: Add filter for inner blocks in the Navigation block #37998

Merged
merged 4 commits into from
Sep 13, 2022
Merged
Changes from 2 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
9 changes: 8 additions & 1 deletion packages/block-library/src/navigation/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -449,9 +449,16 @@ function render_block_core_navigation( $attributes, $content, $block ) {
}

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

}

/**
* Filter navigation block $inner_blocks.
* Allows modification of a navigation block menu items.
gziolo marked this conversation as resolved.
Show resolved Hide resolved
*
* @param \WP_Block_List $inner_blocks
*/
$inner_blocks = apply_filters( 'render_block_core_navigation_inner_blocks', $inner_blocks );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is one filter that uses a different naming pattern. Let's align it with:

/**
* Filters the fallback experience for the Navigation block.
*
* Returning a falsey value will opt out of the fallback and cause the block not to render.
* To customise the blocks provided return an array of blocks - these should be valid
* children of the `core/navigation` block.
*
* @since 5.9.0
*
* @param array[] default fallback blocks provided by the default block mechanic.
*/
return apply_filters( 'block_core_navigation_render_fallback', $fallback_blocks );

gziolo marked this conversation as resolved.
Show resolved Hide resolved

$layout_justification = array(
'left' => 'items-justified-left',
'right' => 'items-justified-right',
Expand Down