/** * Hooked on init add the settings page and options. * */ public static function register_settings() { $options = array(0 => __('Default', 'sprout-invoices')); if (self::$api_key) { // Only do an API callback on the settings page. // TODO register settings on the settings pages only. if (isset($_GET['page']) && $_GET['page'] == 'sprout-apps/settings' && !isset($_GET['tab'])) { $workspaces = Toggl_API::get_workspaces(); if (!empty($workspaces)) { foreach ($workspaces as $key => $workspace) { $options[$workspace->id] = $workspace->name; } } } } // Settings $settings = array('toggl' => array('title' => __('Toggl Settings', 'sprout-invoices'), 'weight' => 1000, 'tab' => 'settings', 'settings' => array(self::API_KEY => array('label' => __('API Key', 'sprout-invoices'), 'option' => array('type' => 'text', 'default' => self::$api_key, 'description' => __('This is your API token found on your profile page, not the Workspace API Token.', 'sprout-invoices'))), self::WORKSPACE_ID => array('label' => __('Workspace', 'sprout-invoices'), 'option' => array('type' => 'select', 'options' => $options, 'default' => self::$workspace_id, 'description' => __('You can select a different workspace after saving your API Token.', 'sprout-invoices')))))); do_action('sprout_settings', $settings, self::SETTINGS_PAGE); }