daily pastebin goal
39%
SHARE
TWEET

Dual Column Latest & Top Donor List

a guest Oct 20th, 2014 5 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. <!-- Show latest Donors, most recent at the top -->
  2. <div class="half first">  
  3. <?php
  4.        
  5. // If the fundraiser exists and fundraising is installed then continue
  6. if(get_post($post_id) && class_exists('WDF')) {
  7.         global $wdf;
  8.         // get_pledge_list() returns standard array() of post objects
  9.         $pledge_list = $wdf->get_pledge_list($post_id);
  10.         if ($pledge_list) {
  11. echo "<div class='clearfix'></div>";
  12. echo "<h2>Latest Donations</h2><ul>";
  13.         foreach($pledge_list as $pledge) {
  14.                 // get_transaction() returns an array of available transaction meta-data;
  15.                 $transaction = $wdf->get_transaction($pledge->ID);
  16.                 //This prints the transaction array so you can see what is available for display.
  17.                 //echo '<pre>'.var_export($transaction,true).'</pre>';
  18.                 $lname = $transaction['last_name'];
  19.                 //echo '<li class="supporter">'.$transaction['first_name'].' '.$lname[0].'. donated $'.$transaction['gross'].' ' .$transaction['status'].'</li>';
  20.                 echo '<li class="supporter">'.$transaction['first_name'].' '.$lname[0].'. donated <span style="float:right; margin-right:5px;">$'.number_format($transaction['gross']).'</span></li>';
  21.                         }
  22.         }
  23. }
  24. echo "</ul>";
  25. ?>    
  26. </div>
  27.  
  28.  
  29. <!-- Show top Donors, grouped by Supporter Spot -->
  30. <div class="half last">
  31. <?php
  32. // If fundraising is installed then continue
  33. if(class_exists('WDF')) {
  34.         global $wdf;
  35.         // get_pledge_list() returns standard array() of post objects
  36.         if(get_post($post_id)) {
  37.                 $pledge_list = $wdf->get_pledge_list($post_id);
  38.                 }
  39.         else
  40.                 {  
  41.                 $pledge_list = $wdf->get_pledge_list();
  42.                 }
  43.         if ($pledge_list) {
  44.         $pledgesort = array();
  45.         // Build array to compare email accounts
  46.         foreach($pledge_list as $pledge) {
  47.                 $transaction = $wdf->get_transaction($pledge->ID);
  48.                 $lname = $transaction['last_name'];
  49.                 $pledgesortdata = array(
  50.                 'name' => $transaction['first_name'].' '.$lname[0],
  51.                 'amount' => intval(preg_replace('~\.0+$~','',$transaction['gross'])),
  52.                 'email' => $transaction['payer_email']
  53.                 );
  54.                 $pledgesort[] = $pledgesortdata;
  55.         }
  56.         // Function to group donation by email address, in case same person makes multiple donations
  57.         function arraySort($input,$sortkey){
  58.           foreach ($input as $key=>$val) $output[$val[$sortkey]][]=$val;
  59.           return $output;
  60.         }
  61.         $pledgesort = arraySort($pledgesort,'email');
  62.         $backerlist = array();
  63.         foreach($pledgesort as $backeremail) {
  64.                         $amount = 0;
  65.                         foreach($backeremail as $key) {
  66.                           $amount = $amount + $key['amount'];
  67.                         }
  68.                 $backerlistdata = array(
  69.                 'name' => $key['name'],
  70.                 'amount' => $amount,
  71.                 'email' => $key['email']
  72.                 );
  73.                 $backerlist[] = $backerlistdata;
  74.         }
  75.         $backerlist = arraySort($backerlist,'amount');
  76.         krsort($backerlist);
  77.         $backerlist = array_slice($backerlist, 0, 10);
  78.         //print_r($backerlist);
  79.         echo '<div id="topbackers">
  80.        <div style="clear:both"></div>
  81.        <h2>Top Donors</h2>
  82.        <ul>
  83.        ';
  84.         $fan = 0;
  85.         foreach($backerlist as $backer) {
  86.                 $fan = $fan + 1;
  87.                
  88.                 echo '<li><span class="homehilight"># '.$fan.' Supporter Spot:</span><br />';
  89.                 $i = 0;                          
  90.                 foreach($backer as $key) {
  91.                 echo '<div>'.$key['name'].'. ';
  92.                 echo ' <span style="float:right; margin-right:5px;">$'.$key['amount'].'</span></div>';
  93.                 }
  94.                 echo '</li>';
  95.                
  96.         }
  97.         echo '</ul></div>';
  98.         }
  99. }
  100. ?>
  101. </div>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top