WordPress.org

Make WordPress Core

Opened 8 years ago

Closed 8 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
Milestone: 3.3.1 Priority: normal
Severity: normal Version: 3.3
Component: Menus Keywords:
Focuses: Cc:
PR Number:

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 8 years ago.

Download all attachments as: .zip

Change History (6)

#1 @duck_
8 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
8 years ago

  • Milestone changed from Awaiting Review to 3.3.1

@nacin
8 years ago

#3 @nacin
8 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
8 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
8 years ago

  • Owner set to ryan
  • Resolution set to fixed
  • Status changed from new to closed

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.