public function get_api_client()
 {
     if (get_option('arlo_test_api')) {
         define('ARLO_TEST_API', true);
     }
     $platform_name = arlo_get_option('platform_name');
     if (!$platform_name) {
         return false;
     }
     if ($client = $this->__get('api_client')) {
         return $client;
     }
     $transport = new \ArloAPI\Transports\Wordpress();
     $transport->setRequestTimeout(30);
     $transport->setUseNewUrlStructure(get_option('arlo_new_url_structure') == 1);
     $client = new \ArloAPI\Client($platform_name, $transport, self::VERSION);
     $this->__set('api_client', $client);
     return $client;
 }
Example #2
0
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;
}