PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.12.2
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.12.2
1.8.13.1 1.8.13 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 All 212 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.8.12.2, at includes/admin/views/dashboard-widgets/donations-widget.php

143 lines 4.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // Exit if accessed directly.
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7
8 /**
9 * Display the donations widget on the dashboard.
10 *
11 * @author WP Charitable LLC
12 * @package Charitable/Admin View/Dashboard Widgets
13 * @since 1.2.0
14 * @version 1.7.0.7
15 * @version 1.8.8.6
16 */
17
18 $charitable_statuses = charitable_get_valid_donation_statuses();
19
20 $charitable_donation_args = array(
21 'post_type' => Charitable::DONATION_POST_TYPE,
22 'posts_per_page' => 5,
23 'post_status' => array_keys( $charitable_statuses ),
24 'fields' => 'ids',
25 );
26 $charitable_donation_args = apply_filters( 'charitable_donations_widget_summary_donation_args', $charitable_donation_args );
27 $charitable_donations = get_posts( $charitable_donation_args );
28
29 $charitable_table = charitable_get_table( 'campaign_donations' );
30
31 $charitable_today = $charitable_table->get_donations_summary_by_period( apply_filters( 'charitable_donations_widget_summary_today', wp_date( 'Y-m-d%' ) ) );
32 $charitable_this_month = $charitable_table->get_donations_summary_by_period( apply_filters( 'charitable_donations_widget_summary_this_month', wp_date( 'Y-m%' ) ) );
33 $charitable_last_month = $charitable_table->get_donations_summary_by_period( apply_filters( 'charitable_donations_widget_summary_last_month', wp_date( 'Y-m%', strtotime( '-1 month' ) ) ) );
34 $charitable_this_year = $charitable_table->get_donations_summary_by_period( apply_filters( 'charitable_donations_widget_summary_this_year', wp_date( 'Y-%' ) ) );
35
36 ?>
37 <div class="charitable-donation-statistics">
38 <div class="cell">
39 <h3 class="amount">
40 <?php echo charitable_format_money( $charitable_today->amount ); // phpcs:ignore ?>
41 </h3>
42 <p class="summary">
43 <?php
44 printf(
45 /* translators: %d: number of donations */
46 wp_kses(
47 _n( '%d donation <span class="time-period">today</span>', '%d donations <span class="time-period">today</span>', $charitable_today->count, 'charitable' ), // phpcs:ignore
48 array(
49 'span' => array(
50 'class' => array(),
51 ),
52 )
53 ),
54 esc_html( $charitable_today->count )
55 );
56 ?>
57 </p>
58 </div>
59 <div class="cell">
60 <h3 class="amount">
61 <?php echo charitable_format_money( $charitable_this_month->amount ); // phpcs:ignore ?>
62 </h3>
63 <p class="summary">
64 <?php
65 printf(
66 /* translators: %d: number of donations */
67 wp_kses(
68 _n( '%d donation <span class="time-period">this month</span>', '%d donations <span class="time-period">this month</span>', $charitable_this_month->count, 'charitable' ), // phpcs:ignore
69 array(
70 'span' => array(
71 'class' => array(),
72 ),
73 )
74 ),
75 esc_html( $charitable_this_month->count )
76 );
77 ?>
78 </p>
79 </div>
80 <div class="cell">
81 <h3 class="amount">
82 <?php echo charitable_format_money( $charitable_last_month->amount ); // phpcs:ignore ?>
83 </h3>
84 <p class="summary">
85 <?php
86 printf(
87 /* translators: %d: number of donations */
88 wp_kses(
89 _n( '%d donation <span class="time-period">last month</span>', '%d donations <span class="time-period">last month</span>', $charitable_last_month->count, 'charitable' ), // phpcs:ignore
90 array(
91 'span' => array(
92 'class' => array(),
93 ),
94 )
95 ),
96 esc_html( $charitable_last_month->count )
97 );
98 ?>
99 </p>
100 </div>
101 <div class="cell">
102 <h3 class="amount">
103 <?php echo charitable_format_money( $charitable_this_year->amount ); // phpcs:ignore ?>
104 </h3>
105 <p class="summary">
106 <?php
107 printf(
108 /* translators: %d: number of donations */
109 wp_kses(
110 _n( '%d donation <span class="time-period">this year</span>', '%d donations <span class="time-period">this year</span>', $charitable_this_year->count, 'charitable' ), // phpcs:ignore
111 array(
112 'span' => array(
113 'class' => array(),
114 ),
115 )
116 ),
117 esc_html( $charitable_this_year->count )
118 );
119 ?>
120 </p>
121 </div>
122 </div>
123 <?php if ( count( $charitable_donations ) ) : ?>
124 <div class="recent-donations">
125 <table>
126 <caption><h3><?php esc_html_e( 'Recent Donations', 'charitable' ); ?></h3></caption>
127 <?php
128 foreach ( $charitable_donations as $charitable_donation_id ) :
129 $charitable_donation = charitable_get_donation( $charitable_donation_id );
130 ?>
131 <tr>
132 <td class="donation-date"><?php echo esc_html( $charitable_donation->get_date() ); ?></td>
133 <td class="donation-id">#<?php echo esc_html( $charitable_donation->get_number() ); ?></td>
134 <td class="donation-status"><?php echo esc_html( $charitable_donation->get_status_label() ); ?></td>
135 <td class="donation-total"><?php echo charitable_format_money( $charitable_donation->get_total(), false, true, $charitable_donation->get_currency() ); // phpcs:ignore ?></td>
136 </tr>
137 <?php
138 endforeach;
139 ?>
140 </table>
141 </div>
142 <?php endif ?>
143