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

Pass block attributes with rendering with location #33043

Merged
Changes from all 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
16 changes: 9 additions & 7 deletions packages/block-library/src/navigation/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,22 @@ function block_core_navigation_build_css_font_sizes( $attributes ) {
* If no location was provided as a block attribute then false is returned.
*
* @param string $location The location of the classic menu to display.
* @param object $attributes The block attributes.
* @return string|false HTML markup of a generated Navigation Block or false if no location is specified.
*/
function gutenberg_render_menu_from_location( $location ) {
function gutenberg_render_menu_from_location( $location, $attributes ) {
if ( empty( $location ) ) {
return false;
}

return wp_nav_menu(
array(
'theme_location' => $location,
'container' => '',
'items_wrap' => '%3$s',
'fallback_cb' => false,
'echo' => false,
'theme_location' => $location,
'container' => '',
'items_wrap' => '%3$s',
'block_attributes' => $attributes,
'fallback_cb' => false,
'echo' => false,
)
);
}
Expand Down Expand Up @@ -154,7 +156,7 @@ function render_block_core_navigation( $attributes, $content, $block ) {
if ( empty( $block->inner_blocks ) ) {
if ( array_key_exists( '__unstableLocation', $attributes ) ) {
$location = $attributes['__unstableLocation'];
$maybe_classic_navigation = gutenberg_render_menu_from_location( $location );
$maybe_classic_navigation = gutenberg_render_menu_from_location( $location, $attributes );
if ( $maybe_classic_navigation ) {
return $maybe_classic_navigation;
}
Expand Down