| 1 |
<?php |
| 2 |
/** |
| 3 |
* Display the site donation stats. |
| 4 |
* |
| 5 |
* Override this template by copying it to yourtheme/charitable/donation-stats.php |
| 6 |
* |
| 7 |
* @package Charitable/Templates/Widgets |
| 8 |
* @author WP Charitable LLC |
| 9 |
* @since 1.5.0 |
| 10 |
* @version 1.6.57 |
| 11 |
*/ |
| 12 |
|
| 13 |
/** |
| 14 |
* Do something before displaying the donation stats. |
| 15 |
* |
| 16 |
* @since 1.6.57 |
| 17 |
* |
| 18 |
* @param array $view_args The view arguments. |
| 19 |
*/ |
| 20 |
do_action( 'charitable_donation_stats_before', $view_args ); |
| 21 |
|
| 22 |
$campaigns_count = Charitable_Campaigns::query( array( |
| 23 |
'posts_per_page' => -1, |
| 24 |
'fields' => 'ids', |
| 25 |
) )->found_posts; |
| 26 |
$campaigns_text = 1 == $campaigns_count ? __( 'Campaign', 'charitable' ) : __( 'Campaigns', 'charitable' ); |
| 27 |
|
| 28 |
/** |
| 29 |
* Filter the donation stats to show. |
| 30 |
* |
| 31 |
* @since 1.5.0 |
| 32 |
* |
| 33 |
* @param array $donation_stats The default stats to show. |
| 34 |
* @param array $view_args All arguments passed to the view. |
| 35 |
*/ |
| 36 |
$donation_stats = apply_filters( 'charitable_donation_stats', array( |
| 37 |
'campaign_count' => array( |
| 38 |
'amount' => $campaigns_count, |
| 39 |
'description' => $campaigns_text, |
| 40 |
), |
| 41 |
'donated' => array( |
| 42 |
'amount' => charitable_format_money( charitable_get_table( 'campaign_donations' )->get_total() ), |
| 43 |
'description' => __( 'Donated', 'charitable' ), |
| 44 |
), |
| 45 |
'donor_count' => array( |
| 46 |
'amount' => charitable_get_table( 'donors' )->count_donors_with_donations(), |
| 47 |
'description' => __( 'Donors', 'charitable' ), |
| 48 |
), |
| 49 |
), $view_args ); |
| 50 |
|
| 51 |
?> |
| 52 |
<ul class="donation-stats"> |
| 53 |
<?php |
| 54 |
foreach ( $donation_stats as $stat ) : |
| 55 |
printf( '<li><span class="figure">%s</span> %s</li>', $stat['amount'], $stat['description'] ); |
| 56 |
endforeach; |
| 57 |
?> |
| 58 |
</ul><!-- .donation-stats --> |
| 59 |
<?php |
| 60 |
|
| 61 |
/** |
| 62 |
* Do something after displaying the donation stats. |
| 63 |
* |
| 64 |
* @since 1.6.57 |
| 65 |
* |
| 66 |
* @param array $view_args The view arguments. |
| 67 |
*/ |
| 68 |
do_action( 'charitable_donation_stats_after', $view_args ); |