Skip to content

Instantly share code, notes, and snippets.

@ramiabraham
Created September 9, 2014 02:50
Show Gist options
  • Select an option

  • Save ramiabraham/72e62a808a100d32a782 to your computer and use it in GitHub Desktop.

Select an option

Save ramiabraham/72e62a808a100d32a782 to your computer and use it in GitHub Desktop.
AffiliateWP Front-EndDashboard Stats For Current User
<?php
/*
Plugin Name: AffiliateWP Dashboard Stats For Current User
Plugin Script: affiliatewp dashboard stats.php
Plugin URI: http://affiliatewp.com
Description: Adds AffiliateWP Dashboard Stats For Current User
Version: 0.1
License: GPL
Author: AffiliateWP
*/
if ( class_exists('Affiliate_WP') ) {
function affwp_add_current_user_referral_counts_shortcode() { ?>
<div class="postbox">
<h3><?php _e( 'Statistics for Current User', 'affiliate-wp' ); ?></h3>
<div class="inside">
<div id="affwp-affiliate-dashboard-referral-counts" class="affwp-tab-content">
<table class="affwp_table">
<thead>
<tr>
<th><?php _e( 'Unpaid Referrals', 'affiliate-wp' ); ?></th>
<th><?php _e( 'Paid Referrals', 'affiliate-wp' ); ?></th>
<th><?php _e( 'Visits', 'affiliate-wp' ); ?></th>
<th><?php _e( 'Conversion Rate', 'affiliate-wp' ); ?></th>
</tr>
</thead>
<tbody>
<tr>
<td><?php echo affwp_count_referrals( affwp_get_affiliate_id(), 'unpaid' ); ?></td>
<td><?php echo affwp_count_referrals( affwp_get_affiliate_id(), 'paid' ); ?></td>
<td><?php echo affwp_count_visits( affwp_get_affiliate_id() ); ?></td>
<td><?php echo affwp_get_affiliate_conversion_rate( affwp_get_affiliate_id() ); ?></td>
</tr>
</tbody>
</table>
<?php do_action( 'affwp_affiliate_dashboard_after_counts', affwp_get_affiliate_id() ); ?>
</div>
<div id="affwp-affiliate-dashboard-earnings-stats" class="affwp-tab-content">
<table class="affwp_table">
<thead>
<tr>
<th><?php _e( 'Unpaid Earnings', 'affiliate-wp' ); ?></th>
<th><?php _e( 'Paid Earnings', 'affiliate-wp' ); ?></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>
<div id="affwp-affiliate-dashboard-referral-campaigns" class="affwp-tab-content">
</div>
</div>
</div>
<?php }
add_shortcode( 'affwp_current_user_stats','affwp_add_current_user_referral_counts_shortcode' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment