[wp-trac] [WordPress Trac] #15214: Add class for menu items containing a sub-menu
WordPress Trac
wp-trac at lists.automattic.com
Mon Oct 25 20:51:40 UTC 2010
#15214: Add class for menu items containing a sub-menu
--------------------------+-------------------------------------------------
Reporter: chrisbliss18 | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Menus | Version: 3.1
Severity: normal | Keywords: has-patch
--------------------------+-------------------------------------------------
I wanted to add a class to the menu item LI elements for navigation menus
that have sub menus. This would allow me to do some specific styling such
as using a background that shows that a sub menu is available on hover.
I found that adding this support for both the wp_nav_menu and
wp_list_pages functions was quite simple. So, I put together a patch in
case it might be a good candidate for core.
The new classes are menu-item-with-sub-menu and page_item_with_children
for wp_nav_menu and wp_list_pages, respectively. These class names were
chosen to closely match the existing navigation classes of menu-item, sub-
menu, page_item, and children.
I should note that while making this modification I found that the
display_element method of the Walker class doesn't set has_children when
$args is an object, just when it is an array. The patch also handles
fixing this shortcoming of the Walker API.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/15214>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list