WordPress.org

Make WordPress Core

Ticket #13994: front-page-current-class.13994.diff

File front-page-current-class.13994.diff, 886 bytes (added by filosofo, 4 years ago)
  • wp-includes/nav-menu-template.php

     
    307307 
    308308        $possible_object_parents = array_filter( $possible_object_parents ); 
    309309 
     310        $front_page_url = home_url('/'); 
     311 
    310312        foreach ( (array) $menu_items as $key => $menu_item ) { 
    311313                $classes = (array) $menu_item->classes; 
    312314                $classes[] = 'menu-item'; 
     
    370372                                $active_parent_item_ids[] = (int) $menu_item->menu_item_parent; 
    371373                                $active_parent_object_ids[] = (int) $menu_item->post_parent; 
    372374                                $active_object = $menu_item->object; 
     375 
     376                        // give front page item current-menu-item class when extra query arguments involved 
     377                        } elseif ( $item_url == $front_page_url && is_front_page() ) { 
     378                                $classes[] = 'current-menu-item'; 
    373379                        } 
    374380                } 
    375381