Changeset 8299
- Timestamp:
- 07/09/2008 04:57:18 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/category-template.php
r8281 r8299 1 1 <?php 2 2 3 function get_category_children($id, $before = '/', $after = '' ) {3 function get_category_children($id, $before = '/', $after = '', $visited=array()) { 4 4 if ( 0 == $id ) 5 5 return ''; … … 15 15 if ( is_wp_error( $category ) ) 16 16 return $category; 17 if ( $category->parent == $id ) { 17 if ( $category->parent == $id && !in_array($category->term_id, $visited) ) { 18 $visited[] = $category->term_id; 18 19 $chain .= $before.$category->term_id.$after; 19 20 $chain .= get_category_children($category->term_id, $before, $after); … … 45 46 } 46 47 47 function get_category_parents($id, $link = FALSE, $separator = '/', $nicename = FALSE ){48 function get_category_parents($id, $link = FALSE, $separator = '/', $nicename = FALSE, $visited = array()){ 48 49 $chain = ''; 49 50 $parent = &get_category($id); … … 56 57 $name = $parent->cat_name; 57 58 58 if ( $parent->parent && ($parent->parent != $parent->term_id) ) 59 $chain .= get_category_parents($parent->parent, $link, $separator, $nicename); 59 if ( $parent->parent && ($parent->parent != $parent->term_id) && !in_array($parent->parent, $visited) ) { 60 $visited[] = $parent->parent; 61 $chain .= get_category_parents($parent->parent, $link, $separator, $nicename, $visited); 62 } 60 63 61 64 if ( $link )
Note: See TracChangeset
for help on using the changeset viewer.