function category_ul($items, $counts)
{
    $post_types = arlo_get_option('post_types');
    $events_url = get_page_link($post_types['event']['posts_page']);
    if (!is_array($items) || empty($items)) {
        return '';
    }
    $regions = get_option('arlo_regions');
    $arlo_region = get_query_var('arlo-region', '');
    $arlo_region = !empty($arlo_region) && array_ikey_exists($arlo_region, $regions) ? $arlo_region : '';
    $html = '<ul class="arlo-category-list">';
    foreach ($items as $cat) {
        $html .= '<li>';
        $html .= '<a href="';
        $html .= $events_url . (!empty($arlo_region) ? 'region-' . $arlo_region . '/' : '');
        if ($cat->c_parent_id != 0) {
            $html .= 'cat-' . esc_attr($cat->c_slug);
        }
        $html .= '">';
        $html .= htmlentities($cat->c_name, ENT_QUOTES, "UTF-8") . (!is_null($counts) ? sprintf($counts, $cat->c_template_num) : '');
        $html .= '</a>';
        if (isset($cat->children)) {
            $html .= category_ul($cat->children, $counts);
        }
        $html .= '</li>';
    }
    $html .= '</ul>';
    return $html;
}
 protected function _parse_dashboard($dashboard, &$parse_dashboard)
 {
     foreach ($dashboard as $key => $value) {
         $model = NULL;
         $group = NULL;
         $group_label = NULL;
         if (is_numeric($key)) {
             if (array_ikey_exists($value, $this->models)) {
                 $model = $value;
             }
         } else {
             if (is_array($value)) {
                 $group = $value;
                 $group_label = $key;
             } else {
                 if (is_string($value)) {
                     if (array_ikey_exists($value, $this->models)) {
                         $model = $value;
                     }
                 }
             }
         }
         if ($model) {
             $this->load->model($model);
             $object = $this->{$model};
             $label = $object->label();
             $parse_dashboard[] = array('_TYPE' => 'MODEL', '_OBJECT' => $object, '_MODEL' => $model, '_LABEL' => $label, '_TABLE' => $object->table, '_COUNT' => $object->count(), '_LINK' => admin_url("model/" . $model));
         } else {
             if ($group) {
                 $parse_dashboard[] = array('_TYPE' => 'GROUP', '_LABEL' => $group_label, '_CHILDREN' => array());
                 end($parse_dashboard);
                 $this->_parse_dashboard($group, $parse_dashboard[key($parse_dashboard)]['_CHILDREN']);
             }
         }
     }
     // foreach end
 }
 public function arlo_widget_get_upcoming_list($qty)
 {
     global $wpdb;
     $regions = get_option('arlo_regions');
     $active = $this->get_import_id();
     $arlo_region = get_query_var('arlo-region', '');
     $arlo_region = !empty($arlo_region) && array_ikey_exists($arlo_region, $regions) ? $arlo_region : (!empty($_COOKIE['arlo-region']) ? $_COOKIE['arlo-region'] : '');
     if (!empty($arlo_region)) {
         $where['region'] = ' e_region = "' . $arlo_region . '" AND et_region = "' . $arlo_region . '"';
     }
     $where['active'] = "e.active = " . $active;
     $where['date'] = " CURDATE() < DATE(e.e_startdatetime) ";
     $where['event'] = "e_parent_arlo_id = 0";
     $t1 = "{$wpdb->prefix}arlo_events";
     $t2 = "{$wpdb->prefix}arlo_eventtemplates";
     $t3 = "{$wpdb->prefix}arlo_venues";
     $sql = "\n\t\tSELECT \n\t\t\te.e_startdatetime, \n\t\t\te.e_locationname, \n\t\t\tet.et_name, \n\t\t\tet.et_post_name\n\t\tFROM \n\t\t\t{$t1} AS e \n\t\tLEFT JOIN \n\t\t\t{$t2} AS et\n\t\tON \n\t\t\te.et_arlo_id = et.et_arlo_id\n\t\tAND\n\t\t\te.active = et.active\n\t\tWHERE\n\t\t\t" . implode(" AND ", $where) . "\n\t\tORDER BY \n\t\t\te.e_startdatetime\n\t\tLIMIT 0, {$qty}";
     $upcoming_array = $wpdb->get_results($sql);
     return $upcoming_array;
 }