Test Failed
Pull Request — master (#1942)
by Devin
05:03
created
includes/admin/reports/graphing.php 1 patch
Spacing   +246 added lines, -246 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
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
 
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	$dates = give_get_report_dates();
26 26
 
27 27
 	// Determine graph options
28
-	switch ( $dates['range'] ) :
28
+	switch ($dates['range']) :
29 29
 		case 'today' :
30 30
 		case 'yesterday' :
31 31
 			$day_by_day = true;
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 			$day_by_day = false;
38 38
 			break;
39 39
 		case 'other' :
40
-			if ( $dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year'] && ( $dates['m_start'] != '12' && $dates['m_end'] != '1' ) ) {
40
+			if ($dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year'] && ($dates['m_start'] != '12' && $dates['m_end'] != '1')) {
41 41
 				$day_by_day = false;
42 42
 			} else {
43 43
 				$day_by_day = true;
@@ -49,61 +49,61 @@  discard block
 block discarded – undo
49 49
 	endswitch;
50 50
 
51 51
 	$earnings_totals = 0.00; // Total earnings for time period shown
52
-	$sales_totals    = 0;            // Total sales for time period shown
52
+	$sales_totals    = 0; // Total sales for time period shown
53 53
 
54 54
 	$earnings_data = array();
55 55
 	$sales_data    = array();
56 56
 
57
-	if ( $dates['range'] == 'today' || $dates['range'] == 'yesterday' ) {
57
+	if ($dates['range'] == 'today' || $dates['range'] == 'yesterday') {
58 58
 		// Hour by hour
59 59
 		$hour  = 1;
60
-		$month = date( 'n', current_time( 'timestamp' ) );
61
-		while ( $hour <= 23 ) :
60
+		$month = date('n', current_time('timestamp'));
61
+		while ($hour <= 23) :
62 62
 
63
-			$sales    = give_get_sales_by_date( $dates['day'], $month, $dates['year'], $hour );
64
-			$earnings = give_get_earnings_by_date( $dates['day'], $month, $dates['year'], $hour );
63
+			$sales    = give_get_sales_by_date($dates['day'], $month, $dates['year'], $hour);
64
+			$earnings = give_get_earnings_by_date($dates['day'], $month, $dates['year'], $hour);
65 65
 
66 66
 			$sales_totals += $sales;
67 67
 			$earnings_totals += $earnings;
68 68
 
69
-			$date            = mktime( $hour, 0, 0, $month, $dates['day'], $dates['year'] ) * 1000;
70
-			$sales_data[]    = array( $date, $sales );
71
-			$earnings_data[] = array( $date, $earnings );
69
+			$date            = mktime($hour, 0, 0, $month, $dates['day'], $dates['year']) * 1000;
70
+			$sales_data[]    = array($date, $sales);
71
+			$earnings_data[] = array($date, $earnings);
72 72
 
73
-			$hour ++;
73
+			$hour++;
74 74
 		endwhile;
75 75
 
76
-	} elseif ( $dates['range'] == 'this_week' || $dates['range'] == 'last_week' ) {
76
+	} elseif ($dates['range'] == 'this_week' || $dates['range'] == 'last_week') {
77 77
 
78 78
 		// Day by day
79 79
 		$day     = $dates['day'];
80 80
 		$day_end = $dates['day_end'];
81 81
 		$month   = $dates['m_start'];
82
-		while ( $day <= $day_end ) :
83
-			$sales = give_get_sales_by_date( $day, $month, $dates['year'] );
82
+		while ($day <= $day_end) :
83
+			$sales = give_get_sales_by_date($day, $month, $dates['year']);
84 84
 			$sales_totals += $sales;
85 85
 
86
-			$earnings = give_get_earnings_by_date( $day, $month, $dates['year'] );
86
+			$earnings = give_get_earnings_by_date($day, $month, $dates['year']);
87 87
 			$earnings_totals += $earnings;
88 88
 
89
-			$date            = mktime( 0, 0, 0, $month, $day, $dates['year'] ) * 1000;
90
-			$sales_data[]    = array( $date, $sales );
91
-			$earnings_data[] = array( $date, $earnings );
92
-			$day ++;
89
+			$date            = mktime(0, 0, 0, $month, $day, $dates['year']) * 1000;
90
+			$sales_data[]    = array($date, $sales);
91
+			$earnings_data[] = array($date, $earnings);
92
+			$day++;
93 93
 		endwhile;
94 94
 
95 95
 	} else {
96 96
 
97 97
 		$y = $dates['year'];
98
-		while ( $y <= $dates['year_end'] ) :
98
+		while ($y <= $dates['year_end']) :
99 99
 
100
-			if ( $dates['year'] == $dates['year_end'] ) {
100
+			if ($dates['year'] == $dates['year_end']) {
101 101
 				$month_start = $dates['m_start'];
102 102
 				$month_end   = $dates['m_end'];
103
-			} elseif ( $y == $dates['year'] ) {
103
+			} elseif ($y == $dates['year']) {
104 104
 				$month_start = $dates['m_start'];
105 105
 				$month_end   = 12;
106
-			} elseif ( $y == $dates['year_end'] ) {
106
+			} elseif ($y == $dates['year_end']) {
107 107
 				$month_start = 1;
108 108
 				$month_end   = $dates['m_end'];
109 109
 			} else {
@@ -112,48 +112,48 @@  discard block
 block discarded – undo
112 112
 			}
113 113
 
114 114
 			$i = $month_start;
115
-			while ( $i <= $month_end ) :
115
+			while ($i <= $month_end) :
116 116
 
117
-				if ( $day_by_day ) {
117
+				if ($day_by_day) {
118 118
 
119
-					if ( $i == $month_end ) {
119
+					if ($i == $month_end) {
120 120
 
121 121
 						$num_of_days = $dates['day_end'];
122 122
 
123 123
 					} else {
124 124
 
125
-						$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
125
+						$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
126 126
 
127 127
 					}
128 128
 
129 129
 					$d = $dates['day'];
130 130
 
131
-					while ( $d <= $num_of_days ) :
131
+					while ($d <= $num_of_days) :
132 132
 
133
-						$sales = give_get_sales_by_date( $d, $i, $y );
133
+						$sales = give_get_sales_by_date($d, $i, $y);
134 134
 						$sales_totals += $sales;
135 135
 
136
-						$earnings = give_get_earnings_by_date( $d, $i, $y );
136
+						$earnings = give_get_earnings_by_date($d, $i, $y);
137 137
 						$earnings_totals += $earnings;
138 138
 
139
-						$date            = mktime( 0, 0, 0, $i, $d, $y ) * 1000;
140
-						$sales_data[]    = array( $date, $sales );
141
-						$earnings_data[] = array( $date, $earnings );
142
-						$d ++;
139
+						$date            = mktime(0, 0, 0, $i, $d, $y) * 1000;
140
+						$sales_data[]    = array($date, $sales);
141
+						$earnings_data[] = array($date, $earnings);
142
+						$d++;
143 143
 
144 144
 					endwhile;
145 145
 
146 146
 				} else {
147 147
 
148
-					$sales = give_get_sales_by_date( null, $i, $y );
148
+					$sales = give_get_sales_by_date(null, $i, $y);
149 149
 					$sales_totals += $sales;
150 150
 
151
-					$earnings = give_get_earnings_by_date( null, $i, $y );
151
+					$earnings = give_get_earnings_by_date(null, $i, $y);
152 152
 					$earnings_totals += $earnings;
153 153
 
154
-					if ( $i == $month_end ) {
154
+					if ($i == $month_end) {
155 155
 
156
-						$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
156
+						$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
157 157
 
158 158
 					} else {
159 159
 
@@ -161,24 +161,24 @@  discard block
 block discarded – undo
161 161
 
162 162
 					}
163 163
 
164
-					$date            = mktime( 0, 0, 0, $i, $num_of_days, $y ) * 1000;
165
-					$sales_data[]    = array( $date, $sales );
166
-					$earnings_data[] = array( $date, $earnings );
164
+					$date            = mktime(0, 0, 0, $i, $num_of_days, $y) * 1000;
165
+					$sales_data[]    = array($date, $sales);
166
+					$earnings_data[] = array($date, $earnings);
167 167
 
168 168
 				}
169 169
 
170
-				$i ++;
170
+				$i++;
171 171
 
172 172
 			endwhile;
173 173
 
174
-			$y ++;
174
+			$y++;
175 175
 		endwhile;
176 176
 
177 177
 	}
178 178
 
179 179
 	$data = array(
180
-		esc_html__( 'Income', 'give' )    => $earnings_data,
181
-		esc_html__( 'Donations', 'give' ) => $sales_data
180
+		esc_html__('Income', 'give')    => $earnings_data,
181
+		esc_html__('Donations', 'give') => $sales_data
182 182
 	);
183 183
 
184 184
 	// start our own output buffer
@@ -191,12 +191,12 @@  discard block
 block discarded – undo
191 191
 				<div class="inside">
192 192
 					<?php give_reports_graph_controls(); ?>
193 193
 					<?php
194
-					$graph = new Give_Graph( $data, array( 'dataType' => array( 'amount', 'count' ) ) );
195
-					$graph->set( 'x_mode', 'time' );
196
-					$graph->set( 'multiple_y_axes', true );
194
+					$graph = new Give_Graph($data, array('dataType' => array('amount', 'count')));
195
+					$graph->set('x_mode', 'time');
196
+					$graph->set('multiple_y_axes', true);
197 197
 					$graph->display();
198 198
 
199
-					if ( 'this_month' == $dates['range'] ) {
199
+					if ('this_month' == $dates['range']) {
200 200
 						$estimated = give_estimated_monthly_stats();
201 201
 					}
202 202
 					?>
@@ -205,21 +205,21 @@  discard block
 block discarded – undo
205 205
 			<table class="widefat reports-table alignleft" style="max-width:450px">
206 206
 				<tbody>
207 207
 				<tr>
208
-					<th scope="row"><strong><?php esc_html_e( 'Total income for period:', 'give' ); ?></strong></th>
209
-					<td><?php echo give_currency_filter( give_format_amount( $earnings_totals, array( 'sanitize' => false ) ) ); ?></td>
208
+					<th scope="row"><strong><?php esc_html_e('Total income for period:', 'give'); ?></strong></th>
209
+					<td><?php echo give_currency_filter(give_format_amount($earnings_totals, array('sanitize' => false))); ?></td>
210 210
 				</tr>
211 211
 				<tr class="alternate">
212
-					<th scope="row"><strong><?php esc_html_e( 'Total donations for period:', 'give' ); ?><strong></th>
212
+					<th scope="row"><strong><?php esc_html_e('Total donations for period:', 'give'); ?><strong></th>
213 213
 					<td><?php echo $sales_totals; ?></td>
214 214
 				</tr>
215
-				<?php if ( 'this_month' == $dates['range'] ) : ?>
215
+				<?php if ('this_month' == $dates['range']) : ?>
216 216
 					<tr>
217
-						<th scope="row"><strong><?php esc_html_e( 'Estimated monthly income:', 'give' ); ?></strong></th>
218
-						<td><?php echo give_currency_filter( give_format_amount( $estimated['earnings'], array( 'sanitize' => false ) ) ); ?></td>
217
+						<th scope="row"><strong><?php esc_html_e('Estimated monthly income:', 'give'); ?></strong></th>
218
+						<td><?php echo give_currency_filter(give_format_amount($estimated['earnings'], array('sanitize' => false))); ?></td>
219 219
 					</tr>
220 220
 					<tr class="alternate">
221
-						<th scope="row"><strong><?php esc_html_e( 'Estimated monthly donations:', 'give' ); ?></strong></th>
222
-						<td><?php echo floor( $estimated['sales'] ); ?></td>
221
+						<th scope="row"><strong><?php esc_html_e('Estimated monthly donations:', 'give'); ?></strong></th>
222
+						<td><?php echo floor($estimated['sales']); ?></td>
223 223
 					</tr>
224 224
 				<?php endif; ?>
225 225
 			</table>
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 			 *
233 233
 			 * @since 1.0
234 234
 			 */
235
-			do_action( 'give_reports_graph_additional_stats' );
235
+			do_action('give_reports_graph_additional_stats');
236 236
 			?>
237 237
 
238 238
 		</div>
@@ -251,12 +251,12 @@  discard block
 block discarded – undo
251 251
  * @since 1.0
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
 block discarded – undo
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
 block discarded – undo
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   = 1;
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
 block discarded – undo
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
-		esc_html__( 'Income', 'give' )    => $earnings_data,
427
-		esc_html__( 'Donations', 'give' ) => $sales_data
426
+		esc_html__('Income', 'give')    => $earnings_data,
427
+		esc_html__('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
 block discarded – undo
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
 block discarded – undo
452 452
 			<table class="widefat reports-table alignleft" style="max-width:450px">
453 453
 				<tbody>
454 454
 				<tr>
455
-					<th scope="row"><strong><?php esc_html_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 esc_html_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 esc_html_e( 'Total donations for period:', 'give' ); ?></strong></th>
459
+					<th scope="row"><strong><?php esc_html_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 esc_html_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 esc_html_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 esc_html_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 esc_html_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>
@@ -484,26 +484,26 @@  discard block
 block discarded – undo
484 484
  * @return void
485 485
  */
486 486
 function give_reports_graph_controls() {
487
-	$date_options = apply_filters( 'give_report_date_options', array(
488
-		'today'        => esc_html__( 'Today', 'give' ),
489
-		'yesterday'    => esc_html__( 'Yesterday', 'give' ),
490
-		'this_week'    => esc_html__( 'This Week', 'give' ),
491
-		'last_week'    => esc_html__( 'Last Week', 'give' ),
492
-		'this_month'   => esc_html__( 'This Month', 'give' ),
493
-		'last_month'   => esc_html__( 'Last Month', 'give' ),
494
-		'this_quarter' => esc_html__( 'This Quarter', 'give' ),
495
-		'last_quarter' => esc_html__( 'Last Quarter', 'give' ),
496
-		'this_year'    => esc_html__( 'This Year', 'give' ),
497
-		'last_year'    => esc_html__( 'Last Year', 'give' ),
498
-		'other'        => esc_html__( 'Custom', 'give' )
499
-	) );
487
+	$date_options = apply_filters('give_report_date_options', array(
488
+		'today'        => esc_html__('Today', 'give'),
489
+		'yesterday'    => esc_html__('Yesterday', 'give'),
490
+		'this_week'    => esc_html__('This Week', 'give'),
491
+		'last_week'    => esc_html__('Last Week', 'give'),
492
+		'this_month'   => esc_html__('This Month', 'give'),
493
+		'last_month'   => esc_html__('Last Month', 'give'),
494
+		'this_quarter' => esc_html__('This Quarter', 'give'),
495
+		'last_quarter' => esc_html__('Last Quarter', 'give'),
496
+		'this_year'    => esc_html__('This Year', 'give'),
497
+		'last_year'    => esc_html__('Last Year', 'give'),
498
+		'other'        => esc_html__('Custom', 'give')
499
+	));
500 500
 
501 501
 	$dates   = give_get_report_dates();
502 502
 	$display = $dates['range'] == 'other' ? '' : 'display: none;';
503
-	$tab     = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'earnings';
503
+	$tab     = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'earnings';
504 504
 
505
-	if ( empty( $dates['day_end'] ) ) {
506
-		$dates['day_end'] = cal_days_in_month( CAL_GREGORIAN, date( 'n' ), date( 'Y' ) );
505
+	if (empty($dates['day_end'])) {
506
+		$dates['day_end'] = cal_days_in_month(CAL_GREGORIAN, date('n'), date('Y'));
507 507
 	}
508 508
 
509 509
 	/**
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
 	 *
512 512
 	 * @since 1.0
513 513
 	 */
514
-	do_action( 'give_report_graph_controls_before' );
514
+	do_action('give_report_graph_controls_before');
515 515
 	?>
516 516
 	<form id="give-graphs-filter" method="get">
517 517
 		<div class="tablenav top">
@@ -519,56 +519,56 @@  discard block
 block discarded – undo
519 519
 
520 520
 				<input type="hidden" name="post_type" value="give_forms" />
521 521
 				<input type="hidden" name="page" value="give-reports" />
522
-				<input type="hidden" name="tab" value="<?php echo esc_attr( $tab ); ?>" />
522
+				<input type="hidden" name="tab" value="<?php echo esc_attr($tab); ?>" />
523 523
 
524
-				<?php if ( isset( $_GET['form-id'] ) ) : ?>
525
-					<input type="hidden" name="form-id" value="<?php echo absint( $_GET['form-id'] ); ?>" />
524
+				<?php if (isset($_GET['form-id'])) : ?>
525
+					<input type="hidden" name="form-id" value="<?php echo absint($_GET['form-id']); ?>" />
526 526
 				<?php endif; ?>
527 527
 
528 528
 				<div id="give-graphs-date-options-wrap">
529 529
 					<select id="give-graphs-date-options" name="range">
530
-						<?php foreach ( $date_options as $key => $option ) : ?>
531
-							<option value="<?php echo esc_attr( $key ); ?>"<?php selected( $key, $dates['range'] ); ?>><?php echo esc_html( $option ); ?></option>
530
+						<?php foreach ($date_options as $key => $option) : ?>
531
+							<option value="<?php echo esc_attr($key); ?>"<?php selected($key, $dates['range']); ?>><?php echo esc_html($option); ?></option>
532 532
 						<?php endforeach; ?>
533 533
 					</select>
534 534
 
535
-					<div id="give-date-range-options" style="<?php echo esc_attr( $display ); ?>">
536
-						<span class="screen-reader-text"><?php esc_html_e( 'From', 'give' ); ?>&nbsp;</span>
535
+					<div id="give-date-range-options" style="<?php echo esc_attr($display); ?>">
536
+						<span class="screen-reader-text"><?php esc_html_e('From', 'give'); ?>&nbsp;</span>
537 537
 						<select id="give-graphs-month-start" name="m_start" aria-label="Start Month">
538
-							<?php for ( $i = 1; $i <= 12; $i ++ ) : ?>
539
-								<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>
538
+							<?php for ($i = 1; $i <= 12; $i++) : ?>
539
+								<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>
540 540
 							<?php endfor; ?>
541 541
 						</select>
542 542
 						<select id="give-graphs-day-start" name="day" aria-label="Start Day">
543
-							<?php for ( $i = 1; $i <= 31; $i ++ ) : ?>
544
-								<option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['day'] ) ); ?>><?php echo esc_html( $i ); ?></option>
543
+							<?php for ($i = 1; $i <= 31; $i++) : ?>
544
+								<option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['day'])); ?>><?php echo esc_html($i); ?></option>
545 545
 							<?php endfor; ?>
546 546
 						</select>
547 547
 						<select id="give-graphs-year-start" name="year" aria-label="Start Year">
548
-							<?php for ( $i = 2007; $i <= date( 'Y' ); $i ++ ) : ?>
549
-								<option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['year'] ) ); ?>><?php echo esc_html( $i ); ?></option>
548
+							<?php for ($i = 2007; $i <= date('Y'); $i++) : ?>
549
+								<option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['year'])); ?>><?php echo esc_html($i); ?></option>
550 550
 							<?php endfor; ?>
551 551
 						</select>
552
-						<span class="screen-reader-text"><?php esc_html_e( 'To', 'give' ); ?>&nbsp;</span>
552
+						<span class="screen-reader-text"><?php esc_html_e('To', 'give'); ?>&nbsp;</span>
553 553
 						<span>&ndash;</span>
554 554
 						<select id="give-graphs-month-end" name="m_end" aria-label="End Month">
555
-							<?php for ( $i = 1; $i <= 12; $i ++ ) : ?>
556
-								<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>
555
+							<?php for ($i = 1; $i <= 12; $i++) : ?>
556
+								<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>
557 557
 							<?php endfor; ?>
558 558
 						</select>
559 559
 						<select id="give-graphs-day-end" name="day_end" aria-label="End Day">
560
-							<?php for ( $i = 1; $i <= 31; $i ++ ) : ?>
561
-								<option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['day_end'] ) ); ?>><?php echo esc_html( $i ); ?></option>
560
+							<?php for ($i = 1; $i <= 31; $i++) : ?>
561
+								<option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['day_end'])); ?>><?php echo esc_html($i); ?></option>
562 562
 							<?php endfor; ?>
563 563
 						</select>
564 564
 						<select id="give-graphs-year-end" name="year_end" aria-label="End Year">
565
-							<?php for ( $i = 2007; $i <= date( 'Y' ); $i ++ ) : ?>
566
-								<option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['year_end'] ) ); ?>><?php echo esc_html( $i ); ?></option>
565
+							<?php for ($i = 2007; $i <= date('Y'); $i++) : ?>
566
+								<option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['year_end'])); ?>><?php echo esc_html($i); ?></option>
567 567
 							<?php endfor; ?>
568 568
 						</select>
569 569
 					</div>
570 570
 
571
-					<input type="submit" class="button-secondary" value="<?php esc_attr_e( 'Filter', 'give' ); ?>" />
571
+					<input type="submit" class="button-secondary" value="<?php esc_attr_e('Filter', 'give'); ?>" />
572 572
 				</div>
573 573
 
574 574
 				<input type="hidden" name="give_action" value="filter_reports" />
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
 	 *
582 582
 	 * @since 1.0
583 583
 	 */
584
-	do_action( 'give_report_graph_controls_after' );
584
+	do_action('give_report_graph_controls_after');
585 585
 }
586 586
 
587 587
 /**
@@ -596,65 +596,65 @@  discard block
 block discarded – undo
596 596
 function give_get_report_dates() {
597 597
 	$dates = array();
598 598
 
599
-	$current_time = current_time( 'timestamp' );
599
+	$current_time = current_time('timestamp');
600 600
 
601
-	$dates['range']    = isset( $_GET['range'] ) ? $_GET['range'] : 'this_month';
602
-	$dates['year']     = isset( $_GET['year'] ) ? $_GET['year'] : date( 'Y' );
603
-	$dates['year_end'] = isset( $_GET['year_end'] ) ? $_GET['year_end'] : date( 'Y' );
604
-	$dates['m_start']  = isset( $_GET['m_start'] ) ? $_GET['m_start'] : 1;
605
-	$dates['m_end']    = isset( $_GET['m_end'] ) ? $_GET['m_end'] : 12;
606
-	$dates['day']      = isset( $_GET['day'] ) ? $_GET['day'] : 1;
607
-	$dates['day_end']  = isset( $_GET['day_end'] ) ? $_GET['day_end'] : cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] );
601
+	$dates['range']    = isset($_GET['range']) ? $_GET['range'] : 'this_month';
602
+	$dates['year']     = isset($_GET['year']) ? $_GET['year'] : date('Y');
603
+	$dates['year_end'] = isset($_GET['year_end']) ? $_GET['year_end'] : date('Y');
604
+	$dates['m_start']  = isset($_GET['m_start']) ? $_GET['m_start'] : 1;
605
+	$dates['m_end']    = isset($_GET['m_end']) ? $_GET['m_end'] : 12;
606
+	$dates['day']      = isset($_GET['day']) ? $_GET['day'] : 1;
607
+	$dates['day_end']  = isset($_GET['day_end']) ? $_GET['day_end'] : cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']);
608 608
 
609 609
 	// Modify dates based on predefined ranges
610
-	switch ( $dates['range'] ) :
610
+	switch ($dates['range']) :
611 611
 
612 612
 		case 'this_month' :
613
-			$dates['m_start']  = date( 'n', $current_time );
614
-			$dates['m_end']    = date( 'n', $current_time );
613
+			$dates['m_start']  = date('n', $current_time);
614
+			$dates['m_end']    = date('n', $current_time);
615 615
 			$dates['day']      = 1;
616
-			$dates['day_end']  = cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] );
617
-			$dates['year']     = date( 'Y' );
618
-			$dates['year_end'] = date( 'Y' );
616
+			$dates['day_end']  = cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']);
617
+			$dates['year']     = date('Y');
618
+			$dates['year_end'] = date('Y');
619 619
 			break;
620 620
 
621 621
 		case 'last_month' :
622
-			if ( date( 'n' ) == 1 ) {
622
+			if (date('n') == 1) {
623 623
 				$dates['m_start']  = 12;
624 624
 				$dates['m_end']    = 12;
625
-				$dates['year']     = date( 'Y', $current_time ) - 1;
626
-				$dates['year_end'] = date( 'Y', $current_time ) - 1;
625
+				$dates['year']     = date('Y', $current_time) - 1;
626
+				$dates['year_end'] = date('Y', $current_time) - 1;
627 627
 			} else {
628
-				$dates['m_start']  = date( 'n' ) - 1;
629
-				$dates['m_end']    = date( 'n' ) - 1;
628
+				$dates['m_start']  = date('n') - 1;
629
+				$dates['m_end']    = date('n') - 1;
630 630
 				$dates['year_end'] = $dates['year'];
631 631
 			}
632
-			$dates['day_end'] = cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] );
632
+			$dates['day_end'] = cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']);
633 633
 			break;
634 634
 
635 635
 		case 'today' :
636
-			$dates['day']     = date( 'd', $current_time );
637
-			$dates['m_start'] = date( 'n', $current_time );
638
-			$dates['m_end']   = date( 'n', $current_time );
639
-			$dates['year']    = date( 'Y', $current_time );
636
+			$dates['day']     = date('d', $current_time);
637
+			$dates['m_start'] = date('n', $current_time);
638
+			$dates['m_end']   = date('n', $current_time);
639
+			$dates['year']    = date('Y', $current_time);
640 640
 			break;
641 641
 
642 642
 		case 'yesterday' :
643 643
 
644
-			$year  = date( 'Y', $current_time );
645
-			$month = date( 'n', $current_time );
646
-			$day   = date( 'd', $current_time );
644
+			$year  = date('Y', $current_time);
645
+			$month = date('n', $current_time);
646
+			$day   = date('d', $current_time);
647 647
 
648
-			if ( $month == 1 && $day == 1 ) {
648
+			if ($month == 1 && $day == 1) {
649 649
 
650 650
 				$year -= 1;
651 651
 				$month = 12;
652
-				$day   = cal_days_in_month( CAL_GREGORIAN, $month, $year );
652
+				$day   = cal_days_in_month(CAL_GREGORIAN, $month, $year);
653 653
 
654
-			} elseif ( $month > 1 && $day == 1 ) {
654
+			} elseif ($month > 1 && $day == 1) {
655 655
 
656 656
 				$month -= 1;
657
-				$day = cal_days_in_month( CAL_GREGORIAN, $month, $year );
657
+				$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
658 658
 
659 659
 			} else {
660 660
 
@@ -670,91 +670,91 @@  discard block
 block discarded – undo
670 670
 			break;
671 671
 
672 672
 		case 'this_week' :
673
-			$dates['day'] = date( 'd', $current_time - ( date( 'w', $current_time ) - 1 ) * 60 * 60 * 24 ) - 1;
674
-			$dates['day'] += get_option( 'start_of_week' );
673
+			$dates['day'] = date('d', $current_time - (date('w', $current_time) - 1) * 60 * 60 * 24) - 1;
674
+			$dates['day'] += get_option('start_of_week');
675 675
 			$dates['day_end'] = $dates['day'] + 6;
676
-			$dates['m_start'] = date( 'n', $current_time );
677
-			$dates['m_end']   = date( 'n', $current_time );
678
-			$dates['year']    = date( 'Y', $current_time );
676
+			$dates['m_start'] = date('n', $current_time);
677
+			$dates['m_end']   = date('n', $current_time);
678
+			$dates['year']    = date('Y', $current_time);
679 679
 			break;
680 680
 
681 681
 		case 'last_week' :
682
-			$dates['day'] = date( 'd', $current_time - ( date( 'w' ) - 1 ) * 60 * 60 * 24 ) - 8;
683
-			$dates['day'] += get_option( 'start_of_week' );
682
+			$dates['day'] = date('d', $current_time - (date('w') - 1) * 60 * 60 * 24) - 8;
683
+			$dates['day'] += get_option('start_of_week');
684 684
 			$dates['day_end'] = $dates['day'] + 6;
685
-			$dates['year']    = date( 'Y' );
686
-
687
-			if ( date( 'j', $current_time ) <= 7 ) {
688
-				$dates['m_start'] = date( 'n', $current_time ) - 1;
689
-				$dates['m_end']   = date( 'n', $current_time ) - 1;
690
-				if ( $dates['m_start'] <= 1 ) {
691
-					$dates['year']     = date( 'Y', $current_time ) - 1;
692
-					$dates['year_end'] = date( 'Y', $current_time ) - 1;
685
+			$dates['year']    = date('Y');
686
+
687
+			if (date('j', $current_time) <= 7) {
688
+				$dates['m_start'] = date('n', $current_time) - 1;
689
+				$dates['m_end']   = date('n', $current_time) - 1;
690
+				if ($dates['m_start'] <= 1) {
691
+					$dates['year']     = date('Y', $current_time) - 1;
692
+					$dates['year_end'] = date('Y', $current_time) - 1;
693 693
 				}
694 694
 			} else {
695
-				$dates['m_start'] = date( 'n', $current_time );
696
-				$dates['m_end']   = date( 'n', $current_time );
695
+				$dates['m_start'] = date('n', $current_time);
696
+				$dates['m_end']   = date('n', $current_time);
697 697
 			}
698 698
 			break;
699 699
 
700 700
 		case 'this_quarter' :
701
-			$month_now = date( 'n', $current_time );
701
+			$month_now = date('n', $current_time);
702 702
 
703
-			if ( $month_now <= 3 ) {
703
+			if ($month_now <= 3) {
704 704
 
705 705
 				$dates['m_start'] = 1;
706 706
 				$dates['m_end']   = 4;
707
-				$dates['year']    = date( 'Y', $current_time );
707
+				$dates['year']    = date('Y', $current_time);
708 708
 
709
-			} else if ( $month_now <= 6 ) {
709
+			} else if ($month_now <= 6) {
710 710
 
711 711
 				$dates['m_start'] = 4;
712 712
 				$dates['m_end']   = 7;
713
-				$dates['year']    = date( 'Y', $current_time );
713
+				$dates['year']    = date('Y', $current_time);
714 714
 
715
-			} else if ( $month_now <= 9 ) {
715
+			} else if ($month_now <= 9) {
716 716
 
717 717
 				$dates['m_start'] = 7;
718 718
 				$dates['m_end']   = 10;
719
-				$dates['year']    = date( 'Y', $current_time );
719
+				$dates['year']    = date('Y', $current_time);
720 720
 
721 721
 			} else {
722 722
 
723 723
 				$dates['m_start']  = 10;
724 724
 				$dates['m_end']    = 1;
725
-				$dates['year']     = date( 'Y', $current_time );
726
-				$dates['year_end'] = date( 'Y', $current_time ) + 1;
725
+				$dates['year']     = date('Y', $current_time);
726
+				$dates['year_end'] = date('Y', $current_time) + 1;
727 727
 
728 728
 			}
729 729
 			break;
730 730
 
731 731
 		case 'last_quarter' :
732
-			$month_now = date( 'n' );
732
+			$month_now = date('n');
733 733
 
734
-			if ( $month_now <= 3 ) {
734
+			if ($month_now <= 3) {
735 735
 
736 736
 				$dates['m_start']  = 10;
737 737
 				$dates['m_end']    = 12;
738
-				$dates['year']     = date( 'Y', $current_time ) - 1; // Previous year
739
-				$dates['year_end'] = date( 'Y', $current_time ) - 1; // Previous year
738
+				$dates['year']     = date('Y', $current_time) - 1; // Previous year
739
+				$dates['year_end'] = date('Y', $current_time) - 1; // Previous year
740 740
 
741
-			} else if ( $month_now <= 6 ) {
741
+			} else if ($month_now <= 6) {
742 742
 
743 743
 				$dates['m_start'] = 1;
744 744
 				$dates['m_end']   = 3;
745
-				$dates['year']    = date( 'Y', $current_time );
745
+				$dates['year']    = date('Y', $current_time);
746 746
 
747
-			} else if ( $month_now <= 9 ) {
747
+			} else if ($month_now <= 9) {
748 748
 
749 749
 				$dates['m_start'] = 4;
750 750
 				$dates['m_end']   = 6;
751
-				$dates['year']    = date( 'Y', $current_time );
751
+				$dates['year']    = date('Y', $current_time);
752 752
 
753 753
 			} else {
754 754
 
755 755
 				$dates['m_start'] = 7;
756 756
 				$dates['m_end']   = 9;
757
-				$dates['year']    = date( 'Y', $current_time );
757
+				$dates['year']    = date('Y', $current_time);
758 758
 
759 759
 			}
760 760
 			break;
@@ -762,19 +762,19 @@  discard block
 block discarded – undo
762 762
 		case 'this_year' :
763 763
 			$dates['m_start'] = 1;
764 764
 			$dates['m_end']   = 12;
765
-			$dates['year']    = date( 'Y', $current_time );
765
+			$dates['year']    = date('Y', $current_time);
766 766
 			break;
767 767
 
768 768
 		case 'last_year' :
769 769
 			$dates['m_start']  = 1;
770 770
 			$dates['m_end']    = 12;
771
-			$dates['year']     = date( 'Y', $current_time ) - 1;
772
-			$dates['year_end'] = date( 'Y', $current_time ) - 1;
771
+			$dates['year']     = date('Y', $current_time) - 1;
772
+			$dates['year_end'] = date('Y', $current_time) - 1;
773 773
 			break;
774 774
 
775 775
 	endswitch;
776 776
 
777
-	return apply_filters( 'give_report_dates', $dates );
777
+	return apply_filters('give_report_dates', $dates);
778 778
 }
779 779
 
780 780
 /**
@@ -785,18 +785,18 @@  discard block
 block discarded – undo
785 785
  *
786 786
  * @param $data
787 787
  */
788
-function give_parse_report_dates( $data ) {
788
+function give_parse_report_dates($data) {
789 789
 	$dates = give_get_report_dates();
790 790
 
791 791
 	$view = give_get_reporting_view();
792
-	$tab  = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'earnings';
793
-	$id   = isset( $_GET['form-id'] ) ? $_GET['form-id'] : null;
792
+	$tab  = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'earnings';
793
+	$id   = isset($_GET['form-id']) ? $_GET['form-id'] : null;
794 794
 
795
-	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 ) ) ) );
795
+	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))));
796 796
 	give_die();
797 797
 }
798 798
 
799
-add_action( 'give_filter_reports', 'give_parse_report_dates' );
799
+add_action('give_filter_reports', 'give_parse_report_dates');
800 800
 
801 801
 
802 802
 /**
@@ -808,22 +808,22 @@  discard block
 block discarded – undo
808 808
  */
809 809
 function give_reports_refresh_button() {
810 810
 
811
-	$url = wp_nonce_url( add_query_arg( array(
811
+	$url = wp_nonce_url(add_query_arg(array(
812 812
 		'give_action'  => 'refresh_reports_transients',
813 813
 		'give-message' => 'refreshed-reports'
814
-	) ), 'give-refresh-reports' );
814
+	)), 'give-refresh-reports');
815 815
 
816 816
 	echo '<a href="'
817
-	     . esc_url_raw( $url )
818
-	     . '" data-tooltip="'. esc_attr__( 'Clicking this will clear the reports cache.', 'give' )
817
+	     . esc_url_raw($url)
818
+	     . '" data-tooltip="'.esc_attr__('Clicking this will clear the reports cache.', 'give')
819 819
 	     . '" data-tooltip-my-position="right center"  data-tooltip-target-position="left center" class="button alignright give-admin-button give-tooltip">'
820 820
 	     . '<span class="give-admin-button-icon give-admin-button-icon-update"></span>'
821
-	     . esc_html__( 'Refresh Report Data', 'give' )
821
+	     . esc_html__('Refresh Report Data', 'give')
822 822
 	     . '</a>';
823 823
 
824 824
 }
825 825
 
826
-add_action( 'give_reports_graph_additional_stats', 'give_reports_refresh_button' );
826
+add_action('give_reports_graph_additional_stats', 'give_reports_refresh_button');
827 827
 
828 828
 /**
829 829
  * Trigger the refresh of reports transients
@@ -834,20 +834,20 @@  discard block
 block discarded – undo
834 834
  *
835 835
  * @return void
836 836
  */
837
-function give_run_refresh_reports_transients( $data ) {
837
+function give_run_refresh_reports_transients($data) {
838 838
 
839
-	if ( ! wp_verify_nonce( $data['_wpnonce'], 'give-refresh-reports' ) ) {
839
+	if ( ! wp_verify_nonce($data['_wpnonce'], 'give-refresh-reports')) {
840 840
 		return;
841 841
 	}
842 842
 
843 843
 	// Monthly stats.
844
-	Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) );
844
+	Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats'));
845 845
 
846 846
 	// Total earning.
847
-	delete_option( 'give_earnings_total' );
847
+	delete_option('give_earnings_total');
848 848
 
849 849
 	// @todo: Refresh only range related stat cache
850 850
 	give_delete_donation_stats();
851 851
 }
852 852
 
853
-add_action( 'give_refresh_reports_transients', 'give_run_refresh_reports_transients' );
854 853
\ No newline at end of file
854
+add_action('give_refresh_reports_transients', 'give_run_refresh_reports_transients');
855 855
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/reports/class-form-reports-table.php 1 patch
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -10,13 +10,13 @@  discard block
 block discarded – undo
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
 
17 17
 // Load WP_List_Table if not loaded
18
-if ( ! class_exists( 'WP_List_Table' ) ) {
19
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
18
+if ( ! class_exists('WP_List_Table')) {
19
+	require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php';
20 20
 }
21 21
 
22 22
 /**
@@ -56,13 +56,13 @@  discard block
 block discarded – undo
56 56
 		global $status, $page;
57 57
 
58 58
 		// Set parent defaults
59
-		parent::__construct( array(
60
-			'singular' => give_get_forms_label_singular(),    // Singular name of the listed records.
61
-			'plural'   => give_get_forms_label_plural(),        // Plural name of the listed records.
59
+		parent::__construct(array(
60
+			'singular' => give_get_forms_label_singular(), // Singular name of the listed records.
61
+			'plural'   => give_get_forms_label_plural(), // Plural name of the listed records.
62 62
 			'ajax'     => false                        // Does this table support ajax?
63
-		) );
63
+		));
64 64
 
65
-		add_action( 'give_report_view_actions', array( $this, 'category_filter' ) );
65
+		add_action('give_report_view_actions', array($this, 'category_filter'));
66 66
 		$this->query();
67 67
 
68 68
 	}
@@ -78,32 +78,32 @@  discard block
 block discarded – undo
78 78
 	 *
79 79
 	 * @return string Column Name
80 80
 	 */
81
-	public function column_default( $item, $column_name ) {
82
-		switch ( $column_name ) {
81
+	public function column_default($item, $column_name) {
82
+		switch ($column_name) {
83 83
 			case 'title':
84
-				$title = empty( $item['title'] ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $item['ID'] ) : $item['title'];
84
+				$title = empty($item['title']) ? sprintf(__('Untitled (#%s)', 'give'), $item['ID']) : $item['title'];
85 85
 
86 86
 				return sprintf(
87 87
 					'<a href="%s">%s</a>',
88
-					get_edit_post_link( $item['ID'] ),
88
+					get_edit_post_link($item['ID']),
89 89
 					$title
90 90
 				);
91 91
 			case 'sales':
92 92
 				return sprintf(
93 93
 					'<a href="%s">%s</a>',
94
-					admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&form_id=' . urlencode( $item['ID'] ) ),
94
+					admin_url('edit.php?post_type=give_forms&page=give-payment-history&form_id='.urlencode($item['ID'])),
95 95
 					$item['sales']
96 96
 				);
97 97
 			case 'earnings' :
98
-				return give_currency_filter( give_format_amount( $item[ $column_name ], array( 'sanitize' => false ) ) );
98
+				return give_currency_filter(give_format_amount($item[$column_name], array('sanitize' => false)));
99 99
 			case 'average_sales' :
100
-				return round( $item[ $column_name ] );
100
+				return round($item[$column_name]);
101 101
 			case 'average_earnings' :
102
-				return give_currency_filter( give_format_amount( $item[ $column_name ], array( 'sanitize' => false ) ) );
102
+				return give_currency_filter(give_format_amount($item[$column_name], array('sanitize' => false)));
103 103
 			case 'details' :
104
-				return '<a href="' . admin_url( 'edit.php?post_type=give_forms&page=give-reports&tab=forms&form-id=' . $item['ID'] ) . '">' . esc_html__( 'View Detailed Report', 'give' ) . '</a>';
104
+				return '<a href="'.admin_url('edit.php?post_type=give_forms&page=give-reports&tab=forms&form-id='.$item['ID']).'">'.esc_html__('View Detailed Report', 'give').'</a>';
105 105
 			default:
106
-				return $item[ $column_name ];
106
+				return $item[$column_name];
107 107
 		}
108 108
 	}
109 109
 
@@ -117,12 +117,12 @@  discard block
 block discarded – undo
117 117
 	 */
118 118
 	public function get_columns() {
119 119
 		$columns = array(
120
-			'title'            => esc_html__( 'Form', 'give' ),
121
-			'sales'            => esc_html__( 'Donations', 'give' ),
122
-			'earnings'         => esc_html__( 'Income', 'give' ),
123
-			'average_sales'    => esc_html__( 'Monthly Average Donations', 'give' ),
124
-			'average_earnings' => esc_html__( 'Monthly Average Income', 'give' ),
125
-			'details'          => esc_html__( 'Detailed Report', 'give' )
120
+			'title'            => esc_html__('Form', 'give'),
121
+			'sales'            => esc_html__('Donations', 'give'),
122
+			'earnings'         => esc_html__('Income', 'give'),
123
+			'average_sales'    => esc_html__('Monthly Average Donations', 'give'),
124
+			'average_earnings' => esc_html__('Monthly Average Income', 'give'),
125
+			'details'          => esc_html__('Detailed Report', 'give')
126 126
 		);
127 127
 
128 128
 		return $columns;
@@ -138,9 +138,9 @@  discard block
 block discarded – undo
138 138
 	 */
139 139
 	public function get_sortable_columns() {
140 140
 		return array(
141
-			'title'    => array( 'title', true ),
142
-			'sales'    => array( 'sales', false ),
143
-			'earnings' => array( 'earnings', false ),
141
+			'title'    => array('title', true),
142
+			'sales'    => array('sales', false),
143
+			'earnings' => array('earnings', false),
144 144
 		);
145 145
 	}
146 146
 
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	 * @return int Current page number
154 154
 	 */
155 155
 	public function get_paged() {
156
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
156
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
157 157
 	}
158 158
 
159 159
 	/**
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	 * @return int Category ID
166 166
 	 */
167 167
 	public function get_category() {
168
-		return isset( $_GET['category'] ) ? absint( $_GET['category'] ) : 0;
168
+		return isset($_GET['category']) ? absint($_GET['category']) : 0;
169 169
 	}
170 170
 
171 171
 	/**
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 	 *
177 177
 	 * @return void
178 178
 	 */
179
-	public function bulk_actions( $which = '' ) {
179
+	public function bulk_actions($which = '') {
180 180
 
181 181
 	}
182 182
 
@@ -188,27 +188,27 @@  discard block
 block discarded – undo
188 188
 	 *
189 189
 	 * @param string $which
190 190
 	 */
191
-	protected function display_tablenav( $which ) {
191
+	protected function display_tablenav($which) {
192 192
 
193
-		if ( 'top' === $which ) {
194
-			wp_nonce_field( 'bulk-' . $this->_args['plural'] );
193
+		if ('top' === $which) {
194
+			wp_nonce_field('bulk-'.$this->_args['plural']);
195 195
 		}
196 196
 		?>
197
-		<div class="tablenav give-clearfix <?php echo esc_attr( $which ); ?>">
197
+		<div class="tablenav give-clearfix <?php echo esc_attr($which); ?>">
198 198
 
199
-			<?php if ( 'top' === $which ) { ?>
199
+			<?php if ('top' === $which) { ?>
200 200
 				<h3 class="alignleft reports-earnings-title">
201
-					<span><?php esc_html_e( 'Donation Forms Report', 'give' ); ?></span>
201
+					<span><?php esc_html_e('Donation Forms Report', 'give'); ?></span>
202 202
 				</h3>
203 203
 			<?php } ?>
204 204
 
205 205
 			<div class="alignright tablenav-right">
206 206
 				<div class="actions bulkactions">
207
-					<?php $this->bulk_actions( $which ); ?>
207
+					<?php $this->bulk_actions($which); ?>
208 208
 				</div>
209 209
 				<?php
210
-				$this->extra_tablenav( $which );
211
-				$this->pagination( $which );
210
+				$this->extra_tablenav($which);
211
+				$this->pagination($which);
212 212
 				?>
213 213
 			</div>
214 214
 
@@ -228,9 +228,9 @@  discard block
 block discarded – undo
228 228
 	 */
229 229
 	public function category_filter() {
230 230
 
231
-		$categories = get_terms( 'form_category' );
232
-		if ( $categories && ! is_wp_error( $categories ) ) {
233
-			echo Give()->html->category_dropdown( 'category', $this->get_category() );
231
+		$categories = get_terms('form_category');
232
+		if ($categories && ! is_wp_error($categories)) {
233
+			echo Give()->html->category_dropdown('category', $this->get_category());
234 234
 		}
235 235
 	}
236 236
 
@@ -244,8 +244,8 @@  discard block
 block discarded – undo
244 244
 	 */
245 245
 	public function query() {
246 246
 
247
-		$orderby  = isset( $_GET['orderby'] ) ? $_GET['orderby'] : 'title';
248
-		$order    = isset( $_GET['order'] ) ? $_GET['order'] : 'DESC';
247
+		$orderby  = isset($_GET['orderby']) ? $_GET['orderby'] : 'title';
248
+		$order    = isset($_GET['order']) ? $_GET['order'] : 'DESC';
249 249
 		$category = $this->get_category();
250 250
 
251 251
 		$args = array(
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 			'suppress_filters' => true
259 259
 		);
260 260
 
261
-		if ( ! empty( $category ) ) {
261
+		if ( ! empty($category)) {
262 262
 			$args['tax_query'] = array(
263 263
 				array(
264 264
 					'taxonomy' => 'form_category',
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 			);
268 268
 		}
269 269
 
270
-		switch ( $orderby ) :
270
+		switch ($orderby) :
271 271
 			case 'title' :
272 272
 				$args['orderby'] = 'title';
273 273
 				break;
@@ -283,9 +283,9 @@  discard block
 block discarded – undo
283 283
 				break;
284 284
 		endswitch;
285 285
 
286
-		$args = apply_filters( 'give_form_reports_prepare_items_args', $args, $this );
286
+		$args = apply_filters('give_form_reports_prepare_items_args', $args, $this);
287 287
 
288
-		$this->donation_forms = new WP_Query( $args );
288
+		$this->donation_forms = new WP_Query($args);
289 289
 
290 290
 		// Store total number of donation forms count.
291 291
 		$this->count = $this->donation_forms->found_posts;
@@ -305,15 +305,15 @@  discard block
 block discarded – undo
305 305
 
306 306
 		$give_forms = $this->donation_forms->posts;
307 307
 
308
-		if ( $give_forms ) {
309
-			foreach ( $give_forms as $form ) {
308
+		if ($give_forms) {
309
+			foreach ($give_forms as $form) {
310 310
 				$reports_data[] = array(
311 311
 					'ID'               => $form,
312
-					'title'            => get_the_title( $form ),
313
-					'sales'            => give_get_form_sales_stats( $form ),
314
-					'earnings'         => give_get_form_earnings_stats( $form ),
315
-					'average_sales'    => give_get_average_monthly_form_sales( $form ),
316
-					'average_earnings' => give_get_average_monthly_form_earnings( $form )
312
+					'title'            => get_the_title($form),
313
+					'sales'            => give_get_form_sales_stats($form),
314
+					'earnings'         => give_get_form_earnings_stats($form),
315
+					'average_sales'    => give_get_average_monthly_form_sales($form),
316
+					'average_earnings' => give_get_average_monthly_form_earnings($form)
317 317
 				);
318 318
 			}
319 319
 		}
@@ -338,14 +338,14 @@  discard block
 block discarded – undo
338 338
 		$columns = $this->get_columns();
339 339
 		$hidden = array(); // No hidden columns
340 340
 		$sortable = $this->get_sortable_columns();
341
-		$this->_column_headers = array( $columns, $hidden, $sortable );
341
+		$this->_column_headers = array($columns, $hidden, $sortable);
342 342
 		$this->items = $this->reports_data();
343 343
 		$total_items = $this->count;
344 344
 
345
-		$this->set_pagination_args( array(
345
+		$this->set_pagination_args(array(
346 346
 				'total_items' => $total_items,
347 347
 				'per_page'    => $this->per_page,
348
-				'total_pages' => ceil( $total_items / $this->per_page )
348
+				'total_pages' => ceil($total_items / $this->per_page)
349 349
 			)
350 350
 		);
351 351
 	}
Please login to merge, or discard this patch.
includes/admin/tools/logs/class-sales-logs-list-table.php 1 patch
Spacing   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -9,13 +9,13 @@  discard block
 block discarded – undo
9 9
  */
10 10
 
11 11
 // Exit if accessed directly.
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit;
14 14
 }
15 15
 
16 16
 // Load WP_List_Table if not loaded.
17
-if ( ! class_exists( 'WP_List_Table' ) ) {
18
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
17
+if ( ! class_exists('WP_List_Table')) {
18
+	require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php';
19 19
 }
20 20
 
21 21
 /**
@@ -44,13 +44,13 @@  discard block
 block discarded – undo
44 44
 		global $status, $page;
45 45
 
46 46
 		// Set parent defaults
47
-		parent::__construct( array(
48
-			'singular' => give_get_forms_label_singular(),    // Singular name of the listed records
49
-			'plural'   => give_get_forms_label_plural(),        // Plural name of the listed records
50
-			'ajax'     => false,// Does this table support ajax?
51
-		) );
47
+		parent::__construct(array(
48
+			'singular' => give_get_forms_label_singular(), // Singular name of the listed records
49
+			'plural'   => give_get_forms_label_plural(), // Plural name of the listed records
50
+			'ajax'     => false, // Does this table support ajax?
51
+		));
52 52
 
53
-		add_action( 'give_log_view_actions', array( $this, 'give_forms_filter' ) );
53
+		add_action('give_log_view_actions', array($this, 'give_forms_filter'));
54 54
 	}
55 55
 
56 56
 	/**
@@ -64,39 +64,39 @@  discard block
 block discarded – undo
64 64
 	 *
65 65
 	 * @return string Column Name
66 66
 	 */
67
-	public function column_default( $item, $column_name ) {
67
+	public function column_default($item, $column_name) {
68 68
 
69
-		$payment = give_get_payment_by( 'id', $item['payment_id'] );
69
+		$payment = give_get_payment_by('id', $item['payment_id']);
70 70
 
71
-		switch ( $column_name ) {
71
+		switch ($column_name) {
72 72
 			case 'form' :
73
-				$form_title = get_the_title( $item[ $column_name ] );
74
-				$form_title = empty( $form_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $item[ $column_name ] ) : $form_title;
75
-				return '<a href="' . esc_url( add_query_arg( 'form', $item[ $column_name ] ) ) . '" >' . $form_title . '</a>';
73
+				$form_title = get_the_title($item[$column_name]);
74
+				$form_title = empty($form_title) ? sprintf(__('Untitled (#%s)', 'give'), $item[$column_name]) : $form_title;
75
+				return '<a href="'.esc_url(add_query_arg('form', $item[$column_name])).'" >'.$form_title.'</a>';
76 76
 
77 77
 			case 'user_id' :
78
-				return '<a href="' .
79
-					   admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . ( ! empty( $item['user_id'] ) ? urlencode( $item['user_id'] ) : give_get_payment_user_email( $item['payment_id'] ) ) ) .
80
-					   '">' . $item['user_name'] . '</a>';
78
+				return '<a href="'.
79
+					   admin_url('edit.php?post_type=give_forms&page=give-payment-history&user='.( ! empty($item['user_id']) ? urlencode($item['user_id']) : give_get_payment_user_email($item['payment_id']))).
80
+					   '">'.$item['user_name'].'</a>';
81 81
 
82 82
 			case 'amount' :
83
-				return give_currency_filter( give_format_amount( $item['amount'], array( 'sanitize' => false ) ) );
83
+				return give_currency_filter(give_format_amount($item['amount'], array('sanitize' => false)));
84 84
 
85 85
 			case 'status' :
86 86
 
87
-				$value = '<div class="give-donation-status status-' . sanitize_title( give_get_payment_status( $payment, true ) ) . '"><span class="give-donation-status-icon"></span> ' . give_get_payment_status( $payment, true ) . '</div>';
87
+				$value = '<div class="give-donation-status status-'.sanitize_title(give_get_payment_status($payment, true)).'"><span class="give-donation-status-icon"></span> '.give_get_payment_status($payment, true).'</div>';
88 88
 
89
-				if ( $payment->mode == 'test' ) {
90
-					$value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="' . esc_attr__( 'This donation was made in test mode.', 'give' ) . '">' . __( 'Test', 'give' ) . '</span>';
89
+				if ($payment->mode == 'test') {
90
+					$value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="'.esc_attr__('This donation was made in test mode.', 'give').'">'.__('Test', 'give').'</span>';
91 91
 				}
92 92
 
93 93
 				return $value;
94 94
 
95 95
 			case 'payment_id' :
96
-				return '<a href="' . admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $item['payment_id'] ) . '">' . give_get_payment_number( $item['payment_id'] ) . '</a>';
96
+				return '<a href="'.admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id='.$item['payment_id']).'">'.give_get_payment_number($item['payment_id']).'</a>';
97 97
 
98 98
 			default:
99
-				return $item[ $column_name ];
99
+				return $item[$column_name];
100 100
 		}
101 101
 	}
102 102
 
@@ -109,13 +109,13 @@  discard block
 block discarded – undo
109 109
 	 */
110 110
 	public function get_columns() {
111 111
 		$columns = array(
112
-			'ID'         => __( 'Log ID', 'give' ),
113
-			'user_id'    => __( 'Donor', 'give' ),
114
-			'form'       => __( 'Form', 'give' ),
115
-			'amount'     => __( 'Donation Amount', 'give' ),
116
-			'status'     => __( 'Status', 'give' ),
117
-			'payment_id' => __( 'Donation ID', 'give' ),
118
-			'date'       => __( 'Date', 'give' ),
112
+			'ID'         => __('Log ID', 'give'),
113
+			'user_id'    => __('Donor', 'give'),
114
+			'form'       => __('Form', 'give'),
115
+			'amount'     => __('Donation Amount', 'give'),
116
+			'status'     => __('Status', 'give'),
117
+			'payment_id' => __('Donation ID', 'give'),
118
+			'date'       => __('Date', 'give'),
119 119
 		);
120 120
 
121 121
 		return $columns;
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 	 * @return int Current page number
130 130
 	 */
131 131
 	public function get_paged() {
132
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
132
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
133 133
 	}
134 134
 
135 135
 	/**
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 	 * @return mixed int If User ID, string If Email/Login
141 141
 	 */
142 142
 	public function get_filtered_user() {
143
-		return isset( $_GET['user'] ) ? absint( $_GET['user'] ) : false;
143
+		return isset($_GET['user']) ? absint($_GET['user']) : false;
144 144
 	}
145 145
 
146 146
 	/**
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 	 * @return int Download ID
152 152
 	 */
153 153
 	public function get_filtered_give_form() {
154
-		return ! empty( $_GET['form'] ) ? absint( $_GET['form'] ) : false;
154
+		return ! empty($_GET['form']) ? absint($_GET['form']) : false;
155 155
 	}
156 156
 
157 157
 	/**
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 	 * @return string|bool string If search is present, false otherwise
163 163
 	 */
164 164
 	public function get_search() {
165
-		return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false;
165
+		return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false;
166 166
 	}
167 167
 
168 168
 
@@ -178,20 +178,20 @@  discard block
 block discarded – undo
178 178
 	 *
179 179
 	 * @param string $which
180 180
 	 */
181
-	protected function display_tablenav( $which ) {
181
+	protected function display_tablenav($which) {
182 182
 
183
-		if ( 'top' === $which ) {
184
-			wp_nonce_field( 'bulk-' . $this->_args['plural'] );
183
+		if ('top' === $which) {
184
+			wp_nonce_field('bulk-'.$this->_args['plural']);
185 185
 		}
186 186
 		?>
187
-		<div class="tablenav <?php echo esc_attr( $which ); ?>">
187
+		<div class="tablenav <?php echo esc_attr($which); ?>">
188 188
 
189 189
 			<div class="alignleft actions bulkactions">
190
-				<?php $this->bulk_actions( $which ); ?>
190
+				<?php $this->bulk_actions($which); ?>
191 191
 			</div>
192 192
 			<?php
193
-			$this->extra_tablenav( $which );
194
-			$this->pagination( $which );
193
+			$this->extra_tablenav($which);
194
+			$this->pagination($which);
195 195
 			?>
196 196
 
197 197
 			<br class="clear"/>
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 
216 216
 		$meta_query = array();
217 217
 
218
-		if ( $user ) {
218
+		if ($user) {
219 219
 			// Show only logs from a specific user.
220 220
 			$meta_query[] = array(
221 221
 				'key'   => '_give_log_user_id',
@@ -224,8 +224,8 @@  discard block
 block discarded – undo
224 224
 		}
225 225
 
226 226
 		$search = $this->get_search();
227
-		if ( $search ) {
228
-			if ( is_email( $search ) ) {
227
+		if ($search) {
228
+			if (is_email($search)) {
229 229
 				// This is an email search. We use this to ensure it works for guest users and logged-in users.
230 230
 				$key     = '_give_log_user_info';
231 231
 				$compare = 'LIKE';
@@ -234,32 +234,32 @@  discard block
 block discarded – undo
234 234
 				$key     = '_give_log_user_id';
235 235
 				$compare = 'LIKE';
236 236
 
237
-				if ( ! is_numeric( $search ) ) {
237
+				if ( ! is_numeric($search)) {
238 238
 					// Searching for user by username
239
-					$user = get_user_by( 'login', $search );
239
+					$user = get_user_by('login', $search);
240 240
 
241
-					if ( $user ) {
241
+					if ($user) {
242 242
 						// Found one, set meta value to user's ID.
243 243
 						$search = $user->ID;
244 244
 					} else {
245 245
 						// No user found so let's do a real search query.
246
-						$users = new WP_User_Query( array(
246
+						$users = new WP_User_Query(array(
247 247
 							'search'         => $search,
248
-							'search_columns' => array( 'user_url', 'user_nicename' ),
248
+							'search_columns' => array('user_url', 'user_nicename'),
249 249
 							'number'         => 1,
250 250
 							'fields'         => 'ids',
251
-						) );
251
+						));
252 252
 
253 253
 						$found_user = $users->get_results();
254 254
 
255
-						if ( $found_user ) {
255
+						if ($found_user) {
256 256
 							$search = $found_user[0];
257 257
 						}
258 258
 					}
259 259
 				}
260 260
 			}
261 261
 
262
-			if ( ! $this->file_search ) {
262
+			if ( ! $this->file_search) {
263 263
 				// Meta query only works for non file name search.
264 264
 				$meta_query[] = array(
265 265
 					'key'     => $key,
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 	 * @since  1.0
281 281
 	 * @return void
282 282
 	 */
283
-	function bulk_actions( $which = '' ) {
283
+	function bulk_actions($which = '') {
284 284
 		give_log_views();
285 285
 	}
286 286
 
@@ -292,24 +292,24 @@  discard block
 block discarded – undo
292 292
 	 * @return void
293 293
 	 */
294 294
 	public function give_forms_filter() {
295
-		$give_forms = get_posts( array(
295
+		$give_forms = get_posts(array(
296 296
 			'post_type'              => 'give_forms',
297 297
 			'post_status'            => 'any',
298
-			'posts_per_page'         => - 1,
298
+			'posts_per_page'         => -1,
299 299
 			'orderby'                => 'title',
300 300
 			'order'                  => 'ASC',
301 301
 			'fields'                 => 'ids',
302 302
 			'update_post_meta_cache' => false,
303 303
 			'update_post_term_cache' => false,
304
-		) );
304
+		));
305 305
 
306
-		if ( $give_forms ) {
306
+		if ($give_forms) {
307 307
 			echo '<select name="form" id="give-log-form-filter">';
308
-			echo '<option value="0">' . __( 'All', 'give' ) . '</option>';
309
-			foreach ( $give_forms as $form ) {
310
-				$form_title = get_the_title( $form );
311
-				$form_title = empty( $form_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $form ) : $form_title;
312
-				echo '<option value="' . $form . '"' . selected( $form, $this->get_filtered_give_form() ) . '>' . esc_html( $form_title ) . '</option>';
308
+			echo '<option value="0">'.__('All', 'give').'</option>';
309
+			foreach ($give_forms as $form) {
310
+				$form_title = get_the_title($form);
311
+				$form_title = empty($form_title) ? sprintf(__('Untitled (#%s)', 'give'), $form) : $form_title;
312
+				echo '<option value="'.$form.'"'.selected($form, $this->get_filtered_give_form()).'>'.esc_html($form_title).'</option>';
313 313
 			}
314 314
 			echo '</select>';
315 315
 		}
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 
330 330
 		$logs_data = array();
331 331
 		$paged     = $this->get_paged();
332
-		$give_form = empty( $_GET['s'] ) ? $this->get_filtered_give_form() : null;
332
+		$give_form = empty($_GET['s']) ? $this->get_filtered_give_form() : null;
333 333
 		$user      = $this->get_filtered_user();
334 334
 
335 335
 		$log_query = array(
@@ -340,38 +340,38 @@  discard block
 block discarded – undo
340 340
 			'posts_per_page' => $this->per_page,
341 341
 		);
342 342
 
343
-		$cache_key = Give_Cache::get_key( 'get_logs', $log_query );
343
+		$cache_key = Give_Cache::get_key('get_logs', $log_query);
344 344
 
345 345
 		// Return result from cache if exist.
346
-		if ( ! ( $logs_data = Give_Cache::get( $cache_key ) ) ) {
347
-			$logs = $give_logs->get_connected_logs( $log_query );
346
+		if ( ! ($logs_data = Give_Cache::get($cache_key))) {
347
+			$logs = $give_logs->get_connected_logs($log_query);
348 348
 
349
-			if ( $logs ) {
350
-				foreach ( $logs as $log ) {
351
-					$payment_id = give_get_meta( $log->ID, '_give_log_payment_id', true );
349
+			if ($logs) {
350
+				foreach ($logs as $log) {
351
+					$payment_id = give_get_meta($log->ID, '_give_log_payment_id', true);
352 352
 
353 353
 					// Make sure this payment hasn't been deleted.
354
-					if ( get_post( $payment_id ) ) :
355
-						$user_info      = give_get_payment_meta_user_info( $payment_id );
356
-						$payment_meta   = give_get_payment_meta( $payment_id );
357
-						$payment_amount = give_get_payment_amount( $payment_id );
354
+					if (get_post($payment_id)) :
355
+						$user_info      = give_get_payment_meta_user_info($payment_id);
356
+						$payment_meta   = give_get_payment_meta($payment_id);
357
+						$payment_amount = give_get_payment_amount($payment_id);
358 358
 
359 359
 						$logs_data[] = array(
360
-							'ID'         => '<span class="give-item-label give-item-label-gray">' . $log->ID . '</span>',
360
+							'ID'         => '<span class="give-item-label give-item-label-gray">'.$log->ID.'</span>',
361 361
 							'payment_id' => $payment_id,
362 362
 							'form'       => $log->post_parent,
363 363
 							'amount'     => $payment_amount,
364 364
 							'user_id'    => $user_info['id'],
365
-							'user_name'  => $user_info['first_name'] . ' ' . $user_info['last_name'],
366
-							'date'       => get_post_field( 'post_date', $payment_id ),
365
+							'user_name'  => $user_info['first_name'].' '.$user_info['last_name'],
366
+							'date'       => get_post_field('post_date', $payment_id),
367 367
 						);
368 368
 
369 369
 					endif;
370 370
 				}
371 371
 
372 372
 				// Cache results.
373
-				if ( ! empty( $logs_data ) ) {
374
-					Give_Cache::set( $cache_key, $logs_data );
373
+				if ( ! empty($logs_data)) {
374
+					Give_Cache::set($cache_key, $logs_data);
375 375
 				}
376 376
 			}
377 377
 		}
@@ -399,15 +399,15 @@  discard block
 block discarded – undo
399 399
 		$columns               = $this->get_columns();
400 400
 		$hidden                = array();
401 401
 		$sortable              = $this->get_sortable_columns();
402
-		$this->_column_headers = array( $columns, $hidden, $sortable );
402
+		$this->_column_headers = array($columns, $hidden, $sortable);
403 403
 		$current_page          = $this->get_pagenum();
404 404
 		$this->items           = $this->get_logs();
405
-		$total_items           = $give_logs->get_log_count( $this->get_filtered_give_form(), 'sale', $this->get_meta_query() );
405
+		$total_items           = $give_logs->get_log_count($this->get_filtered_give_form(), 'sale', $this->get_meta_query());
406 406
 
407
-		$this->set_pagination_args( array(
407
+		$this->set_pagination_args(array(
408 408
 				'total_items' => $total_items,
409 409
 				'per_page'    => $this->per_page,
410
-				'total_pages' => ceil( $total_items / $this->per_page ),
410
+				'total_pages' => ceil($total_items / $this->per_page),
411 411
 			)
412 412
 		);
413 413
 	}
Please login to merge, or discard this patch.
includes/admin/tools/data/tools-actions.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -20,10 +20,10 @@  discard block
 block discarded – undo
20 20
  * @since  1.5
21 21
  */
22 22
 function give_register_batch_recount_export_classes() {
23
-	add_action( 'give_batch_export_class_include', 'give_include_batch_export_class', 10, 1 );
23
+	add_action('give_batch_export_class_include', 'give_include_batch_export_class', 10, 1);
24 24
 }
25 25
 
26
-add_action( 'give_register_batch_exporter', 'give_register_batch_recount_export_classes', 10 );
26
+add_action('give_register_batch_exporter', 'give_register_batch_recount_export_classes', 10);
27 27
 
28 28
 
29 29
 /**
@@ -35,35 +35,35 @@  discard block
 block discarded – undo
35 35
  *
36 36
  * @return void
37 37
  */
38
-function give_include_batch_export_class( $class ) {
39
-	switch ( $class ) {
38
+function give_include_batch_export_class($class) {
39
+	switch ($class) {
40 40
 
41 41
 		case 'Give_Tools_Delete_Donors':
42
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-delete-test-donors.php';
42
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-delete-test-donors.php';
43 43
 			break;
44 44
 
45 45
 		case 'Give_Tools_Delete_Test_Transactions':
46
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-delete-test-transactions.php';
46
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-delete-test-transactions.php';
47 47
 			break;
48 48
 
49 49
 		case 'Give_Tools_Recount_Donor_Stats':
50
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-donor-stats.php';
50
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-donor-stats.php';
51 51
 			break;
52 52
 
53 53
 		case 'Give_Tools_Reset_Stats':
54
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-reset-stats.php';
54
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-reset-stats.php';
55 55
 			break;
56 56
 
57 57
 		case 'Give_Tools_Recount_All_Stats':
58
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-all-stats.php';
58
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-all-stats.php';
59 59
 			break;
60 60
 
61 61
 		case 'Give_Tools_Recount_Form_Stats':
62
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-form-stats.php';
62
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-form-stats.php';
63 63
 			break;
64 64
 
65 65
 		case 'Give_Tools_Recount_Income':
66
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-income.php';
66
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-income.php';
67 67
 			break;
68 68
 	}
69 69
 }
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-recount-form-stats.php 1 patch
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly.
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -59,58 +59,58 @@  discard block
 block discarded – undo
59 59
 	 * @return bool
60 60
 	 */
61 61
 	public function get_data() {
62
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
62
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
63 63
 
64
-		if ( $this->step == 1 ) {
65
-			$this->delete_data( 'give_temp_recount_form_stats' );
64
+		if ($this->step == 1) {
65
+			$this->delete_data('give_temp_recount_form_stats');
66 66
 		}
67 67
 
68
-		$totals = $this->get_stored_data( 'give_temp_recount_form_stats' );
68
+		$totals = $this->get_stored_data('give_temp_recount_form_stats');
69 69
 
70
-		if ( false === $totals ) {
70
+		if (false === $totals) {
71 71
 			$totals = array(
72 72
 				'earnings' => (float) 0,
73 73
 				'sales'    => 0,
74 74
 			);
75
-			$this->store_data( 'give_temp_recount_form_stats', $totals );
75
+			$this->store_data('give_temp_recount_form_stats', $totals);
76 76
 		}
77 77
 
78
-		$args = apply_filters( 'give_recount_form_stats_args', array(
78
+		$args = apply_filters('give_recount_form_stats_args', array(
79 79
 			'give_forms' => $this->form_id,
80 80
 			'number'     => $this->per_step,
81 81
 			'status'     => $accepted_statuses,
82 82
 			'paged'      => $this->step,
83 83
 			'fields'     => 'ids',
84
-		) );
84
+		));
85 85
 
86
-		$payments = new Give_Payments_Query( $args );
86
+		$payments = new Give_Payments_Query($args);
87 87
 		$payments = $payments->get_payments();
88 88
 
89
-		if ( $payments ) {
90
-			foreach ( $payments as $payment ) {
89
+		if ($payments) {
90
+			foreach ($payments as $payment) {
91 91
 				//Ensure acceptible status only
92
-				if ( ! in_array( $payment->post_status, $accepted_statuses ) ) {
92
+				if ( ! in_array($payment->post_status, $accepted_statuses)) {
93 93
 					continue;
94 94
 				}
95 95
 
96 96
 				//Ensure only payments for this form are counted
97
-				if ( $payment->form_id != $this->form_id ) {
97
+				if ($payment->form_id != $this->form_id) {
98 98
 					continue;
99 99
 				}
100 100
 
101
-				$totals['sales'] ++;
101
+				$totals['sales']++;
102 102
 				$totals['earnings'] += $payment->total;
103 103
 
104 104
 			}
105 105
 
106
-			$this->store_data( 'give_temp_recount_form_stats', $totals );
106
+			$this->store_data('give_temp_recount_form_stats', $totals);
107 107
 
108 108
 			return true;
109 109
 		}
110 110
 
111 111
 
112
-		give_update_meta( $this->form_id, '_give_form_sales', $totals['sales'] );
113
-		give_update_meta( $this->form_id, '_give_form_earnings', give_sanitize_amount_for_db( $totals['earnings'] ) );
112
+		give_update_meta($this->form_id, '_give_form_sales', $totals['sales']);
113
+		give_update_meta($this->form_id, '_give_form_earnings', give_sanitize_amount_for_db($totals['earnings']));
114 114
 
115 115
 		return false;
116 116
 	}
@@ -122,35 +122,35 @@  discard block
 block discarded – undo
122 122
 	 * @return int
123 123
 	 */
124 124
 	public function get_percentage_complete() {
125
-		if ( $this->step == 1 ) {
126
-			$this->delete_data( 'give_recount_total_' . $this->form_id );
125
+		if ($this->step == 1) {
126
+			$this->delete_data('give_recount_total_'.$this->form_id);
127 127
 		}
128 128
 
129
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
130
-		$total             = $this->get_stored_data( 'give_recount_total_' . $this->form_id );
129
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
130
+		$total             = $this->get_stored_data('give_recount_total_'.$this->form_id);
131 131
 
132
-		if ( false === $total ) {
132
+		if (false === $total) {
133 133
 			$total = 0;
134
-			$args  = apply_filters( 'give_recount_form_stats_total_args', array(
134
+			$args  = apply_filters('give_recount_form_stats_total_args', array(
135 135
 				'give_forms' => $this->form_id,
136
-				'number'     => - 1,
136
+				'number'     => -1,
137 137
 				'status'     => $accepted_statuses,
138 138
 				'fields'     => 'ids',
139
-			) );
139
+			));
140 140
 
141
-			$payments = new Give_Payments_Query( $args );
142
-			$total    = count( $payments->get_payments() );
143
-			$this->store_data( 'give_recount_total_' . $this->form_id, $total );
141
+			$payments = new Give_Payments_Query($args);
142
+			$total    = count($payments->get_payments());
143
+			$this->store_data('give_recount_total_'.$this->form_id, $total);
144 144
 
145 145
 		}
146 146
 
147 147
 		$percentage = 100;
148 148
 
149
-		if ( $total > 0 ) {
150
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
149
+		if ($total > 0) {
150
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
151 151
 		}
152 152
 
153
-		if ( $percentage > 100 ) {
153
+		if ($percentage > 100) {
154 154
 			$percentage = 100;
155 155
 		}
156 156
 
@@ -164,8 +164,8 @@  discard block
 block discarded – undo
164 164
 	 *
165 165
 	 * @param array $request The Form Data passed into the batch processing
166 166
 	 */
167
-	public function set_properties( $request ) {
168
-		$this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false;
167
+	public function set_properties($request) {
168
+		$this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false;
169 169
 	}
170 170
 
171 171
 	/**
@@ -176,31 +176,31 @@  discard block
 block discarded – undo
176 176
 	 */
177 177
 	public function process_step() {
178 178
 
179
-		if ( ! $this->can_export() ) {
180
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
179
+		if ( ! $this->can_export()) {
180
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
181 181
 		}
182 182
 
183 183
 		$had_data = $this->get_data();
184 184
 
185
-		if ( $had_data ) {
185
+		if ($had_data) {
186 186
 			$this->done = false;
187 187
 
188 188
 			return true;
189 189
 		} else {
190
-			$this->delete_data( 'give_recount_total_' . $this->form_id );
191
-			$this->delete_data( 'give_temp_recount_form_stats' );
190
+			$this->delete_data('give_recount_total_'.$this->form_id);
191
+			$this->delete_data('give_temp_recount_form_stats');
192 192
 			$this->done    = true;
193
-			$this->message = sprintf( esc_html__( 'Donation counts and income amount statistics successfully recounted for "%s".', 'give' ), get_the_title( $this->form_id ) );
193
+			$this->message = sprintf(esc_html__('Donation counts and income amount statistics successfully recounted for "%s".', 'give'), get_the_title($this->form_id));
194 194
 
195 195
 			return false;
196 196
 		}
197 197
 	}
198 198
 
199 199
 	public function headers() {
200
-		ignore_user_abort( true );
200
+		ignore_user_abort(true);
201 201
 
202
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
203
-			set_time_limit( 0 );
202
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
203
+			set_time_limit(0);
204 204
 		}
205 205
 	}
206 206
 
@@ -228,11 +228,11 @@  discard block
 block discarded – undo
228 228
 	 *
229 229
 	 * @return mixed       Returns the data from the database
230 230
 	 */
231
-	private function get_stored_data( $key ) {
231
+	private function get_stored_data($key) {
232 232
 		global $wpdb;
233
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
233
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
234 234
 
235
-		return empty( $value ) ? false : maybe_unserialize( $value );
235
+		return empty($value) ? false : maybe_unserialize($value);
236 236
 	}
237 237
 
238 238
 	/**
@@ -245,10 +245,10 @@  discard block
 block discarded – undo
245 245
 	 *
246 246
 	 * @return void
247 247
 	 */
248
-	private function store_data( $key, $value ) {
248
+	private function store_data($key, $value) {
249 249
 		global $wpdb;
250 250
 
251
-		$value = maybe_serialize( $value );
251
+		$value = maybe_serialize($value);
252 252
 
253 253
 		$data = array(
254 254
 			'option_name'  => $key,
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 			'%s',
263 263
 		);
264 264
 
265
-		$wpdb->replace( $wpdb->options, $data, $formats );
265
+		$wpdb->replace($wpdb->options, $data, $formats);
266 266
 	}
267 267
 
268 268
 	/**
@@ -274,9 +274,9 @@  discard block
 block discarded – undo
274 274
 	 *
275 275
 	 * @return void
276 276
 	 */
277
-	private function delete_data( $key ) {
277
+	private function delete_data($key) {
278 278
 		global $wpdb;
279
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
279
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
280 280
 	}
281 281
 
282 282
 }
283 283
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-recount-all-stats.php 1 patch
Spacing   +94 added lines, -96 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly.
14
-if (! defined('ABSPATH') ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -80,104 +80,102 @@  discard block
 block discarded – undo
80 80
 	 */
81 81
 	public function get_data() {
82 82
 
83
-		$totals             = $this->get_stored_data( 'give_temp_recount_all_stats' );
84
-		$payment_items      = $this->get_stored_data( 'give_temp_payment_items' );
85
-		$processed_payments = $this->get_stored_data( 'give_temp_processed_payments' );
86
-		$accepted_statuses  = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
83
+		$totals             = $this->get_stored_data('give_temp_recount_all_stats');
84
+		$payment_items      = $this->get_stored_data('give_temp_payment_items');
85
+		$processed_payments = $this->get_stored_data('give_temp_processed_payments');
86
+		$accepted_statuses  = apply_filters('give_recount_accepted_statuses', array('publish'));
87 87
 
88
-		if ( false === $totals ) {
88
+		if (false === $totals) {
89 89
 			$totals = array();
90 90
 		}
91 91
 
92
-		if ( false === $payment_items ) {
92
+		if (false === $payment_items) {
93 93
 			$payment_items = array();
94 94
 		}
95 95
 
96
-		if ( false === $processed_payments ) {
96
+		if (false === $processed_payments) {
97 97
 			$processed_payments = array();
98 98
 		}
99 99
 
100
-		$all_forms = $this->get_stored_data( 'give_temp_form_ids' );
100
+		$all_forms = $this->get_stored_data('give_temp_form_ids');
101 101
 
102
-		$payments = $this->get_stored_data( 'give_temp_all_payments_data' );
102
+		$payments = $this->get_stored_data('give_temp_all_payments_data');
103 103
 
104
-		if( false === $payments ) {
105
-			$args = apply_filters( 'give_recount_form_stats_args', array(
104
+		if (false === $payments) {
105
+			$args = apply_filters('give_recount_form_stats_args', array(
106 106
 				'post_parent__in' => $all_forms,
107 107
 				'number'          => $this->per_step,
108 108
 				'status'          => 'publish',
109 109
 				'paged'           => $this->step,
110 110
 				'output'          => 'payments',
111
-			) );
111
+			));
112 112
 
113
-			$payments_query = new Give_Payments_Query( $args );
113
+			$payments_query = new Give_Payments_Query($args);
114 114
 			$payments       = $payments_query->get_payments();
115 115
 		}
116 116
 
117
-		if ( $payments ) {
117
+		if ($payments) {
118 118
 
119 119
 			//Loop through payments
120
-			foreach ( $payments as $payment ) {
120
+			foreach ($payments as $payment) {
121 121
 
122 122
 				// Prevent payments that have all ready been retrieved from a previous sales log from counting again.
123
-				if ( in_array( $payment->ID, $processed_payments ) ) {
123
+				if (in_array($payment->ID, $processed_payments)) {
124 124
 					continue;
125 125
 				}
126 126
 
127 127
 				// Verify accepted status
128
-				if ( ! in_array( $payment->post_status, $accepted_statuses ) ) {
128
+				if ( ! in_array($payment->post_status, $accepted_statuses)) {
129 129
 					$processed_payments[] = $payment->ID;
130 130
 					continue;
131 131
 				}
132 132
 
133
-				$payment_item = $payment_items[ $payment->ID ];
133
+				$payment_item = $payment_items[$payment->ID];
134 134
 
135
-				$form_id = isset( $payment_item['id'] ) ? $payment_item['id'] : '';
135
+				$form_id = isset($payment_item['id']) ? $payment_item['id'] : '';
136 136
 
137 137
 				//Must have a form ID
138
-				if ( empty( $form_id ) ) {
138
+				if (empty($form_id)) {
139 139
 					continue;
140 140
 				}
141 141
 
142 142
 				//Form ID must be within $all_forms array to be validated
143
-				if ( ! in_array( $form_id, $all_forms ) ) {
143
+				if ( ! in_array($form_id, $all_forms)) {
144 144
 					continue;
145 145
 				}
146 146
 
147 147
 				// Set Sales count
148
-				$totals[ $form_id ]['sales'] = isset( $totals[ $form_id ]['sales'] ) ?
149
-					++ $totals[ $form_id ]['sales'] :
150
-					1;
148
+				$totals[$form_id]['sales'] = isset($totals[$form_id]['sales']) ?
149
+					++$totals[$form_id]['sales'] : 1;
151 150
 
152 151
 				// Set Total Earnings
153
-				$totals[ $form_id ]['earnings'] = isset( $totals[ $form_id ]['earnings'] ) ?
154
-					( $totals[ $form_id ]['earnings'] + $payment_item['price'] ) :
155
-					$payment_item['price'];
152
+				$totals[$form_id]['earnings'] = isset($totals[$form_id]['earnings']) ?
153
+					($totals[$form_id]['earnings'] + $payment_item['price']) : $payment_item['price'];
156 154
 
157 155
 				$processed_payments[] = $payment->ID;
158 156
 			}
159 157
 
160 158
 			// Get the list of form ids which does not contain any payment record.
161
-			$remaining_form_ids = array_diff( $all_forms, array_keys($totals) );
162
-			foreach( $remaining_form_ids as $form_id) {
159
+			$remaining_form_ids = array_diff($all_forms, array_keys($totals));
160
+			foreach ($remaining_form_ids as $form_id) {
163 161
 				//If array key doesn't exist, create it
164
-				if ( ! array_key_exists( $form_id, $totals ) ) {
165
-					$totals[ $form_id ] = array(
162
+				if ( ! array_key_exists($form_id, $totals)) {
163
+					$totals[$form_id] = array(
166 164
 						'sales'    => (int) 0,
167 165
 						'earnings' => (float) 0,
168 166
 					);
169 167
 				}
170 168
 			}
171 169
 
172
-			$this->store_data( 'give_temp_processed_payments', $processed_payments );
173
-			$this->store_data( 'give_temp_recount_all_stats', $totals );
170
+			$this->store_data('give_temp_processed_payments', $processed_payments);
171
+			$this->store_data('give_temp_recount_all_stats', $totals);
174 172
 
175 173
 			return true;
176 174
 		}
177 175
 
178
-		foreach ( $totals as $key => $stats ) {
179
-			give_update_meta( $key, '_give_form_sales', $stats['sales'] );
180
-			give_update_meta( $key, '_give_form_earnings', give_sanitize_amount_for_db( $stats['earnings'] ) );
176
+		foreach ($totals as $key => $stats) {
177
+			give_update_meta($key, '_give_form_sales', $stats['sales']);
178
+			give_update_meta($key, '_give_form_earnings', give_sanitize_amount_for_db($stats['earnings']));
181 179
 		}
182 180
 
183 181
 		return false;
@@ -192,20 +190,20 @@  discard block
 block discarded – undo
192 190
 	 */
193 191
 	public function get_percentage_complete() {
194 192
 
195
-		$total = $this->get_stored_data( 'give_recount_all_total' );
193
+		$total = $this->get_stored_data('give_recount_all_total');
196 194
 
197
-		if ( false === $total ) {
195
+		if (false === $total) {
198 196
 			$this->pre_fetch();
199
-			$total = $this->get_stored_data( 'give_recount_all_total' );
197
+			$total = $this->get_stored_data('give_recount_all_total');
200 198
 		}
201 199
 
202 200
 		$percentage = 100;
203 201
 
204
-		if ( $total > 0 ) {
205
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
202
+		if ($total > 0) {
203
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
206 204
 		}
207 205
 
208
-		if ( $percentage > 100 ) {
206
+		if ($percentage > 100) {
209 207
 			$percentage = 100;
210 208
 		}
211 209
 
@@ -219,8 +217,8 @@  discard block
 block discarded – undo
219 217
 	 *
220 218
 	 * @param array $request The Form Data passed into the batch processing
221 219
 	 */
222
-	public function set_properties( $request ) {
223
-		$this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false;
220
+	public function set_properties($request) {
221
+		$this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false;
224 222
 	}
225 223
 
226 224
 	/**
@@ -231,35 +229,35 @@  discard block
 block discarded – undo
231 229
 	 */
232 230
 	public function process_step() {
233 231
 
234
-		if ( ! $this->can_export() ) {
235
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
232
+		if ( ! $this->can_export()) {
233
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
236 234
 		}
237 235
 
238 236
 		$had_data = $this->get_data();
239 237
 
240
-		if ( $had_data ) {
238
+		if ($had_data) {
241 239
 			$this->done = false;
242 240
 
243 241
 			return true;
244 242
 		} else {
245
-			$this->delete_data( 'give_recount_total_' . $this->form_id );
246
-			$this->delete_data( 'give_recount_all_total' );
247
-			$this->delete_data( 'give_temp_recount_all_stats' );
248
-			$this->delete_data( 'give_temp_payment_items' );
249
-			$this->delete_data( 'give_temp_form_ids' );
250
-			$this->delete_data( 'give_temp_processed_payments' );
243
+			$this->delete_data('give_recount_total_'.$this->form_id);
244
+			$this->delete_data('give_recount_all_total');
245
+			$this->delete_data('give_temp_recount_all_stats');
246
+			$this->delete_data('give_temp_payment_items');
247
+			$this->delete_data('give_temp_form_ids');
248
+			$this->delete_data('give_temp_processed_payments');
251 249
 			$this->done    = true;
252
-			$this->message = esc_html__( 'Donation form income amounts and donation counts stats successfully recounted.', 'give' );
250
+			$this->message = esc_html__('Donation form income amounts and donation counts stats successfully recounted.', 'give');
253 251
 
254 252
 			return false;
255 253
 		}
256 254
 	}
257 255
 
258 256
 	public function headers() {
259
-		ignore_user_abort( true );
257
+		ignore_user_abort(true);
260 258
 
261
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
262
-			set_time_limit( 0 );
259
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
260
+			set_time_limit(0);
263 261
 		}
264 262
 	}
265 263
 
@@ -286,69 +284,69 @@  discard block
 block discarded – undo
286 284
 	 */
287 285
 	public function pre_fetch() {
288 286
 
289
-		if ( $this->step == 1 ) {
290
-			$this->delete_data( 'give_temp_recount_all_total' );
291
-			$this->delete_data( 'give_temp_recount_all_stats' );
292
-			$this->delete_data( 'give_temp_payment_items' );
293
-			$this->delete_data( 'give_temp_processed_payments' );
294
-			$this->delete_data( 'give_temp_all_payments_data' );
287
+		if ($this->step == 1) {
288
+			$this->delete_data('give_temp_recount_all_total');
289
+			$this->delete_data('give_temp_recount_all_stats');
290
+			$this->delete_data('give_temp_payment_items');
291
+			$this->delete_data('give_temp_processed_payments');
292
+			$this->delete_data('give_temp_all_payments_data');
295 293
 		}
296 294
 
297
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
298
-		$total             = $this->get_stored_data( 'give_temp_recount_all_total' );
295
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
296
+		$total             = $this->get_stored_data('give_temp_recount_all_total');
299 297
 
300
-		if ( false === $total ) {
298
+		if (false === $total) {
301 299
 			$total         = 0;
302
-			$payment_items = $this->get_stored_data( 'give_temp_payment_items' );
300
+			$payment_items = $this->get_stored_data('give_temp_payment_items');
303 301
 
304
-			if ( false === $payment_items ) {
302
+			if (false === $payment_items) {
305 303
 				$payment_items = array();
306
-				$this->store_data( 'give_temp_payment_items', $payment_items );
304
+				$this->store_data('give_temp_payment_items', $payment_items);
307 305
 			}
308 306
 
309 307
 			$args = array(
310 308
 				'post_status'    => 'publish',
311 309
 				'post_type'      => 'give_forms',
312
-				'posts_per_page' => - 1,
310
+				'posts_per_page' => -1,
313 311
 				'fields'         => 'ids',
314 312
 			);
315 313
 
316
-			$all_forms = get_posts( $args );
317
-			$this->store_data( 'give_temp_form_ids', $all_forms );
314
+			$all_forms = get_posts($args);
315
+			$this->store_data('give_temp_form_ids', $all_forms);
318 316
 
319
-			$args = apply_filters( 'give_recount_form_stats_total_args', array(
317
+			$args = apply_filters('give_recount_form_stats_total_args', array(
320 318
 				'post_parent__in'   => $all_forms,
321 319
 				'number'            => $this->per_step,
322 320
 				'status'            => 'publish',
323 321
 				'page'              => $this->step,
324 322
 				'output'            => 'payments',
325
-			) );
323
+			));
326 324
 
327
-			$payments_query = new Give_Payments_Query( $args );
325
+			$payments_query = new Give_Payments_Query($args);
328 326
 			$payments       = $payments_query->get_payments();
329
-			$total          = wp_count_posts( 'give_payment' )->publish;
327
+			$total          = wp_count_posts('give_payment')->publish;
330 328
 
331
-			$this->store_data( 'give_temp_all_payments_data', $payments );
329
+			$this->store_data('give_temp_all_payments_data', $payments);
332 330
 
333
-			if ( $payments ) {
331
+			if ($payments) {
334 332
 
335
-				foreach ( $payments as $payment ) {
333
+				foreach ($payments as $payment) {
336 334
 
337
-					$payment = new Give_Payment( $payment->ID );
335
+					$payment = new Give_Payment($payment->ID);
338 336
 					$form_id = $payment->form_id;
339 337
 
340 338
 					//If for some reason somehow the form_ID isn't set check payment meta
341
-					if ( empty( $payment->form_id ) ) {
339
+					if (empty($payment->form_id)) {
342 340
 						$payment_meta = $payment->get_meta();
343
-						$form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0;
341
+						$form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0;
344 342
 					}
345 343
 
346
-					if ( ! in_array( $payment->post_status, $accepted_statuses ) ) {
344
+					if ( ! in_array($payment->post_status, $accepted_statuses)) {
347 345
 						continue;
348 346
 					}
349 347
 
350
-					if ( ! array_key_exists( $payment->ID, $payment_items ) ) {
351
-						$payment_items[ $payment->ID ] = array(
348
+					if ( ! array_key_exists($payment->ID, $payment_items)) {
349
+						$payment_items[$payment->ID] = array(
352 350
 							'id'         => $form_id,
353 351
 							'payment_id' => $payment->ID,
354 352
 							'price'      => $payment->total
@@ -359,8 +357,8 @@  discard block
 block discarded – undo
359 357
 
360 358
 			}
361 359
 
362
-			$this->store_data( 'give_temp_payment_items', $payment_items );
363
-			$this->store_data( 'give_recount_all_total', $total );
360
+			$this->store_data('give_temp_payment_items', $payment_items);
361
+			$this->store_data('give_recount_all_total', $total);
364 362
 		}
365 363
 
366 364
 	}
@@ -374,11 +372,11 @@  discard block
 block discarded – undo
374 372
 	 *
375 373
 	 * @return mixed       Returns the data from the database
376 374
 	 */
377
-	private function get_stored_data( $key ) {
375
+	private function get_stored_data($key) {
378 376
 		global $wpdb;
379
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
377
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
380 378
 
381
-		return empty( $value ) ? false : maybe_unserialize( $value );
379
+		return empty($value) ? false : maybe_unserialize($value);
382 380
 	}
383 381
 
384 382
 	/**
@@ -391,10 +389,10 @@  discard block
 block discarded – undo
391 389
 	 *
392 390
 	 * @return void
393 391
 	 */
394
-	private function store_data( $key, $value ) {
392
+	private function store_data($key, $value) {
395 393
 		global $wpdb;
396 394
 
397
-		$value = maybe_serialize( $value );
395
+		$value = maybe_serialize($value);
398 396
 
399 397
 		$data = array(
400 398
 			'option_name'  => $key,
@@ -408,7 +406,7 @@  discard block
 block discarded – undo
408 406
 			'%s',
409 407
 		);
410 408
 
411
-		$wpdb->replace( $wpdb->options, $data, $formats );
409
+		$wpdb->replace($wpdb->options, $data, $formats);
412 410
 	}
413 411
 
414 412
 	/**
@@ -420,9 +418,9 @@  discard block
 block discarded – undo
420 418
 	 *
421 419
 	 * @return void
422 420
 	 */
423
-	private function delete_data( $key ) {
421
+	private function delete_data($key) {
424 422
 		global $wpdb;
425
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
423
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
426 424
 	}
427 425
 
428 426
 }
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-recount-single-donor-stats.php 1 patch
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly.
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -53,40 +53,40 @@  discard block
 block discarded – undo
53 53
 	 */
54 54
 	public function get_data() {
55 55
 
56
-		$donor    = new Give_Donor( $this->customer_id );
57
-		$payments = $this->get_stored_data( 'give_recount_donor_payments_' . $donor->id );
56
+		$donor    = new Give_Donor($this->customer_id);
57
+		$payments = $this->get_stored_data('give_recount_donor_payments_'.$donor->id);
58 58
 
59
-		$offset     = ( $this->step - 1 ) * $this->per_step;
60
-		$step_items = array_slice( $payments, $offset, $this->per_step );
59
+		$offset     = ($this->step - 1) * $this->per_step;
60
+		$step_items = array_slice($payments, $offset, $this->per_step);
61 61
 
62
-		if ( count( $step_items ) > 0 ) {
63
-			$pending_total = (float) $this->get_stored_data( 'give_stats_donor_pending_total' . $donor->id );
62
+		if (count($step_items) > 0) {
63
+			$pending_total = (float) $this->get_stored_data('give_stats_donor_pending_total'.$donor->id);
64 64
 			$step_total    = 0;
65 65
 
66
-			$found_payment_ids = $this->get_stored_data( 'give_stats_found_payments_' . $donor->id );
66
+			$found_payment_ids = $this->get_stored_data('give_stats_found_payments_'.$donor->id);
67 67
 
68
-			foreach ( $step_items as $payment ) {
69
-				$payment = get_post( $payment->ID );
68
+			foreach ($step_items as $payment) {
69
+				$payment = get_post($payment->ID);
70 70
 
71
-				if ( is_null( $payment ) || is_wp_error( $payment ) || 'give_payment' !== $payment->post_type ) {
71
+				if (is_null($payment) || is_wp_error($payment) || 'give_payment' !== $payment->post_type) {
72 72
 
73
-					$missing_payments   = $this->get_stored_data( 'give_stats_missing_payments' . $donor->id );
73
+					$missing_payments   = $this->get_stored_data('give_stats_missing_payments'.$donor->id);
74 74
 					$missing_payments[] = $payment->ID;
75
-					$this->store_data( 'give_stats_missing_payments' . $donor->id, $missing_payments );
75
+					$this->store_data('give_stats_missing_payments'.$donor->id, $missing_payments);
76 76
 
77 77
 					continue;
78 78
 				}
79 79
 
80 80
 				$should_process_payment = 'publish' == $payment->post_status ? true : false;
81
-				$should_process_payment = apply_filters( 'give_donor_recount_should_process_donation', $should_process_payment, $payment );
81
+				$should_process_payment = apply_filters('give_donor_recount_should_process_donation', $should_process_payment, $payment);
82 82
 
83
-				if ( true === $should_process_payment ) {
83
+				if (true === $should_process_payment) {
84 84
 
85 85
 					$found_payment_ids[] = $payment->ID;
86 86
 
87
-					if ( apply_filters( 'give_donor_recount_should_increase_value', true, $payment ) ) {
88
-						$payment_amount = give_get_payment_amount( $payment->ID );
89
-						$step_total     += $payment_amount;
87
+					if (apply_filters('give_donor_recount_should_increase_value', true, $payment)) {
88
+						$payment_amount = give_get_payment_amount($payment->ID);
89
+						$step_total += $payment_amount;
90 90
 					}
91 91
 
92 92
 				}
@@ -94,8 +94,8 @@  discard block
 block discarded – undo
94 94
 			}
95 95
 
96 96
 			$updated_total = $pending_total + $step_total;
97
-			$this->store_data( 'give_stats_donor_pending_total' . $donor->id, $updated_total );
98
-			$this->store_data( 'give_stats_found_payments_' . $donor->id, $found_payment_ids );
97
+			$this->store_data('give_stats_donor_pending_total'.$donor->id, $updated_total);
98
+			$this->store_data('give_stats_found_payments_'.$donor->id, $found_payment_ids);
99 99
 
100 100
 			return true;
101 101
 		}
@@ -112,16 +112,16 @@  discard block
 block discarded – undo
112 112
 	 */
113 113
 	public function get_percentage_complete() {
114 114
 
115
-		$payments = $this->get_stored_data( 'give_recount_donor_payments_' . $this->customer_id );
116
-		$total    = count( $payments );
115
+		$payments = $this->get_stored_data('give_recount_donor_payments_'.$this->customer_id);
116
+		$total    = count($payments);
117 117
 
118 118
 		$percentage = 100;
119 119
 
120
-		if ( $total > 0 ) {
121
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
120
+		if ($total > 0) {
121
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
122 122
 		}
123 123
 
124
-		if ( $percentage > 100 ) {
124
+		if ($percentage > 100) {
125 125
 			$percentage = 100;
126 126
 		}
127 127
 
@@ -135,8 +135,8 @@  discard block
 block discarded – undo
135 135
 	 *
136 136
 	 * @param array $request The Form Data passed into the batch processing
137 137
 	 */
138
-	public function set_properties( $request ) {
139
-		$this->customer_id = isset( $request['customer_id'] ) ? sanitize_text_field( $request['customer_id'] ) : false;
138
+	public function set_properties($request) {
139
+		$this->customer_id = isset($request['customer_id']) ? sanitize_text_field($request['customer_id']) : false;
140 140
 	}
141 141
 
142 142
 	/**
@@ -147,63 +147,63 @@  discard block
 block discarded – undo
147 147
 	 */
148 148
 	public function process_step() {
149 149
 
150
-		if ( ! $this->can_export() ) {
151
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
150
+		if ( ! $this->can_export()) {
151
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
152 152
 		}
153 153
 
154 154
 		$had_data = $this->get_data();
155 155
 
156
-		if ( $had_data ) {
156
+		if ($had_data) {
157 157
 			$this->done = false;
158 158
 
159 159
 			return true;
160 160
 		} else {
161
-			$donor       = new Give_Donor( $this->customer_id );
162
-			$payment_ids = get_option( 'give_stats_found_payments_' . $donor->id, array() );
163
-			$this->delete_data( 'give_stats_found_payments_' . $donor->id );
161
+			$donor       = new Give_Donor($this->customer_id);
162
+			$payment_ids = get_option('give_stats_found_payments_'.$donor->id, array());
163
+			$this->delete_data('give_stats_found_payments_'.$donor->id);
164 164
 
165
-			$removed_payments = array_unique( get_option( 'give_stats_missing_payments' . $donor->id, array() ) );
165
+			$removed_payments = array_unique(get_option('give_stats_missing_payments'.$donor->id, array()));
166 166
 
167 167
 			// Find non-existing payments (deleted) and total up the donation count
168 168
 			$purchase_count = 0;
169
-			foreach ( $payment_ids as $key => $payment_id ) {
170
-				if ( in_array( $payment_id, $removed_payments ) ) {
171
-					unset( $payment_ids[ $key ] );
169
+			foreach ($payment_ids as $key => $payment_id) {
170
+				if (in_array($payment_id, $removed_payments)) {
171
+					unset($payment_ids[$key]);
172 172
 					continue;
173 173
 				}
174 174
 
175
-				$payment = get_post( $payment_id );
176
-				if ( apply_filters( 'give_donor_recount_should_increase_count', true, $payment ) ) {
177
-					$purchase_count ++;
175
+				$payment = get_post($payment_id);
176
+				if (apply_filters('give_donor_recount_should_increase_count', true, $payment)) {
177
+					$purchase_count++;
178 178
 				}
179 179
 			}
180 180
 
181
-			$this->delete_data( 'give_stats_missing_payments' . $donor->id );
181
+			$this->delete_data('give_stats_missing_payments'.$donor->id);
182 182
 
183
-			$pending_total = $this->get_stored_data( 'give_stats_donor_pending_total' . $donor->id );
184
-			$this->delete_data( 'give_stats_donor_pending_total' . $donor->id );
185
-			$this->delete_data( 'give_recount_donor_stats_' . $donor->id );
186
-			$this->delete_data( 'give_recount_donor_payments_' . $this->customer_id );
183
+			$pending_total = $this->get_stored_data('give_stats_donor_pending_total'.$donor->id);
184
+			$this->delete_data('give_stats_donor_pending_total'.$donor->id);
185
+			$this->delete_data('give_recount_donor_stats_'.$donor->id);
186
+			$this->delete_data('give_recount_donor_payments_'.$this->customer_id);
187 187
 
188
-			$payment_ids = implode( ',', $payment_ids );
189
-			$donor->update( array(
188
+			$payment_ids = implode(',', $payment_ids);
189
+			$donor->update(array(
190 190
 				'payment_ids'    => $payment_ids,
191 191
 				'purchase_count' => $purchase_count,
192 192
 				'purchase_value' => $pending_total,
193
-			) );
193
+			));
194 194
 
195 195
 			$this->done    = true;
196
-			$this->message = esc_html__( 'Donor stats have been successfully recounted.', 'give' );
196
+			$this->message = esc_html__('Donor stats have been successfully recounted.', 'give');
197 197
 
198 198
 			return false;
199 199
 		}
200 200
 	}
201 201
 
202 202
 	public function headers() {
203
-		ignore_user_abort( true );
203
+		ignore_user_abort(true);
204 204
 
205
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
206
-			set_time_limit( 0 );
205
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
206
+			set_time_limit(0);
207 207
 		}
208 208
 	}
209 209
 
@@ -230,26 +230,26 @@  discard block
 block discarded – undo
230 230
 	 * @return void
231 231
 	 */
232 232
 	public function pre_fetch() {
233
-		if ( $this->step === 1 ) {
234
-			$allowed_payment_status = apply_filters( 'give_recount_donors_donation_statuses', give_get_payment_status_keys() );
233
+		if ($this->step === 1) {
234
+			$allowed_payment_status = apply_filters('give_recount_donors_donation_statuses', give_get_payment_status_keys());
235 235
 
236 236
 			// Before we start, let's zero out the customer's data
237
-			$donor = new Give_Donor( $this->customer_id );
238
-			$donor->update( array( 'purchase_value' => give_format_amount( 0, array( 'sanitize' => false ) ), 'purchase_count' => 0 ) );
237
+			$donor = new Give_Donor($this->customer_id);
238
+			$donor->update(array('purchase_value' => give_format_amount(0, array('sanitize' => false)), 'purchase_count' => 0));
239 239
 
240
-			$attached_payment_ids = explode( ',', $donor->payment_ids );
240
+			$attached_payment_ids = explode(',', $donor->payment_ids);
241 241
 
242 242
 			$attached_args = array(
243 243
 				'post__in' => $attached_payment_ids,
244
-				'number'   => - 1,
244
+				'number'   => -1,
245 245
 				'status'   => $allowed_payment_status,
246 246
 			);
247 247
 
248
-			$attached_payments = give_get_payments( $attached_args );
248
+			$attached_payments = give_get_payments($attached_args);
249 249
 
250 250
 			$unattached_args = array(
251 251
 				'post__not_in' => $attached_payment_ids,
252
-				'number'       => - 1,
252
+				'number'       => -1,
253 253
 				'status'       => $allowed_payment_status,
254 254
 				'meta_query'   => array(
255 255
 					array(
@@ -259,11 +259,11 @@  discard block
 block discarded – undo
259 259
 				),
260 260
 			);
261 261
 
262
-			$unattached_payments = give_get_payments( $unattached_args );
262
+			$unattached_payments = give_get_payments($unattached_args);
263 263
 
264
-			$payments = array_merge( $attached_payments, $unattached_payments );
264
+			$payments = array_merge($attached_payments, $unattached_payments);
265 265
 
266
-			$this->store_data( 'give_recount_donor_payments_' . $donor->id, $payments );
266
+			$this->store_data('give_recount_donor_payments_'.$donor->id, $payments);
267 267
 		}
268 268
 	}
269 269
 
@@ -276,11 +276,11 @@  discard block
 block discarded – undo
276 276
 	 *
277 277
 	 * @return mixed       Returns the data from the database
278 278
 	 */
279
-	private function get_stored_data( $key ) {
279
+	private function get_stored_data($key) {
280 280
 		global $wpdb;
281
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
281
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
282 282
 
283
-		return empty( $value ) ? false : maybe_unserialize( $value );
283
+		return empty($value) ? false : maybe_unserialize($value);
284 284
 	}
285 285
 
286 286
 	/**
@@ -293,10 +293,10 @@  discard block
 block discarded – undo
293 293
 	 *
294 294
 	 * @return void
295 295
 	 */
296
-	private function store_data( $key, $value ) {
296
+	private function store_data($key, $value) {
297 297
 		global $wpdb;
298 298
 
299
-		$value = maybe_serialize( $value );
299
+		$value = maybe_serialize($value);
300 300
 
301 301
 		$data = array(
302 302
 			'option_name'  => $key,
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 			'%s',
311 311
 		);
312 312
 
313
-		$wpdb->replace( $wpdb->options, $data, $formats );
313
+		$wpdb->replace($wpdb->options, $data, $formats);
314 314
 	}
315 315
 
316 316
 	/**
@@ -322,9 +322,9 @@  discard block
 block discarded – undo
322 322
 	 *
323 323
 	 * @return void
324 324
 	 */
325
-	private function delete_data( $key ) {
325
+	private function delete_data($key) {
326 326
 		global $wpdb;
327
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
327
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
328 328
 	}
329 329
 
330 330
 }
Please login to merge, or discard this patch.
includes/admin/tools/export/class-batch-export-donors.php 1 patch
Spacing   +102 added lines, -104 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly.
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -70,23 +70,23 @@  discard block
 block discarded – undo
70 70
 	 *
71 71
 	 * @param array $request The Form Data passed into the batch processing
72 72
 	 */
73
-	public function set_properties( $request ) {
73
+	public function set_properties($request) {
74 74
 
75 75
 		// Set data from form submission
76
-		if ( isset( $_POST['form'] ) ) {
77
-			parse_str( $_POST['form'], $this->data );
76
+		if (isset($_POST['form'])) {
77
+			parse_str($_POST['form'], $this->data);
78 78
 		}
79 79
 
80 80
 		$this->form = $this->data['forms'];
81 81
 
82 82
 		// Setup donor ids cache.
83
-		if ( ! empty( $this->form ) ) {
83
+		if ( ! empty($this->form)) {
84 84
 			// Cache donor ids to output unique list of donor.
85
-			$this->query_id = give_clean( $_REQUEST['give_export_option']['query_id'] );
85
+			$this->query_id = give_clean($_REQUEST['give_export_option']['query_id']);
86 86
 			$this->cache_donor_ids();
87 87
 		}
88 88
 
89
-		$this->price_id = ! empty( $request['give_price_option'] ) && 'all' !== $request['give_price_option'] ? absint( $request['give_price_option'] ) : null;
89
+		$this->price_id = ! empty($request['give_price_option']) && 'all' !== $request['give_price_option'] ? absint($request['give_price_option']) : null;
90 90
 
91 91
 	}
92 92
 
@@ -101,12 +101,12 @@  discard block
 block discarded – undo
101 101
 		// Fetch already cached donor ids.
102 102
 		$donor_ids = $this->donor_ids;
103 103
 
104
-		if ( $cached_donor_ids = Give_Cache::get( $this->query_id, true ) ) {
105
-			$donor_ids = array_unique( array_merge( $cached_donor_ids, $this->donor_ids ) );
104
+		if ($cached_donor_ids = Give_Cache::get($this->query_id, true)) {
105
+			$donor_ids = array_unique(array_merge($cached_donor_ids, $this->donor_ids));
106 106
 		}
107 107
 
108
-		$donor_ids = array_values( $donor_ids );
109
-		Give_Cache::set( $this->query_id, $donor_ids, HOUR_IN_SECONDS, true );
108
+		$donor_ids = array_values($donor_ids);
109
+		Give_Cache::set($this->query_id, $donor_ids, HOUR_IN_SECONDS, true);
110 110
 	}
111 111
 
112 112
 	/**
@@ -118,14 +118,14 @@  discard block
 block discarded – undo
118 118
 	 */
119 119
 	public function csv_cols() {
120 120
 
121
-		$columns = isset( $this->data['give_export_option'] ) ? $this->data['give_export_option'] : array();
121
+		$columns = isset($this->data['give_export_option']) ? $this->data['give_export_option'] : array();
122 122
 
123 123
 		// We need columns.
124
-		if ( empty( $columns ) ) {
124
+		if (empty($columns)) {
125 125
 			return false;
126 126
 		}
127 127
 
128
-		$cols = $this->get_cols( $columns );
128
+		$cols = $this->get_cols($columns);
129 129
 
130 130
 		return $cols;
131 131
 	}
@@ -137,41 +137,41 @@  discard block
 block discarded – undo
137 137
 	 *
138 138
 	 * @return array
139 139
 	 */
140
-	private function get_cols( $columns ) {
140
+	private function get_cols($columns) {
141 141
 
142 142
 		$cols = array();
143 143
 
144
-		foreach ( $columns as $key => $value ) {
144
+		foreach ($columns as $key => $value) {
145 145
 
146
-			switch ( $key ) {
146
+			switch ($key) {
147 147
 				case 'full_name' :
148
-					$cols['full_name'] = esc_html__( 'Full Name', 'give' );
148
+					$cols['full_name'] = esc_html__('Full Name', 'give');
149 149
 					break;
150 150
 				case 'email' :
151
-					$cols['email'] = esc_html__( 'Email Address', 'give' );
151
+					$cols['email'] = esc_html__('Email Address', 'give');
152 152
 					break;
153 153
 				case 'address' :
154
-					$cols['address_line1']   = esc_html__( 'Address', 'give' );
155
-					$cols['address_line2']   = esc_html__( 'Address 2', 'give' );
156
-					$cols['address_city']    = esc_html__( 'City', 'give' );
157
-					$cols['address_state']   = esc_html__( 'State', 'give' );
158
-					$cols['address_zip']     = esc_html__( 'Zip', 'give' );
159
-					$cols['address_country'] = esc_html__( 'Country', 'give' );
154
+					$cols['address_line1']   = esc_html__('Address', 'give');
155
+					$cols['address_line2']   = esc_html__('Address 2', 'give');
156
+					$cols['address_city']    = esc_html__('City', 'give');
157
+					$cols['address_state']   = esc_html__('State', 'give');
158
+					$cols['address_zip']     = esc_html__('Zip', 'give');
159
+					$cols['address_country'] = esc_html__('Country', 'give');
160 160
 					break;
161 161
 				case 'userid' :
162
-					$cols['userid'] = esc_html__( 'User ID', 'give' );
162
+					$cols['userid'] = esc_html__('User ID', 'give');
163 163
 					break;
164 164
 				case 'donation_form' :
165
-					$cols['donation_form'] = esc_html__( 'Donation Form', 'give' );
165
+					$cols['donation_form'] = esc_html__('Donation Form', 'give');
166 166
 					break;
167 167
 				case 'date_first_donated' :
168
-					$cols['date_first_donated'] = esc_html__( 'First Donation Date', 'give' );
168
+					$cols['date_first_donated'] = esc_html__('First Donation Date', 'give');
169 169
 					break;
170 170
 				case 'donations' :
171
-					$cols['donations'] = esc_html__( 'Number of Donations', 'give' );
171
+					$cols['donations'] = esc_html__('Number of Donations', 'give');
172 172
 					break;
173 173
 				case 'donation_sum' :
174
-					$cols['donation_sum'] = esc_html__( 'Sum of Donations', 'give' );
174
+					$cols['donation_sum'] = esc_html__('Sum of Donations', 'give');
175 175
 					break;
176 176
 			}
177 177
 		}
@@ -192,29 +192,29 @@  discard block
 block discarded – undo
192 192
 		$i = 0;
193 193
 
194 194
 		$data             = array();
195
-		$cached_donor_ids = Give_Cache::get( $this->query_id, true );
195
+		$cached_donor_ids = Give_Cache::get($this->query_id, true);
196 196
 
197
-		if ( ! empty( $this->form ) ) {
197
+		if ( ! empty($this->form)) {
198 198
 
199 199
 			// Export donors for a specific donation form and also within specified timeframe
200 200
 			$args = array(
201 201
 				'output'     => 'payments', // Use 'posts' to get standard post objects
202
-				'post_type'  => array( 'give_payment' ),
202
+				'post_type'  => array('give_payment'),
203 203
 				'number'     => 30,
204 204
 				'paged'      => $this->step,
205 205
 				'status'     => 'publish',
206 206
 				'meta_key'   => '_give_payment_form_id',
207
-				'meta_value' => absint( $this->form ),
207
+				'meta_value' => absint($this->form),
208 208
 			);
209 209
 
210 210
 			// Check for date option filter
211
-			if ( ! empty( $this->data['donor_export_start_date'] ) || ! empty( $this->data['donor_export_end_date'] ) ) {
212
-				$args['start_date'] = ! empty( $this->data['donor_export_start_date'] ) ? date( 'Y-n-d 00:00:00', strtotime( $this->data['donor_export_start_date'] ) ) : date( 'Y-n-d 23:59:59', '1970-1-01 00:00:00' );
213
-				$args['end_date']   = ! empty( $this->data['donor_export_end_date'] ) ? date( 'Y-n-d 23:59:59', strtotime( $this->data['donor_export_end_date'] ) ) : date( 'Y-n-d 23:59:59', current_time( 'timestamp' ) );
211
+			if ( ! empty($this->data['donor_export_start_date']) || ! empty($this->data['donor_export_end_date'])) {
212
+				$args['start_date'] = ! empty($this->data['donor_export_start_date']) ? date('Y-n-d 00:00:00', strtotime($this->data['donor_export_start_date'])) : date('Y-n-d 23:59:59', '1970-1-01 00:00:00');
213
+				$args['end_date']   = ! empty($this->data['donor_export_end_date']) ? date('Y-n-d 23:59:59', strtotime($this->data['donor_export_end_date'])) : date('Y-n-d 23:59:59', current_time('timestamp'));
214 214
 			}
215 215
 
216 216
 			// Check for price option.
217
-			if ( null !== $this->price_id ) {
217
+			if (null !== $this->price_id) {
218 218
 				$args['meta_query'] = array(
219 219
 					array(
220 220
 						'key'   => '_give_payment_price_id',
@@ -223,45 +223,43 @@  discard block
 block discarded – undo
223 223
 				);
224 224
 			}
225 225
 
226
-			$payments_query = new Give_Payments_Query( $args );
226
+			$payments_query = new Give_Payments_Query($args);
227 227
 			$payments       = $payments_query->get_payments();
228 228
 
229
-			if ( $payments ) {
229
+			if ($payments) {
230 230
 				/* @var Give_Payment $payment */
231
-				foreach ( $payments as $payment ) {
231
+				foreach ($payments as $payment) {
232 232
 					// Set donation sum.
233
-					$this->payment_stats[ $payment->customer_id ]['donation_sum'] = isset( $this->payment_stats[ $payment->customer_id ]['donation_sum'] ) ?
234
-						$this->payment_stats[ $payment->customer_id ]['donation_sum'] :
235
-						0;
236
-					$this->payment_stats[ $payment->customer_id ]['donation_sum'] += $payment->total;
233
+					$this->payment_stats[$payment->customer_id]['donation_sum'] = isset($this->payment_stats[$payment->customer_id]['donation_sum']) ?
234
+						$this->payment_stats[$payment->customer_id]['donation_sum'] : 0;
235
+					$this->payment_stats[$payment->customer_id]['donation_sum'] += $payment->total;
237 236
 
238 237
 					// Set donation count.
239
-					$this->payment_stats[ $payment->customer_id ]['donations'] = isset( $this->payment_stats[ $payment->customer_id ]['donations'] ) ?
240
-						++ $this->payment_stats[ $payment->customer_id ]['donations'] :
241
-						1;
238
+					$this->payment_stats[$payment->customer_id]['donations'] = isset($this->payment_stats[$payment->customer_id]['donations']) ?
239
+						++$this->payment_stats[$payment->customer_id]['donations'] : 1;
242 240
 
243 241
 					// Set donation form name.
244
-					$this->payment_stats[ $payment->customer_id ]['form_title'] = $payment->form_title;
242
+					$this->payment_stats[$payment->customer_id]['form_title'] = $payment->form_title;
245 243
 
246 244
 					// Continue if donor already included.
247
-					if ( empty( $payment->customer_id ) ||
248
-					     in_array( $payment->customer_id, $cached_donor_ids )
245
+					if (empty($payment->customer_id) ||
246
+					     in_array($payment->customer_id, $cached_donor_ids)
249 247
 					) {
250 248
 						continue;
251 249
 					}
252 250
 
253 251
 					$this->donor_ids[] = $cached_donor_ids[] = $payment->customer_id;
254 252
 
255
-					$i ++;
253
+					$i++;
256 254
 				}
257 255
 
258
-				if ( ! empty( $this->donor_ids ) ) {
259
-					foreach ( $this->donor_ids as $donor_id ) {
260
-						$donor                      = Give()->donors->get_donor_by( 'id', $donor_id );
261
-						$donor->donation_form_title = $this->payment_stats[ $donor_id ]['form_title'];
262
-						$donor->purchase_count      = $this->payment_stats[ $donor_id ]['donations'];
263
-						$donor->purchase_value      = $this->payment_stats[ $donor_id ]['donation_sum'];
264
-						$data[]                     = $this->set_donor_data( $i, $data, $donor );
256
+				if ( ! empty($this->donor_ids)) {
257
+					foreach ($this->donor_ids as $donor_id) {
258
+						$donor                      = Give()->donors->get_donor_by('id', $donor_id);
259
+						$donor->donation_form_title = $this->payment_stats[$donor_id]['form_title'];
260
+						$donor->purchase_count      = $this->payment_stats[$donor_id]['donations'];
261
+						$donor->purchase_value      = $this->payment_stats[$donor_id]['donation_sum'];
262
+						$data[]                     = $this->set_donor_data($i, $data, $donor);
265 263
 					}
266 264
 
267 265
 					// Cache donor ids only if admin export donor for specific form.
@@ -271,7 +269,7 @@  discard block
 block discarded – undo
271 269
 		} else {
272 270
 
273 271
 			// Export all donors.
274
-			$offset = 30 * ( $this->step - 1 );
272
+			$offset = 30 * ($this->step - 1);
275 273
 
276 274
 			$args = array(
277 275
 				'number' => 30,
@@ -279,31 +277,31 @@  discard block
 block discarded – undo
279 277
 			);
280 278
 
281 279
 			// Check for date option filter
282
-			if ( ! empty( $this->data['donor_export_start_date'] ) || ! empty( $this->data['donor_export_end_date'] ) ) {
280
+			if ( ! empty($this->data['donor_export_start_date']) || ! empty($this->data['donor_export_end_date'])) {
283 281
 				$args['date'] = array(
284
-					'start' => ! empty( $this->data['donor_export_start_date'] ) ? date( 'Y-n-d 00:00:00', strtotime( $this->data['donor_export_start_date'] ) ) : date( 'Y-n-d 23:59:59', '1970-1-01 00:00:00' ),
285
-					'end'   => ! empty( $this->data['donor_export_end_date'] ) ? date( 'Y-n-d 23:59:59', strtotime( $this->data['donor_export_end_date'] ) ) : date( 'Y-n-d 23:59:59', current_time( 'timestamp' ) ),
282
+					'start' => ! empty($this->data['donor_export_start_date']) ? date('Y-n-d 00:00:00', strtotime($this->data['donor_export_start_date'])) : date('Y-n-d 23:59:59', '1970-1-01 00:00:00'),
283
+					'end'   => ! empty($this->data['donor_export_end_date']) ? date('Y-n-d 23:59:59', strtotime($this->data['donor_export_end_date'])) : date('Y-n-d 23:59:59', current_time('timestamp')),
286 284
 				);
287 285
 			}
288 286
 
289
-			$donors = Give()->donors->get_donors( $args );
287
+			$donors = Give()->donors->get_donors($args);
290 288
 
291
-			foreach ( $donors as $donor ) {
289
+			foreach ($donors as $donor) {
292 290
 
293 291
 				// Continue if donor already included.
294
-				if ( empty( $donor->id ) || empty( $donor->payment_ids ) ) {
292
+				if (empty($donor->id) || empty($donor->payment_ids)) {
295 293
 					continue;
296 294
 				}
297 295
 
298
-				$payment                    = new Give_Payment( $donor->payment_ids );
296
+				$payment                    = new Give_Payment($donor->payment_ids);
299 297
 				$donor->donation_form_title = $payment->form_title;
300
-				$data[]                     = $this->set_donor_data( $i, $data, $donor );
301
-				$i ++;
298
+				$data[]                     = $this->set_donor_data($i, $data, $donor);
299
+				$i++;
302 300
 			}
303 301
 		}// End if().
304 302
 
305
-		$data = apply_filters( 'give_export_get_data', $data );
306
-		$data = apply_filters( "give_export_get_data_{$this->export_type}", $data );
303
+		$data = apply_filters('give_export_get_data', $data);
304
+		$data = apply_filters("give_export_get_data_{$this->export_type}", $data);
307 305
 
308 306
 		return $data;
309 307
 	}
@@ -319,18 +317,18 @@  discard block
 block discarded – undo
319 317
 		$percentage = 0;
320 318
 
321 319
 		// We can't count the number when getting them for a specific form.
322
-		if ( empty( $this->form ) ) {
320
+		if (empty($this->form)) {
323 321
 
324 322
 			$total = Give()->donors->count();
325 323
 
326
-			if ( $total > 0 ) {
324
+			if ($total > 0) {
327 325
 
328
-				$percentage = ( ( 30 * $this->step ) / $total ) * 100;
326
+				$percentage = ((30 * $this->step) / $total) * 100;
329 327
 
330 328
 			}
331 329
 		}
332 330
 
333
-		if ( $percentage > 100 ) {
331
+		if ($percentage > 100) {
334 332
 			$percentage = 100;
335 333
 		}
336 334
 
@@ -346,49 +344,49 @@  discard block
 block discarded – undo
346 344
 	 *
347 345
 	 * @return mixed
348 346
 	 */
349
-	private function set_donor_data( $i, $data, $donor ) {
347
+	private function set_donor_data($i, $data, $donor) {
350 348
 
351 349
 		$columns = $this->csv_cols();
352 350
 
353 351
 		// Set address variable
354 352
 		$address = '';
355
-		if ( isset( $donor->user_id ) && $donor->user_id > 0 ) {
356
-			$address = give_get_donor_address( $donor->user_id );
353
+		if (isset($donor->user_id) && $donor->user_id > 0) {
354
+			$address = give_get_donor_address($donor->user_id);
357 355
 		}
358 356
 
359 357
 		// Set columns
360
-		if ( ! empty( $columns['full_name'] ) ) {
361
-			$data[ $i ]['full_name'] = $donor->name;
358
+		if ( ! empty($columns['full_name'])) {
359
+			$data[$i]['full_name'] = $donor->name;
362 360
 		}
363
-		if ( ! empty( $columns['email'] ) ) {
364
-			$data[ $i ]['email'] = $donor->email;
361
+		if ( ! empty($columns['email'])) {
362
+			$data[$i]['email'] = $donor->email;
365 363
 		}
366
-		if ( ! empty( $columns['address_line1'] ) ) {
367
-
368
-			$data[ $i ]['address_line1']   = isset( $address['line1'] ) ? $address['line1'] : '';
369
-			$data[ $i ]['address_line2']   = isset( $address['line2'] ) ? $address['line2'] : '';
370
-			$data[ $i ]['address_city']    = isset( $address['city'] ) ? $address['city'] : '';
371
-			$data[ $i ]['address_state']   = isset( $address['state'] ) ? $address['state'] : '';
372
-			$data[ $i ]['address_zip']     = isset( $address['zip'] ) ? $address['zip'] : '';
373
-			$data[ $i ]['address_country'] = isset( $address['country'] ) ? $address['country'] : '';
364
+		if ( ! empty($columns['address_line1'])) {
365
+
366
+			$data[$i]['address_line1']   = isset($address['line1']) ? $address['line1'] : '';
367
+			$data[$i]['address_line2']   = isset($address['line2']) ? $address['line2'] : '';
368
+			$data[$i]['address_city']    = isset($address['city']) ? $address['city'] : '';
369
+			$data[$i]['address_state']   = isset($address['state']) ? $address['state'] : '';
370
+			$data[$i]['address_zip']     = isset($address['zip']) ? $address['zip'] : '';
371
+			$data[$i]['address_country'] = isset($address['country']) ? $address['country'] : '';
374 372
 		}
375
-		if ( ! empty( $columns['userid'] ) ) {
376
-			$data[ $i ]['userid'] = ! empty( $donor->user_id ) ? $donor->user_id : '';
373
+		if ( ! empty($columns['userid'])) {
374
+			$data[$i]['userid'] = ! empty($donor->user_id) ? $donor->user_id : '';
377 375
 		}
378
-		if ( ! empty( $columns['donation_form'] ) ) {
379
-			$data[ $i ]['donation_form'] = ! empty( $donor->donation_form_title ) ? $donor->donation_form_title : '';
376
+		if ( ! empty($columns['donation_form'])) {
377
+			$data[$i]['donation_form'] = ! empty($donor->donation_form_title) ? $donor->donation_form_title : '';
380 378
 		}
381
-		if ( ! empty( $columns['date_first_donated'] ) ) {
382
-			$data[ $i ]['date_first_donated'] = date_i18n( give_date_format(), strtotime( $donor->date_created ) );
379
+		if ( ! empty($columns['date_first_donated'])) {
380
+			$data[$i]['date_first_donated'] = date_i18n(give_date_format(), strtotime($donor->date_created));
383 381
 		}
384
-		if ( ! empty( $columns['donations'] ) ) {
385
-			$data[ $i ]['donations'] = $donor->purchase_count;
382
+		if ( ! empty($columns['donations'])) {
383
+			$data[$i]['donations'] = $donor->purchase_count;
386 384
 		}
387
-		if ( ! empty( $columns['donation_sum'] ) ) {
388
-			$data[ $i ]['donation_sum'] = give_format_amount( $donor->purchase_value, array( 'sanitize' => false ) );
385
+		if ( ! empty($columns['donation_sum'])) {
386
+			$data[$i]['donation_sum'] = give_format_amount($donor->purchase_value, array('sanitize' => false));
389 387
 		}
390 388
 
391
-		return $data[ $i ];
389
+		return $data[$i];
392 390
 
393 391
 	}
394 392
 
@@ -398,9 +396,9 @@  discard block
 block discarded – undo
398 396
 	 * @param array             $request
399 397
 	 * @param Give_Batch_Export $export
400 398
 	 */
401
-	public function unset_properties( $request, $export ) {
402
-		if ( $export->done ) {
403
-			Give_Cache::delete( "give_cache_{$this->query_id}" );
399
+	public function unset_properties($request, $export) {
400
+		if ($export->done) {
401
+			Give_Cache::delete("give_cache_{$this->query_id}");
404 402
 		}
405 403
 	}
406 404
 }
407 405
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/tools/export/class-export-earnings.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly.
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -38,16 +38,16 @@  discard block
 block discarded – undo
38 38
 	 * @return void
39 39
 	 */
40 40
 	public function headers() {
41
-		ignore_user_abort( true );
41
+		ignore_user_abort(true);
42 42
 
43
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
44
-			set_time_limit( 0 );
43
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
44
+			set_time_limit(0);
45 45
 		}
46 46
 
47 47
 		nocache_headers();
48
-		header( 'Content-Type: text/csv; charset=utf-8' );
49
-		header( 'Content-Disposition: attachment; filename=' . apply_filters( 'give_earnings_export_filename', 'give-export-' . $this->export_type . '-' . date( 'n' ) . '-' . date( 'Y' ) ) . '.csv' );
50
-		header( "Expires: 0" );
48
+		header('Content-Type: text/csv; charset=utf-8');
49
+		header('Content-Disposition: attachment; filename='.apply_filters('give_earnings_export_filename', 'give-export-'.$this->export_type.'-'.date('n').'-'.date('Y')).'.csv');
50
+		header("Expires: 0");
51 51
 
52 52
 	}
53 53
 
@@ -61,10 +61,10 @@  discard block
 block discarded – undo
61 61
 	public function csv_cols() {
62 62
 
63 63
 		$cols = array(
64
-			'date'      => __( 'Date', 'give' ),
65
-			'donations' => __( 'Donations', 'give' ),
64
+			'date'      => __('Date', 'give'),
65
+			'donations' => __('Donations', 'give'),
66 66
 			/* translators: %s: currency */
67
-			'earnings'  => sprintf( __( 'Income (%s)', 'give' ), give_currency_symbol('', true) )
67
+			'earnings'  => sprintf(__('Income (%s)', 'give'), give_currency_symbol('', true))
68 68
 		);
69 69
 
70 70
 		return $cols;
@@ -79,28 +79,28 @@  discard block
 block discarded – undo
79 79
 	 */
80 80
 	public function get_data() {
81 81
 
82
-		$start_year  = isset( $_POST['start_year'] ) ? absint( $_POST['start_year'] ) : date( 'Y' );
83
-		$end_year    = isset( $_POST['end_year'] ) ? absint( $_POST['end_year'] ) : date( 'Y' );
84
-		$start_month = isset( $_POST['start_month'] ) ? absint( $_POST['start_month'] ) : date( 'n' );
85
-		$end_month   = isset( $_POST['end_month'] ) ? absint( $_POST['end_month'] ) : date( 'n' );
82
+		$start_year  = isset($_POST['start_year']) ? absint($_POST['start_year']) : date('Y');
83
+		$end_year    = isset($_POST['end_year']) ? absint($_POST['end_year']) : date('Y');
84
+		$start_month = isset($_POST['start_month']) ? absint($_POST['start_month']) : date('n');
85
+		$end_month   = isset($_POST['end_month']) ? absint($_POST['end_month']) : date('n');
86 86
 
87 87
 		$data  = array();
88 88
 		$year  = $start_year;
89 89
 		$stats = new Give_Payment_Stats;
90 90
 
91
-		while ( $year <= $end_year ) {
91
+		while ($year <= $end_year) {
92 92
 
93
-			if ( $year == $start_year && $year == $end_year ) {
93
+			if ($year == $start_year && $year == $end_year) {
94 94
 
95 95
 				$m1 = $start_month;
96 96
 				$m2 = $end_month;
97 97
 
98
-			} elseif ( $year == $start_year ) {
98
+			} elseif ($year == $start_year) {
99 99
 
100 100
 				$m1 = $start_month;
101 101
 				$m2 = 12;
102 102
 
103
-			} elseif ( $year == $end_year ) {
103
+			} elseif ($year == $end_year) {
104 104
 
105 105
 				$m1 = 1;
106 106
 				$m2 = $end_month;
@@ -112,28 +112,28 @@  discard block
 block discarded – undo
112 112
 
113 113
 			}
114 114
 
115
-			while ( $m1 <= $m2 ) {
115
+			while ($m1 <= $m2) {
116 116
 
117
-				$date1 = mktime( 0, 0, 0, $m1, 1, $year );
118
-				$date2 = mktime( 0, 0, 0, $m1, cal_days_in_month( CAL_GREGORIAN, $m1, $year ), $year );
117
+				$date1 = mktime(0, 0, 0, $m1, 1, $year);
118
+				$date2 = mktime(0, 0, 0, $m1, cal_days_in_month(CAL_GREGORIAN, $m1, $year), $year);
119 119
 
120 120
 				$data[] = array(
121
-					'date'      => date_i18n( 'F Y', $date1 ),
122
-					'donations' => $stats->get_sales( 0, $date1, $date2 ),
123
-					'earnings'  => give_format_amount( $stats->get_earnings( 0, $date1, $date2 ), array( 'sanitize' => false ) ),
121
+					'date'      => date_i18n('F Y', $date1),
122
+					'donations' => $stats->get_sales(0, $date1, $date2),
123
+					'earnings'  => give_format_amount($stats->get_earnings(0, $date1, $date2), array('sanitize' => false)),
124 124
 				);
125 125
 
126
-				$m1 ++;
126
+				$m1++;
127 127
 
128 128
 			}
129 129
 
130 130
 
131
-			$year ++;
131
+			$year++;
132 132
 
133 133
 		}
134 134
 
135
-		$data = apply_filters( 'give_export_get_data', $data );
136
-		$data = apply_filters( "give_export_get_data_{$this->export_type}", $data );
135
+		$data = apply_filters('give_export_get_data', $data);
136
+		$data = apply_filters("give_export_get_data_{$this->export_type}", $data);
137 137
 
138 138
 		return $data;
139 139
 	}
Please login to merge, or discard this patch.