[wp-trac] [WordPress Trac] #23130: nav_menu and custom taxonomies
WordPress Trac
noreply at wordpress.org
Sun Jan 6 14:08:59 UTC 2013
#23130: nav_menu and custom taxonomies
-----------------------------+--------------------------
Reporter: dmikam | Type: defect (bug)
Status: new | Priority: normal
Milestone: Awaiting Review | Component: Menus
Version: 3.5 | Severity: normal
Keywords: |
-----------------------------+--------------------------
I found out that in case when you have some custom taxonomies, their terms
could has the same term_id. The case is when two(or more) terms with the
same term_id but from different taxonomies are added to Nav Menu, and the
user is in one of this terms - they are both marked like active in menu.
This is because of lacking condition in _wp_menu_item_classes_by_context
function in wp-includes/nav-menu-template.php file:
{{{
// if the menu item corresponds to the currently-queried post or taxonomy
object
} elseif (
$menu_item->object_id == $queried_object_id &&
(
( ! empty( $home_page_id ) && 'post_type' ==
$menu_item->type && $wp_query->is_home && $home_page_id ==
$menu_item->object_id ) ||
( 'post_type' == $menu_item->type &&
$wp_query->is_singular ) ||
( 'taxonomy' == $menu_item->type && (
$wp_query->is_category || $wp_query->is_tag || $wp_query->is_tax ))
)
) {
}}}
but it needs to be like that:
{{{
// if the menu item corresponds to the currently-queried post or taxonomy
object
} elseif (
$menu_item->object_id == $queried_object_id &&
(
( ! empty( $home_page_id ) && 'post_type' ==
$menu_item->type && $wp_query->is_home && $home_page_id ==
$menu_item->object_id ) ||
( 'post_type' == $menu_item->type &&
$wp_query->is_singular ) ||
( 'taxonomy' == $menu_item->type && (
$wp_query->is_category || $wp_query->is_tag || $wp_query->is_tax )/*ADDED
CODE-->*/ && $menu_item->object==$queried_object->taxonomy/* <--ADDED
CODE*/)
)
) {
}}}
I found this bug on 3.1.4 version, but looks like it still remains on the
las version of wordpress.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/23130>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list