X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/53f4633144ed68c8b8fb5861f992b5489894a940..4feeb71a9d812a9ae371c28a3d8b442a4394ded7:/wp-includes/class-wp-walker.php diff --git a/wp-includes/class-wp-walker.php b/wp-includes/class-wp-walker.php index 65d8a586..ee68a205 100644 --- a/wp-includes/class-wp-walker.php +++ b/wp-includes/class-wp-walker.php @@ -148,7 +148,7 @@ class Walker { // descend only when the depth is right and there are childrens for this element if ( ($max_depth == 0 || $max_depth > $depth+1 ) && isset( $children_elements[$id]) ) { - foreach( $children_elements[ $id ] as $child ){ + foreach ( $children_elements[ $id ] as $child ){ if ( !isset($newlevel) ) { $newlevel = true; @@ -215,7 +215,7 @@ class Walker { $top_level_elements = array(); $children_elements = array(); foreach ( $elements as $e) { - if ( 0 == $e->$parent_field ) + if ( empty( $e->$parent_field ) ) $top_level_elements[] = $e; else $children_elements[ $e->$parent_field ][] = $e; @@ -250,7 +250,7 @@ class Walker { if ( ( $max_depth == 0 ) && count( $children_elements ) > 0 ) { $empty_array = array(); foreach ( $children_elements as $orphans ) - foreach( $orphans as $op ) + foreach ( $orphans as $op ) $this->display_element( $op, $empty_array, 1, 0, $args, $output ); } @@ -374,7 +374,7 @@ class Walker { if ( $end >= $total_top && count( $children_elements ) > 0 ) { $empty_array = array(); foreach ( $children_elements as $orphans ) - foreach( $orphans as $op ) + foreach ( $orphans as $op ) $this->display_element( $op, $empty_array, 1, 0, $args, $output ); } @@ -382,9 +382,13 @@ class Walker { } /** + * Calculates the total number of root elements. * - * @param array $elements - * @return int + * @since 2.7.0 + * @access public + * + * @param array $elements Elements to list. + * @return int Number of root elements. */ public function get_number_of_root_elements( $elements ){ $num = 0;