[wp-trac] [WordPress Trac] #21070: Added a filter to the sub-menu class attribute
WordPress Trac
wp-trac at lists.automattic.com
Mon Jun 25 14:38:55 UTC 2012
#21070: Added a filter to the sub-menu class attribute
---------------------------+------------------------
Reporter: bjornjohansen | Owner:
Type: enhancement | Status: closed
Priority: normal | Milestone:
Component: Menus | Version: 3.4
Severity: normal | Resolution: duplicate
Keywords: has-patch |
---------------------------+------------------------
Comment (by bjornjohansen):
I'm not happy with the conclusions of the two other tickets.
Regarding 19297:
As the $depth variable isn't passed on to the filter nav_menu_css_class
and the ul element class is hard coded, there actually isn't a very easy
way to do this on your own. For the nav_menu_css_class filter, your
function actually have to make a lot of queries up the menu tree for each
menu item to find the depth. For the ul element, you have to create your
own walker, completely replacing Walker_Nav_Menu::start_lvl().
Regarding 19768:
The proposed solution here causes CSS code which is both very ineffcient
for browsers to render (https://developers.google.com/speed/docs/best-
practices/rendering#UseEfficientCSSSelectors), and makes hard-to-maintain
CSS code.
If you take a look at the Walker_Nav_Menu class, there are actually filter
calls all over the place, which gives a lot of flexibility without the
need for custom walker classes. The exception to this, is the start_lvl
method, which actually doesn't have any filters applied at all.
The patch I provided does not change the default output from WordPress,
but simply gives you a filter to optionally change it. Just like
everything else in WordPress.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/21070#comment:2>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list