[wp-trac] [WordPress Trac] #14041: Ensure a 'has_children' parameter is given to start_el

WordPress Trac wp-trac at lists.automattic.com
Tue Jun 22 08:50:50 UTC 2010


#14041: Ensure a 'has_children' parameter is given to start_el
--------------------------+-------------------------------------------------
 Reporter:  jaapjanfrans  |       Owner:                                  
     Type:  enhancement   |      Status:  new                             
 Priority:  normal        |   Milestone:  Unassigned                      
Component:  General       |     Version:  3.0                             
 Severity:  minor         |    Keywords:  has children,walker,has_children
--------------------------+-------------------------------------------------
 In the current display_element function of the Walker class, a
 'has_children' argument is only added if args[0] is an array.

 I'm not quite sure why this is the case. Wouldn't it be easier if a
 has_children argument is always added and passed on on to the callback
 functions like start_el?

 i've currently modified a custom walker to do it like this:

 {{{
                 //display this element
                 if ( is_array( $args[0] ) )
                         $args[0]['has_children'] = ! empty(
 $children_elements[$element->$id_field] );
                 $cb_args = array_merge( array(&$output, $element, $depth),
 $args);
                 $cb_args['has_children'] = ! empty(
 $children_elements[$element->$id_field] );
 }}}

 But recon it can be done in a cleaner way.

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


More information about the wp-trac mailing list