WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 5 years ago

#21369 closed defect (bug) (fixed)

Duplicate current-menu-item classes in Menu when using multiple taxonomy terms with the same slug

Reported by: jchristopher Owned by: nacin
Milestone: 3.5 Priority: normal
Severity: normal Version: 3.4.1
Component: Menus Keywords: has-patch commit
Focuses: Cc:

Description

If Taxonomy-based Menu items have the same slug (regardless of Taxonomy name) classes of current-menu-item, current-menu-ancestor, etc. will be added to all Taxonomy term Menu items that have the slug of the object currently being viewed. This is not an issue with Page-based Menu items.

Test case: if you have a Category named "Test" with a slug test and also have a Tag named "Test" with a slug test and create a Menu using those two terms, viewing either archive page will result in the menu having two items with a class of current-menu-item which results in unwanted styling. This is not an issue if a Page Menu item has a slug of test.

Screenshot of Menu setup: http://d.pr/i/WtJg/5vBu91hX

Screenshot of duplicate class issue: http://d.pr/i/M4VH/4nbAdJZY

Attachments (1)

21369.patch (780 bytes) - added by SergeyBiryukov 6 years ago.

Download all attachments as: .zip

Change History (10)

#1 @nacin
6 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 3.5

#2 @SergeyBiryukov
6 years ago

  • Keywords has-patch added; needs-patch removed

Categories and tags with the same name share the same ID (related: #5809).

21369.patch adds a check for the queried object taxonomy.

#3 follow-up: @jchristopher
6 years ago

Forgive my ignorance with this process but with a patch submitted will this fix continue to not be in place until 3.5?

#4 in reply to: ↑ 3 ; follow-up: @nacin
6 years ago

Replying to jchristopher:

Forgive my ignorance with this process but with a patch submitted will this fix continue to not be in place until 3.5?

3.5 is the next major release, so it will be fixed then, yes.

You may be able to use a filter to correct the classes in the meantime.

#5 in reply to: ↑ 4 @jchristopher
6 years ago

Replying to nacin:

Replying to jchristopher:

Forgive my ignorance with this process but with a patch submitted will this fix continue to not be in place until 3.5?

3.5 is the next major release, so it will be fixed then, yes.

You may be able to use a filter to correct the classes in the meantime.

Great, thanks Nacin! I'll check into that.

#6 @sc0ttkclark
6 years ago

  • Cc lol@… added

Looking forward to the fix

#7 @ryan
6 years ago

  • Keywords commit added

#8 @nacin
6 years ago

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

In [22302]:

Confirm that the nav menu's underlying object is in the proper taxonomy before adding the current-menu-item class. props SergeyBiryukov. fixes #21369.

#9 @SergeyBiryukov
5 years ago

#23130 was marked as a duplicate.

Note: See TracTickets for help on using tickets.