@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | $dates = give_get_report_dates(); |
27 | 27 | |
28 | 28 | // Determine graph options. |
29 | - switch ( $dates['range'] ) : |
|
29 | + switch ($dates['range']) : |
|
30 | 30 | case 'today' : |
31 | 31 | case 'yesterday' : |
32 | 32 | $day_by_day = true; |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | $day_by_day = false; |
39 | 39 | break; |
40 | 40 | case 'other' : |
41 | - if ( $dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year'] && ( $dates['m_start'] != '12' && $dates['m_end'] != '1' ) ) { |
|
41 | + if ($dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year'] && ($dates['m_start'] != '12' && $dates['m_end'] != '1')) { |
|
42 | 42 | $day_by_day = false; |
43 | 43 | } else { |
44 | 44 | $day_by_day = true; |
@@ -55,60 +55,60 @@ discard block |
||
55 | 55 | $earnings_data = array(); |
56 | 56 | $sales_data = array(); |
57 | 57 | |
58 | - if ( 'today' === $dates['range'] || 'yesterday' === $dates['range'] ) { |
|
58 | + if ('today' === $dates['range'] || 'yesterday' === $dates['range']) { |
|
59 | 59 | |
60 | 60 | // Hour by hour. |
61 | 61 | $hour = 0; |
62 | - $month = date( 'n', current_time( 'timestamp' ) ); |
|
63 | - while ( $hour <= 23 ) : |
|
62 | + $month = date('n', current_time('timestamp')); |
|
63 | + while ($hour <= 23) : |
|
64 | 64 | |
65 | - $start_date = mktime( $hour, 0, 0, $month, $dates['day'], $dates['year'] ); |
|
66 | - $end_date = mktime( $hour, 59, 59, $month, $dates['day'], $dates['year'] ); |
|
67 | - $sales = $donation_stats->get_sales( 0, $start_date, $end_date ); |
|
68 | - $earnings = $donation_stats->get_earnings( 0, $start_date, $end_date ); |
|
65 | + $start_date = mktime($hour, 0, 0, $month, $dates['day'], $dates['year']); |
|
66 | + $end_date = mktime($hour, 59, 59, $month, $dates['day'], $dates['year']); |
|
67 | + $sales = $donation_stats->get_sales(0, $start_date, $end_date); |
|
68 | + $earnings = $donation_stats->get_earnings(0, $start_date, $end_date); |
|
69 | 69 | |
70 | 70 | $sales_totals += $sales; |
71 | 71 | $earnings_totals += $earnings; |
72 | 72 | |
73 | - $sales_data[] = array( $start_date * 1000, $sales ); |
|
74 | - $earnings_data[] = array( $start_date * 1000, $earnings ); |
|
73 | + $sales_data[] = array($start_date * 1000, $sales); |
|
74 | + $earnings_data[] = array($start_date * 1000, $earnings); |
|
75 | 75 | |
76 | - $hour ++; |
|
76 | + $hour++; |
|
77 | 77 | endwhile; |
78 | 78 | |
79 | - } elseif ( 'this_week' === $dates['range'] || 'last_week' === $dates['range'] ) { |
|
79 | + } elseif ('this_week' === $dates['range'] || 'last_week' === $dates['range']) { |
|
80 | 80 | |
81 | 81 | // Day by day. |
82 | 82 | $day = $dates['day']; |
83 | 83 | $day_end = $dates['day_end']; |
84 | 84 | $month = $dates['m_start']; |
85 | - while ( $day <= $day_end ) : |
|
85 | + while ($day <= $day_end) : |
|
86 | 86 | |
87 | - $start_date = mktime( 0, 0, 0, $month, $day, $dates['year'] ); |
|
88 | - $end_date = mktime( 23, 59, 59, $month, $day, $dates['year'] ); |
|
89 | - $sales = $donation_stats->get_sales( 0, $start_date, $end_date ); |
|
90 | - $earnings = $donation_stats->get_earnings( 0, $start_date, $end_date ); |
|
87 | + $start_date = mktime(0, 0, 0, $month, $day, $dates['year']); |
|
88 | + $end_date = mktime(23, 59, 59, $month, $day, $dates['year']); |
|
89 | + $sales = $donation_stats->get_sales(0, $start_date, $end_date); |
|
90 | + $earnings = $donation_stats->get_earnings(0, $start_date, $end_date); |
|
91 | 91 | |
92 | 92 | $sales_totals += $sales; |
93 | 93 | $earnings_totals += $earnings; |
94 | 94 | |
95 | - $sales_data[] = array( $start_date * 1000, $sales ); |
|
96 | - $earnings_data[] = array( $start_date * 1000, $earnings ); |
|
97 | - $day ++; |
|
95 | + $sales_data[] = array($start_date * 1000, $sales); |
|
96 | + $earnings_data[] = array($start_date * 1000, $earnings); |
|
97 | + $day++; |
|
98 | 98 | endwhile; |
99 | 99 | |
100 | 100 | } else { |
101 | 101 | |
102 | 102 | $y = $dates['year']; |
103 | - while ( $y <= $dates['year_end'] ) : |
|
103 | + while ($y <= $dates['year_end']) : |
|
104 | 104 | |
105 | - if ( $dates['year'] === $dates['year_end'] ) { |
|
105 | + if ($dates['year'] === $dates['year_end']) { |
|
106 | 106 | $month_start = $dates['m_start']; |
107 | 107 | $month_end = $dates['m_end']; |
108 | - } elseif ( $y === $dates['year'] ) { |
|
108 | + } elseif ($y === $dates['year']) { |
|
109 | 109 | $month_start = $dates['m_start']; |
110 | 110 | $month_end = 12; |
111 | - } elseif ( $y === $dates['year_end'] ) { |
|
111 | + } elseif ($y === $dates['year_end']) { |
|
112 | 112 | $month_start = 1; |
113 | 113 | $month_end = $dates['m_end']; |
114 | 114 | } else { |
@@ -117,67 +117,67 @@ discard block |
||
117 | 117 | } |
118 | 118 | |
119 | 119 | $i = $month_start; |
120 | - while ( $i <= $month_end ) : |
|
120 | + while ($i <= $month_end) : |
|
121 | 121 | |
122 | - if ( $day_by_day ) { |
|
122 | + if ($day_by_day) { |
|
123 | 123 | |
124 | - if ( $i === $month_end ) { |
|
124 | + if ($i === $month_end) { |
|
125 | 125 | |
126 | 126 | $num_of_days = $dates['day_end']; |
127 | 127 | |
128 | 128 | } else { |
129 | 129 | |
130 | - $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
|
130 | + $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y); |
|
131 | 131 | |
132 | 132 | } |
133 | 133 | |
134 | 134 | $d = $dates['day']; |
135 | 135 | |
136 | - while ( $d <= $num_of_days ) : |
|
136 | + while ($d <= $num_of_days) : |
|
137 | 137 | |
138 | - $start_date = mktime( 0, 0, 0, $i, $d, $y ); |
|
139 | - $end_date = mktime( 23, 59, 59, $i, $d, $y ); |
|
140 | - $sales = $donation_stats->get_sales( 0, $start_date, $end_date ); |
|
141 | - $earnings = $donation_stats->get_earnings( 0, $start_date, $end_date ); |
|
138 | + $start_date = mktime(0, 0, 0, $i, $d, $y); |
|
139 | + $end_date = mktime(23, 59, 59, $i, $d, $y); |
|
140 | + $sales = $donation_stats->get_sales(0, $start_date, $end_date); |
|
141 | + $earnings = $donation_stats->get_earnings(0, $start_date, $end_date); |
|
142 | 142 | |
143 | 143 | $sales_totals += $sales; |
144 | 144 | $earnings_totals += $earnings; |
145 | 145 | |
146 | - $sales_data[] = array( $start_date * 1000, $sales ); |
|
147 | - $earnings_data[] = array( $start_date * 1000, $earnings ); |
|
146 | + $sales_data[] = array($start_date * 1000, $sales); |
|
147 | + $earnings_data[] = array($start_date * 1000, $earnings); |
|
148 | 148 | |
149 | - $d ++; |
|
149 | + $d++; |
|
150 | 150 | |
151 | 151 | endwhile; |
152 | 152 | |
153 | 153 | } else { |
154 | 154 | |
155 | 155 | // This Quarter, Last Quarter, This Year, Last Year. |
156 | - $start_date = mktime( 0, 0, 0, $i, 1, $y ); |
|
157 | - $end_date = mktime( 23, 59, 59, $i + 1, 0, $y ); |
|
158 | - $sales = $donation_stats->get_sales( 0, $start_date, $end_date ); |
|
159 | - $earnings = $donation_stats->get_earnings( 0, $start_date, $end_date ); |
|
156 | + $start_date = mktime(0, 0, 0, $i, 1, $y); |
|
157 | + $end_date = mktime(23, 59, 59, $i + 1, 0, $y); |
|
158 | + $sales = $donation_stats->get_sales(0, $start_date, $end_date); |
|
159 | + $earnings = $donation_stats->get_earnings(0, $start_date, $end_date); |
|
160 | 160 | |
161 | 161 | $sales_totals += $sales; |
162 | 162 | $earnings_totals += $earnings; |
163 | 163 | |
164 | - $sales_data[] = array( $start_date * 1000, $sales ); |
|
165 | - $earnings_data[] = array( $start_date * 1000, $earnings ); |
|
164 | + $sales_data[] = array($start_date * 1000, $sales); |
|
165 | + $earnings_data[] = array($start_date * 1000, $earnings); |
|
166 | 166 | |
167 | 167 | } |
168 | 168 | |
169 | - $i ++; |
|
169 | + $i++; |
|
170 | 170 | |
171 | 171 | endwhile; |
172 | 172 | |
173 | - $y ++; |
|
173 | + $y++; |
|
174 | 174 | endwhile; |
175 | 175 | |
176 | 176 | } |
177 | 177 | |
178 | 178 | $data = array( |
179 | - __( 'Income', 'give' ) => $earnings_data, |
|
180 | - __( 'Donations', 'give' ) => $sales_data |
|
179 | + __('Income', 'give') => $earnings_data, |
|
180 | + __('Donations', 'give') => $sales_data |
|
181 | 181 | ); |
182 | 182 | |
183 | 183 | // start our own output buffer. |
@@ -190,12 +190,12 @@ discard block |
||
190 | 190 | <div class="inside"> |
191 | 191 | <?php give_reports_graph_controls(); ?> |
192 | 192 | <?php |
193 | - $graph = new Give_Graph( $data, array( 'dataType' => array( 'amount', 'count' ) ) ); |
|
194 | - $graph->set( 'x_mode', 'time' ); |
|
195 | - $graph->set( 'multiple_y_axes', true ); |
|
193 | + $graph = new Give_Graph($data, array('dataType' => array('amount', 'count'))); |
|
194 | + $graph->set('x_mode', 'time'); |
|
195 | + $graph->set('multiple_y_axes', true); |
|
196 | 196 | $graph->display(); |
197 | 197 | |
198 | - if ( 'this_month' === $dates['range'] ) { |
|
198 | + if ('this_month' === $dates['range']) { |
|
199 | 199 | $estimated = give_estimated_monthly_stats(); |
200 | 200 | } |
201 | 201 | ?> |
@@ -204,21 +204,21 @@ discard block |
||
204 | 204 | <table class="widefat reports-table alignleft" style="max-width:450px"> |
205 | 205 | <tbody> |
206 | 206 | <tr> |
207 | - <th scope="row"><strong><?php _e( 'Total income for period:', 'give' ); ?></strong></th> |
|
208 | - <td><?php echo give_currency_filter( give_format_amount( $earnings_totals, array( 'sanitize' => false ) ) ); ?></td> |
|
207 | + <th scope="row"><strong><?php _e('Total income for period:', 'give'); ?></strong></th> |
|
208 | + <td><?php echo give_currency_filter(give_format_amount($earnings_totals, array('sanitize' => false))); ?></td> |
|
209 | 209 | </tr> |
210 | 210 | <tr class="alternate"> |
211 | - <th scope="row"><strong><?php _e( 'Total donations for period:', 'give' ); ?><strong></th> |
|
211 | + <th scope="row"><strong><?php _e('Total donations for period:', 'give'); ?><strong></th> |
|
212 | 212 | <td><?php echo $sales_totals; ?></td> |
213 | 213 | </tr> |
214 | - <?php if ( 'this_month' === $dates['range'] ) : ?> |
|
214 | + <?php if ('this_month' === $dates['range']) : ?> |
|
215 | 215 | <tr> |
216 | - <th scope="row"><strong><?php _e( 'Estimated monthly income:', 'give' ); ?></strong></th> |
|
217 | - <td><?php echo give_currency_filter( give_format_amount( $estimated['earnings'], array( 'sanitize' => false ) ) ); ?></td> |
|
216 | + <th scope="row"><strong><?php _e('Estimated monthly income:', 'give'); ?></strong></th> |
|
217 | + <td><?php echo give_currency_filter(give_format_amount($estimated['earnings'], array('sanitize' => false))); ?></td> |
|
218 | 218 | </tr> |
219 | 219 | <tr class="alternate"> |
220 | - <th scope="row"><strong><?php _e( 'Estimated monthly donations:', 'give' ); ?></strong></th> |
|
221 | - <td><?php echo floor( $estimated['sales'] ); ?></td> |
|
220 | + <th scope="row"><strong><?php _e('Estimated monthly donations:', 'give'); ?></strong></th> |
|
221 | + <td><?php echo floor($estimated['sales']); ?></td> |
|
222 | 222 | </tr> |
223 | 223 | <?php endif; ?> |
224 | 224 | </table> |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | * |
232 | 232 | * @since 1.0 |
233 | 233 | */ |
234 | - do_action( 'give_reports_graph_additional_stats' ); |
|
234 | + do_action('give_reports_graph_additional_stats'); |
|
235 | 235 | ?> |
236 | 236 | |
237 | 237 | </div> |
@@ -251,12 +251,12 @@ discard block |
||
251 | 251 | * |
252 | 252 | * @return void |
253 | 253 | */ |
254 | -function give_reports_graph_of_form( $form_id = 0 ) { |
|
254 | +function give_reports_graph_of_form($form_id = 0) { |
|
255 | 255 | // Retrieve the queried dates. |
256 | 256 | $dates = give_get_report_dates(); |
257 | 257 | |
258 | 258 | // Determine graph options. |
259 | - switch ( $dates['range'] ) : |
|
259 | + switch ($dates['range']) : |
|
260 | 260 | case 'today' : |
261 | 261 | case 'yesterday' : |
262 | 262 | $day_by_day = true; |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | $day_by_day = false; |
275 | 275 | break; |
276 | 276 | case 'other' : |
277 | - if ( $dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year'] ) { |
|
277 | + if ($dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year']) { |
|
278 | 278 | $day_by_day = false; |
279 | 279 | } else { |
280 | 280 | $day_by_day = true; |
@@ -286,75 +286,75 @@ discard block |
||
286 | 286 | endswitch; |
287 | 287 | |
288 | 288 | $earnings_totals = (float) 0.00; // Total earnings for time period shown. |
289 | - $sales_totals = 0; // Total sales for time period shown. |
|
289 | + $sales_totals = 0; // Total sales for time period shown. |
|
290 | 290 | |
291 | 291 | $earnings_data = array(); |
292 | 292 | $sales_data = array(); |
293 | 293 | $stats = new Give_Payment_Stats; |
294 | 294 | |
295 | - if ( $dates['range'] == 'today' || $dates['range'] == 'yesterday' ) { |
|
295 | + if ($dates['range'] == 'today' || $dates['range'] == 'yesterday') { |
|
296 | 296 | |
297 | 297 | // Hour by hour |
298 | 298 | $month = $dates['m_start']; |
299 | 299 | $hour = 0; |
300 | 300 | $minute = 0; |
301 | 301 | $second = 0; |
302 | - while ( $hour <= 23 ) : |
|
302 | + while ($hour <= 23) : |
|
303 | 303 | |
304 | - if ( $hour == 23 ) { |
|
304 | + if ($hour == 23) { |
|
305 | 305 | $minute = $second = 59; |
306 | 306 | } |
307 | 307 | |
308 | - $date = mktime( $hour, $minute, $second, $month, $dates['day'], $dates['year'] ); |
|
309 | - $date_end = mktime( $hour + 1, $minute, $second, $month, $dates['day'], $dates['year'] ); |
|
308 | + $date = mktime($hour, $minute, $second, $month, $dates['day'], $dates['year']); |
|
309 | + $date_end = mktime($hour + 1, $minute, $second, $month, $dates['day'], $dates['year']); |
|
310 | 310 | |
311 | - $sales = $stats->get_sales( $form_id, $date, $date_end ); |
|
311 | + $sales = $stats->get_sales($form_id, $date, $date_end); |
|
312 | 312 | $sales_totals += $sales; |
313 | 313 | |
314 | - $earnings = $stats->get_earnings( $form_id, $date, $date_end ); |
|
314 | + $earnings = $stats->get_earnings($form_id, $date, $date_end); |
|
315 | 315 | $earnings_totals += $earnings; |
316 | 316 | |
317 | - $sales_data[] = array( $date * 1000, $sales ); |
|
318 | - $earnings_data[] = array( $date * 1000, $earnings ); |
|
317 | + $sales_data[] = array($date * 1000, $sales); |
|
318 | + $earnings_data[] = array($date * 1000, $earnings); |
|
319 | 319 | |
320 | - $hour ++; |
|
320 | + $hour++; |
|
321 | 321 | endwhile; |
322 | 322 | |
323 | - } elseif ( $dates['range'] == 'this_week' || $dates['range'] == 'last_week' ) { |
|
323 | + } elseif ($dates['range'] == 'this_week' || $dates['range'] == 'last_week') { |
|
324 | 324 | |
325 | 325 | //Day by day. |
326 | 326 | $day = $dates['day']; |
327 | 327 | $day_end = $dates['day_end']; |
328 | 328 | $month = $dates['m_start']; |
329 | - while ( $day <= $day_end ) : |
|
329 | + while ($day <= $day_end) : |
|
330 | 330 | |
331 | - $date = mktime( 0, 0, 0, $month, $day, $dates['year'] ); |
|
332 | - $date_end = mktime( 0, 0, 0, $month, $day + 1, $dates['year'] ); |
|
333 | - $sales = $stats->get_sales( $form_id, $date, $date_end ); |
|
331 | + $date = mktime(0, 0, 0, $month, $day, $dates['year']); |
|
332 | + $date_end = mktime(0, 0, 0, $month, $day + 1, $dates['year']); |
|
333 | + $sales = $stats->get_sales($form_id, $date, $date_end); |
|
334 | 334 | $sales_totals += $sales; |
335 | 335 | |
336 | - $earnings = $stats->get_earnings( $form_id, $date, $date_end ); |
|
336 | + $earnings = $stats->get_earnings($form_id, $date, $date_end); |
|
337 | 337 | $earnings_totals += $earnings; |
338 | 338 | |
339 | - $sales_data[] = array( $date * 1000, $sales ); |
|
340 | - $earnings_data[] = array( $date * 1000, $earnings ); |
|
339 | + $sales_data[] = array($date * 1000, $sales); |
|
340 | + $earnings_data[] = array($date * 1000, $earnings); |
|
341 | 341 | |
342 | - $day ++; |
|
342 | + $day++; |
|
343 | 343 | endwhile; |
344 | 344 | |
345 | 345 | } else { |
346 | 346 | |
347 | 347 | $y = $dates['year']; |
348 | 348 | |
349 | - while ( $y <= $dates['year_end'] ) : |
|
349 | + while ($y <= $dates['year_end']) : |
|
350 | 350 | |
351 | 351 | $last_year = false; |
352 | 352 | |
353 | - if ( $dates['year'] == $dates['year_end'] ) { |
|
353 | + if ($dates['year'] == $dates['year_end']) { |
|
354 | 354 | $month_start = $dates['m_start']; |
355 | 355 | $month_end = $dates['m_end']; |
356 | 356 | $last_year = true; |
357 | - } elseif ( $y == $dates['year'] ) { |
|
357 | + } elseif ($y == $dates['year']) { |
|
358 | 358 | $month_start = $dates['m_start']; |
359 | 359 | $month_end = 12; |
360 | 360 | } else { |
@@ -363,76 +363,76 @@ discard block |
||
363 | 363 | } |
364 | 364 | |
365 | 365 | $i = $month_start; |
366 | - while ( $i <= $month_end ) : |
|
366 | + while ($i <= $month_end) : |
|
367 | 367 | |
368 | - if ( $day_by_day ) { |
|
368 | + if ($day_by_day) { |
|
369 | 369 | |
370 | - if ( $i == $month_end && $last_year ) { |
|
370 | + if ($i == $month_end && $last_year) { |
|
371 | 371 | |
372 | 372 | $num_of_days = $dates['day_end']; |
373 | 373 | |
374 | 374 | } else { |
375 | 375 | |
376 | - $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
|
376 | + $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y); |
|
377 | 377 | |
378 | 378 | } |
379 | 379 | |
380 | 380 | $d = $dates['day']; |
381 | - while ( $d <= $num_of_days ) : |
|
381 | + while ($d <= $num_of_days) : |
|
382 | 382 | |
383 | - $date = mktime( 0, 0, 0, $i, $d, $y ); |
|
384 | - $end_date = mktime( 23, 59, 59, $i, $d, $y ); |
|
383 | + $date = mktime(0, 0, 0, $i, $d, $y); |
|
384 | + $end_date = mktime(23, 59, 59, $i, $d, $y); |
|
385 | 385 | |
386 | - $sales = $stats->get_sales( $form_id, $date, $end_date ); |
|
386 | + $sales = $stats->get_sales($form_id, $date, $end_date); |
|
387 | 387 | $sales_totals += $sales; |
388 | 388 | |
389 | - $earnings = $stats->get_earnings( $form_id, $date, $end_date ); |
|
389 | + $earnings = $stats->get_earnings($form_id, $date, $end_date); |
|
390 | 390 | $earnings_totals += $earnings; |
391 | 391 | |
392 | - $sales_data[] = array( $date * 1000, $sales ); |
|
393 | - $earnings_data[] = array( $date * 1000, $earnings ); |
|
394 | - $d ++; |
|
392 | + $sales_data[] = array($date * 1000, $sales); |
|
393 | + $earnings_data[] = array($date * 1000, $earnings); |
|
394 | + $d++; |
|
395 | 395 | |
396 | 396 | endwhile; |
397 | 397 | |
398 | 398 | } else { |
399 | 399 | |
400 | - $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
|
400 | + $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y); |
|
401 | 401 | |
402 | - $date = mktime( 0, 0, 0, $i, 1, $y ); |
|
403 | - $end_date = mktime( 23, 59, 59, $i, $num_of_days, $y ); |
|
402 | + $date = mktime(0, 0, 0, $i, 1, $y); |
|
403 | + $end_date = mktime(23, 59, 59, $i, $num_of_days, $y); |
|
404 | 404 | |
405 | - $sales = $stats->get_sales( $form_id, $date, $end_date ); |
|
405 | + $sales = $stats->get_sales($form_id, $date, $end_date); |
|
406 | 406 | $sales_totals += $sales; |
407 | 407 | |
408 | - $earnings = $stats->get_earnings( $form_id, $date, $end_date ); |
|
408 | + $earnings = $stats->get_earnings($form_id, $date, $end_date); |
|
409 | 409 | $earnings_totals += $earnings; |
410 | 410 | |
411 | - $sales_data[] = array( $date * 1000, $sales ); |
|
412 | - $earnings_data[] = array( $date * 1000, $earnings ); |
|
411 | + $sales_data[] = array($date * 1000, $sales); |
|
412 | + $earnings_data[] = array($date * 1000, $earnings); |
|
413 | 413 | |
414 | 414 | } |
415 | 415 | |
416 | - $i ++; |
|
416 | + $i++; |
|
417 | 417 | |
418 | 418 | endwhile; |
419 | 419 | |
420 | - $y ++; |
|
420 | + $y++; |
|
421 | 421 | endwhile; |
422 | 422 | |
423 | 423 | } |
424 | 424 | |
425 | 425 | $data = array( |
426 | - __( 'Income', 'give' ) => $earnings_data, |
|
427 | - __( 'Donations', 'give' ) => $sales_data |
|
426 | + __('Income', 'give') => $earnings_data, |
|
427 | + __('Donations', 'give') => $sales_data |
|
428 | 428 | ); |
429 | 429 | |
430 | 430 | ?> |
431 | 431 | <h3><span><?php |
432 | 432 | printf( |
433 | 433 | /* translators: %s: form title */ |
434 | - esc_html__( 'Income Report for %s', 'give' ), |
|
435 | - get_the_title( $form_id ) |
|
434 | + esc_html__('Income Report for %s', 'give'), |
|
435 | + get_the_title($form_id) |
|
436 | 436 | ); |
437 | 437 | ?></span></h3> |
438 | 438 | <div id="give-dashboard-widgets-wrap"> |
@@ -441,9 +441,9 @@ discard block |
||
441 | 441 | <div class="inside"> |
442 | 442 | <?php give_reports_graph_controls(); ?> |
443 | 443 | <?php |
444 | - $graph = new Give_Graph( $data, array( 'dataType' => array( 'amount', 'count' ) ) ); |
|
445 | - $graph->set( 'x_mode', 'time' ); |
|
446 | - $graph->set( 'multiple_y_axes', true ); |
|
444 | + $graph = new Give_Graph($data, array('dataType' => array('amount', 'count'))); |
|
445 | + $graph->set('x_mode', 'time'); |
|
446 | + $graph->set('multiple_y_axes', true); |
|
447 | 447 | $graph->display(); |
448 | 448 | ?> |
449 | 449 | </div> |
@@ -452,20 +452,20 @@ discard block |
||
452 | 452 | <table class="widefat reports-table alignleft" style="max-width:450px"> |
453 | 453 | <tbody> |
454 | 454 | <tr> |
455 | - <th scope="row"><strong><?php _e( 'Total income for period:', 'give' ); ?></strong></th> |
|
456 | - <td><?php echo give_currency_filter( give_format_amount( $earnings_totals, array( 'sanitize' => false ) ) ); ?></td> |
|
455 | + <th scope="row"><strong><?php _e('Total income for period:', 'give'); ?></strong></th> |
|
456 | + <td><?php echo give_currency_filter(give_format_amount($earnings_totals, array('sanitize' => false))); ?></td> |
|
457 | 457 | </tr> |
458 | 458 | <tr class="alternate"> |
459 | - <th scope="row"><strong><?php _e( 'Total donations for period:', 'give' ); ?></strong></th> |
|
459 | + <th scope="row"><strong><?php _e('Total donations for period:', 'give'); ?></strong></th> |
|
460 | 460 | <td><?php echo $sales_totals; ?></td> |
461 | 461 | </tr> |
462 | 462 | <tr> |
463 | - <th scope="row"><strong><?php _e( 'Average monthly income:', 'give' ); ?></strong></th> |
|
464 | - <td><?php echo give_currency_filter( give_format_amount( give_get_average_monthly_form_earnings( $form_id ), array( 'sanitize' => false ) ) ); ?></td> |
|
463 | + <th scope="row"><strong><?php _e('Average monthly income:', 'give'); ?></strong></th> |
|
464 | + <td><?php echo give_currency_filter(give_format_amount(give_get_average_monthly_form_earnings($form_id), array('sanitize' => false))); ?></td> |
|
465 | 465 | </tr> |
466 | 466 | <tr class="alternate"> |
467 | - <th scope="row"><strong><?php _e( 'Average monthly donations:', 'give' ); ?></strong></th> |
|
468 | - <td><?php echo number_format( give_get_average_monthly_form_sales( $form_id ), 0 ); ?></td> |
|
467 | + <th scope="row"><strong><?php _e('Average monthly donations:', 'give'); ?></strong></th> |
|
468 | + <td><?php echo number_format(give_get_average_monthly_form_sales($form_id), 0); ?></td> |
|
469 | 469 | </tr> |
470 | 470 | </tbody> |
471 | 471 | </table> |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | * |
479 | 479 | * @since 2.2.1 |
480 | 480 | */ |
481 | - do_action( 'give_reports_graph_additional_stats' ); |
|
481 | + do_action('give_reports_graph_additional_stats'); |
|
482 | 482 | ?> |
483 | 483 | |
484 | 484 | </div> |
@@ -496,26 +496,26 @@ discard block |
||
496 | 496 | * @return void |
497 | 497 | */ |
498 | 498 | function give_reports_graph_controls() { |
499 | - $date_options = apply_filters( 'give_report_date_options', array( |
|
500 | - 'today' => __( 'Today', 'give' ), |
|
501 | - 'yesterday' => __( 'Yesterday', 'give' ), |
|
502 | - 'this_week' => __( 'This Week', 'give' ), |
|
503 | - 'last_week' => __( 'Last Week', 'give' ), |
|
504 | - 'this_month' => __( 'This Month', 'give' ), |
|
505 | - 'last_month' => __( 'Last Month', 'give' ), |
|
506 | - 'this_quarter' => __( 'This Quarter', 'give' ), |
|
507 | - 'last_quarter' => __( 'Last Quarter', 'give' ), |
|
508 | - 'this_year' => __( 'This Year', 'give' ), |
|
509 | - 'last_year' => __( 'Last Year', 'give' ), |
|
510 | - 'other' => __( 'Custom', 'give' ) |
|
511 | - ) ); |
|
499 | + $date_options = apply_filters('give_report_date_options', array( |
|
500 | + 'today' => __('Today', 'give'), |
|
501 | + 'yesterday' => __('Yesterday', 'give'), |
|
502 | + 'this_week' => __('This Week', 'give'), |
|
503 | + 'last_week' => __('Last Week', 'give'), |
|
504 | + 'this_month' => __('This Month', 'give'), |
|
505 | + 'last_month' => __('Last Month', 'give'), |
|
506 | + 'this_quarter' => __('This Quarter', 'give'), |
|
507 | + 'last_quarter' => __('Last Quarter', 'give'), |
|
508 | + 'this_year' => __('This Year', 'give'), |
|
509 | + 'last_year' => __('Last Year', 'give'), |
|
510 | + 'other' => __('Custom', 'give') |
|
511 | + )); |
|
512 | 512 | |
513 | 513 | $dates = give_get_report_dates(); |
514 | 514 | $display = $dates['range'] == 'other' ? '' : 'display: none;'; |
515 | - $tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'earnings'; |
|
515 | + $tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'earnings'; |
|
516 | 516 | |
517 | - if ( empty( $dates['day_end'] ) ) { |
|
518 | - $dates['day_end'] = cal_days_in_month( CAL_GREGORIAN, date( 'n' ), date( 'Y' ) ); |
|
517 | + if (empty($dates['day_end'])) { |
|
518 | + $dates['day_end'] = cal_days_in_month(CAL_GREGORIAN, date('n'), date('Y')); |
|
519 | 519 | } |
520 | 520 | |
521 | 521 | /** |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | * |
524 | 524 | * @since 1.0 |
525 | 525 | */ |
526 | - do_action( 'give_report_graph_controls_before' ); |
|
526 | + do_action('give_report_graph_controls_before'); |
|
527 | 527 | ?> |
528 | 528 | <form id="give-graphs-filter" method="get"> |
529 | 529 | <div class="tablenav top"> |
@@ -531,56 +531,56 @@ discard block |
||
531 | 531 | |
532 | 532 | <input type="hidden" name="post_type" value="give_forms" /> |
533 | 533 | <input type="hidden" name="page" value="give-reports" /> |
534 | - <input type="hidden" name="tab" value="<?php echo esc_attr( $tab ); ?>" /> |
|
534 | + <input type="hidden" name="tab" value="<?php echo esc_attr($tab); ?>" /> |
|
535 | 535 | |
536 | - <?php if ( isset( $_GET['form-id'] ) ) : ?> |
|
537 | - <input type="hidden" name="form-id" value="<?php echo absint( $_GET['form-id'] ); ?>" /> |
|
536 | + <?php if (isset($_GET['form-id'])) : ?> |
|
537 | + <input type="hidden" name="form-id" value="<?php echo absint($_GET['form-id']); ?>" /> |
|
538 | 538 | <?php endif; ?> |
539 | 539 | |
540 | 540 | <div id="give-graphs-date-options-wrap"> |
541 | 541 | <select id="give-graphs-date-options" name="range"> |
542 | - <?php foreach ( $date_options as $key => $option ) : ?> |
|
543 | - <option value="<?php echo esc_attr( $key ); ?>"<?php selected( $key, $dates['range'] ); ?>><?php echo esc_html( $option ); ?></option> |
|
542 | + <?php foreach ($date_options as $key => $option) : ?> |
|
543 | + <option value="<?php echo esc_attr($key); ?>"<?php selected($key, $dates['range']); ?>><?php echo esc_html($option); ?></option> |
|
544 | 544 | <?php endforeach; ?> |
545 | 545 | </select> |
546 | 546 | |
547 | - <div id="give-date-range-options" style="<?php echo esc_attr( $display ); ?>"> |
|
548 | - <span class="screen-reader-text"><?php _e( 'From', 'give' ); ?> </span> |
|
547 | + <div id="give-date-range-options" style="<?php echo esc_attr($display); ?>"> |
|
548 | + <span class="screen-reader-text"><?php _e('From', 'give'); ?> </span> |
|
549 | 549 | <select id="give-graphs-month-start" name="m_start" aria-label="Start Month"> |
550 | - <?php for ( $i = 1; $i <= 12; $i ++ ) : ?> |
|
551 | - <option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['m_start'] ) ); ?>><?php echo esc_html( give_month_num_to_name( $i ) ); ?></option> |
|
550 | + <?php for ($i = 1; $i <= 12; $i++) : ?> |
|
551 | + <option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['m_start'])); ?>><?php echo esc_html(give_month_num_to_name($i)); ?></option> |
|
552 | 552 | <?php endfor; ?> |
553 | 553 | </select> |
554 | 554 | <select id="give-graphs-day-start" name="day" aria-label="Start Day"> |
555 | - <?php for ( $i = 1; $i <= 31; $i ++ ) : ?> |
|
556 | - <option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['day'] ) ); ?>><?php echo esc_html( $i ); ?></option> |
|
555 | + <?php for ($i = 1; $i <= 31; $i++) : ?> |
|
556 | + <option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['day'])); ?>><?php echo esc_html($i); ?></option> |
|
557 | 557 | <?php endfor; ?> |
558 | 558 | </select> |
559 | 559 | <select id="give-graphs-year-start" name="year" aria-label="Start Year"> |
560 | - <?php for ( $i = 2007; $i <= date( 'Y' ); $i ++ ) : ?> |
|
561 | - <option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['year'] ) ); ?>><?php echo esc_html( $i ); ?></option> |
|
560 | + <?php for ($i = 2007; $i <= date('Y'); $i++) : ?> |
|
561 | + <option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['year'])); ?>><?php echo esc_html($i); ?></option> |
|
562 | 562 | <?php endfor; ?> |
563 | 563 | </select> |
564 | - <span class="screen-reader-text"><?php esc_html_e( 'To', 'give' ); ?> </span> |
|
564 | + <span class="screen-reader-text"><?php esc_html_e('To', 'give'); ?> </span> |
|
565 | 565 | <span>–</span> |
566 | 566 | <select id="give-graphs-month-end" name="m_end" aria-label="End Month"> |
567 | - <?php for ( $i = 1; $i <= 12; $i ++ ) : ?> |
|
568 | - <option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['m_end'] ) ); ?>><?php echo esc_html( give_month_num_to_name( $i ) ); ?></option> |
|
567 | + <?php for ($i = 1; $i <= 12; $i++) : ?> |
|
568 | + <option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['m_end'])); ?>><?php echo esc_html(give_month_num_to_name($i)); ?></option> |
|
569 | 569 | <?php endfor; ?> |
570 | 570 | </select> |
571 | 571 | <select id="give-graphs-day-end" name="day_end" aria-label="End Day"> |
572 | - <?php for ( $i = 1; $i <= 31; $i ++ ) : ?> |
|
573 | - <option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['day_end'] ) ); ?>><?php echo esc_html( $i ); ?></option> |
|
572 | + <?php for ($i = 1; $i <= 31; $i++) : ?> |
|
573 | + <option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['day_end'])); ?>><?php echo esc_html($i); ?></option> |
|
574 | 574 | <?php endfor; ?> |
575 | 575 | </select> |
576 | 576 | <select id="give-graphs-year-end" name="year_end" aria-label="End Year"> |
577 | - <?php for ( $i = 2007; $i <= date( 'Y' ); $i ++ ) : ?> |
|
578 | - <option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['year_end'] ) ); ?>><?php echo esc_html( $i ); ?></option> |
|
577 | + <?php for ($i = 2007; $i <= date('Y'); $i++) : ?> |
|
578 | + <option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['year_end'])); ?>><?php echo esc_html($i); ?></option> |
|
579 | 579 | <?php endfor; ?> |
580 | 580 | </select> |
581 | 581 | </div> |
582 | 582 | |
583 | - <input type="submit" class="button-secondary" value="<?php _e( 'Filter', 'give' ); ?>" /> |
|
583 | + <input type="submit" class="button-secondary" value="<?php _e('Filter', 'give'); ?>" /> |
|
584 | 584 | </div> |
585 | 585 | |
586 | 586 | <input type="hidden" name="give_action" value="filter_reports" /> |
@@ -593,7 +593,7 @@ discard block |
||
593 | 593 | * |
594 | 594 | * @since 1.0 |
595 | 595 | */ |
596 | - do_action( 'give_report_graph_controls_after' ); |
|
596 | + do_action('give_report_graph_controls_after'); |
|
597 | 597 | } |
598 | 598 | |
599 | 599 | /** |
@@ -609,67 +609,67 @@ discard block |
||
609 | 609 | function give_get_report_dates() { |
610 | 610 | $dates = array(); |
611 | 611 | |
612 | - $current_time = current_time( 'timestamp' ); |
|
612 | + $current_time = current_time('timestamp'); |
|
613 | 613 | |
614 | - $dates['range'] = isset( $_GET['range'] ) ? $_GET['range'] : 'this_month'; |
|
615 | - $dates['year'] = isset( $_GET['year'] ) ? $_GET['year'] : date( 'Y' ); |
|
616 | - $dates['year_end'] = isset( $_GET['year_end'] ) ? $_GET['year_end'] : date( 'Y' ); |
|
617 | - $dates['m_start'] = isset( $_GET['m_start'] ) ? $_GET['m_start'] : 1; |
|
618 | - $dates['m_end'] = isset( $_GET['m_end'] ) ? $_GET['m_end'] : 12; |
|
619 | - $dates['day'] = isset( $_GET['day'] ) ? $_GET['day'] : 1; |
|
620 | - $dates['day_end'] = isset( $_GET['day_end'] ) ? $_GET['day_end'] : cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] ); |
|
614 | + $dates['range'] = isset($_GET['range']) ? $_GET['range'] : 'this_month'; |
|
615 | + $dates['year'] = isset($_GET['year']) ? $_GET['year'] : date('Y'); |
|
616 | + $dates['year_end'] = isset($_GET['year_end']) ? $_GET['year_end'] : date('Y'); |
|
617 | + $dates['m_start'] = isset($_GET['m_start']) ? $_GET['m_start'] : 1; |
|
618 | + $dates['m_end'] = isset($_GET['m_end']) ? $_GET['m_end'] : 12; |
|
619 | + $dates['day'] = isset($_GET['day']) ? $_GET['day'] : 1; |
|
620 | + $dates['day_end'] = isset($_GET['day_end']) ? $_GET['day_end'] : cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']); |
|
621 | 621 | |
622 | 622 | // Modify dates based on predefined ranges. |
623 | - switch ( $dates['range'] ) : |
|
623 | + switch ($dates['range']) : |
|
624 | 624 | |
625 | 625 | case 'this_month' : |
626 | - $dates['m_start'] = date( 'n', $current_time ); |
|
627 | - $dates['m_end'] = date( 'n', $current_time ); |
|
626 | + $dates['m_start'] = date('n', $current_time); |
|
627 | + $dates['m_end'] = date('n', $current_time); |
|
628 | 628 | $dates['day'] = 1; |
629 | - $dates['day_end'] = cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] ); |
|
630 | - $dates['year'] = date( 'Y' ); |
|
631 | - $dates['year_end'] = date( 'Y' ); |
|
629 | + $dates['day_end'] = cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']); |
|
630 | + $dates['year'] = date('Y'); |
|
631 | + $dates['year_end'] = date('Y'); |
|
632 | 632 | break; |
633 | 633 | |
634 | 634 | case 'last_month' : |
635 | - if ( date( 'n' ) == 1 ) { |
|
635 | + if (date('n') == 1) { |
|
636 | 636 | $dates['m_start'] = 12; |
637 | 637 | $dates['m_end'] = 12; |
638 | - $dates['year'] = date( 'Y', $current_time ) - 1; |
|
639 | - $dates['year_end'] = date( 'Y', $current_time ) - 1; |
|
638 | + $dates['year'] = date('Y', $current_time) - 1; |
|
639 | + $dates['year_end'] = date('Y', $current_time) - 1; |
|
640 | 640 | } else { |
641 | - $dates['m_start'] = date( 'n' ) - 1; |
|
642 | - $dates['m_end'] = date( 'n' ) - 1; |
|
641 | + $dates['m_start'] = date('n') - 1; |
|
642 | + $dates['m_end'] = date('n') - 1; |
|
643 | 643 | $dates['year_end'] = $dates['year']; |
644 | 644 | } |
645 | - $dates['day_end'] = cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] ); |
|
645 | + $dates['day_end'] = cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']); |
|
646 | 646 | break; |
647 | 647 | |
648 | 648 | case 'today' : |
649 | - $dates['day'] = date( 'd', $current_time ); |
|
650 | - $dates['day_end'] = date( 'd', $current_time ); |
|
651 | - $dates['m_start'] = date( 'n', $current_time ); |
|
652 | - $dates['m_end'] = date( 'n', $current_time ); |
|
653 | - $dates['year'] = date( 'Y', $current_time ); |
|
654 | - $dates['year_end'] = date( 'Y', $current_time ); |
|
649 | + $dates['day'] = date('d', $current_time); |
|
650 | + $dates['day_end'] = date('d', $current_time); |
|
651 | + $dates['m_start'] = date('n', $current_time); |
|
652 | + $dates['m_end'] = date('n', $current_time); |
|
653 | + $dates['year'] = date('Y', $current_time); |
|
654 | + $dates['year_end'] = date('Y', $current_time); |
|
655 | 655 | break; |
656 | 656 | |
657 | 657 | case 'yesterday' : |
658 | 658 | |
659 | - $year = date( 'Y', $current_time ); |
|
660 | - $month = date( 'n', $current_time ); |
|
661 | - $day = date( 'd', $current_time ); |
|
659 | + $year = date('Y', $current_time); |
|
660 | + $month = date('n', $current_time); |
|
661 | + $day = date('d', $current_time); |
|
662 | 662 | |
663 | - if ( $month == 1 && $day == 1 ) { |
|
663 | + if ($month == 1 && $day == 1) { |
|
664 | 664 | |
665 | 665 | $year -= 1; |
666 | 666 | $month = 12; |
667 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
667 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
668 | 668 | |
669 | - } elseif ( $month > 1 && $day == 1 ) { |
|
669 | + } elseif ($month > 1 && $day == 1) { |
|
670 | 670 | |
671 | 671 | $month -= 1; |
672 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
672 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
673 | 673 | |
674 | 674 | } else { |
675 | 675 | |
@@ -685,48 +685,48 @@ discard block |
||
685 | 685 | break; |
686 | 686 | |
687 | 687 | case 'this_week' : |
688 | - $dates['day'] = date( 'd', $current_time - ( date( 'w', $current_time ) - 1 ) * 60 * 60 * 24 ) - 1; |
|
689 | - $dates['day'] += get_option( 'start_of_week' ); |
|
688 | + $dates['day'] = date('d', $current_time - (date('w', $current_time) - 1) * 60 * 60 * 24) - 1; |
|
689 | + $dates['day'] += get_option('start_of_week'); |
|
690 | 690 | $dates['day_end'] = $dates['day'] + 6; |
691 | - $dates['m_start'] = date( 'n', $current_time ); |
|
692 | - $dates['m_end'] = date( 'n', $current_time ); |
|
693 | - $dates['year'] = date( 'Y', $current_time ); |
|
691 | + $dates['m_start'] = date('n', $current_time); |
|
692 | + $dates['m_end'] = date('n', $current_time); |
|
693 | + $dates['year'] = date('Y', $current_time); |
|
694 | 694 | break; |
695 | 695 | |
696 | 696 | case 'last_week' : |
697 | - $dates['day'] = date( 'd', $current_time - ( date( 'w' ) - 1 ) * 60 * 60 * 24 ) - 8; |
|
698 | - $dates['day'] += get_option( 'start_of_week' ); |
|
697 | + $dates['day'] = date('d', $current_time - (date('w') - 1) * 60 * 60 * 24) - 8; |
|
698 | + $dates['day'] += get_option('start_of_week'); |
|
699 | 699 | $dates['day_end'] = $dates['day'] + 6; |
700 | - $dates['year'] = date( 'Y' ); |
|
701 | - |
|
702 | - if ( date( 'j', $current_time ) <= 7 ) { |
|
703 | - $dates['m_start'] = date( 'n', $current_time ) - 1; |
|
704 | - $dates['m_end'] = date( 'n', $current_time ) - 1; |
|
705 | - if ( $dates['m_start'] <= 1 ) { |
|
706 | - $dates['year'] = date( 'Y', $current_time ) - 1; |
|
707 | - $dates['year_end'] = date( 'Y', $current_time ) - 1; |
|
700 | + $dates['year'] = date('Y'); |
|
701 | + |
|
702 | + if (date('j', $current_time) <= 7) { |
|
703 | + $dates['m_start'] = date('n', $current_time) - 1; |
|
704 | + $dates['m_end'] = date('n', $current_time) - 1; |
|
705 | + if ($dates['m_start'] <= 1) { |
|
706 | + $dates['year'] = date('Y', $current_time) - 1; |
|
707 | + $dates['year_end'] = date('Y', $current_time) - 1; |
|
708 | 708 | } |
709 | 709 | } else { |
710 | - $dates['m_start'] = date( 'n', $current_time ); |
|
711 | - $dates['m_end'] = date( 'n', $current_time ); |
|
710 | + $dates['m_start'] = date('n', $current_time); |
|
711 | + $dates['m_end'] = date('n', $current_time); |
|
712 | 712 | } |
713 | 713 | break; |
714 | 714 | |
715 | 715 | case 'this_quarter' : |
716 | - $month_now = date( 'n', $current_time ); |
|
717 | - $dates['year'] = date( 'Y', $current_time ); |
|
716 | + $month_now = date('n', $current_time); |
|
717 | + $dates['year'] = date('Y', $current_time); |
|
718 | 718 | |
719 | - if ( $month_now <= 3 ) { |
|
719 | + if ($month_now <= 3) { |
|
720 | 720 | |
721 | 721 | $dates['m_start'] = 1; |
722 | 722 | $dates['m_end'] = 4; |
723 | 723 | |
724 | - } else if ( $month_now <= 6 ) { |
|
724 | + } else if ($month_now <= 6) { |
|
725 | 725 | |
726 | 726 | $dates['m_start'] = 4; |
727 | 727 | $dates['m_end'] = 7; |
728 | 728 | |
729 | - } else if ( $month_now <= 9 ) { |
|
729 | + } else if ($month_now <= 9) { |
|
730 | 730 | |
731 | 731 | $dates['m_start'] = 7; |
732 | 732 | $dates['m_end'] = 10; |
@@ -735,28 +735,28 @@ discard block |
||
735 | 735 | |
736 | 736 | $dates['m_start'] = 10; |
737 | 737 | $dates['m_end'] = 1; |
738 | - $dates['year_end'] = date( 'Y', $current_time ) + 1; |
|
738 | + $dates['year_end'] = date('Y', $current_time) + 1; |
|
739 | 739 | |
740 | 740 | } |
741 | 741 | break; |
742 | 742 | |
743 | 743 | case 'last_quarter' : |
744 | - $month_now = date( 'n', $current_time ); |
|
745 | - $dates['year'] = date( 'Y', $current_time ); |
|
746 | - $dates['year_end'] = date( 'Y', $current_time ); |
|
744 | + $month_now = date('n', $current_time); |
|
745 | + $dates['year'] = date('Y', $current_time); |
|
746 | + $dates['year_end'] = date('Y', $current_time); |
|
747 | 747 | |
748 | - if ( $month_now <= 3 ) { |
|
748 | + if ($month_now <= 3) { |
|
749 | 749 | |
750 | 750 | $dates['m_start'] = 10; |
751 | 751 | $dates['m_end'] = 1; |
752 | - $dates['year'] = date( 'Y', $current_time ) - 1; // Previous year. |
|
752 | + $dates['year'] = date('Y', $current_time) - 1; // Previous year. |
|
753 | 753 | |
754 | - } else if ( $month_now <= 6 ) { |
|
754 | + } else if ($month_now <= 6) { |
|
755 | 755 | |
756 | 756 | $dates['m_start'] = 1; |
757 | 757 | $dates['m_end'] = 4; |
758 | 758 | |
759 | - } else if ( $month_now <= 9 ) { |
|
759 | + } else if ($month_now <= 9) { |
|
760 | 760 | |
761 | 761 | $dates['m_start'] = 4; |
762 | 762 | $dates['m_end'] = 7; |
@@ -772,20 +772,20 @@ discard block |
||
772 | 772 | case 'this_year' : |
773 | 773 | $dates['m_start'] = 1; |
774 | 774 | $dates['m_end'] = 12; |
775 | - $dates['year'] = date( 'Y', $current_time ); |
|
776 | - $dates['year_end'] = date( 'Y', $current_time ); |
|
775 | + $dates['year'] = date('Y', $current_time); |
|
776 | + $dates['year_end'] = date('Y', $current_time); |
|
777 | 777 | break; |
778 | 778 | |
779 | 779 | case 'last_year' : |
780 | 780 | $dates['m_start'] = 1; |
781 | 781 | $dates['m_end'] = 12; |
782 | - $dates['year'] = date( 'Y', $current_time ) - 1; |
|
783 | - $dates['year_end'] = date( 'Y', $current_time ) - 1; |
|
782 | + $dates['year'] = date('Y', $current_time) - 1; |
|
783 | + $dates['year_end'] = date('Y', $current_time) - 1; |
|
784 | 784 | break; |
785 | 785 | |
786 | 786 | endswitch; |
787 | 787 | |
788 | - return apply_filters( 'give_report_dates', $dates ); |
|
788 | + return apply_filters('give_report_dates', $dates); |
|
789 | 789 | } |
790 | 790 | |
791 | 791 | /** |
@@ -796,18 +796,18 @@ discard block |
||
796 | 796 | * |
797 | 797 | * @param $data |
798 | 798 | */ |
799 | -function give_parse_report_dates( $data ) { |
|
799 | +function give_parse_report_dates($data) { |
|
800 | 800 | $dates = give_get_report_dates(); |
801 | 801 | |
802 | 802 | $view = give_get_reporting_view(); |
803 | - $tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'earnings'; |
|
804 | - $id = isset( $_GET['form-id'] ) ? $_GET['form-id'] : null; |
|
803 | + $tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'earnings'; |
|
804 | + $id = isset($_GET['form-id']) ? $_GET['form-id'] : null; |
|
805 | 805 | |
806 | - wp_redirect( add_query_arg( $dates, admin_url( 'edit.php?post_type=give_forms&page=give-reports&tab=' . esc_attr( $tab ) . '&view=' . esc_attr( $view ) . '&form-id=' . absint( $id ) ) ) ); |
|
806 | + wp_redirect(add_query_arg($dates, admin_url('edit.php?post_type=give_forms&page=give-reports&tab='.esc_attr($tab).'&view='.esc_attr($view).'&form-id='.absint($id)))); |
|
807 | 807 | give_die(); |
808 | 808 | } |
809 | 809 | |
810 | -add_action( 'give_filter_reports', 'give_parse_report_dates' ); |
|
810 | +add_action('give_filter_reports', 'give_parse_report_dates'); |
|
811 | 811 | |
812 | 812 | |
813 | 813 | /** |
@@ -819,23 +819,23 @@ discard block |
||
819 | 819 | */ |
820 | 820 | function give_reports_refresh_button() { |
821 | 821 | |
822 | - $url = wp_nonce_url( add_query_arg( array( |
|
822 | + $url = wp_nonce_url(add_query_arg(array( |
|
823 | 823 | 'give_action' => 'refresh_reports_transients', |
824 | 824 | 'give-messages[]' => 'refreshed-reports' |
825 | - ) ), 'give-refresh-reports' ); |
|
825 | + )), 'give-refresh-reports'); |
|
826 | 826 | |
827 | - echo Give()->tooltips->render_link( array( |
|
828 | - 'label' => esc_attr__( 'Clicking this will clear the reports cache.', 'give' ), |
|
829 | - 'tag_content' => '<span class="give-admin-button-icon give-admin-button-icon-update"></span>' . esc_html__( 'Refresh Report Data', 'give' ), |
|
827 | + echo Give()->tooltips->render_link(array( |
|
828 | + 'label' => esc_attr__('Clicking this will clear the reports cache.', 'give'), |
|
829 | + 'tag_content' => '<span class="give-admin-button-icon give-admin-button-icon-update"></span>'.esc_html__('Refresh Report Data', 'give'), |
|
830 | 830 | 'link' => $url, |
831 | 831 | 'position' => 'left', |
832 | 832 | 'attributes' => array( |
833 | 833 | 'class' => 'button alignright give-admin-button' |
834 | 834 | ) |
835 | - ) ); |
|
835 | + )); |
|
836 | 836 | } |
837 | 837 | |
838 | -add_action( 'give_reports_graph_additional_stats', 'give_reports_refresh_button' ); |
|
838 | +add_action('give_reports_graph_additional_stats', 'give_reports_refresh_button'); |
|
839 | 839 | |
840 | 840 | /** |
841 | 841 | * Trigger the refresh of reports transients |
@@ -846,20 +846,20 @@ discard block |
||
846 | 846 | * |
847 | 847 | * @return void |
848 | 848 | */ |
849 | -function give_run_refresh_reports_transients( $data ) { |
|
849 | +function give_run_refresh_reports_transients($data) { |
|
850 | 850 | |
851 | - if ( ! wp_verify_nonce( $data['_wpnonce'], 'give-refresh-reports' ) ) { |
|
851 | + if ( ! wp_verify_nonce($data['_wpnonce'], 'give-refresh-reports')) { |
|
852 | 852 | return; |
853 | 853 | } |
854 | 854 | |
855 | 855 | // Monthly stats. |
856 | - Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) ); |
|
856 | + Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats')); |
|
857 | 857 | |
858 | 858 | // Total earning. |
859 | - delete_option( 'give_earnings_total' ); |
|
859 | + delete_option('give_earnings_total'); |
|
860 | 860 | |
861 | 861 | // @todo: Refresh only range related stat cache |
862 | 862 | give_delete_donation_stats(); |
863 | 863 | } |
864 | 864 | |
865 | -add_action( 'give_refresh_reports_transients', 'give_run_refresh_reports_transients' ); |
|
866 | 865 | \ No newline at end of file |
866 | +add_action('give_refresh_reports_transients', 'give_run_refresh_reports_transients'); |
|
867 | 867 | \ No newline at end of file |