WordPress.org

Make WordPress Core

Opened 10 months ago

Last modified 3 weeks ago

#39077 new defect (bug)

Navigation menu items should be defined as being hierarchical

Reported by: schlessera Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.0
Component: Menus Keywords: has-patch needs-unit-tests
Focuses: Cc:

Description

Menu items are hierarchical in nature, as each menu item can be attached as a child to a parent item. This is what allows one to build submenus at differing levels.

These hierarchical relationships are persisted into the database using the post_parent column to attach parent IDs to child IDs.

However, when the nav_menu_item is registered during the bootstrapping process, it is defined as being hierarchical => false, which is conceptually wrong. It just happens to be irrelevant, because the user interface for menus is a custom implementation that considerably differs from standard post list tables.

As these nav_menu_item elements might need to be iterated over through other means than the menu UI, they should be correctly represented as being hierarchical in nature (and thus making use of the post_parent database table column).

Attachments (1)

39077.1.diff (471 bytes) - added by schlessera 10 months ago.

Download all attachments as: .zip

Change History (4)

@schlessera
10 months ago

#1 @helen
10 months ago

  • Version changed from trunk to 3.0

#2 @welcher
9 months ago

  • Keywords has-patch needs-unit-tests added

Patch is pretty straight forward. Let's add some tests.

#3 @schlessera
3 weeks ago

@welcher I'm not sure what specific tests you have in mind.

What could be tested is: "a nav_menu_item's hierarchical property should return true", but that would just test whether the register_post_type() correctly assigns that property (which is already tested in several other places, directly or indirectly).

Any specific test you would like to see?

Note: See TracTickets for help on using tickets.