/**
  * Start the element output.
  *
  * @see   Walker::start_el()
  *
  * @since 8.1.6
  *
  * @uses   esc_attr()
  * @uses   number_format_i18n()
  * @uses   cnTerm::get()
  *
  * @param string $output Passed by reference. Used to append additional content.
  * @param object $term   Term object.
  * @param int    $depth  Depth of category in reference to parents. Default 0.
  * @param array  $args   An array of arguments. @see CN_Walker_Term_List::render()
  * @param int    $id     ID of the current term.
  */
 public function start_el(&$output, $term, $depth = 0, $args = array(), $id = 0)
 {
     $indent = str_repeat("\t", $depth);
     $count = $args['show_count'] ? '<span class="cn-cat-count">&nbsp;(' . esc_html(number_format_i18n($term->count)) . ')</span>' : '';
     $url = cnTerm::permalink($term, 'category', $args);
     $html = sprintf('<a href="%1$s" title="%2$s">%3$s</a>', $url, esc_attr($term->name), esc_html($term->name) . $count);
     /**
      * Allows extensions to alter the HTML of term list item.
      *
      * @since 8.5.18
      *
      * @param string        $html  The HTML.
      * @param cnTerm_Object $term  The current term.
      * @param int           $depth Depth of category. Used for tab indentation.
      * @param array         $args  The method attributes.
      */
     $html = apply_filters('cn_term_list_item', $html, $term, $depth, $args);
     $class = array('cat-item', 'cat-item-' . $term->term_id, 'cn-cat-parent');
     $termChildren = cnTerm::getTaxonomyTerms($term->taxonomy, array('parent' => $term->term_id, 'hide_empty' => FALSE, 'fields' => 'count'));
     if (!empty($termChildren)) {
         $class[] = 'cn-cat-has-children';
     }
     if (!empty($args['current_category'])) {
         if (is_numeric($args['current_category'])) {
             $_current_category = cnTerm::get($args['current_category'], $term->taxonomy);
             // cnTerm::get() can return NULL || an instance of WP_Error, so, lets check for that.
             if (is_null($_current_category) || is_wp_error($_current_category)) {
                 $_current_category = new stdClass();
                 $_current_category->parent = 0;
             }
         } else {
             $_current_category = new stdClass();
             $_current_category->parent = 0;
         }
         if ($term->slug == $args['current_category']) {
             $class[] = ' current-cat';
         } elseif ($term->term_id == $args['current_category']) {
             $class[] = ' current-cat';
         } elseif ($term->term_id == $_current_category->parent) {
             $class[] = ' current-cat-parent';
         }
     }
     /**
      * Allows extensions to add/remove class names to the current term list item.
      *
      * @since 8.5.18
      *
      * @param array         $class The array of class names.
      * @param cnTerm_Object $term  The current term.
      * @param int           $depth Depth of category. Used for tab indentation.
      * @param array         $args  The method attributes.
      */
     $class = apply_filters('cn_term_list_item_class', $class, $term, $depth, $args);
     $class = cnSanitize::htmlClass($class);
     $output .= "{$indent}<li" . ' class="' . cnFunction::escAttributeDeep($class) . '"' . ">{$html}";
     // Do not add EOL here, it'll add unwanted whitespace if terms are inline.
 }