Changeset 13939
- Timestamp:
- 04/02/2010 05:33:18 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/comment-template.php
r13938 r13939 1268 1268 1269 1269 /** 1270 * This function operates the same as Walker::display_element(), with one small change. 1271 * Instead of elements being moved to the end of the listing when their threading reaches 1272 * $max_depth, the children are displayed inline. 1270 * This function is designed to enhance Walker::display_element() to 1271 * display children of higher nesting levels than selected inline on 1272 * the highest depth level displayed. This prevents them being orphaned 1273 * at the end of the comment list. 1273 1274 * 1274 1275 * Example: max_depth = 2, with 5 levels of nested content. … … 1290 1291 1291 1292 $id_field = $this->db_fields['id']; 1292 1293 //display this element1294 if ( is_array( $args[0] ) )1295 $args[0]['has_children'] = ! empty( $children_elements[$element->$id_field] );1296 $cb_args = array_merge( array(&$output, $element, $depth), $args);1297 call_user_func_array(array(&$this, 'start_el'), $cb_args);1298 1299 1293 $id = $element->$id_field; 1300 1294 1301 // descend only when the depth is right and there are childrens for this element 1302 if ( ($max_depth == 0 || $max_depth > $depth+1 ) && isset( $children_elements[$id]) ) { 1303 1304 foreach( $children_elements[ $id ] as $child ){ 1305 1306 if ( !isset($newlevel) ) { 1307 $newlevel = true; 1308 //start the child delimiter 1309 $cb_args = array_merge( array(&$output, $depth), $args); 1310 call_user_func_array(array(&$this, 'start_lvl'), $cb_args); 1311 } 1312 $this->display_element( $child, $children_elements, $max_depth, $depth + 1, $args, $output ); 1313 } 1314 unset( $children_elements[ $id ] ); 1315 } 1316 1317 if ( isset($newlevel) && $newlevel ){ 1318 //end the child delimiter 1319 $cb_args = array_merge( array(&$output, $depth), $args); 1320 call_user_func_array(array(&$this, 'end_lvl'), $cb_args); 1321 } 1322 1323 //end this element 1324 $cb_args = array_merge( array(&$output, $element, $depth), $args); 1325 call_user_func_array(array(&$this, 'end_el'), $cb_args); 1326 1295 parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output ); 1296 1297 // If we're at the max depth, and the current element still has children, loop over those and display them at this level 1298 // This is to prevent them being orphaned to the end of the list. 1327 1299 if ( $max_depth <= $depth + 1 && isset( $children_elements[$id]) ) { 1328 // this if block is the only change from Walker::display_element() 1329 foreach ( $children_elements[ $id ] as $child ) 1300 foreach ( $children_elements[ $id ] as $child ) 1330 1301 $this->display_element( $child, $children_elements, $max_depth, $depth, $args, $output ); 1302 1331 1303 unset( $children_elements[ $id ] ); 1332 1304 }
Note: See TracChangeset
for help on using the changeset viewer.