public static function init()
 {
     self::$api_key = get_option(self::API_KEY, '');
     self::$workspace_id = get_option(self::WORKSPACE_ID, '');
     if (is_admin()) {
         // register settings
         self::register_settings();
         if (self::$api_key != '') {
             // Meta boxes
             add_action('admin_init', array(__CLASS__, 'register_meta_boxes'));
         }
     }
 }
function sa_load_time_tracking_toggl_addon()
{
    if (class_exists('Time_Tracking_Toggl')) {
        return;
    }
    require_once 'inc/Toggl_Controller.php';
    require_once 'inc/Toggl_Settings.php';
    require_once 'inc/Toggl_API.php';
    Toggl_Controller::init();
    // init sub classes
    Toggl_Settings::init();
    Toggl_API::init();
}
 /**
  * Uses old toggl api
  * @param  array  $args query args
  * @return
  */
 public static function detail_api_request($args = array(), $page = 1)
 {
     $args = array_merge($args, array('user_agent' => self::APP_DOMAIN, 'page' => $page, 'since' => date('c', strtotime('-1 year')), 'until' => date('c', time())));
     $args = apply_filters('si_toggle_api_request_args', $args, $page);
     $endpoint = add_query_arg($args, 'https://toggl.com/reports/api/v2/details');
     $params = array('method' => 'GET', 'headers' => array('Content-type' => 'application/json', 'Authorization' => 'Basic ' . base64_encode(Toggl_Settings::get_api_key() . ':api_token')), 'httpversion' => '1.1', 'timeout' => apply_filters('http_request_timeout', 15), 'sslverify' => false);
     $request_response = wp_remote_request($endpoint, $params);
     $api_response = json_decode(wp_remote_retrieve_body($request_response));
     if ($api_response->total_count > $page * 50) {
         // Loop through until we get them all.
         $paged_response = self::detail_api_request($args, $page + 1);
         $api_response->data = array_merge($api_response->data, $paged_response->data);
     }
     return $api_response;
 }