function wpfilebase_widgets_init()
 {
     wpfb_loadclass('Widget');
     WPFB_Widget::register();
 }
 function widget($args, $instance)
 {
     // if no filebrowser this widget doosnt work
     if (WPFB_Core::$settings->file_browser_post_id <= 0) {
         return;
     }
     wpfb_loadclass('Category', 'Output');
     extract($args);
     $title = apply_filters('widget_title', $instance['title']);
     echo $before_widget, $before_title . (empty($title) ? __('File Categories', WPFB) : $title) . $after_title;
     $tree = !empty($instance['hierarchical']);
     // load all categories
     WPFB_Category::GetCats();
     $cats = WPFB_Category::GetCats(($tree ? 'WHERE cat_parent = ' . (empty($instance['root-cat']) ? 0 : (int) $instance['root-cat']) : '') . ' ORDER BY ' . $instance['sort-by'] . ' ' . ($instance['sort-asc'] ? 'ASC' : 'DESC'));
     echo '<ul>';
     foreach ($cats as $cat) {
         if ($tree) {
             WPFB_Widget::CatTree($cat);
         } elseif ($cat->CurUserCanAccess(true)) {
             echo '<li><a href="' . $cat->GetUrl() . '">' . esc_html($cat->cat_name) . '</a></li>';
         }
     }
     echo '</ul>';
     echo $after_widget;
 }