WordPress.org

Make WordPress Core

Opened 22 months ago

Last modified 14 months ago

#35702 new enhancement

No current-menu-item in WP custom menus

Reported by: dotancohen Owned by:
Milestone: Awaiting Review 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 22 months ago.
Diff file which resolves the issue for a common use case.
wp_35702.2.diff (986 bytes) - added by dotancohen 22 months ago.
Better diff, doesn't break other pages!

Download all attachments as: .zip

Change History (5)

@dotancohen
22 months ago

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

#1 @dotancohen
22 months 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
22 months ago

Better diff, doesn't break other pages!

#2 @obenland
20 months ago

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

#3 @welcher
14 months 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.