Example #1
0
 /** @see WP_Widget::widget */
 function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('widget_title', $instance['title']);
     ?>
           <?php 
     echo $before_widget;
     ?>
               <?php 
     if ($title) {
         echo $before_title . $title . $after_title;
     }
     echo "<ul>";
     wpdm_list_categories();
     echo "</ul>";
     echo $after_widget;
     ?>
     <?php 
 }
Example #2
0
/**
 * @usage Render Download Manager Category List with ul/li hirarchy
 * @param int $parent
 * @param int $level
 * @param bool $recur
 */
function wpdm_list_categories($parent = 0, $level = 0, $recur = true)
{
    $parent = isset($parent) ? $parent : 0;
    $args = array('orderby' => 'name', 'order' => 'ASC', 'hide_empty' => false, 'exclude' => array(), 'exclude_tree' => array(), 'include' => array(), 'number' => '', 'fields' => 'all', 'slug' => '', 'parent' => $parent, 'hierarchical' => true, 'child_of' => 0, 'get' => '', 'name__like' => '', 'pad_counts' => false, 'offset' => '', 'search' => '', 'cache_domain' => 'core');
    $cats = get_terms('wpdmcategory', $args);
    if ($parent && $level > 0 && wpdm_cat_has_child($parent)) {
        echo "<ul>";
    }
    foreach ($cats as $id => $cat) {
        $pres = str_repeat("&mdash;", $level);
        $catlink = get_term_link($cat);
        echo "<li><a href='{$catlink}'>{$cat->name}</a>\n";
        if ($recur) {
            wpdm_list_categories($id, $level + 1, $recur);
        }
        echo "</li>\n";
    }
    if ($parent && $level > 0 && wpdm_cat_has_child($parent)) {
        echo "</ul>";
    }
}