} elseif (cnQuery::getVar('cn-cat')) {
                $currentCategory = cnQuery::getVar('cn-cat');
            } else {
                $currentCategory = '';
            }
            $out .= '<li class="cat-item cat-item-' . $category->term_id . ($currentCategory == $category->slug || $currentCategory == $category->term_id ? ' current-cat' : '') . ' cn-cat-parent">';
            // Create the permalink anchor.
            $out .= cnURL::permalink(array('type' => 'category', 'slug' => implode('/', $slug), 'title' => $category->name, 'text' => $category->name . $count, 'home_id' => $atts['home_id'], 'force_home' => $atts['force_home'], 'return' => TRUE));
            /*
             * Only show the descendants based on the following criteria:
             * 	- There are descendant categories.
             * 	- The descendant depth is < than the current $level
             *
             * When descendant depth is set to 0, show all descendants.
             * When descendant depth is set to < $level, call the recursive function.
             */
            if (!empty($category->children) && ($depth <= 0 ? -1 : $level) < $depth) {
                $out .= '<ul class="children cn-cat-children">';
                foreach ($category->children as $child) {
                    $out .= self::categoryLinkDescendant($child, $level + 1, $depth, $slug, $atts);
                }
                $out .= '</ul>';
            }
            $out .= '</li>';
        }
        return $out;
    }
}
// Init the Template Parts API
cnTemplatePart::init();