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(); }
public static function toggl_entry_fields($project_id = 0) { $toggl_projects = array(0 => __('None', 'sprout-invoices'), 'create_new' => __('Create Project at Toggl', 'sprout-invoices')); foreach (Toggl_API::get_projects() as $key => $project) { $toggl_projects[$project->id] = $project->name; } $fields['toggl_id'] = array('weight' => 10, 'label' => __('Toggl Project', 'sprout-invoices'), 'type' => 'select', 'description' => __('Link a project at toggl or create a new one.', 'sprout-invoices'), 'options' => $toggl_projects, 'default' => self::get_projects_toggl_id($project_id), 'attributes' => array('class' => 'select2')); $fields['sync_time'] = array('weight' => 50, 'label' => __('Sync Time with Toggl', 'sprout-invoices'), 'type' => 'checkbox', 'default' => self::does_sync_time($project_id), 'description' => __('Automatically send time created here to Toggle and delete any time at Toggl if deleted here.', 'sprout-invoices')); $fields['pulldown_time'] = array('weight' => 60, 'label' => __('Retrieve Project Time from Toggl', 'sprout-invoices'), 'type' => 'checkbox', 'description' => __('Check, then save to import time for this project. Time does not import automatically (yet).', 'sprout-invoices')); $activities = SI_Time::get_activities(); $fields['default_activity'] = array('weight' => 70, 'label' => __('Activity for Imported Time', 'sprout-invoices'), 'type' => 'select', 'options' => $activities, 'default' => self::get_projects_default_time_import_activity($project_id), 'description' => __('Check, then save to import time for this project. Time does not import automatically (yet).', 'sprout -invoices'), 'attributes' => array('class' => 'select2')); $fields = apply_filters('si_toggl_time_entry_form_fields', $fields); uasort($fields, array(__CLASS__, 'sort_by_weight')); return $fields; }
public static function update_toggl_project($post_id, $post) { $toggl_id = self::get_projects_toggl_id($post_id); if (!$toggl_id) { // no id found to update return; } $data = array('project' => array('name' => $post->post_title)); Toggl_API::api_request('projects/' . $toggl_id, $data); }