Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!-- Show latest Donors, most recent at the top -->
- <div class="half first">
- <?php
- // If the fundraiser exists and fundraising is installed then continue
- if(get_post($post_id) && class_exists('WDF')) {
- global $wdf;
- // get_pledge_list() returns standard array() of post objects
- $pledge_list = $wdf->get_pledge_list($post_id);
- if ($pledge_list) {
- echo "<div class='clearfix'></div>";
- echo "<h2>Latest Donations</h2><ul>";
- foreach($pledge_list as $pledge) {
- // get_transaction() returns an array of available transaction meta-data;
- $transaction = $wdf->get_transaction($pledge->ID);
- //This prints the transaction array so you can see what is available for display.
- //echo '<pre>'.var_export($transaction,true).'</pre>';
- $lname = $transaction['last_name'];
- //echo '<li class="supporter">'.$transaction['first_name'].' '.$lname[0].'. donated $'.$transaction['gross'].' ' .$transaction['status'].'</li>';
- echo '<li class="supporter">'.$transaction['first_name'].' '.$lname[0].'. donated <span style="float:right; margin-right:5px;">$'.number_format($transaction['gross']).'</span></li>';
- }
- }
- }
- echo "</ul>";
- ?>
- </div>
- <!-- Show top Donors, grouped by Supporter Spot -->
- <div class="half last">
- <?php
- // If fundraising is installed then continue
- if(class_exists('WDF')) {
- global $wdf;
- // get_pledge_list() returns standard array() of post objects
- if(get_post($post_id)) {
- $pledge_list = $wdf->get_pledge_list($post_id);
- }
- else
- {
- $pledge_list = $wdf->get_pledge_list();
- }
- if ($pledge_list) {
- $pledgesort = array();
- // Build array to compare email accounts
- foreach($pledge_list as $pledge) {
- $transaction = $wdf->get_transaction($pledge->ID);
- $lname = $transaction['last_name'];
- $pledgesortdata = array(
- 'name' => $transaction['first_name'].' '.$lname[0],
- 'amount' => intval(preg_replace('~\.0+$~','',$transaction['gross'])),
- 'email' => $transaction['payer_email']
- );
- $pledgesort[] = $pledgesortdata;
- }
- // Function to group donation by email address, in case same person makes multiple donations
- function arraySort($input,$sortkey){
- foreach ($input as $key=>$val) $output[$val[$sortkey]][]=$val;
- return $output;
- }
- $pledgesort = arraySort($pledgesort,'email');
- $backerlist = array();
- foreach($pledgesort as $backeremail) {
- $amount = 0;
- foreach($backeremail as $key) {
- $amount = $amount + $key['amount'];
- }
- $backerlistdata = array(
- 'name' => $key['name'],
- 'amount' => $amount,
- 'email' => $key['email']
- );
- $backerlist[] = $backerlistdata;
- }
- $backerlist = arraySort($backerlist,'amount');
- krsort($backerlist);
- $backerlist = array_slice($backerlist, 0, 10);
- //print_r($backerlist);
- echo '<div id="topbackers">
- <div style="clear:both"></div>
- <h2>Top Donors</h2>
- <ul>
- ';
- $fan = 0;
- foreach($backerlist as $backer) {
- $fan = $fan + 1;
- echo '<li><span class="homehilight"># '.$fan.' Supporter Spot:</span><br />';
- $i = 0;
- foreach($backer as $key) {
- echo '<div>'.$key['name'].'. ';
- echo ' <span style="float:right; margin-right:5px;">$'.$key['amount'].'</span></div>';
- }
- echo '</li>';
- }
- echo '</ul></div>';
- }
- }
- ?>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement