[wp-trac] [WordPress Trac] #37136: 'nav_menu_link_attributes' filter is called with $args as an object instead of an array

WordPress Trac noreply at wordpress.org
Thu Jun 23 17:11:49 UTC 2016


#37136: 'nav_menu_link_attributes' filter is called with $args as an object instead
of an array
--------------------------+------------------------------
 Reporter:  Fab1en        |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Menus         |     Version:
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:  docs, template
--------------------------+------------------------------
Changes (by ocean90):

 * focuses:  template => docs, template
 * version:  trunk =>


Comment:

 `walk_nav_menu_tree()` expects an object while `walk_page_tree()` want's
 to have an array.

 Function stack:
 {{{
 #1 wp_nav_menu( array(2) )      .../header.php:56
 #2 walk_nav_menu_tree( array(3), long, object(stdClass)[89] )   .../nav-
 menu-template.php:183
 #3 call_user_func_array( array(2), array(3) )   .../nav-menu-
 template.php:500
 #4 Walker->walk( array(3), long, object(stdClass)[89] ) .../nav-menu-
 template.php:500
 #5 Walker->display_element( object(WP_Post)[129], array(0), long, long,
 array(1), string(0) )   .../class-wp-walker.php:247
 #6 call_user_func_array:( array(2), array(4) )  .../class-wp-
 walker.php:149
 #7 Walker_Nav_Menu->start_el( string(0), object(WP_Post)[129], long,
 object(stdClass)[89], ??? )        .../class-wp-walker.php:149
 }}}

 An array to object conversion doesn't really happen but in step !#6 the
 array with the WP_Term object gets merged with into another array:
 `$cb_args = array_merge( array(&$output, $element, $depth), $args );`
 (`WP_Walker::display_element()`).

 Looks like we need to improve the docs here.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/37136#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list