Ejemplo n.º 1
0
 /**
  * Retrieve the array of plugin settings
  *
  * @since 1.0
  * @return array
  */
 function get_registered_settings()
 {
     // get currently logged in username
     $user_info = get_userdata(get_current_user_id());
     $username = $user_info ? esc_html($user_info->user_login) : '';
     $settings = array('general' => apply_filters('affwp_settings_general', array('license' => array('name' => '<strong>' . __('License Settings', 'affiliate-wp') . '</strong>', 'desc' => '', 'type' => 'header'), 'license_key' => array('name' => __('License Key', 'affiliate-wp'), 'desc' => '<p class="description">' . sprintf(__('Please enter your license key. An active license key is needed for automatic plugin updates and <a href="%s" target="_blank">support</a>.', 'affiliate-wp'), 'http://affiliatewp.com/support/') . '</p>', 'type' => 'license'), 'pages' => array('name' => '<strong>' . __('Pages', 'affiliate-wp') . '</strong>', 'desc' => '', 'type' => 'header'), 'affiliates_page' => array('name' => __('Affiliate Area', 'affiliate-wp'), 'desc' => '<p class="description">' . __('This is the page where affiliates will manage their affiliate account.', 'affiliate-wp') . '</p>', 'type' => 'select', 'options' => affwp_get_pages()), 'terms_of_use' => array('name' => __('Terms of Use', 'affiliate-wp'), 'desc' => '<p class="description">' . __('Select the page that shows the terms of use for Affiliate Registration', 'affiliate-wp') . '</p>', 'type' => 'select', 'options' => affwp_get_pages()), 'referrals' => array('name' => '<strong>' . __('Referral Settings', 'affiliate-wp') . '</strong>', 'desc' => '', 'type' => 'header'), 'referral_var' => array('name' => __('Referral Variable', 'affiliate-wp'), 'desc' => '<p class="description">' . sprintf(__('The URL variable for referral URLs. For example: <strong>%s</strong>.', 'affiliate-wp'), esc_url(add_query_arg(affiliate_wp()->tracking->get_referral_var(), '1', home_url('/')))) . '</p>', 'type' => 'text', 'std' => 'ref'), 'referral_format' => array('name' => __('Default Referral Format', 'affiliate-wp'), 'desc' => '<p class="description">' . sprintf(__('Show referral URLs to affiliates with either their affiliate ID or Username appended.<br/> For example: <strong>%s or %s</strong>.', 'affiliate-wp'), esc_url(add_query_arg(affiliate_wp()->tracking->get_referral_var(), '1', home_url('/'))), esc_url(add_query_arg(affiliate_wp()->tracking->get_referral_var(), $username, home_url('/')))) . '</p>', 'type' => 'select', 'options' => array('id' => __('ID', 'affiliate-wp'), 'username' => __('Username', 'affiliate-wp')), 'std' => 'id'), 'referral_pretty_urls' => array('name' => __('Pretty Affiliate URLs', 'affiliate-wp'), 'desc' => '<p class="description">' . sprintf(__('Show pretty affiliate referrals to affiliates. For example: <strong>%s or %s</strong>', 'affiliate-wp'), home_url('/') . affiliate_wp()->tracking->get_referral_var() . '/1', home_url('/') . trailingslashit(affiliate_wp()->tracking->get_referral_var()) . $username) . '</p>', 'type' => 'checkbox'), 'referral_rate_type' => array('name' => __('Referral Rate Type', 'affiliate-wp'), 'desc' => '<p class="description">' . __('Should referrals be based on a percentage or flat rate amounts?', 'affiliate-wp') . '</p>', 'type' => 'select', 'options' => affwp_get_affiliate_rate_types()), 'referral_rate' => array('name' => __('Referral Rate', 'affiliate-wp'), 'desc' => '<p class="description">' . __('Default referral rate. A percentage if Referral Rate Type is Percentage, a flat amount otherwise. Rates can be set for each affiliate individually as well.', 'affiliate-wp') . '</p>', 'type' => 'number', 'size' => 'small', 'step' => '0.01', 'std' => '20'), 'exclude_shipping' => array('name' => __('Exclude Shipping', 'affiliate-wp'), 'desc' => '<p class="description">' . __('Should shipping costs be excluded from referral calculations?', 'affiliate-wp') . '</p>', 'type' => 'checkbox'), 'exclude_tax' => array('name' => __('Exclude Tax', 'affiliate-wp'), 'desc' => '<p class="description">' . __('Should taxes be excluded from referral calculations?', 'affiliate-wp') . '</p>', 'type' => 'checkbox'), 'cookie_exp' => array('name' => __('Cookie Expiration', 'affiliate-wp'), 'desc' => '<p class="description">' . __('How many days should the referral tracking cookie be valid for?', 'affiliate-wp') . '</p>', 'type' => 'number', 'size' => 'small', 'std' => '1'), 'currency_settings' => array('name' => '<strong>' . __('Currency Settings', 'affiliate-wp') . '</strong>', 'desc' => __('Configure the currency options', 'affiliate-wp'), 'type' => 'header'), 'currency' => array('name' => __('Currency', 'affiliate-wp'), 'desc' => '<p class="description">' . __('Choose your currency. Note that some payment gateways have currency restrictions.', 'affiliate-wp') . '</p>', 'type' => 'select', 'options' => affwp_get_currencies()), 'currency_position' => array('name' => __('Currency Position', 'affiliate-wp'), 'desc' => '<p class="description">' . __('Choose the location of the currency sign.', 'affiliate-wp') . '</p>', 'type' => 'select', 'options' => array('before' => __('Before - $10', 'affiliate-wp'), 'after' => __('After - 10$', 'affiliate-wp'))), 'thousands_separator' => array('name' => __('Thousands Separator', 'affiliate-wp'), 'desc' => '<p class="description">' . __('The symbol (usually , or .) to separate thousands', 'affiliate-wp') . '</p>', 'type' => 'text', 'size' => 'small', 'std' => ','), 'decimal_separator' => array('name' => __('Decimal Separator', 'affiliate-wp'), 'desc' => '<p class="description">' . __('The symbol (usually , or .) to separate decimal points', 'affiliate-wp') . '</p>', 'type' => 'text', 'size' => 'small', 'std' => '.'))), 'integrations' => apply_filters('affwp_settings_integrations', array('integrations' => array('name' => __('Integrations', 'affiliate-wp'), 'desc' => sprintf(__('Choose the integrations to enable. If you are not using any of these, you may use the <strong>[affiliate_conversion_script]</strong> short code to track and create referrals. Refer to the <a href="%s" target="_blank">documentation</a> for help using this.', 'affiliate-wp'), 'http://affiliatewp.com/docs/custom-referral-tracking/'), 'type' => 'multicheck', 'options' => affiliate_wp()->integrations->get_integrations()))), 'emails' => apply_filters('affwp_settings_emails', array('email_logo' => array('name' => __('Logo', 'affiliate-wp'), 'desc' => __('Upload or choose a logo to be displayed at the top of emails.', 'affiliate-wp'), 'type' => 'upload'), 'email_template' => array('name' => __('Email Template', 'affiliate-wp'), 'desc' => __('Choose a template to use for email messages.', 'affiliate-wp'), 'type' => 'select', 'options' => affwp_get_email_templates()), 'from_name' => array('name' => __('From Name', 'affiliate-wp'), 'desc' => __('The name emails are said to come from. This should probably be your site name.', 'affiliate-wp'), 'type' => 'text', 'std' => get_bloginfo('name')), 'from_email' => array('name' => __('From Email', 'affiliate-wp'), 'desc' => __('Email to send emails from. This will act as the "from" and "reply-to" address.', 'affiliate-wp'), 'type' => 'text', 'std' => get_bloginfo('admin_email')), 'registration_notifications' => array('name' => __('Notify Admins', 'affiliate-wp'), 'desc' => __('Notify site admins of new affiliate registrations?', 'affiliate-wp'), 'type' => 'checkbox'), 'registration_subject' => array('name' => __('Registration Email Subject', 'affiliate-wp'), 'desc' => __('Enter the subject line for the registration email sent to admins when new affiliates register.', 'affiliate-wp'), 'type' => 'text', 'std' => __('New Affiliate Registration', 'affiliate-wp')), 'registration_email' => array('name' => __('Registration Email Content', 'affiliate-wp'), 'desc' => __('Enter the email to send when a new affiliate registers. HTML is accepted. Available template tags:', 'affiliate-wp') . '<br />' . affwp_get_emails_tags_list(), 'type' => 'rich_editor', 'std' => sprintf(__('A new affiliate has registered on your site, %s', 'affiliate-wp'), home_url()) . "\n\n" . __('Name: ', 'affiliate-wp') . "{name}\n\n{website}\n\n{promo_method}"), 'accepted_subject' => array('name' => __('Application Accepted Email Subject', 'affiliate-wp'), 'desc' => __('Enter the subject line for accepted application emails sent to affiliates when their account is approved.', 'affiliate-wp'), 'type' => 'text', 'std' => __('Affiliate Application Accepted', 'affiliate-wp')), 'accepted_email' => array('name' => __('Application Accepted Email Content', 'affiliate-wp'), 'desc' => __('Enter the email to send when an application is accepted. HTML is accepted. Available template tags:', 'affiliate-wp') . '<br />' . affwp_get_emails_tags_list(), 'type' => 'rich_editor', 'std' => __('Congratulations {name}!', 'affiliate-wp') . "\n\n" . sprintf(__('Your affiliate application on %s has been accepted!', 'affiliate-wp'), home_url()) . "\n\n" . __('Log into your affiliate area at', 'affiliate-wp') . ' {login_url}'), 'referral_subject' => array('name' => __('New Referral Email Subject', 'affiliate-wp'), 'desc' => __('Enter the subject line for new referral emails sent when affiliates earn referrals.', 'affiliate-wp'), 'type' => 'text', 'std' => __('Referral Awarded!', 'affiliate-wp')), 'referral_email' => array('name' => __('New Referral Email Content', 'affiliate-wp'), 'desc' => __('Enter the email to send on new referrals. HTML is accepted. Available template tags:', 'affiliate-wp') . '<br />' . affwp_get_emails_tags_list(), 'type' => 'rich_editor', 'std' => __('Congratulations {name}!', 'affiliate-wp') . "\n\n" . __('You have been awarded a new referral of', 'affiliate-wp') . ' {amount} ' . sprintf(__('on %s!', 'affiliate-wp'), home_url()) . "\n\n" . __('Log into your affiliate area to view your earnings or disable these notifications:', 'affiliate-wp') . ' {login_url}'))), 'misc' => apply_filters('affwp_settings_misc', array('allow_affiliate_registration' => array('name' => __('Allow affiliate registration', 'affiliate-wp'), 'desc' => __('Should affiliates be able to register accounts for themselves?', 'affiliate-wp'), 'type' => 'checkbox'), 'require_approval' => array('name' => __('Require approval', 'affiliate-wp'), 'desc' => __('Require that site admins approve affiliates before they can begin earning referrals?', 'affiliate-wp'), 'type' => 'checkbox'), 'auto_register' => array('name' => __('Auto Register New Users', 'affiliate-wp'), 'desc' => __('Automatically register new users as affiliates?', 'affiliate-wp'), 'type' => 'checkbox'), 'revoke_on_refund' => array('name' => __('Reject Unpaid Referrals on Refund?', 'affiliate-wp'), 'desc' => __('Should unpaid referrals get automatically rejected when the originating purchase is refunded or revoked?', 'affiliate-wp'), 'type' => 'checkbox'), 'tracking_fallback' => array('name' => __('Use Fallback Referral Tracking Method?', 'affiliate-wp'), 'desc' => __('The method used to track referral links can fail on sites that have jQuery errors. Check this if referrals are not getting tracked properly.', 'affiliate-wp'), 'type' => 'checkbox'), 'ignore_zero_referrals' => array('name' => __('Ignore Zero Referrals?', 'affiliate-wp'), 'desc' => __('Check this box if you would like AffiliateWP to completely ignore referrals for a zero total amount. This can be useful for multi-price products that start at zero, or if a discount was used, which resulted in a zero amount. Please note: if this setting is enabled and a visit results in a zero referral, then the visit would be considered not converted.', 'affiliate-wp'), 'type' => 'checkbox'), 'uninstall_on_delete' => array('name' => __('Remove Data on Uninstall?', 'affiliate-wp'), 'desc' => __('Check this box if you would like AffiliateWP to completely remove all of its data when the plugin is deleted.', 'affiliate-wp'), 'type' => 'checkbox'))));
     return apply_filters('affwp_settings', $settings);
 }
/**
 * Retrieves the referral rate type for an affiliate
 *
 * Either "flat" or "percentage"
 *
 * @since 1.1
 * @return string
 */
function affwp_get_affiliate_rate_type($affiliate_id = 0)
{
    // Allowed types
    $types = affwp_get_affiliate_rate_types();
    // default rate
    $type = affiliate_wp()->settings->get('referral_rate_type', 'percentage');
    $affiliate_rate_type = affiliate_wp()->affiliates->get_column('rate_type', $affiliate_id);
    $affiliate_rate = affiliate_wp()->affiliates->get_column('rate', $affiliate_id);
    if (!empty($affiliate_rate_type) && !empty($affiliate_rate)) {
        $type = $affiliate_rate_type;
    }
    if (!array_key_exists($type, $types)) {
        $type = 'percentage';
    }
    return apply_filters('affwp_get_affiliate_rate_type', $type, $affiliate_id);
}
Ejemplo n.º 3
0
				<th scope="row">
					<label for="rate_type"><?php 
_e('Referral Rate Type', 'affiliate-wp');
?>
</label>
				</th>

				<td>
					<select name="rate_type" id="rate_type">
						<option value=""><?php 
_e('Site Default', 'affiliate-wp');
?>
</option>
						<?php 
foreach (affwp_get_affiliate_rate_types() as $key => $type) {
    ?>
							<option value="<?php 
    echo esc_attr($key);
    ?>
"><?php 
    echo esc_html($type);
    ?>
</option>
						<?php 
}
?>
					</select>
					<p class="description"><?php 
_e('The affiliate\'s referral rate type.', 'affiliate-wp');
?>
Ejemplo n.º 4
0
 function test_get_affiliate_rate_types()
 {
     $this->assertArrayHasKey('percentage', affwp_get_affiliate_rate_types());
     $this->assertArrayHasKey('flat', affwp_get_affiliate_rate_types());
     $this->assertArrayNotHasKey('test', affwp_get_affiliate_rate_types());
 }