Skip to content

Commit

Permalink
Use get_queried_object_id when setting current-menu-item classes (#…
Browse files Browse the repository at this point in the history
…44474)

This commit applies the same fix as #43800 but at other places where we are adding the current-menu-item class:
* in the page-list block
* in the navigation-submenu block
  • Loading branch information
BenoitZugmeyer authored Sep 27, 2022
1 parent af7ff63 commit 995154f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/block-library/src/navigation-submenu/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) {

$css_classes = trim( implode( ' ', $classes ) );
$has_submenu = count( $block->inner_blocks ) > 0;
$is_active = ! empty( $attributes['id'] ) && ( get_the_ID() === (int) $attributes['id'] );
$is_active = ! empty( $attributes['id'] ) && ( get_queried_object_id() === (int) $attributes['id'] );

$show_submenu_indicators = isset( $block->context['showSubmenuIcon'] ) && $block->context['showSubmenuIcon'];
$open_on_click = isset( $block->context['openSubmenusOnClick'] ) && $block->context['openSubmenusOnClick'];
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/page-list/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ function render_block_core_page_list( $attributes, $content, $block ) {
$active_page_ancestor_ids = array();

foreach ( (array) $all_pages as $page ) {
$is_active = ! empty( $page->ID ) && ( get_the_ID() === $page->ID );
$is_active = ! empty( $page->ID ) && ( get_queried_object_id() === $page->ID );

if ( $is_active ) {
$active_page_ancestor_ids = get_post_ancestors( $page->ID );
Expand Down

0 comments on commit 995154f

Please sign in to comment.