Changeset 13932
- Timestamp:
- 04/02/2010 04:05:01 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/comment-template.php
r13827 r13932 1265 1265 break; 1266 1266 } 1267 } 1268 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. 1273 * 1274 * Example: max_depth = 2, with 5 levels of nested content. 1275 * 1 1276 * 1.1 1277 * 1.1.1 1278 * 1.1.1.1 1279 * 1.1.1.1.1 1280 * 1.1.2 1281 * 1.1.2.1 1282 * 2 1283 * 2.2 1284 * 1285 */ 1286 function display_element( $element, &$children_elements, $max_depth, $depth=0, $args, &$output ) { 1287 1288 if ( !$element ) 1289 return; 1290 1291 $id_field = $this->db_fields['id']; 1292 1293 //display this element 1294 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 $id = $element->$id_field; 1300 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 } elseif ( $max_depth <= $depth + 1 && isset( $children_elements[$id]) ) { 1316 // this elseif block is the only change from Walker::display_element() 1317 foreach( $children_elements[ $id ] as $child ) 1318 $this->display_element( $child, $children_elements, $max_depth, $depth, $args, $output ); 1319 unset( $children_elements[ $id ] ); 1320 } 1321 1322 if ( isset($newlevel) && $newlevel ){ 1323 //end the child delimiter 1324 $cb_args = array_merge( array(&$output, $depth), $args); 1325 call_user_func_array(array(&$this, 'end_lvl'), $cb_args); 1326 } 1327 1328 //end this element 1329 $cb_args = array_merge( array(&$output, $element, $depth), $args); 1330 call_user_func_array(array(&$this, 'end_el'), $cb_args); 1267 1331 } 1268 1332
Note: See TracChangeset
for help on using the changeset viewer.