Exemple #1
0
 /**
  * Process the recount
  *
  * @since       1.0
  * @return      void
  */
 public function process_recount($data)
 {
     if (!is_admin() || !current_user_can('manage_affiliates')) {
         return;
     }
     $user_id = !empty($data['user_id']) ? absint($data['user_id']) : false;
     $affiliate_id = affwp_get_affiliate_id($user_id);
     if (empty($user_id) || empty($affiliate_id)) {
         return;
     }
     $type = !empty($data['recount_type']) ? $data['recount_type'] : false;
     if (empty($type)) {
         return;
     }
     switch ($type) {
         case 'earnings':
             $this->recount_earnings($affiliate_id);
             break;
         case 'referrals':
             $this->recount_referrals($affiliate_id);
             break;
         case 'visits':
             $this->recount_visits($affiliate_id);
             break;
     }
     wp_redirect(admin_url('admin.php?page=affiliate-wp-tools&tab=recount&affwp_notice=stats_recounted'));
     exit;
 }
/**
 * Plugin Name: AffiliateWP - Append Affiliate ID To Jetpack Sharing Links
 * Plugin URI: http://affiliatewp.com
 * Description: Automatically appends an affiliate's ID to Jetpack sharing links.
 * Author: Andrew Munro, Sumobi
 * Author URI: http://sumobi.com
 * Version: 1.0
 */
function affwp_custom_append_affiliate_id_to_jetpack_sharing_links($permalink, $post_id, $id)
{
    // return if non-affiliate
    if (!(is_user_logged_in() && affwp_is_affiliate())) {
        return $permalink;
    }
    // append referral variable and affiliate ID to sharing links in Jetpack
    $permalink = add_query_arg(affiliate_wp()->tracking->get_referral_var(), affwp_get_affiliate_id(), $permalink);
    return $permalink;
}
 /**
  * Get the affiliate ID from the referral value
  *
  * @since 1.0.3
  * @param string $referral_value
  * @return $affiliate_id, false otherwise
  */
 private function get_affiliate_id_from_referral_value($referral_value = '')
 {
     if (!is_numeric($referral_value)) {
         // username used instead of user ID
         // get user by WP username
         $user = get_user_by('login', $referral_value);
         // get the user ID
         $user_id = $user->ID;
         // get the affiliate ID from the user ID
         $affiliate_id = affwp_get_affiliate_id($user_id);
     } else {
         // affiliate ID was used instead of username
         // Usernames must have at least 4 characters
         $affiliate_id = $referral_value;
     }
     if ($affiliate_id) {
         return $affiliate_id;
     }
     return false;
 }
Exemple #4
0
/**
 * Process a referrals export
 *
 * @since       1.0
 * @return      void
 */
function affwp_process_referrals_export()
{
    if (empty($_POST['affwp_export_referrals_nonce'])) {
        return;
    }
    if (!wp_verify_nonce($_POST['affwp_export_referrals_nonce'], 'affwp_export_referrals_nonce')) {
        return;
    }
    if (!current_user_can('manage_options')) {
        return;
    }
    $start = !empty($_POST['start_date']) ? sanitize_text_field($_POST['start_date']) : false;
    $end = !empty($_POST['end_date']) ? sanitize_text_field($_POST['end_date']) : false;
    $status = !empty($_POST['status']) ? sanitize_text_field($_POST['status']) : false;
    $user_id = !empty($_POST['user_id']) ? absint($_POST['user_id']) : false;
    $export = new Affiliate_WP_Referral_Export();
    $export->date = array('start' => $start, 'end' => $end);
    $export->status = $status;
    if (!empty($user_id)) {
        $export->affiliate = affwp_get_affiliate_id($user_id);
    }
    $export->export();
}
 /**
  * Show an affiliate's name
  *
  * [affiliate_name]
  *
  * @since  1.1.1
  */
 function affiliate_name($atts, $content = null)
 {
     if (!(affwp_is_affiliate() && affwp_is_active_affiliate())) {
         return;
     }
     $atts = shortcode_atts(array('first_name_only' => ''), $atts, 'affiliate_name');
     if (isset($atts['first_name_only']) && 'yes' === $atts['first_name_only']) {
         global $current_user;
         get_currentuserinfo();
         $content = $current_user->user_firstname;
     } else {
         $content = affiliate_wp()->affiliates->get_affiliate_name(affwp_get_affiliate_id());
     }
     return do_shortcode($content);
 }
 /**
  * Updates the affiliate ID in the discounts meta if it is an affiliate's discount
  *
  * @access  public
  * @since   1.1
  */
 public function update_discount_affiliate($discount_id = 0, $args)
 {
     if (empty($_POST['user_id'])) {
         $user = get_user_by('login', $_POST['user_name']);
         if ($user) {
             $user_id = $user->ID;
         }
     } else {
         $user_id = absint($_POST['user_id']);
     }
     if (empty($_POST['user_name'])) {
         delete_user_meta($user_id, 'affwp_discount_rcp_' . $discount_id);
         return;
     }
     if (empty($_POST['user_id']) && empty($_POST['user_name'])) {
         return;
     }
     $affiliate_id = affwp_get_affiliate_id($user_id);
     update_user_meta($user_id, 'affwp_discount_rcp_' . $discount_id, $affiliate_id);
 }
/**
 * Updates an affiliate's profile settings
 *
 * @since 1.0
 * @return bool
 */
function affwp_update_profile_settings($data = array())
{
    if (!is_user_logged_in()) {
        return false;
    }
    if (empty($data['affiliate_id'])) {
        return false;
    }
    if (affwp_get_affiliate_id() != $data['affiliate_id'] && !current_user_can('manage_affiliates')) {
        return false;
    }
    $affiliate_id = absint($data['affiliate_id']);
    $user_id = affwp_get_affiliate_user_id($affiliate_id);
    if (!empty($data['referral_notifications'])) {
        update_user_meta($user_id, 'affwp_referral_notifications', '1');
    } else {
        delete_user_meta($user_id, 'affwp_referral_notifications');
    }
    if (!empty($data['payment_email']) && is_email($data['payment_email'])) {
        affiliate_wp()->affiliates->update($affiliate_id, array('payment_email' => $data['payment_email']), '', 'affiliate');
    }
    do_action('affwp_update_affiliate_profile_settings', $data);
    if (!empty($_POST['affwp_action'])) {
        wp_redirect(add_query_arg('affwp_notice', 'profile-updated'));
        exit;
    }
}
"><i></i></span>
						</td>
					</tr>
				<?php 
    }
    ?>

			<?php 
} else {
    ?>

				<tr>
					<td colspan="3"><?php 
    _e('You have not received any visits yet.', 'affiliate-wp');
    ?>
</td>
				</tr>

			<?php 
}
?>
		</tbody>
	</table>

	<p class="affwp-pagination">
		<?php 
echo paginate_links(array('current' => $page, 'total' => ceil(affwp_get_affiliate_visit_count(affwp_get_affiliate_id()) / $per_page), 'add_fragment' => '#affwp-affiliate-dashboard-visits', 'add_args' => array('tab' => 'visits')));
?>
	</p>

</div>
<div id="affwp-affiliate-dashboard-visits" class="affwp-tab-content">

	<h4><?php 
_e('Referral URL Visits', 'affiliate-wp');
?>
</h4>

	<?php 
$per_page = 30;
$page = get_query_var('paged') ? get_query_var('paged') : 1;
$pages = absint(ceil(affwp_get_affiliate_visit_count(affwp_get_affiliate_id()) / $per_page));
$visits = affiliate_wp()->visits->get_visits(array('number' => $per_page, 'offset' => $per_page * ($page - 1), 'affiliate_id' => affwp_get_affiliate_id()));
?>

	<table id="affwp-affiliate-dashboard-visits" class="affwp-table">
		<thead>
			<tr>
				<th class="visit-url"><?php 
_e('URL', 'affiliate-wp');
?>
</th>
				<th class="referring-url"><?php 
_e('Referring URL', 'affiliate-wp');
?>
</th>
				<th class="referral-status"><?php 
_e('Converted', 'affiliate-wp');
?>
</th>
			</tr>
		</thead>
/**
 * Get the referral format value
 *
 * @since 1.6
 * @param string $format referral format passed in via [affiliate_referral_url] shortcode
 * @return string affiliate ID or username
 */
function affwp_get_referral_format_value($format = '', $affiliate_id = 0)
{
    // get affiliate's user ID
    $user_id = affwp_get_affiliate_user_id($affiliate_id);
    if (!$format) {
        $format = affwp_get_referral_format();
    }
    switch ($format) {
        case 'username':
            $value = urlencode(affwp_get_affiliate_username($affiliate_id));
            break;
        case 'id':
        default:
            $value = affwp_get_affiliate_id($user_id);
            break;
    }
    return apply_filters('affwp_get_referral_format_value', $value, $format, $affiliate_id);
}
 /**
  * Save coupon meta
  *
  * @access public
  * @since   1.7.5
  */
 public function store_discount_affiliate($post_id, $post)
 {
     // If this is an autosave, our form has not been submitted, so we don't want to do anything.
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return $post_id;
     }
     // Don't save revisions and autosaves
     if (wp_is_post_revision($post_id) || wp_is_post_autosave($post_id)) {
         return $post_id;
     }
     if (!is_admin()) {
         return $post_id;
     }
     $post = get_post($post_id);
     if (!$post) {
         return $post_id;
     }
     // Check post type is coupon
     if ('memberpresscoupon' != $post->post_type) {
         return $post_id;
     }
     // Check user permission
     if (!current_user_can('edit_post', $post_id)) {
         return $post_id;
     }
     if (empty($_POST['user_name'])) {
         delete_post_meta($post_id, 'affwp_discount_affiliate');
         return;
     }
     if (empty($_POST['user_id']) && empty($_POST['user_name'])) {
         return;
     }
     if (empty($_POST['user_id'])) {
         $user = get_user_by('login', $_POST['user_name']);
         if ($user) {
             $user_id = $user->ID;
         }
     } else {
         $user_id = absint($_POST['user_id']);
     }
     $affiliate_id = affwp_get_affiliate_id($user_id);
     update_post_meta($post_id, 'affwp_discount_affiliate', $affiliate_id);
 }
<?php

/*
Template Name: Referral History
*/
get_header();
$referrals = affiliate_wp()->referrals->get_referrals(array('number' => $per_page, 'offset' => $per_page * ($page - 1), 'affiliate_id' => affwp_get_affiliate_id(), 'status' => array('paid', 'unpaid', 'rejected')));
?>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
<link rel="stylesheet" href="http://www.thecannabismethod.com/wp-content/themes/zerif-lite-child/css/dashboard.css">
</header>


		<div id="content" class="site-content">

<div id="dashboard" class="container">

	<div class="row">
		<div class="col-sm-12">
	        <h1 class="page-header">Referral History</h1>
	    </div>
	</div>
		
	<div class="row">
		<div class="col-sm-12">
			<table>
				<tr><th>ID</th><th>Date</th><th>Status</th><th>Credit</th></tr>
				
				<?php 
if ($referrals) {
    ?>
 function test_get_affiliate_id()
 {
     $this->assertFalse(affwp_get_affiliate_id());
     $this->assertEquals($this->_affiliate_id, affwp_get_affiliate_id($this->_user_id));
 }
/**
 * Builds an affiliate's referral URL
 * Used by creatives, referral URL generator and [affiliate_referral_url] shortcode
 *
 * @since  1.6
 * @return string
 * @param  $args array of arguments. $base_url, $format, $pretty
 */
function affwp_get_affiliate_referral_url($args = array())
{
    $defaults = array('pretty' => '', 'format' => '');
    $args = wp_parse_args($args, $defaults);
    // get affiliate ID if passed in
    $affiliate_id = isset($args['affiliate_id']) ? $args['affiliate_id'] : affwp_get_affiliate_id();
    // get format, username or id
    $format = isset($args['format']) ? $args['format'] : affwp_get_referral_format();
    // pretty URLs
    if (!empty($args['pretty']) && 'yes' == $args['pretty']) {
        // pretty URLS explicitly turned on
        $pretty = true;
    } elseif (!empty($args['pretty']) && 'no' == $args['pretty'] || false === $args['pretty']) {
        // pretty URLS explicitly turned off
        $pretty = false;
    } else {
        // pretty URLs set from admin
        $pretty = affwp_is_pretty_referral_urls();
    }
    // get base URL
    if (isset($args['base_url'])) {
        $base_url = $args['base_url'];
    } else {
        $base_url = affwp_get_affiliate_base_url();
    }
    // add trailing slash only if no query string exists and there's no fragment identifier
    if (isset($args['base_url']) && !array_key_exists('query', parse_url($base_url)) && !array_key_exists('fragment', parse_url($base_url))) {
        $base_url = trailingslashit($args['base_url']);
    }
    // the format value, either affiliate's ID or username
    $format_value = affwp_get_referral_format_value($format, $affiliate_id);
    $url_parts = parse_url($base_url);
    // if fragment identifier exists in base URL, strip it and store in variable so we can append it later
    $fragment = array_key_exists('fragment', $url_parts) ? '#' . $url_parts['fragment'] : '';
    // if query exists in base URL, strip it and store in variable so we can append to the end of the URL
    $query_string = array_key_exists('query', $url_parts) ? '?' . $url_parts['query'] : '';
    $url_scheme = isset($url_parts['scheme']) ? $url_parts['scheme'] : 'http';
    $url_host = isset($url_parts['host']) ? $url_parts['host'] : '';
    $constructed_url = $url_scheme . '://' . $url_host . $url_parts['path'];
    $base_url = $constructed_url;
    // set up URLs
    $pretty_urls = trailingslashit($base_url) . trailingslashit(affiliate_wp()->tracking->get_referral_var()) . trailingslashit($format_value) . $query_string . $fragment;
    $non_pretty_urls = esc_url(add_query_arg(affiliate_wp()->tracking->get_referral_var(), $format_value, $base_url . $query_string . $fragment));
    if ($pretty) {
        $referral_url = $pretty_urls;
    } else {
        $referral_url = $non_pretty_urls;
    }
    return $referral_url;
}
		</div>

		<div class="affwp-wrap affwp-send-notifications-wrap">
			<input id="affwp-referral-notifications" type="checkbox" name="referral_notifications" value="1"<?php 
checked(true, get_user_meta(affwp_get_affiliate_user_id(affwp_get_affiliate_id()), 'affwp_referral_notifications', true));
?>
/>
			<label for="affwp-referral-notifications"><?php 
_e('Enable New Referral Notifications', 'affiliate-wp');
?>
</label>
		</div>

		<?php 
do_action('affwp_affiliate_dashboard_before_submit', affwp_get_affiliate_id(), affwp_get_affiliate_user_id(affwp_get_affiliate_id()));
?>

		<div class="affwp-save-profile-wrap">
			<input type="hidden" name="affwp_action" value="update_profile_settings" />
			<input type="hidden" name="affiliate_id" value="<?php 
echo esc_attr(affwp_get_affiliate_id());
?>
" />
			<input type="submit" class="button" value="<?php 
esc_attr_e('Save Profile Settings', 'affiliate-wp');
?>
" />
		</div>
	</form>
</div>
 public static function generate_affiliatewp_referral_link($permalink)
 {
     if (!(is_user_logged_in() && affwp_is_affiliate())) {
         return $permalink;
     }
     // append referral variable and affiliate ID to sharing links in Jetpack
     $permalink = add_query_arg(affiliate_wp()->tracking->get_referral_var(), affwp_get_affiliate_id(), $permalink);
     return $permalink;
 }
</th>
				<th><?php 
_e('Commission Rate', 'affiliate-wp');
?>
</th>
			</tr>
		</thead>

		<tbody>
			<tr>
				<td><?php 
echo affwp_get_affiliate_unpaid_earnings(affwp_get_affiliate_id(), true);
?>
</td>
				<td><?php 
echo affwp_get_affiliate_earnings(affwp_get_affiliate_id(), true);
?>
</td>
				<td><?php 
echo affwp_get_affiliate_rate(affwp_get_affiliate_id(), true);
?>
</td>
			</tr>
		</tbody>
	</table>

	<?php 
do_action('affwp_affiliate_dashboard_after_earnings', affwp_get_affiliate_id());
?>

</div>
 /**
  * Register the affiliate / user
  *
  * @since 1.0
  */
 private function register_user()
 {
     $status = affiliate_wp()->settings->get('require_approval') ? 'pending' : 'active';
     if (!is_user_logged_in()) {
         $name = explode(' ', sanitize_text_field($_POST['affwp_user_name']));
         $user_first = $name[0];
         $user_last = isset($name[1]) ? $name[1] : '';
         $args = array('user_login' => sanitize_text_field($_POST['affwp_user_login']), 'user_email' => sanitize_text_field($_POST['affwp_user_email']), 'user_pass' => sanitize_text_field($_POST['affwp_user_pass']), 'display_name' => $user_first . ' ' . $user_last, 'first_name' => $user_first, 'last_name' => $user_last);
         $user_id = wp_insert_user($args);
     } else {
         $user_id = get_current_user_id();
         $user = (array) get_userdata($user_id);
         $args = (array) $user['data'];
     }
     // promotion method
     $promotion_method = isset($_POST['affwp_promotion_method']) ? sanitize_text_field($_POST['affwp_promotion_method']) : '';
     if ($promotion_method) {
         update_user_meta($user_id, 'affwp_promotion_method', $promotion_method);
     }
     // website URL
     $website_url = isset($_POST['affwp_user_url']) ? sanitize_text_field($_POST['affwp_user_url']) : '';
     if ($website_url) {
         wp_update_user(array('ID' => $user_id, 'user_url' => $website_url));
     }
     $affiliate_id = affwp_add_affiliate(array('status' => $status, 'user_id' => $user_id, 'payment_email' => !empty($_POST['affwp_payment_email']) ? sanitize_text_field($_POST['affwp_payment_email']) : '', 'status' => affiliate_wp()->settings->get('require_approval') ? 'pending' : 'active'));
     if (!is_user_logged_in()) {
         $this->log_user_in($user_id, sanitize_text_field($_POST['affwp_user_login']));
     }
     // Retrieve affiliate ID. Resolves issues with caching on some hosts, such as GoDaddy
     $affiliate_id = affwp_get_affiliate_id($user_id);
     do_action('affwp_register_user', $affiliate_id, $status, $args);
 }
</div>
<br>

<div id="affwp-affiliate-dashboard-graphs" class="affwp-tab-content">

	<h4>Referrals Graph</h4>

	<?php 
$graph = new Affiliate_WP_Referrals_Graph();
$graph->set('x_mode', 'time');
$graph->set('affiliate_id', affwp_get_affiliate_id());
$graph->display();
?>

	<?php 
do_action('affwp_affiliate_dashboard_after_graphs', affwp_get_affiliate_id());
?>

</div>

<script>
	jQuery(document).ready(function($) {
		/*tool tip*/
		$('[data-toggle="tooltip"]').tooltip();
		/*copy to clipboard*/
		$('body').append('<input id="clipBoard" type="text" style="opacity: 0;position: absolute;bottom: 0; z-index: -100;">');
		$('.aff_link').click(function(e) {
			var link = $(this).html();
			$('#clipBoard').val(link); // local storage
			document.execCommand('copy', false, document.getElementById('clipBoard').select());
			$(this).attr('title', 'Copied').tooltip('fixTitle').tooltip('show');
 /**
  * Get the affiliate's ID from their user login
  *
  * @since 1.3
  */
 public function get_affiliate_id_from_login($login = '')
 {
     $affiliate_id = 0;
     if (!empty($login)) {
         $user = get_user_by('login', sanitize_text_field(urldecode($login)));
         if ($user) {
             $affiliate_id = affwp_get_affiliate_id($user->ID);
         }
     }
     return apply_filters('affwp_tracking_get_affiliate_id', $affiliate_id, $login);
 }
				<tr>
					<td colspan="3"><?php 
    _e('You have not made any referrals yet.', 'affiliate-wp');
    ?>
</td>
				</tr>

			<?php 
}
?>
		</tbody>
	</table>

	<?php 
do_action('affwp_referrals_dashboard_after_table', affwp_get_affiliate_id());
?>

	<?php 
if ($pages > 1) {
    ?>

		<p class="affwp-pagination">
			<?php 
    echo paginate_links(array('current' => $page, 'total' => $pages, 'add_fragment' => '#affwp-affiliate-dashboard-referrals', 'add_args' => array('tab' => 'referrals')));
    ?>
		</p>

	<?php 
}
?>
/**
 * Get the referral format value
 *
 * @since 1.6
 * @param string $format referral format passed in via [affiliate_referral_url] shortcode
 * @return string affiliate ID or username
 */
function affwp_get_referral_format_value($format = '', $affiliate_id = 0)
{
    // get affiliate's user ID
    $user_id = affwp_get_affiliate_user_id($affiliate_id);
    if (!$format) {
        $format = affwp_get_referral_format();
    }
    switch ($format) {
        case 'username':
            $value = affwp_get_affiliate_username($affiliate_id);
            break;
        case 'id':
        default:
            $value = affwp_get_affiliate_id($user_id);
            break;
    }
    return $value;
}
<?php

$affiliate_id = affwp_get_affiliate_id();
$user_email = affwp_get_affiliate_email($affiliate_id);
$payment_email = affwp_get_affiliate_payment_email($affiliate_id, $user_email);
// Fallback to user_email
?>

<div id="affwp-affiliate-dashboard-profile" class="affwp-tab-content">

	<h4><?php 
_e('Profile Settings', 'affiliate-wp');
?>
</h4>

	<form id="affwp-affiliate-dashboard-profile-form" class="affwp-form" method="post">

		<div class="affwp-wrap affwp-payment-email-wrap">
			<label for="affwp-payment-email"><?php 
_e('Your payment email', 'affiliate-wp');
?>
</label>
			<input id="affwp-payment-email" type="email" name="payment_email" value="<?php 
echo esc_attr($payment_email);
?>
" />
		</div>

		<div class="affwp-wrap affwp-send-notifications-wrap">
			<input id="affwp-referral-notifications" type="checkbox" name="referral_notifications" value="1" <?php 
checked(true, get_user_meta(affwp_get_affiliate_user_id($affiliate_id), 'affwp_referral_notifications', true));
<div id="affwp-affiliate-dashboard-url-generator" class="affwp-tab-content">

	<h4><?php 
_e('Referral URL Generator', 'affiliate-wp');
?>
</h4>

	<?php 
if ('id' == affwp_get_referral_format()) {
    ?>
		<p><?php 
    printf(__('Your affiliate ID is: <strong>%s</strong>', 'affiliate-wp'), affwp_get_affiliate_id());
    ?>
</p>
	<?php 
} elseif ('username' == affwp_get_referral_format()) {
    ?>
		<p><?php 
    printf(__('Your affiliate username is: <strong>%s</strong>', 'affiliate-wp'), affwp_get_affiliate_username());
    ?>
</p>
	<?php 
}
?>

	<p><?php 
printf(__('Your referral URL is: <strong>%s</strong>', 'affiliate-wp'), esc_url(urldecode(affwp_get_affiliate_referral_url())));
?>
</p>
	<p><?php 
_e('Enter any URL from this website in the form below to generate a referral link!', 'affiliate-wp');
Exemple #25
0
 /**
  * Stores the affiliate ID in the coupons meta if it is an affiliate's coupon
  *
  * @access  public
  * @since   1.3
  */
 public function store_coupon_affiliate($coupon_id = 0, $data = array())
 {
     if (empty($_POST['user_name'])) {
         delete_post_meta($coupon_id, 'affwp_coupon_affiliate');
         return;
     }
     if (empty($_POST['user_id']) && empty($_POST['user_name'])) {
         return;
     }
     if (empty($_POST['user_id'])) {
         $user = get_user_by('login', $_POST['user_name']);
         if ($user) {
             $user_id = $user->ID;
         }
     } else {
         $user_id = absint($_POST['user_id']);
     }
     $affiliate_id = affwp_get_affiliate_id($user_id);
     update_post_meta($coupon_id, 'affwp_coupon_affiliate', $affiliate_id);
 }
    echo $active_tab == 'settings' ? ' active' : '';
    ?>
">
				<a href="<?php 
    echo esc_url(add_query_arg('tab', 'settings', get_permalink(affiliate_wp()->settings->get('affiliates_page'))));
    ?>
"><?php 
    _e('Settings', 'affiliate-wp');
    ?>
</a>
			</li>
			<?php 
    do_action('affwp_affiliate_dashboard_tabs', affwp_get_affiliate_id(), $active_tab);
    ?>
		</ul>

		<?php 
    affiliate_wp()->templates->get_template_part('dashboard-tab', $active_tab);
    ?>

		<?php 
    do_action('affwp_affiliate_dashboard_bottom', affwp_get_affiliate_id());
    ?>

	<?php 
}
?>

	
</div>
Exemple #27
0
 /**
  * Saves an affiliate coupon
  *
  * @access  public
  * @since   1.7.5
  */
 public function save_affiliate_coupon($save_id = 0)
 {
     global $wpdb;
     if (empty($_REQUEST['affwp_pmp_coupon_nonce'])) {
         return;
     }
     if (!wp_verify_nonce($_REQUEST['affwp_pmp_coupon_nonce'], 'affwp_pmp_coupon_nonce')) {
         return;
     }
     $user_name = sanitize_text_field($_POST['user_name']);
     if (empty($_POST['user_id'])) {
         $user = get_user_by('login', $_POST['user_name']);
         if ($user) {
             $user_id = $user->ID;
         }
     } else {
         $user_id = absint($_POST['user_id']);
     }
     $coupon = $wpdb->get_row("SELECT * FROM {$wpdb->pmpro_discount_codes} WHERE code = '" . esc_sql($_REQUEST['code']) . "' LIMIT 1");
     $affiliate_id = affwp_get_affiliate_id($user_id);
     if (empty($_POST['user_name'])) {
         affwp_delete_affiliate_meta($affiliate_id, 'affwp_discount_pmp_' . $coupon->id);
         return;
     }
     affwp_update_affiliate_meta($affiliate_id, 'affwp_discount_pmp_' . $coupon->id, $coupon->code);
 }
        ?>
</td>
						<td><?php 
        echo esc_html(affwp_format_amount($campaign->conversion_rate));
        ?>
%</td>
					</tr>
				<?php 
    }
    ?>
			<?php 
} else {
    ?>
				<tr>
					<td colspan="5"><?php 
    _e('You have no referrals or visits that included a campaign name.', 'affiliate-wp');
    ?>
</td>
				</tr>
			<?php 
}
?>
		</tbody>
	</table>

	<?php 
do_action('affwp_affiliate_dashboard_after_campaign_stats', affwp_get_affiliate_id());
?>

</div>
Exemple #29
-1
function count_referrals()
{
    $total = affwp_count_referrals(affwp_get_affiliate_id(), 'unpaid') + affwp_count_referrals(affwp_get_affiliate_id(), 'paid');
    return $total;
}