<div id="affwp-affiliate-dashboard-referrals" class="affwp-tab-content"> <h4><?php _e('Referrals', 'affiliate-wp'); ?> </h4> <?php $per_page = 30; $page = get_query_var('paged') ? get_query_var('paged') : 1; $pages = absint(ceil(affwp_count_referrals(affwp_get_affiliate_id()) / $per_page)); $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'))); ?> <?php do_action('affwp_referrals_dashboard_before_table', affwp_get_affiliate_id()); ?> <table id="affwp-affiliate-dashboard-referrals" class="affwp-table"> <thead> <tr> <th class="referral-amount"><?php _e('Amount', 'affiliate-wp'); ?> </th> <th class="referral-description"><?php _e('Description', 'affiliate-wp'); ?> </th> <th class="referral-status"><?php _e('Status', 'affiliate-wp');
} ?> <?php } else { ?> <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()); ?> <p class="affwp-pagination"> <?php echo paginate_links(array('current' => $page, 'total' => ceil(affwp_count_referrals(affwp_get_affiliate_id()) / $per_page), 'add_fragment' => '#affwp-affiliate-dashboard-referrals', 'add_args' => array('tab' => 'referrals'))); ?> </p> </div>
<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_count_referrals(affwp_get_affiliate_id(), 'unpaid'); ?> </td> <td><?php echo affwp_count_referrals(affwp_get_affiliate_id(), 'paid'); ?> </td> </tr> </tbody> </table> <?php do_action('affwp_affiliate_dashboard_after_counts', affwp_get_affiliate_id()); ?> </div> <br> <div id="affwp-affiliate-dashboard-referral-counts" class="affwp-tab-content">
/** * Show the total number of unpaid/paid referrals for the logged in affiliate * * [affiliate_referrals status="paid"] * [affiliate_referrals status="unpaid"] * * @since 1.1 */ function affiliate_referrals($atts, $content = null) { if (!(affwp_is_affiliate() && affwp_is_active_affiliate())) { return; } $atts = shortcode_atts(array('status' => ''), $atts, 'affiliate_referrals'); switch ($atts['status']) { case 'paid': $content = affwp_count_referrals(affwp_get_affiliate_id(), 'paid'); break; case 'unpaid': $content = affwp_count_referrals(affwp_get_affiliate_id(), 'unpaid'); break; } return do_shortcode($content); }
function count_referrals() { $total = affwp_count_referrals(affwp_get_affiliate_id(), 'unpaid') + affwp_count_referrals(affwp_get_affiliate_id(), 'paid'); return $total; }