Make WordPress Core

Opened 15 years ago

Closed 15 years ago

#19699 closed defect (bug) (fixed)

current-menu-item and current_page_item classes incorrectly added to custom menu items with no URL value.

Reported by: tschoonover Owned by: ryan
Priority: normal Milestone: 3.3.1
Component: Menus Version: 3.3
Severity: normal Keywords:
Cc: Focuses:

Description

If the current page is the home page, the _wp_menu_item_classes_by_context function will incorrectly add the current-menu-item and current_page_item classes to any custom menu items that do not have a value for URL. This occurs because the custom menu item URL (after formatting) compares equal to the home page URL.

Note - a custom menu item might not have a URL value if it is used as only a parent container for another submenu.

Attachments (1)

19699.diff (1.2 KB ) - added by nacin 15 years ago.

Download all attachments as: .zip

Change History (6)

#1 @duck_
15 years ago

Caused by [18746] for #15954 because $_root_relative_current is an empty string for the home page. We could check if the URL is empty for custom menu items before adding classes.

#2 @nacin
15 years ago

  • Milestone Awaiting Review3.3.1

@nacin
15 years ago

#3 @nacin
15 years ago

Attached patch prevents an empty URL from triggering the current-menu-item class.

It also allows a relative root URL ("/") to trigger the current-menu-item class, as before.

#4 @nacin
15 years ago

In [19657]:

Properly handle a blank nav menu custom URL when determining what page we're on. see #19699 for trunk.

#5 @ryan
15 years ago

  • Owner set to ryan
  • Resolutionfixed
  • Status newclosed

In [19658]:

Properly handle a blank nav menu custom URL when determining what page we're on. fixes #19699 for 3.3

Note: See TracTickets for help on using tickets.