title: Walker_Category - Apply Class To Parent Category Items
body: <p>The code below adds a custom class to all lis items. </p>
  
  <p>How can this be adapted to add a custom class to list items that are parent category items?</p>
  
  <p>I am not entirely sure how to check if a category is a parent in this context.</p>
  
  <pre><code>class Cat_Walker extends Walker_Category {
  function start_el( &amp;$output, $category, $depth = 0, $args = array(), $current_object_id = 0 ) {
          extract($args);
  
          $cat_name = esc_attr( $category-&gt;name );
          $cat_name = apply_filters( 'list_cats', $cat_name, $category );
          $link = '&lt;a href="' . esc_attr( get_term_link($category) ) . '" ';
          $link .= 'data-filter="' . urldecode($category-&gt;slug) . '" ';
          if ( $use_desc_for_title == 0 || empty($category-&gt;description) )
                  $link .= 'title="' . esc_attr( sprintf(__( 'View all posts filed under %s', 'framework' ), $cat_name) ) . '"';
          else
                  $link .= 'title="' . esc_attr( strip_tags( apply_filters( 'category_description', $category-&gt;description, $category ) ) ) . '"';
          $link .= '&gt;';
          $link .= $cat_name . '&lt;/a&gt;';
  
          if ( !empty($feed_image) || !empty($feed) ) {
                  $link .= ' ';
  
                  if ( empty($feed_image) )
                          $link .= '(';
  
                  $link .= '&lt;a href="' . get_term_feed_link( $category-&gt;term_id, $category-&gt;taxonomy, $feed_type ) . '"';
  
                  if ( empty($feed) ) {
                          $alt = ' alt="' . sprintf(__( 'Feed for all posts filed under %s', 'framework' ), $cat_name ) . '"';
                  } else {
                          $title = ' title="' . $feed . '"';
                          $alt = ' alt="' . $feed . '"';
                          $name = $feed;
                          $link .= $title;
                  }
  
                  $link .= '&gt;';
  
                  if ( empty($feed_image) )
                          $link .= $name;
                  else
                          $link .= "&lt;img src='$feed_image'$alt$title" . ' /&gt;';
  
                  $link .= '&lt;/a&gt;';
  
                  if ( empty($feed_image) )
                          $link .= ')';
          }
  
          if ( !empty($show_count) )
                  $link .= ' (' . intval($category-&gt;count) . ')';
  
          if ( !empty($show_date) )
                  $link .= ' ' . gmdate('Y-m-d', $category-&gt;last_update_timestamp);
  
          if ( 'list' == $args['style'] ) {
                  $output .= "\t&lt;li";
                  $class = 'cat-item cat-item-' . $category-&gt;term_id;
  
                  if ( $category-&gt;term_id == $category-&gt;parent ) {
                      $class .=  ' true';
                  } else {
                      $class .=  ' false';
                  }
  
                  if ( !empty($current_category) ) {
                          $_current_category = get_term( $current_category, $category-&gt;taxonomy );
                          if ( $category-&gt;term_id == $current_category )
                                  $class .=  ' current-cat';
                          elseif ( $category-&gt;term_id == $_current_category-&gt;parent )
                                  $class .=  ' current-cat-parent';
                  }
                  $output .=  ' class="' . $class . '"';
                  $output .= "&gt;$link\n";
          } else {
                  $output .= "\t$link&lt;br /&gt;\n";
          }
  }
  }
  </code></pre>