_term_rows

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

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: