[wp-trac] [WordPress Trac] #16594: inconsistency in wp_nav_menu_items

WordPress Trac wp-trac at lists.automattic.com
Sat Feb 19 10:43:12 UTC 2011


#16594: inconsistency in wp_nav_menu_items
--------------------------+-----------------------------
 Reporter:  thomask       |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Menus         |    Version:  3.1
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 Not sure if it is a bug: when I create a menu, e.g.
 wp_nav_menu(array( 'theme_location' => 'footer' ));
 and put there a menu (E.g. named "My menu") using nav-menu.php editor and
 then try to call wp_nav_menu_items filter to see all arguments, e.g.
 {{{
 add_filter('wp_nav_menu_items','my_test', 10, 2);
 function my_test($items, $args) {
 print_r ($args);
 }
 }}}
 the resulting object is

 {{{
 (
     [menu] =>
     [container] => div
     [container_class] =>
     [container_id] =>
     [menu_class] => menu
     [menu_id] =>
     [echo] => 1
     [fallback_cb] =>
     [before] =>
     [after] =>
     [link_before] =>
     [link_after] =>
     [items_wrap] => <ul id="%1$s" class="%2$s">%3$s</ul>
     [depth] => 0
     [walker] =>
     [theme_location] => menu
 )
 }}}

 But if I put the same "My menu" to the same place using widget, I got
 object with extended 'menu'

 {{{
     [menu] => stdClass Object
         (
             [term_id] => 4
             [name] => My menu
             [slug] => my-menu
             [term_group] => 0
             [term_taxonomy_id] => 4
             [taxonomy] => nav_menu
             [description] =>
             [parent] => 0
             [count] => 3
         )

     [container] => div
     [container_class] =>
     [container_id] =>
     [menu_class] => menu
     [menu_id] =>
     [echo] => 1
     [fallback_cb] =>
     [before] =>
     [after] =>
     [link_before] =>
     [link_after] =>
     [items_wrap] => <ul id="%1$s" class="%2$s">%3$s</ul>
     [depth] => 0
     [walker] =>
     [theme_location] =>
 }}}

 I guess that they should be the same (except 'theme_location') - the
 problem is, that using the first scenario, i got no way to find "My menu"
 details - id, name, slug ... of the menu, so i even cannot filter by them
 in my functions (e.g. apply filter just for a specific menu).

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/16594>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list