0); if ( !empty($_GET['s']) ) $args['search'] = $_GET['s']; $categories = get_categories( $args ); } if ( !$categories ) return false; $children = _get_term_hierarchy('category'); $start = ($page - 1) * $per_page; $end = $start + $per_page; $i = -1; ob_start(); foreach ( $categories as $category ) { if ( $count >= $end ) break; $i++; if ( $category->parent != $parent ) continue; // If the page starts in a subtree, print the parents. if ( $count == $start && $category->parent > 0 ) { $my_parents = array(); $my_parent = $category->parent; while ( $my_parent) { $my_parent = get_category($my_parent); $my_parents[] = $my_parent; if ( !$my_parent->parent ) break; $my_parent = $my_parent->parent; } $num_parents = count($my_parents); while( $my_parent = array_pop($my_parents) ) { echo "\t" . _cat_row( $my_parent, $level - $num_parents ); $num_parents--; } } if ( $count >= $start ) echo "\t" . _cat_row( $category, $level ); unset($categories[$i]); // Prune the working set $count++; if ( isset($children[$category->term_id]) ) _cat_rows( $categories, $count, $category->term_id, $level + 1, $page, $per_page ); } $output = ob_get_contents(); ob_end_clean(); $output = apply_filters('cat_rows', $output); echo $output; } function _cat_row( $category, $level, $name_override = false ) { global $class; $category = get_category( $category ); $pad = str_repeat( '— ', $level ); $name = ( $name_override ? $name_override : $pad . ' ' . $category->name ); if ( current_user_can( 'manage_categories' ) ) { $edit = "name)) . "'>$name"; } else { $edit = $name; } $class = " class='alternate'" == $class ? '' : " class='alternate'"; $category->count = number_format_i18n( $category->count ); $posts_count = ( $category->count > 0 ) ? "$category->count" : $category->count; $output = "