Ticket #28801: class-wp-walker.php.patch
| File class-wp-walker.php.patch, 1.4 KB (added by , 9 years ago) |
|---|
-
src/wp-includes/class-wp-walker.php
214 214 */ 215 215 $top_level_elements = array(); 216 216 $children_elements = array(); 217 218 /* 219 * Default $root to the first element 220 * Used in the case that there are no top level elements 221 */ 222 $first = array_slice( $elements, 0, 1 ); 223 $root = $first[0]; 224 $element_ids = array_map(function($element){ return $element->ID; }, $elements); 225 217 226 foreach ( $elements as $e) { 218 if ( empty( $e->$parent_field ) ) 227 // If the parent_field is not blank OR in the list of elements update to be the root element 228 if ( !empty( $e->parent_field) && !in_array($e->parent_field, $element_ids)) 229 $root = $e; 230 elseif ( empty( $e->$parent_field ) ) 219 231 $top_level_elements[] = $e; 220 232 else 221 233 $children_elements[ $e->$parent_field ][] = $e; … … 223 235 224 236 /* 225 237 * When none of the elements is top level. 226 * Assume the first one must be root of the sub elements.238 * Set the element buckets based on the root defined above 227 239 */ 228 240 if ( empty($top_level_elements) ) { 229 230 $first = array_slice( $elements, 0, 1 );231 $root = $first[0];232 233 241 $top_level_elements = array(); 234 242 $children_elements = array(); 235 243 foreach ( $elements as $e) {