From d8c50c7a129439e7260774b79dc5a184be6ba977 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 5 Jul 2017 21:31:44 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@41008 git-svn-id: http://core.svn.wordpress.org/trunk@40858 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/nav-menu-template.php | 11 +++++++++++ wp-includes/version.php | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/wp-includes/nav-menu-template.php b/wp-includes/nav-menu-template.php index f6a38e8b67..5b49937890 100644 --- a/wp-includes/nav-menu-template.php +++ b/wp-includes/nav-menu-template.php @@ -394,6 +394,17 @@ function _wp_menu_item_classes_by_context( &$menu_items ) { ) { $classes[] = 'current-menu-item'; $menu_items[$key]->current = true; + $_anc_id = (int) $menu_item->db_id; + + while( + ( $_anc_id = get_post_meta( $_anc_id, '_menu_item_menu_item_parent', true ) ) && + ! in_array( $_anc_id, $active_ancestor_item_ids ) + ) { + $active_ancestor_item_ids[] = $_anc_id; + } + + $active_parent_item_ids[] = (int) $menu_item->menu_item_parent; + // if the menu item corresponds to the currently-requested URL } elseif ( 'custom' == $menu_item->object && isset( $_SERVER['HTTP_HOST'] ) ) { $_root_relative_current = untrailingslashit( $_SERVER['REQUEST_URI'] ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 68b351fc38..5b5a8bfedd 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.9-alpha-41007'; +$wp_version = '4.9-alpha-41008'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.