Premium Lite

Use Affiliate Power Premium with the permanently free lite version. All you need is your email. The lite version is limited to 100 sales per month. You can always upgrade to an unlimited license.
More information about Affiliate Power Premium

', 'affiliate-power'), plugins_url('img/affiliate-power-premium.png', __FILE__)); self::$lite_optin_html = apply_filters('affiliate_power_lite_optin_text', self::$lite_optin_html); } static function activation() { global $wpdb; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); //daily import at 03:00 if (!wp_next_scheduled('affiliate_power_daily_event')) wp_schedule_event( strtotime('tomorrow')+3600*3, 'daily', 'affiliate_power_daily_event'); //create options if this is a new installation $options = get_option('affiliate-power-options'); if (!$options) add_option('affiliate-power-options', array()); $sql = 'CREATE TABLE '.$wpdb->prefix.'ap_transaction ( ap_transactionID bigint(20) unsigned AUTO_INCREMENT, network varchar(32), TransactionId_network varchar(128), Date datetime, SubId varchar(64) DEFAULT NULL, ProgramId int(10) unsigned, ProgramTitle varchar(1024), Transaction char(1), Price float unsigned, Commission float, Confirmed float, CheckDate datetime, TransactionStatus varchar(64), postID bigint(20) signed, source_url varchar(512), referer varchar(512) DEFAULT NULL, landing_page varchar(512), screen_width int(10), PRIMARY KEY (ap_transactionID), UNIQUE KEY uniIdNetwork (TransactionId_network,network), KEY SubId (SubId), KEY TransactionStatus (TransactionStatus), KEY ProgramId (ProgramId), KEY network (network), KEY Date (Date), KEY postID (postID) );'; dbDelta($sql); //meta options for infotext etc. $meta_options = get_option('affiliate-power-meta-options'); if (!$meta_options) $meta_options = array(); if (!isset($meta_options['installstamp']) || $meta_options['installstamp'] == '') $meta_options['installstamp'] = date('U'); if (!isset($meta_options['hide-infotext'])) $meta_options['hide-infotext'] = 1; if (!isset($meta_options['show-infotext-timestamp'])) $meta_options['show-infotext-timestamp'] = time()+86400*6; $user = wp_get_current_user(); $first_name = ($user->user_firstname != '') ? $user->user_firstname : $user->user_login; $meta_options['infotext'] = sprintf( __('

Awesome %s, you made more than €1000 since installing Affiliate Power

Congratulations to your thriving affiliate business. I hope Affiliate Power is helping you to keep track of all your money. If yes, could you please do me a big favor and give it a 5-star rating on WordPress.org? This would go a long way in spreading the word and boost my motivation.
~ Jonas Breuer

', 'affiliate-power'), $first_name ); update_option('affiliate-power-meta-options', $meta_options); //welcome message when first install $version = get_option('affiliate-power-version', '0.0.0'); if ($version == '0.0.0') add_action('admin_notices', array('Affiliate_Power', 'activationMessage')); else add_action('admin_notices', array('Affiliate_Power', 'updateMessage')); do_action('affiliate_power_activation'); } static function deactivation() { wp_clear_scheduled_hook('affiliate_power_daily_event'); } static function uninstall() { global $wpdb; $sql = 'DROP TABLE IF EXISTS '.$wpdb->prefix.'ap_transaction;'; $wpdb->query($sql); delete_option('affiliate-power-meta-options'); delete_option('affiliate-power-options'); delete_option('affiliate-power-version'); delete_option('affiliate-power-premium'); do_action('affiliate_power_uninstall'); } static function init() { //run activation if user updated the plugin $version = get_option('affiliate-power-version', '0.0.0'); $premium = get_option('affiliate-power-premium', false); if ($version != AFFILIATE_POWER_VERSION || $premium != AFFILIATE_POWER_PREMIUM) { self::activation(); update_option('affiliate-power-version', AFFILIATE_POWER_VERSION); update_option('affiliate-power-premium', AFFILIATE_POWER_PREMIUM); } //deactivate infotext if (isset($_GET['action']) && ($_GET['action'] == 'affiliate-power-hide-infotext' || $_GET['action'] == 'affiliate-power-postpone-infotext')) { $meta_options = get_option('affiliate-power-meta-options'); $meta_options['hide-infotext'] = 1; if ($_GET['action'] == 'affiliate-power-postpone-infotext') $meta_options['show-infotext-timestamp'] = time()+86400*6; else $meta_options['show-infotext-timestamp'] = -1; update_option('affiliate-power-meta-options', $meta_options); } $options = get_option('affiliate-power-options'); if (isset($options['licence-key']) && !empty($options['licence-key']) && !AFFILIATE_POWER_PREMIUM) { add_action('admin_notices', array('Affiliate_Power', 'updatePremiumMessage')); } //debugging if (current_user_can('manage_options') && isset($_GET['ap_test'])) { //Affiliate_Power::activation(); //Affiliate_Power_Apis::downloadTransactions(); //Affiliate_Power_Cron::sendAdminMail(); //Affiliate_Power_Cron::checkInfotext(); //include_once('apis/tradedoubler.php'); //print_r(Affiliate_Power_Api_Tradedoubler::downloadTransactions(time()-86400*20, time())); } } static function activationMessage() { ob_start(); sprintf(__('
Affiliate Power

Welcome to Affiliate Power!

Whats next? First, you should enter your Affiliate network data on the Settings Page. Then, you can download your old sales and the plugin will create the first statistics.

', 'affiliate-power'), plugins_url('img/affiliate-power-36.png', __FILE__), admin_url('admin.php?page=affiliate-power-settings')); echo ob_get_clean(); } static function updateMessage() { $user = wp_get_current_user(); $first_name = ($user->user_firstname != '') ? $user->user_firstname : $user->user_login; ob_start(); sprintf(__('
Affiliate Power

Affiliate Power Update

Hey %s, thank you for updating to the new version of Affiliate Power. For security and compatibility reasons (and for all the cool new features) you should always use the newest version of the plugin.

', 'affiliate-power'), plugins_url('img/affiliate-power-36.png', __FILE__), $first_name); echo ob_get_clean(); } static function updatePremiumMessage() { ob_start(); echo '
'.__('

Update to Affiliate Power Premium

You entered a valid license key, but you didn\'t download the premium version yet. Please go to the update page and update to the premium version. It might take up to 5 minutes, until WordPress informs you about the new version.

', 'affiliate-power').'
'; echo ob_get_clean(); } static function checkLicenceKey ($licence_key, $type='normal') { $action = ($type == 'max_sales') ? 'max_sales' : 'check'; $licence_key_hash = md5($licence_key); $http_answer = wp_remote_post(AFFILIATE_POWER_API_URL, array( 'headers' => array('referer' => $_SERVER['HTTP_HOST']), 'body' => array('action' => $action, 'key' => $licence_key_hash, 'plugin_version' => AFFILIATE_POWER_VERSION) )); if (is_wp_error($http_answer) || $http_answer['response']['code'] != 200) return false; return $http_answer['body']; } static function checkVersion($transient) { if (empty($transient->checked)) { return $transient; } $options = get_option('affiliate-power-options'); $premium_valid = false; if (isset($options['licence-key']) && !empty($options['licence-key'])) { $licence_status = self::checkLicenceKey($options['licence-key']); if ($licence_status == 'ok') $premium_valid = true; } if (!AFFILIATE_POWER_PREMIUM && $premium_valid) $updating_to_premium = true; else $updating_to_premium = false; $http_answer = wp_remote_post(AFFILIATE_POWER_API_URL, array('body' => array('action' => 'version'))); if (is_wp_error($http_answer) || $http_answer['response']['code'] != 200) $new_version = AFFILIATE_POWER_VERSION; else $new_version = $http_answer['body']; if ( (version_compare(AFFILIATE_POWER_VERSION, $new_version, '<') && AFFILIATE_POWER_PREMIUM) || $updating_to_premium ) { $obj = new stdClass(); $obj->slug = 'affiliate-power'; $obj->new_version = $new_version; $obj->url = AFFILIATE_POWER_API_URL; $obj->package = AFFILIATE_POWER_API_URL . '?key=' . md5($options['licence-key']); $transient->response['affiliate-power/affiliate-power.php'] = $obj; } return $transient; } static function getNewVersionInfo($false, $action, $arg) { if (isset($arg->slug) && $arg->slug == 'affiliate-power' && AFFILIATE_POWER_PREMIUM ) { $http_answer = wp_remote_post(AFFILIATE_POWER_API_URL, array('body' => array('action' => 'info'))); if (is_wp_error($http_answer) || $http_answer['response']['code'] != 200) return $false; $information = unserialize($http_answer['body']); return $information; } return $false; } }