array( 'slug' => 'adcell', 'link_pattern' => 'adcell', 'label' => 'Adcell', 'fields' => array( array('slug' => 'username', 'label' => 'Username', 'info' => __('The Adcell Username is the number, you are using to login on the adcell page.', 'affiliate-power'), 'validation' => 'ctype_digit'), array('slug' => 'password', 'label' => 'API Password', 'info' => __('The Adcell API password is a special access to the Adcell API. Please do not enter your normal Adcell password here. The API password can be defined in the publisher area, menu item "My Data".', 'affiliate-power')), array('type' => 'checkbox', 'slug' => 'referer-filter', 'label' => 'Website Filter', 'info' => __('Only save sales, which came from this domain. This option makes only sense if you are using your Adcell account for several pages.', 'affiliate-power')), ), ), 'awin' => array( 'slug' => 'awin', 'link_pattern' => 'awin', 'label' => 'Awin', 'fields' => array( array('slug' => 'id', 'label' => 'Publisher ID', 'info' => __('You can find the Awin Publisher ID at the top of the publisher area, next to your company name.', 'affiliate-power'), 'validation' => 'ctype_digit', 'allowed_chars' => ','), array('slug' => 'token', 'label' => 'API Token', 'info' => __('You can find the Awin API Token at the top of the publisher area, where it says Hello... -> API Credentials.', 'affiliate-power'), 'validation' => 'ctype_alnum', 'allowed_chars' => array(',', '-')), array('slug' => 'referer', 'label' => 'Referer Domain', 'info' => __('If you are using your awin account for several pages, you can enter the domain of this page here (without https and www). The plugin will only import sales from this domain. If you are using your awin account only for this page anyway, just leave the field empty. In this case, the plugin will download all sales.', 'affiliate-power')), ), ), 'belboon' => array( 'slug' => 'belboon', 'link_pattern' => '(belboon)|(https://[a-z]+\.r\.[a-z]+\.com/ts/[a-z0-9]+/tsc)', 'label' => 'Belboon', 'fields' => array( array('slug' => 'userid', 'label' => 'Partner Id', 'info' => __('You can find the numeric belboon Partner Id at the top of the publisher area, next to your name.', 'affiliate-power'), 'validation' => 'ctype_digit'), array('slug' => 'key', 'label' => 'Magic Key', 'info' => __('You can create the magic key in the publisher area, top menu at your account name, menu item Credentials. Give it a name of your choice and allow access to all APIs.', 'affiliate-power'), 'validation' => 'ctype_alnum', 'allowed_chars' => '-'), array('slug' => 'platform', 'label' => 'Ad Space Name', 'info' => __('If you are using your belboon account for several pages, you can enter the ad space name for this page here. The plugin will only import sales from this ad space. Please do not enter the ad space id but the name. You can find the ad space name in the publisher area, top menu at your account name, menu item Ad space. If you are using several ad spaces for this page you can separate the ad space names with comma. If you are using your belboon account only for this site anyway, just leave the field empty. In this case, the plugin will download all sales.', 'affiliate-power')), ), ), 'cj' => array( 'slug' => 'cj', 'link_pattern' => 'click-[0-9]+-[0-9]+', 'label' => 'Commission Junction', 'fields' => array( array('slug' => 'id', 'label' => 'PID', 'info' => __('The PID identifies your website at Commission Junction. You can find it in the publisher area of Commission Junction at the menu item Account -> Website Settings.', 'affiliate-power'), 'validation' => 'ctype_digit'), array('slug' => 'key', 'label' => 'Developer Key', 'info' => __('The Commission Junction Developer Key is a special access to the Commission Junction API. Please do not enter your normal password here. In order to get the key, you have to go to the Webservice-Site of Commission Junction, and login with your normal account data.', 'affiliate-power')), ), ), 'digistore24' => array( 'slug' => 'digistore24', 'link_pattern' => '(digistore24)|(/#aff=)', 'label' => 'Digistore24', 'check_login_params' => 1, 'fields' => array( array('slug' => 'key', 'label' => 'API Key', 'info' => __('The Digistore24 API key is a special access to the Digistore24 API. Please do not enter your normal password here. Follow these steps to get the key:
  1. Login on the Digistore24 Page
  2. Make sure you are in the vendor view. You can change that in the top left corner
  3. Click on Settings -> Account access -> Api keys
  4. Create a new key with the name "Affiliate Power" and Read access
  5. Copy the created API key into this field. It should look something like 1234-XYZ123xyz...
', 'affiliate-power')), ), ), 'financeads' => array( 'slug' => 'fads', 'link_pattern' => 'financeads', 'label' => 'financeAds', 'fields' => array( array('slug' => 'id', 'label' => 'Partner ID', 'info' => __('The five digit Partner ID identifies your account at financeAds.', 'affiliate-power')), array('slug' => 'key', 'label' => 'API Key', 'info' => __('The financeAds API Key is a special access to the financeAds API. Please do not enter your normal password here. In order to get the key, you have to go to the financeAds panel and login with your normal account data. Then you have to go to Auswertung -> Auswertungs API and click the link: API Key anzeigen. If you can\'t find the API Key or the sales are not imported, you might have to contact financeAds first and ask them to activate your access to the API and to the all sales report.', 'affiliate-power')), array('slug' => 'wfid', 'label' => 'Ad Space ID', 'info' => __('If you are using your financeAds account for several pages, enter the Ad Space ID you defined in the login area for this page. The plugin will only import sales from this Ad Space. If you are using your account only for this page anyway, just leave the field empty. In this case, the plugin will download all sales.', 'affiliate-power')), ), ), 'tradedoubler' => array( 'slug' => 'tradedoubler', 'link_pattern' => 'tradedoubler', 'label' => 'Tradedoubler', 'check_login_params' => 3, 'fields' => array( array('slug' => 'key', 'label' => 'Report Key', 'info' => __('The Tradedoubler Report Key is a special access to the Tradedoubler API. Please do not enter your normal Tradedoubler password here. In order to get the Tradedoubler Report Key, you have to wirte an email with your username to support.uk@tradedoubler.com (you can also change the country code if you are not in the UK) and ask for a Report Key. You will get an email with the key.', 'affiliate-power'), 'validation' => 'ctype_alnum'), array('slug' => 'sitename', 'label' => 'Site name', 'info' => __('If you are using your Tradedoubler account for several pages, enter the site name you defined in the Tradedoubler login area for this page. The plugin will only import sales from this site name. Please do not enter the site id but the name. You can find the site name in the publisher area, menu item Sites -> Sites. If you are using several sites for this page you can separate the site names with comma. If you are using your account only for this page anyway, just leave the field empty. In this case, the plugin will download all sales.', 'affiliate-power')), array('type' => 'checkbox', 'slug' => 'us-format', 'label' => 'US format', 'info' => __('Activate this checkbox, if your tradedoubler account is using US format. It might be using US format even if you are not in ths US. You can check this by looking at the dates in the Tradedoubler login area. If they list the month first (mm/dd/yy), your account is using US format.', 'affiliate-power')), ), ), 'webgains' => array( 'slug' => 'webgains', 'link_pattern' => 'wgcampaignid', 'label' => 'Webgains', 'check_login_params' => 2, 'fields' => array( array('slug' => 'publisher_id', 'label' => 'Publisher-ID', 'info' => __('You can find your numeric Publisher-ID in your Publisher account settings (bottom left corner after logging in).'), 'validation' => 'ctype_digit'), array('slug' => 'token', 'label' => 'API Token', 'info' => __('To generate an API Token, login into your Webgains account, click on your username in the top right corner and on "Manage API Tokens". Click on "Generate new token", give it a name and copy the generated token (yes, it is crazy long).')), ), ), ); } static function addSettings() { register_setting( 'affiliate-power-options', 'affiliate-power-options', array('Affiliate_Power_Settings', 'optionsValidate') ); add_settings_section('affiliate-power-main', __('Basic settings', 'affiliate-power'), array('Affiliate_Power_Settings', 'optionsMainText'), 'affiliate-power-options'); add_settings_field('affiliate-power-add-sub-ids', __('Activate tracking', 'affiliate-power'), array('Affiliate_Power_Settings', 'addSubIdsField'), 'affiliate-power-options', 'affiliate-power-main'); add_settings_field('affiliate-power-send-mail-transactions', __('Daily email report', 'affiliate-power'), array('Affiliate_Power_Settings', 'addSendMailTransactionsField'), 'affiliate-power-options', 'affiliate-power-main'); add_settings_field('affiliate-power-licence-key', __('License key', 'affiliate-power'), array('Affiliate_Power_Settings', 'addLicenceKeyField'), 'affiliate-power-options', 'affiliate-power-main'); add_settings_field('affiliate-power-landing-params', __('URL-Parameter', 'affiliate-power'), array('Affiliate_Power_Settings', 'addLandingParamsField'), 'affiliate-power-options', 'affiliate-power-main'); add_settings_section('affiliate-power-networks', __('Affiliate-Networks', 'affiliate-power'), array('Affiliate_Power_Settings', 'optionsNetworksText'), 'affiliate-power-options'); $options = get_option('affiliate-power-options'); foreach (self::$network_data as $network) { add_settings_section('affiliate-power-networks-'.$network['slug'], __($network['label'], 'affiliate-power'), array('Affiliate_Power_Settings', 'dummyFunction'), 'affiliate-power-options'); foreach ($network['fields'] as $field) { $network_field_slug = $network['slug'].'-'.$field['slug']; add_settings_field('affiliate-power-'.$network_field_slug, $network['label'].' '.$field['label'], function() use ($network_field_slug, $field, $options) { if (!isset($options[$network_field_slug])) $options[$network_field_slug] = ''; if (isset($field['type']) && $field['type'] == 'checkbox') echo ' '; else echo ' '; echo '[?]'; echo ''; }, 'affiliate-power-options', 'affiliate-power-networks-'.$network['slug']); } //foreach ($network['fields'] as $field) } //foreach (self::$network_data as $network) } //function static function dummyFunction() { } static function optionsPage() { include_once 'options-head.php'; //we need this to show error messages ?>

'.$meta_options['infotext'].'
'; } ?>
'.$section['title'].''; echo '
'; // a div for the accordion content if ( $section['callback'] ) call_user_func( $section['callback'], $section ); if ($section['id'] == 'affiliate-power-networks') echo '
'; //open an accordion for the following networks if ( ! isset( $wp_settings_fields ) || !isset( $wp_settings_fields[$page] ) || !isset( $wp_settings_fields[$page][$section['id']] ) ) continue; echo ''; do_settings_fields( $page, $section['id'] ); echo '
'; echo '
'; } ?>

Please be patient while saving. The plugin performs a test login at the networks which takes a few seconds.

', 'affiliate-power'); } static function optionsMainText() { _e('

Anything is not working or you have an idea for a cool feature? Send me an email

', 'affiliate-power'); } static function addSubIdsField() { $output = " [?] ".__("", "affiliate-power")."
".__('Only in the premium version', 'affiliate-power'); $output = apply_filters('affiliate_power_add_sub_ids_field', $output); echo $output; } static function addSendMailTransactionsField() { $options = get_option('affiliate-power-options'); if (!isset($options['send-mail-transactions'])) $options['send-mail-transactions'] = 0; $checked = $options['send-mail-transactions'] ? ' checked' : ''; echo " "; echo "[?]"; _e("", "affiliate-power"); } static function addLicenceKeyField() { $options = get_option('affiliate-power-options'); if (!isset($options['licence-key'])) $options['licence-key'] = ''; echo " "; echo "[?]"; _e("", "affiliate-power"); } static function addLandingParamsField() { $output = " [?]".__("", "affiliate-power"); $output = apply_filters('affiliate_power_add_landing_params_field', $output); echo $output; } //Network Settings static function optionsNetworksText() { _e('

Are you missing a network? Make your voice heard

', 'affiliate-power'); } //Validation static function optionsValidate($input) { //Main Settings if (isset($input['send-mail-transactions']) && $input['send-mail-transactions'] == 1) $whitelist['send-mail-transactions'] = 1; else $whitelist['send-mail-transactions'] = 0; if (isset($input['licence-key']) && ctype_alnum($input['licence-key'])) { $check_result = Affiliate_Power::checkLicenceKey($input['licence-key']); if ($check_result == false || $check_result == 'database_error' || $check_result == 'database_charset_error') add_settings_error('affiliate-power-options', 'affiliate-power-error-licence-key', __('The licence key could not be checked. Please try again later and let me know if it is still not working.', 'affiliate-power') ); elseif ($check_result == 'outdated_key') add_settings_error('affiliate-power-options', 'affiliate-power-error-licence-key', __('The licence key is outdated. Please renew your licence key.', 'affiliate-power') ); elseif ($check_result == 'invalid_key_format' || $check_result == 'invalid_key') add_settings_error('affiliate-power-options', 'affiliate-power-error-licence-key', __('The licence key is invalid. Please check again. If you are sure you entered the right key, let me know, and I will check it out.', 'affiliate-power') ); elseif ($check_result == 'ok') $whitelist['licence-key'] = $input['licence-key']; } elseif (!empty($input['licence-key'])) add_settings_error('affiliate-power-options', 'affiliate-power-error-licence-key', __('Invalid license key. The key should only contain numbers and letters.', 'affiliate-power')); foreach (self::$network_data as $network_name => $network) { foreach ($network['fields'] as $field) { $network_field_slug = $network['slug'].'-'.$field['slug']; if (isset($field['validation'])) { if (isset($field['allowed_chars'])) $check_value = str_replace($field['allowed_chars'], '', $input[$network_field_slug]); else $check_value = $input[$network_field_slug]; if ($field['validation']($check_value)) $whitelist[$network_field_slug] = esc_html($input[$network_field_slug]); elseif (!empty($input[$network_field_slug])) add_settings_error('affiliate-power-options', 'affiliate-power-error-'.$network_field_slug, __('Invalid', 'affiliate-power').': '.$network['label'].' '.$field['label'], 'error'); } elseif (isset($field['type']) && $field['type'] == 'checkbox') { if (isset($input[$network_field_slug]) && $input[$network_field_slug] == 1) $whitelist[$network_field_slug] = 1; else $whitelist[$network_field_slug] = 0; } elseif (!empty($input[$network_field_slug])) { $whitelist[$network_field_slug] = esc_html($input[$network_field_slug]); } } if (!isset($network['check_login_params'])) $network['check_login_params'] = 2; if ($network['check_login_params'] > 0) { $testlogin_result = null; $checkparams_keys = array(); for ($i=0; $i<$network['check_login_params']; $i++) $checkparams_keys[] = $network['slug'].'-'.$network['fields'][$i]['slug']; if ($network['check_login_params'] == 1 && isset($whitelist[$checkparams_keys[0]])) $testlogin_result = Affiliate_Power_Apis::checkNetworkLogin($network_name, $whitelist[$checkparams_keys[0]]); elseif ($network['check_login_params'] == 2 && isset($whitelist[$checkparams_keys[0]]) && isset($whitelist[$checkparams_keys[1]])) $testlogin_result = Affiliate_Power_Apis::checkNetworkLogin($network_name, $whitelist[$checkparams_keys[0]], $whitelist[$checkparams_keys[1]]); elseif ($network['check_login_params'] == 3 && isset($whitelist[$checkparams_keys[0]]) && isset($whitelist[$checkparams_keys[1]]) && isset($whitelist[$checkparams_keys[2]])) $testlogin_result = Affiliate_Power_Apis::checkNetworkLogin($network_name, $whitelist[$checkparams_keys[0]], $whitelist[$checkparams_keys[1]], $whitelist[$checkparams_keys[2]]); if ($testlogin_result === false) add_settings_error('affiliate-power-options', 'affiliate-power-error-'.$network['slug'].'-login', $network['label'].' '.__('test login failed. Please check your data.', 'affiliate-power'), 'error'); } } $whitelist = apply_filters('affiliate_power_options_validate', $whitelist, $input); return $whitelist; } }