Fix a bug where woocommerce removes the current-menu-item class (#45095)
* Fix a bug where woocommerce removes the current-menu-item class from a menu item (e.g. taxonomy) because its id matches with page_for_posts option * Add changefile(s) from automation for the following project(s): woocommerce * Add changefile(s) from automation for the following project(s): woocommerce * Apply suggestions from code review Co-authored-by: Vedanshu Jain <vedanshu.jain.2012@gmail.com> * Add changefile(s) from automation for the following project(s): woocommerce --------- Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Vedanshu Jain <vedanshu.jain.2012@gmail.com>
This commit is contained in:
parent
ece00533e4
commit
acea491755
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: fix
|
||||
|
||||
Fix a bug where woocommerce removes the current-menu-item class. #### Comment <!-- If the changes in this pull request don't warrant a changelog entry, you can alternatively supply a comment here. Note that comments are only accepted with a significance of "Patch" -->
|
|
@ -168,7 +168,7 @@ function wc_nav_menu_item_classes( $menu_items ) {
|
|||
$menu_id = (int) $menu_item->object_id;
|
||||
|
||||
// Unset active class for blog page.
|
||||
if ( $page_for_posts === $menu_id ) {
|
||||
if ( $page_for_posts === $menu_id && isset( $menu_item->object ) && 'page' === $menu_item->object ) {
|
||||
$menu_items[ $key ]->current = false;
|
||||
|
||||
if ( in_array( 'current_page_parent', $classes, true ) ) {
|
||||
|
|
Loading…
Reference in New Issue