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