WordPress.org

Make WordPress Core


Ignore:
Timestamp:
07/05/2017 09:30:30 PM (12 months ago)
Author:
SergeyBiryukov
Message:

Menus: Make sure current-menu-parent and current-menu-ancestor classes are properly set for parent items of post type archive submenu items.

Props mrwweb, ajoah, welcher.
Fixes #39800.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/nav-menu-template.php

    r40969 r41008  
    395395            $classes[] = 'current-menu-item';
    396396            $menu_items[$key]->current = true;
     397            $_anc_id = (int) $menu_item->db_id;
     398
     399            while(
     400                ( $_anc_id = get_post_meta( $_anc_id, '_menu_item_menu_item_parent', true ) ) &&
     401                ! in_array( $_anc_id, $active_ancestor_item_ids )
     402            ) {
     403                $active_ancestor_item_ids[] = $_anc_id;
     404            }
     405
     406            $active_parent_item_ids[] = (int) $menu_item->menu_item_parent;
     407
    397408        // if the menu item corresponds to the currently-requested URL
    398409        } elseif ( 'custom' == $menu_item->object && isset( $_SERVER['HTTP_HOST'] ) ) {
Note: See TracChangeset for help on using the changeset viewer.