WordPress.org

Make WordPress Core

Opened 6 years ago

Last modified 2 years ago

#35702 new enhancement

No current-menu-item in WP custom menus

Reported by: dotancohen Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Menus Keywords: needs-refresh
Focuses: ui, template Cc:

Description

The _wp_menu_item_classes_by_context() method misses some menu item matches for the currently-queried object. This patch adds support for a common case.

Attachments (2)

wp_35702.diff (933 bytes) - added by dotancohen 6 years ago.
Diff file which resolves the issue for a common use case.
wp_35702.2.diff (986 bytes) - added by dotancohen 6 years ago.
Better diff, doesn't break other pages!

Download all attachments as: .zip

Change History (5)

@dotancohen
6 years ago

Diff file which resolves the issue for a common use case.

#1 @dotancohen
6 years ago

My test case is for the taxonomy archive "מוצרים", where the custom menu was set "/מוצרים" and "/מוצרים/", both of which are valid links but neither of which was matched by the pre-patch WP trunk. With the patch both cases are matched properly.

@dotancohen
6 years ago

Better diff, doesn't break other pages!

#2 @obenland
6 years ago

  • Type changed from defect (bug) to enhancement
  • Version trunk deleted

#3 @welcher
5 years ago

  • Keywords needs-refresh added

@dotancohen - Thanks for the patch!

It just needs some clean up to match coding standards for whitespace. https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#space-usage

After that, let's get some unit tests in place.

Note: See TracTickets for help on using tickets.