Definition:
function _term_rows( $taxonomy, $terms, &$children, $page = 1, $per_page = 20, &$count, $parent = 0, $level = 0 ) {}
Parameters
- $taxonomy
- $terms
- &$children
- $page
- $per_page
- &$count
- $parent
- $level
Source code
function _term_rows( $taxonomy, $terms, &$children, $page = 1, $per_page = 20, &$count, $parent = 0, $level = 0 ) {
$start = ($page - 1) * $per_page;
$end = $start + $per_page;
$output = '';
foreach ( $terms as $key => $term ) {
if ( $count >= $end )
break;
if ( $term->parent != $parent && empty($_GET['s']) )
continue;
// If the page starts in a subtree, print the parents.
if ( $count == $start && $term->parent > 0 && empty($_GET['s']) ) {
$my_parents = $parent_ids = array();
$p = $term->parent;
while ( $p ) {
$my_parent = get_term( $p, $taxonomy );
$my_parents[] = $my_parent;
$p = $my_parent->parent;
if ( in_array($p, $parent_ids) ) // Prevent parent loops.
break;
$parent_ids[] = $p;
}
unset($parent_ids);
$num_parents = count($my_parents);
while ( $my_parent = array_pop($my_parents) ) {
$output .= "\t" . _tag_row( $my_parent, $level - $num_parents, $taxonomy );
$num_parents--;
}
}
if ( $count >= $start )
$output .= "\t" . _tag_row( $term, $level, $taxonomy );
++$count;
unset($terms[$key]);
if ( isset($children[$term->term_id]) && empty($_GET['s']) )
$output .= _term_rows( $taxonomy, $terms, $children, $page, $per_page, $count, $term->term_id, $level + 1 );
}
return $output;
}
4379

February 12, 2011 


No comments yet... Be the first to leave a reply!