PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.6.22
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.6.22
1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 1.7.0.9 1.8.0 All 210 releases
charitable / includes / admin / views / dashboard-widgets / donations-widget.php

donations-widget.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.6.22, at includes/admin/views/dashboard-widgets/donations-widget.php

105 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Display the donations widget on the dashboard.
4 *
5 * @author Studio 164a
6 * @package Charitable/Admin View/Dashboard Widgets
7 * @since 1.2.0
8 */
9
10 $statuses = charitable_get_valid_donation_statuses();
11
12 $donations = get_posts( array(
13 'post_type' => Charitable::DONATION_POST_TYPE,
14 'posts_per_page' => 5,
15 'post_status' => array_keys( $statuses ),
16 'fields' => 'ids',
17 ) );
18
19 $table = charitable_get_table( 'campaign_donations' );
20
21 $today = $table->get_donations_summary_by_period( date( 'Y-m-d%' ) );
22 $this_month = $table->get_donations_summary_by_period( date( 'Y-m%' ) );
23 $last_month = $table->get_donations_summary_by_period( date( 'Y-m%', strtotime( '-1 month' ) ) );
24 $this_year = $table->get_donations_summary_by_period( date( 'Y-%' ) );
25
26 ?>
27 <div class="charitable-donation-statistics">
28 <div class="cell">
29 <h3 class="amount">
30 <?php echo charitable_format_money( $today->amount ); ?>
31 </h3>
32 <p class="summary">
33 <?php
34 printf(
35 /* translators: %d: number of donations */
36 _n( '%d donation <span class="time-period">today</span>', '%d donations <span class="time-period">today</span>', $today->count, 'charitable' ),
37 $today->count
38 );
39 ?>
40 </p>
41 </div>
42 <div class="cell">
43 <h3 class="amount">
44 <?php echo charitable_format_money( $this_month->amount ); ?>
45 </h3>
46 <p class="summary">
47 <?php
48 printf(
49 /* translators: %d: number of donations */
50 _n( '%d donation <span class="time-period">this month</span>', '%d donations <span class="time-period">this month</span>', $this_month->count, 'charitable' ),
51 $this_month->count
52 );
53 ?>
54 </p>
55 </div>
56 <div class="cell">
57 <h3 class="amount">
58 <?php echo charitable_format_money( $last_month->amount ); ?>
59 </h3>
60 <p class="summary">
61 <?php
62 printf(
63 /* translators: %d: number of donations */
64 _n( '%d donation <span class="time-period">last month</span>', '%d donations <span class="time-period">last month</span>', $last_month->count, 'charitable' ),
65 $last_month->count
66 );
67 ?>
68 </p>
69 </div>
70 <div class="cell">
71 <h3 class="amount">
72 <?php echo charitable_format_money( $this_year->amount ); ?>
73 </h3>
74 <p class="summary">
75 <?php
76 printf(
77 /* translators: %d: number of donations */
78 _n( '%d donation <span class="time-period">this year</span>', '%d donations <span class="time-period">this year</span>', $this_year->count, 'charitable' ),
79 $this_year->count
80 );
81 ?>
82 </p>
83 </div>
84 </div>
85 <?php if ( count( $donations ) ) : ?>
86 <div class="recent-donations">
87 <table>
88 <caption><h3><?php _e( 'Recent Donations', 'charitable' ); ?></h3></caption>
89 <?php
90 foreach ( $donations as $donation_id ) :
91 $donation = charitable_get_donation( $donation_id );
92 ?>
93 <tr>
94 <td class="donation-date"><?php echo $donation->get_date(); ?></td>
95 <td class="donation-id">#<?php echo $donation->get_number(); ?></td>
96 <td class="donation-status"><?php echo $donation->get_status_label(); ?></td>
97 <td class="donation-total"><?php echo charitable_format_money( $donation->get_total_donation_amount() ); ?></td>
98 </tr>
99 <?php
100 endforeach;
101 ?>
102 </table>
103 </div>
104 <?php endif ?>
105