Test Failed
Pull Request — master (#2814)
by Devin
05:29
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
 
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	$dates          = give_get_report_dates();
27 27
 
28 28
 	// Determine graph options.
29
-	switch ( $dates['range'] ) :
29
+	switch ($dates['range']) :
30 30
 		case 'today' :
31 31
 		case 'yesterday' :
32 32
 			$day_by_day = true;
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 			$day_by_day = false;
39 39
 			break;
40 40
 		case 'other' :
41
-			if ( $dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year'] && ( $dates['m_start'] != '12' && $dates['m_end'] != '1' ) ) {
41
+			if ($dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year'] && ($dates['m_start'] != '12' && $dates['m_end'] != '1')) {
42 42
 				$day_by_day = false;
43 43
 			} else {
44 44
 				$day_by_day = true;
@@ -55,60 +55,60 @@  discard block
 block discarded – undo
55 55
 	$earnings_data = array();
56 56
 	$sales_data    = array();
57 57
 
58
-	if ( 'today' === $dates['range'] || 'yesterday' === $dates['range'] ) {
58
+	if ('today' === $dates['range'] || 'yesterday' === $dates['range']) {
59 59
 
60 60
 		// Hour by hour.
61 61
 		$hour  = 0;
62
-		$month = date( 'n', current_time( 'timestamp' ) );
63
-		while ( $hour <= 23 ) :
62
+		$month = date('n', current_time('timestamp'));
63
+		while ($hour <= 23) :
64 64
 
65
-			$start_date = mktime( $hour, 0, 0, $month, $dates['day'], $dates['year'] );
66
-			$end_date   = mktime( $hour, 59, 59, $month, $dates['day'], $dates['year'] );
67
-			$sales      = $donation_stats->get_sales( 0, $start_date, $end_date );
68
-			$earnings   = $donation_stats->get_earnings( 0, $start_date, $end_date );
65
+			$start_date = mktime($hour, 0, 0, $month, $dates['day'], $dates['year']);
66
+			$end_date   = mktime($hour, 59, 59, $month, $dates['day'], $dates['year']);
67
+			$sales      = $donation_stats->get_sales(0, $start_date, $end_date);
68
+			$earnings   = $donation_stats->get_earnings(0, $start_date, $end_date);
69 69
 
70 70
 			$sales_totals    += $sales;
71 71
 			$earnings_totals += $earnings;
72 72
 
73
-			$sales_data[]    = array( $start_date * 1000, $sales );
74
-			$earnings_data[] = array( $start_date * 1000, $earnings );
73
+			$sales_data[]    = array($start_date * 1000, $sales);
74
+			$earnings_data[] = array($start_date * 1000, $earnings);
75 75
 
76
-			$hour ++;
76
+			$hour++;
77 77
 		endwhile;
78 78
 
79
-	} elseif ( 'this_week' === $dates['range'] || 'last_week' === $dates['range'] ) {
79
+	} elseif ('this_week' === $dates['range'] || 'last_week' === $dates['range']) {
80 80
 
81 81
 		// Day by day.
82 82
 		$day     = $dates['day'];
83 83
 		$day_end = $dates['day_end'];
84 84
 		$month   = $dates['m_start'];
85
-		while ( $day <= $day_end ) :
85
+		while ($day <= $day_end) :
86 86
 
87
-			$start_date = mktime( 0, 0, 0, $month, $day, $dates['year'] );
88
-			$end_date   = mktime( 23, 59, 59, $month, $day, $dates['year'] );
89
-			$sales      = $donation_stats->get_sales( 0, $start_date, $end_date );
90
-			$earnings   = $donation_stats->get_earnings( 0, $start_date, $end_date );
87
+			$start_date = mktime(0, 0, 0, $month, $day, $dates['year']);
88
+			$end_date   = mktime(23, 59, 59, $month, $day, $dates['year']);
89
+			$sales      = $donation_stats->get_sales(0, $start_date, $end_date);
90
+			$earnings   = $donation_stats->get_earnings(0, $start_date, $end_date);
91 91
 
92 92
 			$sales_totals    += $sales;
93 93
 			$earnings_totals += $earnings;
94 94
 
95
-			$sales_data[]    = array( $start_date * 1000, $sales );
96
-			$earnings_data[] = array( $start_date * 1000, $earnings );
97
-			$day ++;
95
+			$sales_data[]    = array($start_date * 1000, $sales);
96
+			$earnings_data[] = array($start_date * 1000, $earnings);
97
+			$day++;
98 98
 		endwhile;
99 99
 
100 100
 	} else {
101 101
 
102 102
 		$y = $dates['year'];
103
-		while ( $y <= $dates['year_end'] ) :
103
+		while ($y <= $dates['year_end']) :
104 104
 
105
-			if ( $dates['year'] === $dates['year_end'] ) {
105
+			if ($dates['year'] === $dates['year_end']) {
106 106
 				$month_start = $dates['m_start'];
107 107
 				$month_end   = $dates['m_end'];
108
-			} elseif ( $y === $dates['year'] ) {
108
+			} elseif ($y === $dates['year']) {
109 109
 				$month_start = $dates['m_start'];
110 110
 				$month_end   = 12;
111
-			} elseif ( $y === $dates['year_end'] ) {
111
+			} elseif ($y === $dates['year_end']) {
112 112
 				$month_start = 1;
113 113
 				$month_end   = $dates['m_end'];
114 114
 			} else {
@@ -117,67 +117,67 @@  discard block
 block discarded – undo
117 117
 			}
118 118
 
119 119
 			$i = $month_start;
120
-			while ( $i <= $month_end ) :
120
+			while ($i <= $month_end) :
121 121
 
122
-				if ( $day_by_day ) {
122
+				if ($day_by_day) {
123 123
 
124
-					if ( $i === $month_end ) {
124
+					if ($i === $month_end) {
125 125
 
126 126
 						$num_of_days = $dates['day_end'];
127 127
 
128 128
 					} else {
129 129
 
130
-						$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
130
+						$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
131 131
 
132 132
 					}
133 133
 
134 134
 					$d = $dates['day'];
135 135
 
136
-					while ( $d <= $num_of_days ) :
136
+					while ($d <= $num_of_days) :
137 137
 
138
-						$start_date = mktime( 0, 0, 0, $i, $d, $y );
139
-						$end_date   = mktime( 23, 59, 59, $i, $d, $y );
140
-						$sales      = $donation_stats->get_sales( 0, $start_date, $end_date );
141
-						$earnings   = $donation_stats->get_earnings( 0, $start_date, $end_date );
138
+						$start_date = mktime(0, 0, 0, $i, $d, $y);
139
+						$end_date   = mktime(23, 59, 59, $i, $d, $y);
140
+						$sales      = $donation_stats->get_sales(0, $start_date, $end_date);
141
+						$earnings   = $donation_stats->get_earnings(0, $start_date, $end_date);
142 142
 
143 143
 						$sales_totals    += $sales;
144 144
 						$earnings_totals += $earnings;
145 145
 
146
-						$sales_data[]    = array( $start_date * 1000, $sales );
147
-						$earnings_data[] = array( $start_date * 1000, $earnings );
146
+						$sales_data[]    = array($start_date * 1000, $sales);
147
+						$earnings_data[] = array($start_date * 1000, $earnings);
148 148
 
149
-						$d ++;
149
+						$d++;
150 150
 
151 151
 					endwhile;
152 152
 
153 153
 				} else {
154 154
 
155 155
 					// This Quarter, Last Quarter, This Year, Last Year.
156
-					$start_date = mktime( 0, 0, 0, $i, 1, $y );
157
-					$end_date   = mktime( 23, 59, 59, $i + 1, 0, $y );
158
-					$sales      = $donation_stats->get_sales( 0, $start_date, $end_date );
159
-					$earnings   = $donation_stats->get_earnings( 0, $start_date, $end_date );
156
+					$start_date = mktime(0, 0, 0, $i, 1, $y);
157
+					$end_date   = mktime(23, 59, 59, $i + 1, 0, $y);
158
+					$sales      = $donation_stats->get_sales(0, $start_date, $end_date);
159
+					$earnings   = $donation_stats->get_earnings(0, $start_date, $end_date);
160 160
 
161 161
 					$sales_totals    += $sales;
162 162
 					$earnings_totals += $earnings;
163 163
 
164
-					$sales_data[]    = array( $start_date * 1000, $sales );
165
-					$earnings_data[] = array( $start_date * 1000, $earnings );
164
+					$sales_data[]    = array($start_date * 1000, $sales);
165
+					$earnings_data[] = array($start_date * 1000, $earnings);
166 166
 
167 167
 				}
168 168
 
169
-				$i ++;
169
+				$i++;
170 170
 
171 171
 			endwhile;
172 172
 
173
-			$y ++;
173
+			$y++;
174 174
 		endwhile;
175 175
 
176 176
 	}
177 177
 
178 178
 	$data = array(
179
-		__( 'Income', 'give' )    => $earnings_data,
180
-		__( 'Donations', 'give' ) => $sales_data
179
+		__('Income', 'give')    => $earnings_data,
180
+		__('Donations', 'give') => $sales_data
181 181
 	);
182 182
 
183 183
 	// start our own output buffer.
@@ -190,12 +190,12 @@  discard block
 block discarded – undo
190 190
 				<div class="inside">
191 191
 					<?php give_reports_graph_controls(); ?>
192 192
 					<?php
193
-					$graph = new Give_Graph( $data, array( 'dataType' => array( 'amount', 'count' ) ) );
194
-					$graph->set( 'x_mode', 'time' );
195
-					$graph->set( 'multiple_y_axes', true );
193
+					$graph = new Give_Graph($data, array('dataType' => array('amount', 'count')));
194
+					$graph->set('x_mode', 'time');
195
+					$graph->set('multiple_y_axes', true);
196 196
 					$graph->display();
197 197
 
198
-					if ( 'this_month' === $dates['range'] ) {
198
+					if ('this_month' === $dates['range']) {
199 199
 						$estimated = give_estimated_monthly_stats();
200 200
 					}
201 201
 					?>
@@ -204,21 +204,21 @@  discard block
 block discarded – undo
204 204
 			<table class="widefat reports-table alignleft" style="max-width:450px">
205 205
 				<tbody>
206 206
 				<tr>
207
-					<th scope="row"><strong><?php _e( 'Total income for period:', 'give' ); ?></strong></th>
208
-					<td><?php echo give_currency_filter( give_format_amount( $earnings_totals, array( 'sanitize' => false ) ) ); ?></td>
207
+					<th scope="row"><strong><?php _e('Total income for period:', 'give'); ?></strong></th>
208
+					<td><?php echo give_currency_filter(give_format_amount($earnings_totals, array('sanitize' => false))); ?></td>
209 209
 				</tr>
210 210
 				<tr class="alternate">
211
-					<th scope="row"><strong><?php _e( 'Total donations for period:', 'give' ); ?><strong></th>
211
+					<th scope="row"><strong><?php _e('Total donations for period:', 'give'); ?><strong></th>
212 212
 					<td><?php echo $sales_totals; ?></td>
213 213
 				</tr>
214
-				<?php if ( 'this_month' === $dates['range'] ) : ?>
214
+				<?php if ('this_month' === $dates['range']) : ?>
215 215
 					<tr>
216
-						<th scope="row"><strong><?php _e( 'Estimated monthly income:', 'give' ); ?></strong></th>
217
-						<td><?php echo give_currency_filter( give_format_amount( $estimated['earnings'], array( 'sanitize' => false ) ) ); ?></td>
216
+						<th scope="row"><strong><?php _e('Estimated monthly income:', 'give'); ?></strong></th>
217
+						<td><?php echo give_currency_filter(give_format_amount($estimated['earnings'], array('sanitize' => false))); ?></td>
218 218
 					</tr>
219 219
 					<tr class="alternate">
220
-						<th scope="row"><strong><?php _e( 'Estimated monthly donations:', 'give' ); ?></strong></th>
221
-						<td><?php echo floor( $estimated['sales'] ); ?></td>
220
+						<th scope="row"><strong><?php _e('Estimated monthly donations:', 'give'); ?></strong></th>
221
+						<td><?php echo floor($estimated['sales']); ?></td>
222 222
 					</tr>
223 223
 				<?php endif; ?>
224 224
 			</table>
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 			 *
232 232
 			 * @since 1.0
233 233
 			 */
234
-			do_action( 'give_reports_graph_additional_stats' );
234
+			do_action('give_reports_graph_additional_stats');
235 235
 			?>
236 236
 
237 237
 		</div>
@@ -251,12 +251,12 @@  discard block
 block discarded – undo
251 251
  *
252 252
  * @return void
253 253
  */
254
-function give_reports_graph_of_form( $form_id = 0 ) {
254
+function give_reports_graph_of_form($form_id = 0) {
255 255
 	// Retrieve the queried dates.
256 256
 	$dates = give_get_report_dates();
257 257
 
258 258
 	// Determine graph options.
259
-	switch ( $dates['range'] ) :
259
+	switch ($dates['range']) :
260 260
 		case 'today' :
261 261
 		case 'yesterday' :
262 262
 			$day_by_day = true;
@@ -274,7 +274,7 @@  discard block
 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   = 0;
300 300
 		$minute = 0;
301 301
 		$second = 0;
302
-		while ( $hour <= 23 ) :
302
+		while ($hour <= 23) :
303 303
 
304
-			if ( $hour == 23 ) {
304
+			if ($hour == 23) {
305 305
 				$minute = $second = 59;
306 306
 			}
307 307
 
308
-			$date     = mktime( $hour, $minute, $second, $month, $dates['day'], $dates['year'] );
309
-			$date_end = mktime( $hour + 1, $minute, $second, $month, $dates['day'], $dates['year'] );
308
+			$date     = mktime($hour, $minute, $second, $month, $dates['day'], $dates['year']);
309
+			$date_end = mktime($hour + 1, $minute, $second, $month, $dates['day'], $dates['year']);
310 310
 
311
-			$sales = $stats->get_sales( $form_id, $date, $date_end );
311
+			$sales = $stats->get_sales($form_id, $date, $date_end);
312 312
 			$sales_totals += $sales;
313 313
 
314
-			$earnings = $stats->get_earnings( $form_id, $date, $date_end );
314
+			$earnings = $stats->get_earnings($form_id, $date, $date_end);
315 315
 			$earnings_totals += $earnings;
316 316
 
317
-			$sales_data[]    = array( $date * 1000, $sales );
318
-			$earnings_data[] = array( $date * 1000, $earnings );
317
+			$sales_data[]    = array($date * 1000, $sales);
318
+			$earnings_data[] = array($date * 1000, $earnings);
319 319
 
320
-			$hour ++;
320
+			$hour++;
321 321
 		endwhile;
322 322
 
323
-	} elseif ( $dates['range'] == 'this_week' || $dates['range'] == 'last_week' ) {
323
+	} elseif ($dates['range'] == 'this_week' || $dates['range'] == 'last_week') {
324 324
 
325 325
 		//Day by day.
326 326
 		$day     = $dates['day'];
327 327
 		$day_end = $dates['day_end'];
328 328
 		$month   = $dates['m_start'];
329
-		while ( $day <= $day_end ) :
329
+		while ($day <= $day_end) :
330 330
 
331
-			$date     = mktime( 0, 0, 0, $month, $day, $dates['year'] );
332
-			$date_end = mktime( 0, 0, 0, $month, $day + 1, $dates['year'] );
333
-			$sales    = $stats->get_sales( $form_id, $date, $date_end );
331
+			$date     = mktime(0, 0, 0, $month, $day, $dates['year']);
332
+			$date_end = mktime(0, 0, 0, $month, $day + 1, $dates['year']);
333
+			$sales    = $stats->get_sales($form_id, $date, $date_end);
334 334
 			$sales_totals += $sales;
335 335
 
336
-			$earnings = $stats->get_earnings( $form_id, $date, $date_end );
336
+			$earnings = $stats->get_earnings($form_id, $date, $date_end);
337 337
 			$earnings_totals += $earnings;
338 338
 
339
-			$sales_data[]    = array( $date * 1000, $sales );
340
-			$earnings_data[] = array( $date * 1000, $earnings );
339
+			$sales_data[]    = array($date * 1000, $sales);
340
+			$earnings_data[] = array($date * 1000, $earnings);
341 341
 
342
-			$day ++;
342
+			$day++;
343 343
 		endwhile;
344 344
 
345 345
 	} else {
346 346
 
347 347
 		$y = $dates['year'];
348 348
 
349
-		while ( $y <= $dates['year_end'] ) :
349
+		while ($y <= $dates['year_end']) :
350 350
 
351 351
 			$last_year = false;
352 352
 
353
-			if ( $dates['year'] == $dates['year_end'] ) {
353
+			if ($dates['year'] == $dates['year_end']) {
354 354
 				$month_start = $dates['m_start'];
355 355
 				$month_end   = $dates['m_end'];
356 356
 				$last_year   = true;
357
-			} elseif ( $y == $dates['year'] ) {
357
+			} elseif ($y == $dates['year']) {
358 358
 				$month_start = $dates['m_start'];
359 359
 				$month_end   = 12;
360 360
 			} else {
@@ -363,76 +363,76 @@  discard block
 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
-		__( 'Income', 'give' )    => $earnings_data,
427
-		__( 'Donations', 'give' ) => $sales_data
426
+		__('Income', 'give')    => $earnings_data,
427
+		__('Donations', 'give') => $sales_data
428 428
 	);
429 429
 
430 430
 	?>
431 431
 	<h3><span><?php
432 432
 			printf(
433 433
 			/* translators: %s: form title */
434
-				esc_html__( 'Income Report for %s', 'give' ),
435
-				get_the_title( $form_id )
434
+				esc_html__('Income Report for %s', 'give'),
435
+				get_the_title($form_id)
436 436
 			);
437 437
 			?></span></h3>
438 438
 	<div id="give-dashboard-widgets-wrap">
@@ -441,9 +441,9 @@  discard block
 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 _e( 'Total income for period:', 'give' ); ?></strong></th>
456
-					<td><?php echo give_currency_filter( give_format_amount( $earnings_totals, array( 'sanitize' => false ) ) ); ?></td>
455
+					<th scope="row"><strong><?php _e('Total income for period:', 'give'); ?></strong></th>
456
+					<td><?php echo give_currency_filter(give_format_amount($earnings_totals, array('sanitize' => false))); ?></td>
457 457
 				</tr>
458 458
 				<tr class="alternate">
459
-					<th scope="row"><strong><?php _e( 'Total donations for period:', 'give' ); ?></strong></th>
459
+					<th scope="row"><strong><?php _e('Total donations for period:', 'give'); ?></strong></th>
460 460
 					<td><?php echo $sales_totals; ?></td>
461 461
 				</tr>
462 462
 				<tr>
463
-					<th scope="row"><strong><?php _e( 'Average monthly income:', 'give' ); ?></strong></th>
464
-					<td><?php echo give_currency_filter( give_format_amount( give_get_average_monthly_form_earnings( $form_id ), array( 'sanitize' => false ) ) ); ?></td>
463
+					<th scope="row"><strong><?php _e('Average monthly income:', 'give'); ?></strong></th>
464
+					<td><?php echo give_currency_filter(give_format_amount(give_get_average_monthly_form_earnings($form_id), array('sanitize' => false))); ?></td>
465 465
 				</tr>
466 466
 				<tr class="alternate">
467
-					<th scope="row"><strong><?php _e( 'Average monthly donations:', 'give' ); ?></strong></th>
468
-					<td><?php echo number_format( give_get_average_monthly_form_sales( $form_id ), 0 ); ?></td>
467
+					<th scope="row"><strong><?php _e('Average monthly donations:', 'give'); ?></strong></th>
468
+					<td><?php echo number_format(give_get_average_monthly_form_sales($form_id), 0); ?></td>
469 469
 				</tr>
470 470
 				</tbody>
471 471
 			</table>
@@ -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'        => __( 'Today', 'give' ),
489
-		'yesterday'    => __( 'Yesterday', 'give' ),
490
-		'this_week'    => __( 'This Week', 'give' ),
491
-		'last_week'    => __( 'Last Week', 'give' ),
492
-		'this_month'   => __( 'This Month', 'give' ),
493
-		'last_month'   => __( 'Last Month', 'give' ),
494
-		'this_quarter' => __( 'This Quarter', 'give' ),
495
-		'last_quarter' => __( 'Last Quarter', 'give' ),
496
-		'this_year'    => __( 'This Year', 'give' ),
497
-		'last_year'    => __( 'Last Year', 'give' ),
498
-		'other'        => __( 'Custom', 'give' )
499
-	) );
487
+	$date_options = apply_filters('give_report_date_options', array(
488
+		'today'        => __('Today', 'give'),
489
+		'yesterday'    => __('Yesterday', 'give'),
490
+		'this_week'    => __('This Week', 'give'),
491
+		'last_week'    => __('Last Week', 'give'),
492
+		'this_month'   => __('This Month', 'give'),
493
+		'last_month'   => __('Last Month', 'give'),
494
+		'this_quarter' => __('This Quarter', 'give'),
495
+		'last_quarter' => __('Last Quarter', 'give'),
496
+		'this_year'    => __('This Year', 'give'),
497
+		'last_year'    => __('Last Year', 'give'),
498
+		'other'        => __('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 _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 _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 _e( 'Filter', 'give' ); ?>" />
571
+					<input type="submit" class="button-secondary" value="<?php _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
 /**
@@ -597,67 +597,67 @@  discard block
 block discarded – undo
597 597
 function give_get_report_dates() {
598 598
 	$dates = array();
599 599
 
600
-	$current_time = current_time( 'timestamp' );
600
+	$current_time = current_time('timestamp');
601 601
 
602
-	$dates['range']    = isset( $_GET['range'] ) ? $_GET['range'] : 'this_month';
603
-	$dates['year']     = isset( $_GET['year'] ) ? $_GET['year'] : date( 'Y' );
604
-	$dates['year_end'] = isset( $_GET['year_end'] ) ? $_GET['year_end'] : date( 'Y' );
605
-	$dates['m_start']  = isset( $_GET['m_start'] ) ? $_GET['m_start'] : 1;
606
-	$dates['m_end']    = isset( $_GET['m_end'] ) ? $_GET['m_end'] : 12;
607
-	$dates['day']      = isset( $_GET['day'] ) ? $_GET['day'] : 1;
608
-	$dates['day_end']  = isset( $_GET['day_end'] ) ? $_GET['day_end'] : cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] );
602
+	$dates['range']    = isset($_GET['range']) ? $_GET['range'] : 'this_month';
603
+	$dates['year']     = isset($_GET['year']) ? $_GET['year'] : date('Y');
604
+	$dates['year_end'] = isset($_GET['year_end']) ? $_GET['year_end'] : date('Y');
605
+	$dates['m_start']  = isset($_GET['m_start']) ? $_GET['m_start'] : 1;
606
+	$dates['m_end']    = isset($_GET['m_end']) ? $_GET['m_end'] : 12;
607
+	$dates['day']      = isset($_GET['day']) ? $_GET['day'] : 1;
608
+	$dates['day_end']  = isset($_GET['day_end']) ? $_GET['day_end'] : cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']);
609 609
 
610 610
 	// Modify dates based on predefined ranges.
611
-	switch ( $dates['range'] ) :
611
+	switch ($dates['range']) :
612 612
 
613 613
 		case 'this_month' :
614
-			$dates['m_start']  = date( 'n', $current_time );
615
-			$dates['m_end']    = date( 'n', $current_time );
614
+			$dates['m_start']  = date('n', $current_time);
615
+			$dates['m_end']    = date('n', $current_time);
616 616
 			$dates['day']      = 1;
617
-			$dates['day_end']  = cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] );
618
-			$dates['year']     = date( 'Y' );
619
-			$dates['year_end'] = date( 'Y' );
617
+			$dates['day_end']  = cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']);
618
+			$dates['year']     = date('Y');
619
+			$dates['year_end'] = date('Y');
620 620
 			break;
621 621
 
622 622
 		case 'last_month' :
623
-			if ( date( 'n' ) == 1 ) {
623
+			if (date('n') == 1) {
624 624
 				$dates['m_start']  = 12;
625 625
 				$dates['m_end']    = 12;
626
-				$dates['year']     = date( 'Y', $current_time ) - 1;
627
-				$dates['year_end'] = date( 'Y', $current_time ) - 1;
626
+				$dates['year']     = date('Y', $current_time) - 1;
627
+				$dates['year_end'] = date('Y', $current_time) - 1;
628 628
 			} else {
629
-				$dates['m_start']  = date( 'n' ) - 1;
630
-				$dates['m_end']    = date( 'n' ) - 1;
629
+				$dates['m_start']  = date('n') - 1;
630
+				$dates['m_end']    = date('n') - 1;
631 631
 				$dates['year_end'] = $dates['year'];
632 632
 			}
633
-			$dates['day_end'] = cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] );
633
+			$dates['day_end'] = cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']);
634 634
 			break;
635 635
 
636 636
 		case 'today' :
637
-			$dates['day']      = date( 'd', $current_time );
638
-			$dates['day_end']  = date( 'd', $current_time );
639
-			$dates['m_start']  = date( 'n', $current_time );
640
-			$dates['m_end']    = date( 'n', $current_time );
641
-			$dates['year']     = date( 'Y', $current_time );
642
-			$dates['year_end'] = date( 'Y', $current_time );
637
+			$dates['day']      = date('d', $current_time);
638
+			$dates['day_end']  = date('d', $current_time);
639
+			$dates['m_start']  = date('n', $current_time);
640
+			$dates['m_end']    = date('n', $current_time);
641
+			$dates['year']     = date('Y', $current_time);
642
+			$dates['year_end'] = date('Y', $current_time);
643 643
 			break;
644 644
 
645 645
 		case 'yesterday' :
646 646
 
647
-			$year  = date( 'Y', $current_time );
648
-			$month = date( 'n', $current_time );
649
-			$day   = date( 'd', $current_time );
647
+			$year  = date('Y', $current_time);
648
+			$month = date('n', $current_time);
649
+			$day   = date('d', $current_time);
650 650
 
651
-			if ( $month == 1 && $day == 1 ) {
651
+			if ($month == 1 && $day == 1) {
652 652
 
653 653
 				$year -= 1;
654 654
 				$month = 12;
655
-				$day   = cal_days_in_month( CAL_GREGORIAN, $month, $year );
655
+				$day   = cal_days_in_month(CAL_GREGORIAN, $month, $year);
656 656
 
657
-			} elseif ( $month > 1 && $day == 1 ) {
657
+			} elseif ($month > 1 && $day == 1) {
658 658
 
659 659
 				$month -= 1;
660
-				$day = cal_days_in_month( CAL_GREGORIAN, $month, $year );
660
+				$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
661 661
 
662 662
 			} else {
663 663
 
@@ -673,48 +673,48 @@  discard block
 block discarded – undo
673 673
 			break;
674 674
 
675 675
 		case 'this_week' :
676
-			$dates['day'] = date( 'd', $current_time - ( date( 'w', $current_time ) - 1 ) * 60 * 60 * 24 ) - 1;
677
-			$dates['day'] += get_option( 'start_of_week' );
676
+			$dates['day'] = date('d', $current_time - (date('w', $current_time) - 1) * 60 * 60 * 24) - 1;
677
+			$dates['day'] += get_option('start_of_week');
678 678
 			$dates['day_end'] = $dates['day'] + 6;
679
-			$dates['m_start'] = date( 'n', $current_time );
680
-			$dates['m_end']   = date( 'n', $current_time );
681
-			$dates['year']    = date( 'Y', $current_time );
679
+			$dates['m_start'] = date('n', $current_time);
680
+			$dates['m_end']   = date('n', $current_time);
681
+			$dates['year']    = date('Y', $current_time);
682 682
 			break;
683 683
 
684 684
 		case 'last_week' :
685
-			$dates['day'] = date( 'd', $current_time - ( date( 'w' ) - 1 ) * 60 * 60 * 24 ) - 8;
686
-			$dates['day'] += get_option( 'start_of_week' );
685
+			$dates['day'] = date('d', $current_time - (date('w') - 1) * 60 * 60 * 24) - 8;
686
+			$dates['day'] += get_option('start_of_week');
687 687
 			$dates['day_end'] = $dates['day'] + 6;
688
-			$dates['year']    = date( 'Y' );
689
-
690
-			if ( date( 'j', $current_time ) <= 7 ) {
691
-				$dates['m_start'] = date( 'n', $current_time ) - 1;
692
-				$dates['m_end']   = date( 'n', $current_time ) - 1;
693
-				if ( $dates['m_start'] <= 1 ) {
694
-					$dates['year']     = date( 'Y', $current_time ) - 1;
695
-					$dates['year_end'] = date( 'Y', $current_time ) - 1;
688
+			$dates['year']    = date('Y');
689
+
690
+			if (date('j', $current_time) <= 7) {
691
+				$dates['m_start'] = date('n', $current_time) - 1;
692
+				$dates['m_end']   = date('n', $current_time) - 1;
693
+				if ($dates['m_start'] <= 1) {
694
+					$dates['year']     = date('Y', $current_time) - 1;
695
+					$dates['year_end'] = date('Y', $current_time) - 1;
696 696
 				}
697 697
 			} else {
698
-				$dates['m_start'] = date( 'n', $current_time );
699
-				$dates['m_end']   = date( 'n', $current_time );
698
+				$dates['m_start'] = date('n', $current_time);
699
+				$dates['m_end']   = date('n', $current_time);
700 700
 			}
701 701
 			break;
702 702
 
703 703
 		case 'this_quarter' :
704
-			$month_now     = date( 'n', $current_time );
705
-			$dates['year'] = date( 'Y', $current_time );
704
+			$month_now     = date('n', $current_time);
705
+			$dates['year'] = date('Y', $current_time);
706 706
 
707
-			if ( $month_now <= 3 ) {
707
+			if ($month_now <= 3) {
708 708
 
709 709
 				$dates['m_start'] = 1;
710 710
 				$dates['m_end']   = 4;
711 711
 
712
-			} else if ( $month_now <= 6 ) {
712
+			} else if ($month_now <= 6) {
713 713
 
714 714
 				$dates['m_start'] = 4;
715 715
 				$dates['m_end']   = 7;
716 716
 
717
-			} else if ( $month_now <= 9 ) {
717
+			} else if ($month_now <= 9) {
718 718
 
719 719
 				$dates['m_start'] = 7;
720 720
 				$dates['m_end']   = 10;
@@ -723,28 +723,28 @@  discard block
 block discarded – undo
723 723
 
724 724
 				$dates['m_start']  = 10;
725 725
 				$dates['m_end']    = 1;
726
-				$dates['year_end'] = date( 'Y', $current_time ) + 1;
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', $current_time );
733
-			$dates['year']     = date( 'Y', $current_time );
734
-			$dates['year_end'] = date( 'Y', $current_time );
732
+			$month_now         = date('n', $current_time);
733
+			$dates['year']     = date('Y', $current_time);
734
+			$dates['year_end'] = date('Y', $current_time);
735 735
 
736
-			if ( $month_now <= 3 ) {
736
+			if ($month_now <= 3) {
737 737
 
738 738
 				$dates['m_start'] = 10;
739 739
 				$dates['m_end']   = 1;
740
-				$dates['year']    = date( 'Y', $current_time ) - 1; // Previous year.
740
+				$dates['year']    = date('Y', $current_time) - 1; // Previous year.
741 741
 
742
-			} else if ( $month_now <= 6 ) {
742
+			} else if ($month_now <= 6) {
743 743
 
744 744
 				$dates['m_start'] = 1;
745 745
 				$dates['m_end']   = 4;
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']   = 7;
@@ -760,20 +760,20 @@  discard block
 block discarded – undo
760 760
 		case 'this_year' :
761 761
 			$dates['m_start']  = 1;
762 762
 			$dates['m_end']    = 12;
763
-			$dates['year']     = date( 'Y', $current_time );
764
-			$dates['year_end'] = date( 'Y', $current_time );
763
+			$dates['year']     = date('Y', $current_time);
764
+			$dates['year_end'] = date('Y', $current_time);
765 765
 			break;
766 766
 
767 767
 		case 'last_year' :
768 768
 			$dates['m_start']  = 1;
769 769
 			$dates['m_end']    = 12;
770
-			$dates['year']     = date( 'Y', $current_time ) - 1;
771
-			$dates['year_end'] = date( 'Y', $current_time ) - 1;
770
+			$dates['year']     = date('Y', $current_time) - 1;
771
+			$dates['year_end'] = date('Y', $current_time) - 1;
772 772
 			break;
773 773
 
774 774
 	endswitch;
775 775
 
776
-	return apply_filters( 'give_report_dates', $dates );
776
+	return apply_filters('give_report_dates', $dates);
777 777
 }
778 778
 
779 779
 /**
@@ -784,18 +784,18 @@  discard block
 block discarded – undo
784 784
  *
785 785
  * @param $data
786 786
  */
787
-function give_parse_report_dates( $data ) {
787
+function give_parse_report_dates($data) {
788 788
 	$dates = give_get_report_dates();
789 789
 
790 790
 	$view = give_get_reporting_view();
791
-	$tab  = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'earnings';
792
-	$id   = isset( $_GET['form-id'] ) ? $_GET['form-id'] : null;
791
+	$tab  = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'earnings';
792
+	$id   = isset($_GET['form-id']) ? $_GET['form-id'] : null;
793 793
 
794
-	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 ) ) ) );
794
+	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 795
 	give_die();
796 796
 }
797 797
 
798
-add_action( 'give_filter_reports', 'give_parse_report_dates' );
798
+add_action('give_filter_reports', 'give_parse_report_dates');
799 799
 
800 800
 
801 801
 /**
@@ -807,23 +807,23 @@  discard block
 block discarded – undo
807 807
  */
808 808
 function give_reports_refresh_button() {
809 809
 
810
-	$url = wp_nonce_url( add_query_arg( array(
810
+	$url = wp_nonce_url(add_query_arg(array(
811 811
 		'give_action'  => 'refresh_reports_transients',
812 812
 		'give-message' => 'refreshed-reports'
813
-	) ), 'give-refresh-reports' );
813
+	)), 'give-refresh-reports');
814 814
 
815
-	echo Give()->tooltips->render_link( array(
816
-		'label'       => esc_attr__( 'Clicking this will clear the reports cache.', 'give' ),
817
-		'tag_content' => '<span class="give-admin-button-icon give-admin-button-icon-update"></span>' . esc_html__( 'Refresh Report Data', 'give' ),
815
+	echo Give()->tooltips->render_link(array(
816
+		'label'       => esc_attr__('Clicking this will clear the reports cache.', 'give'),
817
+		'tag_content' => '<span class="give-admin-button-icon give-admin-button-icon-update"></span>'.esc_html__('Refresh Report Data', 'give'),
818 818
 		'link'        => $url,
819 819
 		'position'    => 'left',
820 820
 		'attributes'  => array(
821 821
 			'class' => 'button alignright give-admin-button'
822 822
 		)
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/forms/class-metabox-form-data.php 2 patches
Spacing   +300 added lines, -304 removed lines patch added patch discarded remove patch
@@ -46,24 +46,24 @@  discard block
 block discarded – undo
46 46
 	 */
47 47
 	function __construct() {
48 48
 		$this->metabox_id    = 'give-metabox-form-data';
49
-		$this->metabox_label = __( 'Donation Form Options', 'give' );
49
+		$this->metabox_label = __('Donation Form Options', 'give');
50 50
 
51 51
 		// Setup.
52
-		add_action( 'admin_init', array( $this, 'setup' ) );
52
+		add_action('admin_init', array($this, 'setup'));
53 53
 
54 54
 		// Add metabox.
55
-		add_action( 'add_meta_boxes', array( $this, 'add_meta_box' ), 10 );
55
+		add_action('add_meta_boxes', array($this, 'add_meta_box'), 10);
56 56
 
57 57
 		// Save form meta.
58
-		add_action( 'save_post_give_forms', array( $this, 'save' ), 10, 2 );
58
+		add_action('save_post_give_forms', array($this, 'save'), 10, 2);
59 59
 
60 60
 		// cmb2 old setting loaders.
61 61
 		// add_filter( 'give_metabox_form_data_settings', array( $this, 'cmb2_metabox_settings' ) );
62 62
 		// Add offline donations options.
63
-		add_filter( 'give_metabox_form_data_settings', array( $this, 'add_offline_donations_setting_tab' ), 0, 1 );
63
+		add_filter('give_metabox_form_data_settings', array($this, 'add_offline_donations_setting_tab'), 0, 1);
64 64
 
65 65
 		// Maintain active tab query parameter after save.
66
-		add_filter( 'redirect_post_location', array( $this, 'maintain_active_tab' ), 10, 2 );
66
+		add_filter('redirect_post_location', array($this, 'maintain_active_tab'), 10, 2);
67 67
 	}
68 68
 
69 69
 	/**
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	 */
88 88
 	function get_settings() {
89 89
 		$post_id           = give_get_admin_post_id();
90
-		$price_placeholder = give_format_decimal( '1.00', false, false );
90
+		$price_placeholder = give_format_decimal('1.00', false, false);
91 91
 
92 92
 		// Start with an underscore to hide fields from custom fields list
93 93
 		$prefix = '_give_';
@@ -96,27 +96,27 @@  discard block
 block discarded – undo
96 96
 			/**
97 97
 			 * Repeatable Field Groups
98 98
 			 */
99
-			'form_field_options'    => apply_filters( 'give_forms_field_options', array(
99
+			'form_field_options'    => apply_filters('give_forms_field_options', array(
100 100
 				'id'        => 'form_field_options',
101
-				'title'     => __( 'Donation Options', 'give' ),
101
+				'title'     => __('Donation Options', 'give'),
102 102
 				'icon-html' => '<span class="give-icon give-icon-heart"></span>',
103
-				'fields'    => apply_filters( 'give_forms_donation_form_metabox_fields', array(
103
+				'fields'    => apply_filters('give_forms_donation_form_metabox_fields', array(
104 104
 					// Donation Option.
105 105
 					array(
106
-						'name'        => __( 'Donation Option', 'give' ),
107
-						'description' => __( 'Do you want this form to have one set donation price or multiple levels (for example, $10, $20, $50)?', 'give' ),
108
-						'id'          => $prefix . 'price_option',
106
+						'name'        => __('Donation Option', 'give'),
107
+						'description' => __('Do you want this form to have one set donation price or multiple levels (for example, $10, $20, $50)?', 'give'),
108
+						'id'          => $prefix.'price_option',
109 109
 						'type'        => 'radio_inline',
110 110
 						'default'     => 'multi',
111
-						'options'     => apply_filters( 'give_forms_price_options', array(
112
-							'multi' => __( 'Multi-level Donation', 'give' ),
113
-							'set'   => __( 'Set Donation', 'give' ),
114
-						) ),
111
+						'options'     => apply_filters('give_forms_price_options', array(
112
+							'multi' => __('Multi-level Donation', 'give'),
113
+							'set'   => __('Set Donation', 'give'),
114
+						)),
115 115
 					),
116 116
 					array(
117
-						'name'        => __( 'Set Donation', 'give' ),
118
-						'description' => __( 'This is the set donation amount for this form. If you have a "Custom Amount Minimum" set, make sure it is less than this amount.', 'give' ),
119
-						'id'          => $prefix . 'set_price',
117
+						'name'        => __('Set Donation', 'give'),
118
+						'description' => __('This is the set donation amount for this form. If you have a "Custom Amount Minimum" set, make sure it is less than this amount.', 'give'),
119
+						'id'          => $prefix.'set_price',
120 120
 						'type'        => 'text_small',
121 121
 						'data_type'   => 'price',
122 122
 						'attributes'  => array(
@@ -126,34 +126,34 @@  discard block
 block discarded – undo
126 126
 					),
127 127
 					// Display Style.
128 128
 					array(
129
-						'name'          => __( 'Display Style', 'give' ),
130
-						'description'   => __( 'Set how the donations levels will display on the form.', 'give' ),
131
-						'id'            => $prefix . 'display_style',
129
+						'name'          => __('Display Style', 'give'),
130
+						'description'   => __('Set how the donations levels will display on the form.', 'give'),
131
+						'id'            => $prefix.'display_style',
132 132
 						'type'          => 'radio_inline',
133 133
 						'default'       => 'buttons',
134 134
 						'options'       => array(
135
-							'buttons'  => __( 'Buttons', 'give' ),
136
-							'radios'   => __( 'Radios', 'give' ),
137
-							'dropdown' => __( 'Dropdown', 'give' ),
135
+							'buttons'  => __('Buttons', 'give'),
136
+							'radios'   => __('Radios', 'give'),
137
+							'dropdown' => __('Dropdown', 'give'),
138 138
 						),
139 139
 						'wrapper_class' => 'give-hidden',
140 140
 					),
141 141
 					// Custom Amount.
142 142
 					array(
143
-						'name'        => __( 'Custom Amount', 'give' ),
144
-						'description' => __( 'Do you want the user to be able to input their own donation amount?', 'give' ),
145
-						'id'          => $prefix . 'custom_amount',
143
+						'name'        => __('Custom Amount', 'give'),
144
+						'description' => __('Do you want the user to be able to input their own donation amount?', 'give'),
145
+						'id'          => $prefix.'custom_amount',
146 146
 						'type'        => 'radio_inline',
147 147
 						'default'     => 'disabled',
148 148
 						'options'     => array(
149
-							'enabled'  => __( 'Enabled', 'give' ),
150
-							'disabled' => __( 'Disabled', 'give' ),
149
+							'enabled'  => __('Enabled', 'give'),
150
+							'disabled' => __('Disabled', 'give'),
151 151
 						),
152 152
 					),
153 153
 					array(
154
-						'name'          => __( 'Minimum Amount', 'give' ),
155
-						'description'   => __( 'Enter the minimum custom donation amount.', 'give' ),
156
-						'id'            => $prefix . 'custom_amount_minimum',
154
+						'name'          => __('Minimum Amount', 'give'),
155
+						'description'   => __('Enter the minimum custom donation amount.', 'give'),
156
+						'id'            => $prefix.'custom_amount_minimum',
157 157
 						'type'          => 'text_small',
158 158
 						'data_type'     => 'price',
159 159
 						'attributes'    => array(
@@ -163,37 +163,37 @@  discard block
 block discarded – undo
163 163
 						'wrapper_class' => 'give-hidden',
164 164
 					),
165 165
 					array(
166
-						'name'          => __( 'Custom Amount Text', 'give' ),
167
-						'description'   => __( 'This text appears as a label below the custom amount field for set donation forms. For multi-level forms the text will appear as it\'s own level (ie button, radio, or select option).', 'give' ),
168
-						'id'            => $prefix . 'custom_amount_text',
166
+						'name'          => __('Custom Amount Text', 'give'),
167
+						'description'   => __('This text appears as a label below the custom amount field for set donation forms. For multi-level forms the text will appear as it\'s own level (ie button, radio, or select option).', 'give'),
168
+						'id'            => $prefix.'custom_amount_text',
169 169
 						'type'          => 'text_medium',
170 170
 						'attributes'    => array(
171 171
 							'rows'        => 3,
172
-							'placeholder' => __( 'Give a Custom Amount', 'give' ),
172
+							'placeholder' => __('Give a Custom Amount', 'give'),
173 173
 						),
174 174
 						'wrapper_class' => 'give-hidden',
175 175
 					),
176 176
 					// Donation Levels.
177 177
 					array(
178
-						'id'            => $prefix . 'donation_levels',
178
+						'id'            => $prefix.'donation_levels',
179 179
 						'type'          => 'group',
180 180
 						'options'       => array(
181
-							'add_button'    => __( 'Add Level', 'give' ),
182
-							'header_title'  => __( 'Donation Level', 'give' ),
181
+							'add_button'    => __('Add Level', 'give'),
182
+							'header_title'  => __('Donation Level', 'give'),
183 183
 							'remove_button' => '<span class="dashicons dashicons-no"></span>',
184 184
 						),
185 185
 						'wrapper_class' => 'give-hidden',
186 186
 						// Fields array works the same, except id's only need to be unique for this group.
187 187
 						// Prefix is not needed.
188
-						'fields'        => apply_filters( 'give_donation_levels_table_row', array(
188
+						'fields'        => apply_filters('give_donation_levels_table_row', array(
189 189
 							array(
190
-								'name' => __( 'ID', 'give' ),
191
-								'id'   => $prefix . 'id',
190
+								'name' => __('ID', 'give'),
191
+								'id'   => $prefix.'id',
192 192
 								'type' => 'levels_id',
193 193
 							),
194 194
 							array(
195
-								'name'       => __( 'Amount', 'give' ),
196
-								'id'         => $prefix . 'amount',
195
+								'name'       => __('Amount', 'give'),
196
+								'id'         => $prefix.'amount',
197 197
 								'type'       => 'text_small',
198 198
 								'data_type'  => 'price',
199 199
 								'attributes' => array(
@@ -202,112 +202,112 @@  discard block
 block discarded – undo
202 202
 								),
203 203
 							),
204 204
 							array(
205
-								'name'       => __( 'Text', 'give' ),
206
-								'id'         => $prefix . 'text',
205
+								'name'       => __('Text', 'give'),
206
+								'id'         => $prefix.'text',
207 207
 								'type'       => 'text',
208 208
 								'attributes' => array(
209
-									'placeholder' => __( 'Donation Level', 'give' ),
209
+									'placeholder' => __('Donation Level', 'give'),
210 210
 									'class'       => 'give-multilevel-text-field',
211 211
 								),
212 212
 							),
213 213
 							array(
214
-								'name' => __( 'Default', 'give' ),
215
-								'id'   => $prefix . 'default',
214
+								'name' => __('Default', 'give'),
215
+								'id'   => $prefix.'default',
216 216
 								'type' => 'give_default_radio_inline',
217 217
 							),
218
-						) ),
218
+						)),
219 219
 					),
220 220
 					array(
221 221
 						'name'  => 'donation_options_docs',
222 222
 						'type'  => 'docs_link',
223 223
 						'url'   => 'http://docs.givewp.com/form-donation-options',
224
-						'title' => __( 'Donation Options', 'give' ),
224
+						'title' => __('Donation Options', 'give'),
225 225
 					),
226 226
 				),
227 227
 					$post_id
228 228
 				),
229
-			) ),
229
+			)),
230 230
 
231 231
 			/**
232 232
 			 * Display Options
233 233
 			 */
234
-			'form_display_options'  => apply_filters( 'give_form_display_options', array(
234
+			'form_display_options'  => apply_filters('give_form_display_options', array(
235 235
 					'id'        => 'form_display_options',
236
-					'title'     => __( 'Form Display', 'give' ),
236
+					'title'     => __('Form Display', 'give'),
237 237
 					'icon-html' => '<span class="give-icon give-icon-display"></span>',
238
-					'fields'    => apply_filters( 'give_forms_display_options_metabox_fields', array(
238
+					'fields'    => apply_filters('give_forms_display_options_metabox_fields', array(
239 239
 						array(
240
-							'name'    => __( 'Display Options', 'give' ),
241
-							'desc'    => sprintf( __( 'How would you like to display donation information for this form?', 'give' ), '#' ),
242
-							'id'      => $prefix . 'payment_display',
240
+							'name'    => __('Display Options', 'give'),
241
+							'desc'    => sprintf(__('How would you like to display donation information for this form?', 'give'), '#'),
242
+							'id'      => $prefix.'payment_display',
243 243
 							'type'    => 'radio_inline',
244 244
 							'options' => array(
245
-								'onpage' => __( 'All Fields', 'give' ),
246
-								'modal'  => __( 'Modal', 'give' ),
247
-								'reveal' => __( 'Reveal', 'give' ),
248
-								'button' => __( 'Button', 'give' ),
245
+								'onpage' => __('All Fields', 'give'),
246
+								'modal'  => __('Modal', 'give'),
247
+								'reveal' => __('Reveal', 'give'),
248
+								'button' => __('Button', 'give'),
249 249
 							),
250 250
 							'default' => 'onpage',
251 251
 						),
252 252
 						array(
253
-							'id'            => $prefix . 'reveal_label',
254
-							'name'          => __( 'Continue Button', 'give' ),
255
-							'desc'          => __( 'The button label for displaying the additional payment fields.', 'give' ),
253
+							'id'            => $prefix.'reveal_label',
254
+							'name'          => __('Continue Button', 'give'),
255
+							'desc'          => __('The button label for displaying the additional payment fields.', 'give'),
256 256
 							'type'          => 'text_small',
257 257
 							'attributes'    => array(
258
-								'placeholder' => __( 'Donate Now', 'give' ),
258
+								'placeholder' => __('Donate Now', 'give'),
259 259
 							),
260 260
 							'wrapper_class' => 'give-hidden',
261 261
 						),
262 262
 						array(
263
-							'id'         => $prefix . 'checkout_label',
264
-							'name'       => __( 'Submit Button', 'give' ),
265
-							'desc'       => __( 'The button label for completing a donation.', 'give' ),
263
+							'id'         => $prefix.'checkout_label',
264
+							'name'       => __('Submit Button', 'give'),
265
+							'desc'       => __('The button label for completing a donation.', 'give'),
266 266
 							'type'       => 'text_small',
267 267
 							'attributes' => array(
268
-								'placeholder' => __( 'Donate Now', 'give' ),
268
+								'placeholder' => __('Donate Now', 'give'),
269 269
 							),
270 270
 						),
271 271
 						array(
272
-							'name' => __( 'Default Gateway', 'give' ),
273
-							'desc' => __( 'By default, the gateway for this form will inherit the global default gateway (set under Give > Settings > Payment Gateways). This option allows you to customize the default gateway for this form only.', 'give' ),
274
-							'id'   => $prefix . 'default_gateway',
272
+							'name' => __('Default Gateway', 'give'),
273
+							'desc' => __('By default, the gateway for this form will inherit the global default gateway (set under Give > Settings > Payment Gateways). This option allows you to customize the default gateway for this form only.', 'give'),
274
+							'id'   => $prefix.'default_gateway',
275 275
 							'type' => 'default_gateway',
276 276
 						),
277 277
 						array(
278
-							'name'    => __( 'Guest Donations', 'give' ),
279
-							'desc'    => __( 'Do you want to allow non-logged-in users to make donations?', 'give' ),
280
-							'id'      => $prefix . 'logged_in_only',
278
+							'name'    => __('Guest Donations', 'give'),
279
+							'desc'    => __('Do you want to allow non-logged-in users to make donations?', 'give'),
280
+							'id'      => $prefix.'logged_in_only',
281 281
 							'type'    => 'radio_inline',
282 282
 							'default' => 'enabled',
283 283
 							'options' => array(
284
-								'enabled'  => __( 'Enabled', 'give' ),
285
-								'disabled' => __( 'Disabled', 'give' ),
284
+								'enabled'  => __('Enabled', 'give'),
285
+								'disabled' => __('Disabled', 'give'),
286 286
 							),
287 287
 						),
288 288
 						array(
289
-							'name'    => __( 'Registration', 'give' ),
290
-							'desc'    => __( 'Display the registration and login forms in the payment section for non-logged-in users.', 'give' ),
291
-							'id'      => $prefix . 'show_register_form',
289
+							'name'    => __('Registration', 'give'),
290
+							'desc'    => __('Display the registration and login forms in the payment section for non-logged-in users.', 'give'),
291
+							'id'      => $prefix.'show_register_form',
292 292
 							'type'    => 'radio',
293 293
 							'options' => array(
294
-								'none'         => __( 'None', 'give' ),
295
-								'registration' => __( 'Registration', 'give' ),
296
-								'login'        => __( 'Login', 'give' ),
297
-								'both'         => __( 'Registration + Login', 'give' ),
294
+								'none'         => __('None', 'give'),
295
+								'registration' => __('Registration', 'give'),
296
+								'login'        => __('Login', 'give'),
297
+								'both'         => __('Registration + Login', 'give'),
298 298
 							),
299 299
 							'default' => 'none',
300 300
 						),
301 301
 						array(
302
-							'name'    => __( 'Floating Labels', 'give' ),
302
+							'name'    => __('Floating Labels', 'give'),
303 303
 							/* translators: %s: forms http://docs.givewp.com/form-floating-labels */
304
-							'desc'    => sprintf( __( 'Select the <a href="%s" target="_blank">floating labels</a> setting for this Give form. Be aware that if you have the "Disable CSS" option enabled, you will need to style the floating labels yourself.', 'give' ), esc_url( 'http://docs.givewp.com/form-floating-labels' ) ),
305
-							'id'      => $prefix . 'form_floating_labels',
304
+							'desc'    => sprintf(__('Select the <a href="%s" target="_blank">floating labels</a> setting for this Give form. Be aware that if you have the "Disable CSS" option enabled, you will need to style the floating labels yourself.', 'give'), esc_url('http://docs.givewp.com/form-floating-labels')),
305
+							'id'      => $prefix.'form_floating_labels',
306 306
 							'type'    => 'radio_inline',
307 307
 							'options' => array(
308
-								'global'   => __( 'Global Option', 'give' ),
309
-								'enabled'  => __( 'Enabled', 'give' ),
310
-								'disabled' => __( 'Disabled', 'give' ),
308
+								'global'   => __('Global Option', 'give'),
309
+								'enabled'  => __('Enabled', 'give'),
310
+								'disabled' => __('Disabled', 'give'),
311 311
 							),
312 312
 							'default' => 'global',
313 313
 						),
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 							'name'  => 'form_display_docs',
316 316
 							'type'  => 'docs_link',
317 317
 							'url'   => 'http://docs.givewp.com/form-display-options',
318
-							'title' => __( 'Form Display', 'give' ),
318
+							'title' => __('Form Display', 'give'),
319 319
 						),
320 320
 					),
321 321
 						$post_id
@@ -326,41 +326,41 @@  discard block
 block discarded – undo
326 326
 			/**
327 327
 			 * Donation Goals
328 328
 			 */
329
-			'donation_goal_options' => apply_filters( 'give_donation_goal_options', array(
329
+			'donation_goal_options' => apply_filters('give_donation_goal_options', array(
330 330
 				'id'        => 'donation_goal_options',
331
-				'title'     => __( 'Donation Goal', 'give' ),
331
+				'title'     => __('Donation Goal', 'give'),
332 332
 				'icon-html' => '<span class="give-icon give-icon-target"></span>',
333
-				'fields'    => apply_filters( 'give_forms_donation_goal_metabox_fields', array(
333
+				'fields'    => apply_filters('give_forms_donation_goal_metabox_fields', array(
334 334
 					// Goals
335 335
 					array(
336
-						'name'        => __( 'Donation Goal', 'give' ),
337
-						'description' => __( 'Do you want to set a donation goal for this form?', 'give' ),
338
-						'id'          => $prefix . 'goal_option',
336
+						'name'        => __('Donation Goal', 'give'),
337
+						'description' => __('Do you want to set a donation goal for this form?', 'give'),
338
+						'id'          => $prefix.'goal_option',
339 339
 						'type'        => 'radio_inline',
340 340
 						'default'     => 'disabled',
341 341
 						'options'     => array(
342
-							'enabled'  => __( 'Enabled', 'give' ),
343
-							'disabled' => __( 'Disabled', 'give' ),
342
+							'enabled'  => __('Enabled', 'give'),
343
+							'disabled' => __('Disabled', 'give'),
344 344
 						),
345 345
 					),
346 346
 
347 347
 					array(
348
-						'name'        => __( 'Goal Format', 'give' ),
349
-						'description' => __( 'Do you want to display the total amount raised based on your monetary goal or a percentage? For instance, "$500 of $1,000 raised" or "50% funded" or "1 of 5 donations".', 'give' ),
350
-						'id'          => $prefix . 'goal_format',
348
+						'name'        => __('Goal Format', 'give'),
349
+						'description' => __('Do you want to display the total amount raised based on your monetary goal or a percentage? For instance, "$500 of $1,000 raised" or "50% funded" or "1 of 5 donations".', 'give'),
350
+						'id'          => $prefix.'goal_format',
351 351
 						'type'        => 'radio_inline',
352 352
 						'default'     => 'amount',
353 353
 						'options'     => array(
354
-							'amount'     => __( 'Amount', 'give' ),
355
-							'percentage' => __( 'Percentage', 'give' ),
356
-							'donation'   => __( 'Number of Donations', 'give' ),
354
+							'amount'     => __('Amount', 'give'),
355
+							'percentage' => __('Percentage', 'give'),
356
+							'donation'   => __('Number of Donations', 'give'),
357 357
 						),
358 358
 					),
359 359
 
360 360
 					array(
361
-						'name'          => __( 'Goal Amount', 'give' ),
362
-						'description'   => __( 'This is the monetary goal amount you want to reach for this form.', 'give' ),
363
-						'id'            => $prefix . 'set_goal',
361
+						'name'          => __('Goal Amount', 'give'),
362
+						'description'   => __('This is the monetary goal amount you want to reach for this form.', 'give'),
363
+						'id'            => $prefix.'set_goal',
364 364
 						'type'          => 'text_small',
365 365
 						'data_type'     => 'price',
366 366
 						'attributes'    => array(
@@ -371,9 +371,9 @@  discard block
 block discarded – undo
371 371
 					),
372 372
 
373 373
 					array(
374
-						'id'         => $prefix . 'number_of_donation_goal',
375
-						'name'       => __( 'Donation Goal', 'give' ),
376
-						'desc'       => __( 'Set total number of donations as a goal.', 'give' ),
374
+						'id'         => $prefix.'number_of_donation_goal',
375
+						'name'       => __('Donation Goal', 'give'),
376
+						'desc'       => __('Set total number of donations as a goal.', 'give'),
377 377
 						'type'       => 'number',
378 378
 						'default'    => 1,
379 379
 						'attributes' => array(
@@ -382,85 +382,85 @@  discard block
 block discarded – undo
382 382
 					),
383 383
 
384 384
 					array(
385
-						'name'          => __( 'Progress Bar Color', 'give' ),
386
-						'desc'          => __( 'Customize the color of the goal progress bar.', 'give' ),
387
-						'id'            => $prefix . 'goal_color',
385
+						'name'          => __('Progress Bar Color', 'give'),
386
+						'desc'          => __('Customize the color of the goal progress bar.', 'give'),
387
+						'id'            => $prefix.'goal_color',
388 388
 						'type'          => 'colorpicker',
389 389
 						'default'       => '#2bc253',
390 390
 						'wrapper_class' => 'give-hidden',
391 391
 					),
392 392
 
393 393
 					array(
394
-						'name'          => __( 'Close Form', 'give' ),
395
-						'desc'          => __( 'Do you want to close the donation forms and stop accepting donations once this goal has been met?', 'give' ),
396
-						'id'            => $prefix . 'close_form_when_goal_achieved',
394
+						'name'          => __('Close Form', 'give'),
395
+						'desc'          => __('Do you want to close the donation forms and stop accepting donations once this goal has been met?', 'give'),
396
+						'id'            => $prefix.'close_form_when_goal_achieved',
397 397
 						'type'          => 'radio_inline',
398 398
 						'default'       => 'disabled',
399 399
 						'options'       => array(
400
-							'enabled'  => __( 'Enabled', 'give' ),
401
-							'disabled' => __( 'Disabled', 'give' ),
400
+							'enabled'  => __('Enabled', 'give'),
401
+							'disabled' => __('Disabled', 'give'),
402 402
 						),
403 403
 						'wrapper_class' => 'give-hidden',
404 404
 					),
405 405
 					array(
406
-						'name'          => __( 'Goal Achieved Message', 'give' ),
407
-						'desc'          => __( 'Do you want to display a custom message when the goal is closed?', 'give' ),
408
-						'id'            => $prefix . 'form_goal_achieved_message',
406
+						'name'          => __('Goal Achieved Message', 'give'),
407
+						'desc'          => __('Do you want to display a custom message when the goal is closed?', 'give'),
408
+						'id'            => $prefix.'form_goal_achieved_message',
409 409
 						'type'          => 'wysiwyg',
410
-						'default'       => __( 'Thank you to all our donors, we have met our fundraising goal.', 'give' ),
410
+						'default'       => __('Thank you to all our donors, we have met our fundraising goal.', 'give'),
411 411
 						'wrapper_class' => 'give-hidden',
412 412
 					),
413 413
 					array(
414 414
 						'name'  => 'donation_goal_docs',
415 415
 						'type'  => 'docs_link',
416 416
 						'url'   => 'http://docs.givewp.com/form-donation-goal',
417
-						'title' => __( 'Donation Goal', 'give' ),
417
+						'title' => __('Donation Goal', 'give'),
418 418
 					),
419 419
 				),
420 420
 					$post_id
421 421
 				),
422
-			) ),
422
+			)),
423 423
 
424 424
 			/**
425 425
 			 * Content Field
426 426
 			 */
427
-			'form_content_options'  => apply_filters( 'give_forms_content_options', array(
427
+			'form_content_options'  => apply_filters('give_forms_content_options', array(
428 428
 				'id'        => 'form_content_options',
429
-				'title'     => __( 'Form Content', 'give' ),
429
+				'title'     => __('Form Content', 'give'),
430 430
 				'icon-html' => '<span class="give-icon give-icon-edit"></span>',
431
-				'fields'    => apply_filters( 'give_forms_content_options_metabox_fields', array(
431
+				'fields'    => apply_filters('give_forms_content_options_metabox_fields', array(
432 432
 
433 433
 					// Donation content.
434 434
 					array(
435
-						'name'        => __( 'Display Content', 'give' ),
436
-						'description' => __( 'Do you want to add custom content to this form?', 'give' ),
437
-						'id'          => $prefix . 'display_content',
435
+						'name'        => __('Display Content', 'give'),
436
+						'description' => __('Do you want to add custom content to this form?', 'give'),
437
+						'id'          => $prefix.'display_content',
438 438
 						'type'        => 'radio_inline',
439 439
 						'options'     => array(
440
-							'enabled'  => __( 'Enabled', 'give' ),
441
-							'disabled' => __( 'Disabled', 'give' ),
440
+							'enabled'  => __('Enabled', 'give'),
441
+							'disabled' => __('Disabled', 'give'),
442 442
 						),
443 443
 						'default'     => 'disabled',
444 444
 					),
445 445
 
446 446
 					// Content placement.
447 447
 					array(
448
-						'name'          => __( 'Content Placement', 'give' ),
449
-						'description'   => __( 'This option controls where the content appears within the donation form.', 'give' ),
450
-						'id'            => $prefix . 'content_placement',
448
+						'name'          => __('Content Placement', 'give'),
449
+						'description'   => __('This option controls where the content appears within the donation form.', 'give'),
450
+						'id'            => $prefix.'content_placement',
451 451
 						'type'          => 'radio_inline',
452
-						'options'       => apply_filters( 'give_forms_content_options_select', array(
453
-								'give_pre_form'  => __( 'Above fields', 'give' ),
454
-								'give_post_form' => __( 'Below fields', 'give' ),
452
+						'options'       => apply_filters('give_forms_content_options_select', array(
453
+								'give_pre_form'  => __('Above fields', 'give'),
454
+								'give_post_form' => __('Below fields', 'give'),
455 455
 							)
456 456
 						),
457 457
 						'default'       => 'give_pre_form',
458 458
 						'wrapper_class' => 'give-hidden',
459 459
 					),
460 460
 					array(
461
-						'name'          => __( 'Content', 'give' ),
462
-						'description'   => __( 'This content will display on the single give form page.', 'give' ),
463
-						'id'            => $prefix . 'form_content',
461
+						'name'          => __('Content', 'give'),
462
+						'description'   => __('This content will display on the single give form page.', 'give'),
463
+						'id'            => $prefix.'form_content',
464 464
 						'type'          => 'wysiwyg',
465 465
 						'wrapper_class' => 'give-hidden',
466 466
 					),
@@ -468,51 +468,51 @@  discard block
 block discarded – undo
468 468
 						'name'  => 'form_content_docs',
469 469
 						'type'  => 'docs_link',
470 470
 						'url'   => 'http://docs.givewp.com/form-content',
471
-						'title' => __( 'Form Content', 'give' ),
471
+						'title' => __('Form Content', 'give'),
472 472
 					),
473 473
 				),
474 474
 					$post_id
475 475
 				),
476
-			) ),
476
+			)),
477 477
 
478 478
 			/**
479 479
 			 * Terms & Conditions
480 480
 			 */
481
-			'form_terms_options'    => apply_filters( 'give_forms_terms_options', array(
481
+			'form_terms_options'    => apply_filters('give_forms_terms_options', array(
482 482
 				'id'        => 'form_terms_options',
483
-				'title'     => __( 'Terms & Conditions', 'give' ),
483
+				'title'     => __('Terms & Conditions', 'give'),
484 484
 				'icon-html' => '<span class="give-icon give-icon-checklist"></span>',
485
-				'fields'    => apply_filters( 'give_forms_terms_options_metabox_fields', array(
485
+				'fields'    => apply_filters('give_forms_terms_options_metabox_fields', array(
486 486
 					// Donation Option
487 487
 					array(
488
-						'name'        => __( 'Terms and Conditions', 'give' ),
489
-						'description' => __( 'Do you want to require the donor to accept terms prior to being able to complete their donation?', 'give' ),
490
-						'id'          => $prefix . 'terms_option',
488
+						'name'        => __('Terms and Conditions', 'give'),
489
+						'description' => __('Do you want to require the donor to accept terms prior to being able to complete their donation?', 'give'),
490
+						'id'          => $prefix.'terms_option',
491 491
 						'type'        => 'radio_inline',
492
-						'options'     => apply_filters( 'give_forms_content_options_select', array(
493
-								'global'   => __( 'Global Option', 'give' ),
494
-								'enabled'  => __( 'Customize', 'give' ),
495
-								'disabled' => __( 'Disable', 'give' ),
492
+						'options'     => apply_filters('give_forms_content_options_select', array(
493
+								'global'   => __('Global Option', 'give'),
494
+								'enabled'  => __('Customize', 'give'),
495
+								'disabled' => __('Disable', 'give'),
496 496
 							)
497 497
 						),
498 498
 						'default'     => 'global',
499 499
 					),
500 500
 					array(
501
-						'id'            => $prefix . 'agree_label',
502
-						'name'          => __( 'Agreement Label', 'give' ),
503
-						'desc'          => __( 'The label shown next to the agree to terms check box. Add your own to customize or leave blank to use the default text placeholder.', 'give' ),
501
+						'id'            => $prefix.'agree_label',
502
+						'name'          => __('Agreement Label', 'give'),
503
+						'desc'          => __('The label shown next to the agree to terms check box. Add your own to customize or leave blank to use the default text placeholder.', 'give'),
504 504
 						'type'          => 'text',
505 505
 						'size'          => 'regular',
506 506
 						'attributes'    => array(
507
-							'placeholder' => __( 'Agree to Terms?', 'give' ),
507
+							'placeholder' => __('Agree to Terms?', 'give'),
508 508
 						),
509 509
 						'wrapper_class' => 'give-hidden',
510 510
 					),
511 511
 					array(
512
-						'id'            => $prefix . 'agree_text',
513
-						'name'          => __( 'Agreement Text', 'give' ),
514
-						'desc'          => __( 'This is the actual text which the user will have to agree to in order to make a donation.', 'give' ),
515
-						'default'       => give_get_option( 'agreement_text' ),
512
+						'id'            => $prefix.'agree_text',
513
+						'name'          => __('Agreement Text', 'give'),
514
+						'desc'          => __('This is the actual text which the user will have to agree to in order to make a donation.', 'give'),
515
+						'default'       => give_get_option('agreement_text'),
516 516
 						'type'          => 'wysiwyg',
517 517
 						'wrapper_class' => 'give-hidden',
518 518
 					),
@@ -520,18 +520,18 @@  discard block
 block discarded – undo
520 520
 						'name'  => 'terms_docs',
521 521
 						'type'  => 'docs_link',
522 522
 						'url'   => 'http://docs.givewp.com/form-terms',
523
-						'title' => __( 'Terms and Conditions', 'give' ),
523
+						'title' => __('Terms and Conditions', 'give'),
524 524
 					),
525 525
 				),
526 526
 					$post_id
527 527
 				),
528
-			) ),
528
+			)),
529 529
 		);
530 530
 
531 531
 		/**
532 532
 		 * Filter the metabox tabbed panel settings.
533 533
 		 */
534
-		$settings = apply_filters( 'give_metabox_form_data_settings', $settings, $post_id );
534
+		$settings = apply_filters('give_metabox_form_data_settings', $settings, $post_id);
535 535
 
536 536
 		// Output.
537 537
 		return $settings;
@@ -548,8 +548,8 @@  discard block
 block discarded – undo
548 548
 		add_meta_box(
549 549
 			$this->get_metabox_ID(),
550 550
 			$this->get_metabox_label(),
551
-			array( $this, 'output' ),
552
-			array( 'give_forms' ),
551
+			array($this, 'output'),
552
+			array('give_forms'),
553 553
 			'normal',
554 554
 			'high'
555 555
 		);
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
 	function enqueue_script() {
567 567
 		global $post;
568 568
 
569
-		if ( is_object( $post ) && 'give_forms' === $post->post_type ) {
569
+		if (is_object($post) && 'give_forms' === $post->post_type) {
570 570
 
571 571
 		}
572 572
 	}
@@ -604,32 +604,32 @@  discard block
 block discarded – undo
604 604
 	public function get_tabs() {
605 605
 		$tabs = array();
606 606
 
607
-		if ( ! empty( $this->settings ) ) {
608
-			foreach ( $this->settings as $setting ) {
609
-				if ( ! isset( $setting['id'] ) || ! isset( $setting['title'] ) ) {
607
+		if ( ! empty($this->settings)) {
608
+			foreach ($this->settings as $setting) {
609
+				if ( ! isset($setting['id']) || ! isset($setting['title'])) {
610 610
 					continue;
611 611
 				}
612 612
 				$tab = array(
613 613
 					'id'        => $setting['id'],
614 614
 					'label'     => $setting['title'],
615
-					'icon-html' => ( ! empty( $setting['icon-html'] ) ? $setting['icon-html'] : '' ),
615
+					'icon-html' => ( ! empty($setting['icon-html']) ? $setting['icon-html'] : ''),
616 616
 				);
617 617
 
618
-				if ( $this->has_sub_tab( $setting ) ) {
619
-					if ( empty( $setting['sub-fields'] ) ) {
618
+				if ($this->has_sub_tab($setting)) {
619
+					if (empty($setting['sub-fields'])) {
620 620
 						$tab = array();
621 621
 					} else {
622
-						foreach ( $setting['sub-fields'] as $sub_fields ) {
622
+						foreach ($setting['sub-fields'] as $sub_fields) {
623 623
 							$tab['sub-fields'][] = array(
624 624
 								'id'        => $sub_fields['id'],
625 625
 								'label'     => $sub_fields['title'],
626
-								'icon-html' => ( ! empty( $sub_fields['icon-html'] ) ? $sub_fields['icon-html'] : '' ),
626
+								'icon-html' => ( ! empty($sub_fields['icon-html']) ? $sub_fields['icon-html'] : ''),
627 627
 							);
628 628
 						}
629 629
 					}
630 630
 				}
631 631
 
632
-				if ( ! empty( $tab ) ) {
632
+				if ( ! empty($tab)) {
633 633
 					$tabs[] = $tab;
634 634
 				}
635 635
 			}
@@ -647,33 +647,33 @@  discard block
 block discarded – undo
647 647
 	 */
648 648
 	public function output() {
649 649
 		// Bailout.
650
-		if ( $form_data_tabs = $this->get_tabs() ) :
651
-			$active_tab = ! empty( $_GET['give_tab'] ) ? give_clean( $_GET['give_tab'] ) : 'form_field_options';
652
-			wp_nonce_field( 'give_save_form_meta', 'give_form_meta_nonce' );
650
+		if ($form_data_tabs = $this->get_tabs()) :
651
+			$active_tab = ! empty($_GET['give_tab']) ? give_clean($_GET['give_tab']) : 'form_field_options';
652
+			wp_nonce_field('give_save_form_meta', 'give_form_meta_nonce');
653 653
 			?>
654 654
 			<input id="give_form_active_tab" type="hidden" name="give_form_active_tab">
655 655
 			<div class="give-metabox-panel-wrap">
656 656
 				<ul class="give-form-data-tabs give-metabox-tabs">
657
-					<?php foreach ( $form_data_tabs as $index => $form_data_tab ) : ?>
657
+					<?php foreach ($form_data_tabs as $index => $form_data_tab) : ?>
658 658
 						<?php
659 659
 						// Determine if current tab is active.
660 660
 						$is_active = $active_tab === $form_data_tab['id'] ? true : false;
661 661
 						?>
662
-						<li class="<?php echo "{$form_data_tab['id']}_tab" . ( $is_active ? ' active' : '' ) . ( $this->has_sub_tab( $form_data_tab ) ? ' has-sub-fields' : '' ); ?>">
662
+						<li class="<?php echo "{$form_data_tab['id']}_tab".($is_active ? ' active' : '').($this->has_sub_tab($form_data_tab) ? ' has-sub-fields' : ''); ?>">
663 663
 							<a href="#<?php echo $form_data_tab['id']; ?>" data-tab-id="<?php echo $form_data_tab['id']; ?>">
664
-								<?php if ( ! empty( $form_data_tab['icon-html'] ) ) : ?>
664
+								<?php if ( ! empty($form_data_tab['icon-html'])) : ?>
665 665
 									<?php echo $form_data_tab['icon-html']; ?>
666 666
 								<?php else : ?>
667 667
 									<span class="give-icon give-icon-default"></span>
668 668
 								<?php endif; ?>
669 669
 								<span class="give-label"><?php echo $form_data_tab['label']; ?></span>
670 670
 							</a>
671
-							<?php if ( $this->has_sub_tab( $form_data_tab ) ) : ?>
671
+							<?php if ($this->has_sub_tab($form_data_tab)) : ?>
672 672
 								<ul class="give-metabox-sub-tabs give-hidden">
673
-									<?php foreach ( $form_data_tab['sub-fields'] as $sub_tab ) : ?>
673
+									<?php foreach ($form_data_tab['sub-fields'] as $sub_tab) : ?>
674 674
 										<li class="<?php echo "{$sub_tab['id']}_tab"; ?>">
675 675
 											<a href="#<?php echo $sub_tab['id']; ?>" data-tab-id="<?php echo $sub_tab['id']; ?>">
676
-												<?php if ( ! empty( $sub_tab['icon-html'] ) ) : ?>
676
+												<?php if ( ! empty($sub_tab['icon-html'])) : ?>
677 677
 													<?php echo $sub_tab['icon-html']; ?>
678 678
 												<?php else : ?>
679 679
 													<span class="give-icon give-icon-default"></span>
@@ -688,29 +688,29 @@  discard block
 block discarded – undo
688 688
 					<?php endforeach; ?>
689 689
 				</ul>
690 690
 
691
-				<?php foreach ( $this->settings as $setting ) : ?>
692
-					<?php do_action( "give_before_{$setting['id']}_settings" ); ?>
691
+				<?php foreach ($this->settings as $setting) : ?>
692
+					<?php do_action("give_before_{$setting['id']}_settings"); ?>
693 693
 					<?php
694 694
 					// Determine if current panel is active.
695 695
 					$is_active = $active_tab === $setting['id'] ? true : false;
696 696
 					?>
697
-					<div id="<?php echo $setting['id']; ?>" class="panel give_options_panel<?php echo( $is_active ? ' active' : '' ); ?>">
698
-						<?php if ( ! empty( $setting['fields'] ) ) : ?>
699
-							<?php foreach ( $setting['fields'] as $field ) : ?>
700
-								<?php give_render_field( $field ); ?>
697
+					<div id="<?php echo $setting['id']; ?>" class="panel give_options_panel<?php echo($is_active ? ' active' : ''); ?>">
698
+						<?php if ( ! empty($setting['fields'])) : ?>
699
+							<?php foreach ($setting['fields'] as $field) : ?>
700
+								<?php give_render_field($field); ?>
701 701
 							<?php endforeach; ?>
702 702
 						<?php endif; ?>
703 703
 					</div>
704
-					<?php do_action( "give_after_{$setting['id']}_settings" ); ?>
704
+					<?php do_action("give_after_{$setting['id']}_settings"); ?>
705 705
 
706 706
 
707
-					<?php if ( $this->has_sub_tab( $setting ) ) : ?>
708
-						<?php if ( ! empty( $setting['sub-fields'] ) ) : ?>
709
-							<?php foreach ( $setting['sub-fields'] as $index => $sub_fields ) : ?>
707
+					<?php if ($this->has_sub_tab($setting)) : ?>
708
+						<?php if ( ! empty($setting['sub-fields'])) : ?>
709
+							<?php foreach ($setting['sub-fields'] as $index => $sub_fields) : ?>
710 710
 								<div id="<?php echo $sub_fields['id']; ?>" class="panel give_options_panel give-hidden">
711
-									<?php if ( ! empty( $sub_fields['fields'] ) ) : ?>
712
-										<?php foreach ( $sub_fields['fields'] as $sub_field ) : ?>
713
-											<?php give_render_field( $sub_field ); ?>
711
+									<?php if ( ! empty($sub_fields['fields'])) : ?>
712
+										<?php foreach ($sub_fields['fields'] as $sub_field) : ?>
713
+											<?php give_render_field($sub_field); ?>
714 714
 										<?php endforeach; ?>
715 715
 									<?php endif; ?>
716 716
 								</div>
@@ -733,9 +733,9 @@  discard block
 block discarded – undo
733 733
 	 *
734 734
 	 * @return bool
735 735
 	 */
736
-	private function has_sub_tab( $field_setting ) {
736
+	private function has_sub_tab($field_setting) {
737 737
 		$has_sub_tab = false;
738
-		if ( array_key_exists( 'sub-fields', $field_setting ) ) {
738
+		if (array_key_exists('sub-fields', $field_setting)) {
739 739
 			$has_sub_tab = true;
740 740
 		}
741 741
 
@@ -750,13 +750,13 @@  discard block
 block discarded – undo
750 750
 	 * @return array
751 751
 	 */
752 752
 	function cmb2_metabox_settings() {
753
-		$all_cmb2_settings   = apply_filters( 'cmb2_meta_boxes', array() );
753
+		$all_cmb2_settings   = apply_filters('cmb2_meta_boxes', array());
754 754
 		$give_forms_settings = $all_cmb2_settings;
755 755
 
756 756
 		// Filter settings: Use only give forms related settings.
757
-		foreach ( $all_cmb2_settings as $index => $setting ) {
758
-			if ( ! in_array( 'give_forms', $setting['object_types'] ) ) {
759
-				unset( $give_forms_settings[ $index ] );
757
+		foreach ($all_cmb2_settings as $index => $setting) {
758
+			if ( ! in_array('give_forms', $setting['object_types'])) {
759
+				unset($give_forms_settings[$index]);
760 760
 			}
761 761
 		}
762 762
 
@@ -774,96 +774,96 @@  discard block
 block discarded – undo
774 774
 	 *
775 775
 	 * @return void
776 776
 	 */
777
-	public function save( $post_id, $post ) {
777
+	public function save($post_id, $post) {
778 778
 
779 779
 		// $post_id and $post are required.
780
-		if ( empty( $post_id ) || empty( $post ) ) {
780
+		if (empty($post_id) || empty($post)) {
781 781
 			return;
782 782
 		}
783 783
 
784 784
 		// Don't save meta boxes for revisions or autosaves.
785
-		if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
785
+		if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) {
786 786
 			return;
787 787
 		}
788 788
 
789 789
 		// Check the nonce.
790
-		if ( empty( $_POST['give_form_meta_nonce'] ) || ! wp_verify_nonce( $_POST['give_form_meta_nonce'], 'give_save_form_meta' ) ) {
790
+		if (empty($_POST['give_form_meta_nonce']) || ! wp_verify_nonce($_POST['give_form_meta_nonce'], 'give_save_form_meta')) {
791 791
 			return;
792 792
 		}
793 793
 
794 794
 		// Check the post being saved == the $post_id to prevent triggering this call for other save_post events.
795
-		if ( empty( $_POST['post_ID'] ) || $_POST['post_ID'] != $post_id ) {
795
+		if (empty($_POST['post_ID']) || $_POST['post_ID'] != $post_id) {
796 796
 			return;
797 797
 		}
798 798
 
799 799
 		// Check user has permission to edit.
800
-		if ( ! current_user_can( 'edit_post', $post_id ) ) {
800
+		if ( ! current_user_can('edit_post', $post_id)) {
801 801
 			return;
802 802
 		}
803 803
 
804 804
 		// Fire action before saving form meta.
805
-		do_action( 'give_pre_process_give_forms_meta', $post_id, $post );
805
+		do_action('give_pre_process_give_forms_meta', $post_id, $post);
806 806
 
807 807
 		/**
808 808
 		 * Filter the meta key to save.
809 809
 		 * Third party addon developer can remove there meta keys from this array to handle saving data on there own.
810 810
 		 */
811
-		$form_meta_keys = apply_filters( 'give_process_form_meta_keys', $this->get_meta_keys_from_settings() );
811
+		$form_meta_keys = apply_filters('give_process_form_meta_keys', $this->get_meta_keys_from_settings());
812 812
 
813 813
 		// Save form meta data.
814
-		if ( ! empty( $form_meta_keys ) ) {
815
-			foreach ( $form_meta_keys as $form_meta_key ) {
814
+		if ( ! empty($form_meta_keys)) {
815
+			foreach ($form_meta_keys as $form_meta_key) {
816 816
 
817 817
 				// Set default value for checkbox fields.
818 818
 				if (
819
-					! isset( $_POST[ $form_meta_key ] )
820
-					&& ( 'checkbox' === $this->get_field_type( $form_meta_key ) )
819
+					! isset($_POST[$form_meta_key])
820
+					&& ('checkbox' === $this->get_field_type($form_meta_key))
821 821
 				) {
822
-					$_POST[ $form_meta_key ] = '';
822
+					$_POST[$form_meta_key] = '';
823 823
 				}
824 824
 
825
-				if ( isset( $_POST[ $form_meta_key ] ) ) {
826
-					$setting_field = $this->get_setting_field( $form_meta_key );
827
-					if ( ! empty( $setting_field['type'] ) ) {
828
-						switch ( $setting_field['type'] ) {
825
+				if (isset($_POST[$form_meta_key])) {
826
+					$setting_field = $this->get_setting_field($form_meta_key);
827
+					if ( ! empty($setting_field['type'])) {
828
+						switch ($setting_field['type']) {
829 829
 							case 'textarea':
830 830
 							case 'wysiwyg':
831
-								$form_meta_value = wp_kses_post( $_POST[ $form_meta_key ] );
831
+								$form_meta_value = wp_kses_post($_POST[$form_meta_key]);
832 832
 								break;
833 833
 
834 834
 							case 'group':
835 835
 								$form_meta_value = array();
836 836
 
837
-								foreach ( $_POST[ $form_meta_key ] as $index => $group ) {
837
+								foreach ($_POST[$form_meta_key] as $index => $group) {
838 838
 
839 839
 									// Do not save template input field values.
840
-									if ( '{{row-count-placeholder}}' === $index ) {
840
+									if ('{{row-count-placeholder}}' === $index) {
841 841
 										continue;
842 842
 									}
843 843
 
844 844
 									$group_meta_value = array();
845
-									foreach ( $group as $field_id => $field_value ) {
846
-										switch ( $this->get_field_type( $field_id, $form_meta_key ) ) {
845
+									foreach ($group as $field_id => $field_value) {
846
+										switch ($this->get_field_type($field_id, $form_meta_key)) {
847 847
 											case 'wysiwyg':
848
-												$group_meta_value[ $field_id ] = wp_kses_post( $field_value );
848
+												$group_meta_value[$field_id] = wp_kses_post($field_value);
849 849
 												break;
850 850
 
851 851
 											default:
852
-												$group_meta_value[ $field_id ] = give_clean( $field_value );
852
+												$group_meta_value[$field_id] = give_clean($field_value);
853 853
 										}
854 854
 									}
855 855
 
856
-									if ( ! empty( $group_meta_value ) ) {
857
-										$form_meta_value[ $index ] = $group_meta_value;
856
+									if ( ! empty($group_meta_value)) {
857
+										$form_meta_value[$index] = $group_meta_value;
858 858
 									}
859 859
 								}
860 860
 
861 861
 								// Arrange repeater field keys in order.
862
-								$form_meta_value = array_values( $form_meta_value );
862
+								$form_meta_value = array_values($form_meta_value);
863 863
 								break;
864 864
 
865 865
 							default:
866
-								$form_meta_value = give_clean( $_POST[ $form_meta_key ] );
866
+								$form_meta_value = give_clean($_POST[$form_meta_key]);
867 867
 						}// End switch().
868 868
 
869 869
 						/**
@@ -873,24 +873,24 @@  discard block
 block discarded – undo
873 873
 						 */
874 874
 						$form_meta_value = apply_filters(
875 875
 							'give_pre_save_form_meta_value',
876
-							$this->sanitize_form_meta( $form_meta_value, $setting_field ),
876
+							$this->sanitize_form_meta($form_meta_value, $setting_field),
877 877
 							$form_meta_key,
878 878
 							$this,
879 879
 							$post_id
880 880
 						);
881 881
 
882 882
 						// Save data.
883
-						give_update_meta( $post_id, $form_meta_key, $form_meta_value );
883
+						give_update_meta($post_id, $form_meta_key, $form_meta_value);
884 884
 
885 885
 						// Fire after saving form meta key.
886
-						do_action( "give_save_{$form_meta_key}", $form_meta_key, $form_meta_value, $post_id, $post );
886
+						do_action("give_save_{$form_meta_key}", $form_meta_key, $form_meta_value, $post_id, $post);
887 887
 					}// End if().
888 888
 				}// End if().
889 889
 			}// End foreach().
890 890
 		}// End if().
891 891
 
892 892
 		// Fire action after saving form meta.
893
-		do_action( 'give_post_process_give_forms_meta', $post_id, $post );
893
+		do_action('give_post_process_give_forms_meta', $post_id, $post);
894 894
 	}
895 895
 
896 896
 
@@ -903,10 +903,10 @@  discard block
 block discarded – undo
903 903
 	 *
904 904
 	 * @return string
905 905
 	 */
906
-	private function get_field_id( $field ) {
906
+	private function get_field_id($field) {
907 907
 		$field_id = '';
908 908
 
909
-		if ( array_key_exists( 'id', $field ) ) {
909
+		if (array_key_exists('id', $field)) {
910 910
 			$field_id = $field['id'];
911 911
 
912 912
 		}
@@ -923,12 +923,12 @@  discard block
 block discarded – undo
923 923
 	 *
924 924
 	 * @return array
925 925
 	 */
926
-	private function get_fields_id( $setting ) {
926
+	private function get_fields_id($setting) {
927 927
 		$meta_keys = array();
928 928
 
929
-		if ( ! empty( $setting ) ) {
930
-			foreach ( $setting['fields'] as $field ) {
931
-				if ( $field_id = $this->get_field_id( $field ) ) {
929
+		if ( ! empty($setting)) {
930
+			foreach ($setting['fields'] as $field) {
931
+				if ($field_id = $this->get_field_id($field)) {
932 932
 					$meta_keys[] = $field_id;
933 933
 				}
934 934
 			}
@@ -946,14 +946,14 @@  discard block
 block discarded – undo
946 946
 	 *
947 947
 	 * @return array
948 948
 	 */
949
-	private function get_sub_fields_id( $setting ) {
949
+	private function get_sub_fields_id($setting) {
950 950
 		$meta_keys = array();
951 951
 
952
-		if ( $this->has_sub_tab( $setting ) && ! empty( $setting['sub-fields'] ) ) {
953
-			foreach ( $setting['sub-fields'] as $fields ) {
954
-				if ( ! empty( $fields['fields'] ) ) {
955
-					foreach ( $fields['fields'] as $field ) {
956
-						if ( $field_id = $this->get_field_id( $field ) ) {
952
+		if ($this->has_sub_tab($setting) && ! empty($setting['sub-fields'])) {
953
+			foreach ($setting['sub-fields'] as $fields) {
954
+				if ( ! empty($fields['fields'])) {
955
+					foreach ($fields['fields'] as $field) {
956
+						if ($field_id = $this->get_field_id($field)) {
957 957
 							$meta_keys[] = $field_id;
958 958
 						}
959 959
 					}
@@ -975,14 +975,14 @@  discard block
 block discarded – undo
975 975
 	private function get_meta_keys_from_settings() {
976 976
 		$meta_keys = array();
977 977
 
978
-		foreach ( $this->settings as $setting ) {
979
-			$meta_key = $this->get_fields_id( $setting );
978
+		foreach ($this->settings as $setting) {
979
+			$meta_key = $this->get_fields_id($setting);
980 980
 
981
-			if ( $this->has_sub_tab( $setting ) ) {
982
-				$meta_key = array_merge( $meta_key, $this->get_sub_fields_id( $setting ) );
981
+			if ($this->has_sub_tab($setting)) {
982
+				$meta_key = array_merge($meta_key, $this->get_sub_fields_id($setting));
983 983
 			}
984 984
 
985
-			$meta_keys = array_merge( $meta_keys, $meta_key );
985
+			$meta_keys = array_merge($meta_keys, $meta_key);
986 986
 		}
987 987
 
988 988
 		return $meta_keys;
@@ -999,10 +999,10 @@  discard block
 block discarded – undo
999 999
 	 *
1000 1000
 	 * @return string
1001 1001
 	 */
1002
-	function get_field_type( $field_id, $group_id = '' ) {
1003
-		$field = $this->get_setting_field( $field_id, $group_id );
1002
+	function get_field_type($field_id, $group_id = '') {
1003
+		$field = $this->get_setting_field($field_id, $group_id);
1004 1004
 
1005
-		$type = array_key_exists( 'type', $field )
1005
+		$type = array_key_exists('type', $field)
1006 1006
 			? $field['type']
1007 1007
 			: '';
1008 1008
 
@@ -1020,12 +1020,12 @@  discard block
 block discarded – undo
1020 1020
 	 *
1021 1021
 	 * @return array
1022 1022
 	 */
1023
-	private function get_field( $setting, $field_id ) {
1023
+	private function get_field($setting, $field_id) {
1024 1024
 		$setting_field = array();
1025 1025
 
1026
-		if ( ! empty( $setting['fields'] ) ) {
1027
-			foreach ( $setting['fields'] as $field ) {
1028
-				if ( array_key_exists( 'id', $field ) && $field['id'] === $field_id ) {
1026
+		if ( ! empty($setting['fields'])) {
1027
+			foreach ($setting['fields'] as $field) {
1028
+				if (array_key_exists('id', $field) && $field['id'] === $field_id) {
1029 1029
 					$setting_field = $field;
1030 1030
 					break;
1031 1031
 				}
@@ -1045,12 +1045,12 @@  discard block
 block discarded – undo
1045 1045
 	 *
1046 1046
 	 * @return array
1047 1047
 	 */
1048
-	private function get_sub_field( $setting, $field_id ) {
1048
+	private function get_sub_field($setting, $field_id) {
1049 1049
 		$setting_field = array();
1050 1050
 
1051
-		if ( ! empty( $setting['sub-fields'] ) ) {
1052
-			foreach ( $setting['sub-fields'] as $fields ) {
1053
-				if ( $field = $this->get_field( $fields, $field_id ) ) {
1051
+		if ( ! empty($setting['sub-fields'])) {
1052
+			foreach ($setting['sub-fields'] as $fields) {
1053
+				if ($field = $this->get_field($fields, $field_id)) {
1054 1054
 					$setting_field = $field;
1055 1055
 					break;
1056 1056
 				}
@@ -1070,17 +1070,17 @@  discard block
 block discarded – undo
1070 1070
 	 *
1071 1071
 	 * @return array
1072 1072
 	 */
1073
-	function get_setting_field( $field_id, $group_id = '' ) {
1073
+	function get_setting_field($field_id, $group_id = '') {
1074 1074
 		$setting_field = array();
1075 1075
 
1076 1076
 		$_field_id = $field_id;
1077
-		$field_id  = empty( $group_id ) ? $field_id : $group_id;
1077
+		$field_id  = empty($group_id) ? $field_id : $group_id;
1078 1078
 
1079
-		if ( ! empty( $this->settings ) ) {
1080
-			foreach ( $this->settings as $setting ) {
1079
+		if ( ! empty($this->settings)) {
1080
+			foreach ($this->settings as $setting) {
1081 1081
 				if (
1082
-					( $this->has_sub_tab( $setting ) && ( $setting_field = $this->get_sub_field( $setting, $field_id ) ) )
1083
-					|| ( $setting_field = $this->get_field( $setting, $field_id ) )
1082
+					($this->has_sub_tab($setting) && ($setting_field = $this->get_sub_field($setting, $field_id)))
1083
+					|| ($setting_field = $this->get_field($setting, $field_id))
1084 1084
 				) {
1085 1085
 					break;
1086 1086
 				}
@@ -1088,9 +1088,9 @@  discard block
 block discarded – undo
1088 1088
 		}
1089 1089
 
1090 1090
 		// Get field from group.
1091
-		if ( ! empty( $group_id ) ) {
1092
-			foreach ( $setting_field['fields'] as $field ) {
1093
-				if ( array_key_exists( 'id', $field ) && $field['id'] === $_field_id ) {
1091
+		if ( ! empty($group_id)) {
1092
+			foreach ($setting_field['fields'] as $field) {
1093
+				if (array_key_exists('id', $field) && $field['id'] === $_field_id) {
1094 1094
 					$setting_field = $field;
1095 1095
 				}
1096 1096
 			}
@@ -1109,14 +1109,14 @@  discard block
 block discarded – undo
1109 1109
 	 *
1110 1110
 	 * @return mixed
1111 1111
 	 */
1112
-	function add_offline_donations_setting_tab( $settings ) {
1113
-		if ( give_is_gateway_active( 'offline' ) ) {
1114
-			$settings['offline_donations_options'] = apply_filters( 'give_forms_offline_donations_options', array(
1112
+	function add_offline_donations_setting_tab($settings) {
1113
+		if (give_is_gateway_active('offline')) {
1114
+			$settings['offline_donations_options'] = apply_filters('give_forms_offline_donations_options', array(
1115 1115
 				'id'        => 'offline_donations_options',
1116
-				'title'     => __( 'Offline Donations', 'give' ),
1116
+				'title'     => __('Offline Donations', 'give'),
1117 1117
 				'icon-html' => '<span class="give-icon give-icon-purse"></span>',
1118
-				'fields'    => apply_filters( 'give_forms_offline_donations_metabox_fields', array() ),
1119
-			) );
1118
+				'fields'    => apply_filters('give_forms_offline_donations_metabox_fields', array()),
1119
+			));
1120 1120
 		}
1121 1121
 
1122 1122
 		return $settings;
@@ -1134,37 +1134,33 @@  discard block
 block discarded – undo
1134 1134
 	 *
1135 1135
 	 * @return mixed
1136 1136
 	 */
1137
-	function sanitize_form_meta( $meta_value, $setting_field ) {
1138
-		switch ( $setting_field['type'] ) {
1137
+	function sanitize_form_meta($meta_value, $setting_field) {
1138
+		switch ($setting_field['type']) {
1139 1139
 			case 'group':
1140
-				if ( ! empty( $setting_field['fields'] ) ) {
1141
-					foreach ( $setting_field['fields'] as $field ) {
1142
-						if ( empty( $field['data_type'] ) || 'price' !== $field['data_type'] ) {
1140
+				if ( ! empty($setting_field['fields'])) {
1141
+					foreach ($setting_field['fields'] as $field) {
1142
+						if (empty($field['data_type']) || 'price' !== $field['data_type']) {
1143 1143
 							continue;
1144 1144
 						}
1145 1145
 
1146
-						foreach ( $meta_value as $index => $meta_data ) {
1147
-							if ( ! isset( $meta_value[ $index ][ $field['id'] ] ) ) {
1146
+						foreach ($meta_value as $index => $meta_data) {
1147
+							if ( ! isset($meta_value[$index][$field['id']])) {
1148 1148
 								continue;
1149 1149
 							}
1150 1150
 
1151
-							$meta_value[ $index ][ $field['id'] ] = ! empty( $meta_value[ $index ][ $field['id'] ] ) ?
1152
-								give_sanitize_amount_for_db( $meta_value[ $index ][ $field['id'] ] ) :
1153
-								( ( '_give_amount' === $field['id'] && empty( $field_value ) ) ?
1154
-									give_sanitize_amount_for_db( '1.00' ) :
1155
-									0 );
1151
+							$meta_value[$index][$field['id']] = ! empty($meta_value[$index][$field['id']]) ?
1152
+								give_sanitize_amount_for_db($meta_value[$index][$field['id']]) : (('_give_amount' === $field['id'] && empty($field_value)) ?
1153
+									give_sanitize_amount_for_db('1.00') : 0);
1156 1154
 						}
1157 1155
 					}
1158 1156
 				}
1159 1157
 				break;
1160 1158
 
1161 1159
 			default:
1162
-				if ( ! empty( $setting_field['data_type'] ) && 'price' === $setting_field['data_type'] ) {
1160
+				if ( ! empty($setting_field['data_type']) && 'price' === $setting_field['data_type']) {
1163 1161
 					$meta_value = $meta_value ?
1164
-						give_sanitize_amount_for_db( $meta_value ) :
1165
-						( in_array( $setting_field['id'], array( '_give_set_price', '_give_custom_amount_minimum', '_give_set_goal' ) ) ?
1166
-							give_sanitize_amount_for_db( '1.00' ) :
1167
-							0 );
1162
+						give_sanitize_amount_for_db($meta_value) : (in_array($setting_field['id'], array('_give_set_price', '_give_custom_amount_minimum', '_give_set_goal')) ?
1163
+							give_sanitize_amount_for_db('1.00') : 0);
1168 1164
 				}
1169 1165
 		}
1170 1166
 
@@ -1182,12 +1178,12 @@  discard block
 block discarded – undo
1182 1178
 	 *
1183 1179
 	 * @return string The URL after redirect.
1184 1180
 	 */
1185
-	public function maintain_active_tab( $location, $post_id ) {
1181
+	public function maintain_active_tab($location, $post_id) {
1186 1182
 		if (
1187
-			'give_forms' === get_post_type( $post_id ) &&
1188
-			! empty( $_POST['give_form_active_tab'] )
1183
+			'give_forms' === get_post_type($post_id) &&
1184
+			! empty($_POST['give_form_active_tab'])
1189 1185
 		) {
1190
-			$location = add_query_arg( 'give_tab', give_clean( $_POST['give_form_active_tab'] ), $location );
1186
+			$location = add_query_arg('give_tab', give_clean($_POST['give_form_active_tab']), $location);
1191 1187
 		}
1192 1188
 
1193 1189
 		return $location;
Please login to merge, or discard this patch.
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -663,9 +663,12 @@  discard block
 block discarded – undo
663 663
 							<a href="#<?php echo $form_data_tab['id']; ?>" data-tab-id="<?php echo $form_data_tab['id']; ?>">
664 664
 								<?php if ( ! empty( $form_data_tab['icon-html'] ) ) : ?>
665 665
 									<?php echo $form_data_tab['icon-html']; ?>
666
-								<?php else : ?>
666
+								<?php else {
667
+	: ?>
667 668
 									<span class="give-icon give-icon-default"></span>
668
-								<?php endif; ?>
669
+								<?php endif;
670
+}
671
+?>
669 672
 								<span class="give-label"><?php echo $form_data_tab['label']; ?></span>
670 673
 							</a>
671 674
 							<?php if ( $this->has_sub_tab( $form_data_tab ) ) : ?>
@@ -675,9 +678,12 @@  discard block
 block discarded – undo
675 678
 											<a href="#<?php echo $sub_tab['id']; ?>" data-tab-id="<?php echo $sub_tab['id']; ?>">
676 679
 												<?php if ( ! empty( $sub_tab['icon-html'] ) ) : ?>
677 680
 													<?php echo $sub_tab['icon-html']; ?>
678
-												<?php else : ?>
681
+												<?php else {
682
+	: ?>
679 683
 													<span class="give-icon give-icon-default"></span>
680
-												<?php endif; ?>
684
+												<?php endif;
685
+}
686
+?>
681 687
 												<span class="give-label"><?php echo $sub_tab['label']; ?></span>
682 688
 											</a>
683 689
 										</li>
Please login to merge, or discard this patch.
includes/admin/payments/view-payment-details.php 1 patch
Spacing   +143 added lines, -143 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
-if ( ! current_user_can( 'view_give_payments' ) ) {
17
+if ( ! current_user_can('view_give_payments')) {
18 18
 	wp_die(
19
-		__( 'Sorry, you are not allowed to access this page.', 'give' ), __( 'Error', 'give' ), array(
19
+		__('Sorry, you are not allowed to access this page.', 'give'), __('Error', 'give'), array(
20 20
 			'response' => 403,
21 21
 		)
22 22
 	);
@@ -28,27 +28,27 @@  discard block
 block discarded – undo
28 28
  * @since 1.0
29 29
  * @return void
30 30
  */
31
-if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
32
-	wp_die( __( 'Donation ID not supplied. Please try again.', 'give' ), __( 'Error', 'give' ), array( 'response' => 400 ) );
31
+if ( ! isset($_GET['id']) || ! is_numeric($_GET['id'])) {
32
+	wp_die(__('Donation ID not supplied. Please try again.', 'give'), __('Error', 'give'), array('response' => 400));
33 33
 }
34 34
 
35 35
 // Setup the variables
36
-$payment_id = absint( $_GET['id'] );
37
-$payment    = new Give_Payment( $payment_id );
36
+$payment_id = absint($_GET['id']);
37
+$payment    = new Give_Payment($payment_id);
38 38
 
39 39
 // Sanity check... fail if donation ID is invalid
40 40
 $payment_exists = $payment->ID;
41
-if ( empty( $payment_exists ) ) {
42
-	wp_die( __( 'The specified ID does not belong to a donation. Please try again.', 'give' ), __( 'Error', 'give' ), array( 'response' => 400 ) );
41
+if (empty($payment_exists)) {
42
+	wp_die(__('The specified ID does not belong to a donation. Please try again.', 'give'), __('Error', 'give'), array('response' => 400));
43 43
 }
44 44
 
45 45
 $number         = $payment->number;
46 46
 $payment_meta   = $payment->get_meta();
47
-$transaction_id = esc_attr( $payment->transaction_id );
47
+$transaction_id = esc_attr($payment->transaction_id);
48 48
 $user_id        = $payment->user_id;
49 49
 $donor_id       = $payment->customer_id;
50
-$payment_date   = strtotime( $payment->date );
51
-$user_info      = give_get_payment_meta_user_info( $payment_id );
50
+$payment_date   = strtotime($payment->date);
51
+$user_info      = give_get_payment_meta_user_info($payment_id);
52 52
 $address        = $payment->address;
53 53
 $currency_code  = $payment->currency;
54 54
 $gateway        = $payment->gateway;
@@ -61,13 +61,13 @@  discard block
 block discarded – undo
61 61
 	<?php
62 62
 		printf(
63 63
 			/* translators: %s: donation number */
64
-			esc_html__( 'Donation %s', 'give' ),
64
+			esc_html__('Donation %s', 'give'),
65 65
 			$number
66 66
 		);
67
-		if ( $payment_mode == 'test' ) {
67
+		if ($payment_mode == 'test') {
68 68
 			echo Give()->tooltips->render_span(array(
69
-				'label' => __( 'This donation was made in test mode.', 'give' ),
70
-				'tag_content' => __( 'Test Donation', 'give' ),
69
+				'label' => __('This donation was made in test mode.', 'give'),
70
+				'tag_content' => __('Test Donation', 'give'),
71 71
 				'position'=> 'right',
72 72
 				'attributes' => array(
73 73
 					'id' => 'test-payment-label',
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	 *
87 87
 	 * @param int $payment_id Payment id.
88 88
 	 */
89
-	do_action( 'give_view_order_details_before', $payment_id );
89
+	do_action('give_view_order_details_before', $payment_id);
90 90
 	?>
91 91
 
92 92
 	<hr class="wp-header-end">
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 		 *
101 101
 		 * @param int $payment_id Payment id.
102 102
 		 */
103
-		do_action( 'give_view_order_details_form_top', $payment_id );
103
+		do_action('give_view_order_details_form_top', $payment_id);
104 104
 		?>
105 105
 		<div id="poststuff">
106 106
 			<div id="give-dashboard-widgets-wrap">
@@ -116,12 +116,12 @@  discard block
 block discarded – undo
116 116
 							 *
117 117
 							 * @param int $payment_id Payment id.
118 118
 							 */
119
-							do_action( 'give_view_order_details_sidebar_before', $payment_id );
119
+							do_action('give_view_order_details_sidebar_before', $payment_id);
120 120
 							?>
121 121
 
122 122
 							<div id="give-order-update" class="postbox give-order-data">
123 123
 
124
-								<h3 class="hndle"><?php _e( 'Update Donation', 'give' ); ?></h3>
124
+								<h3 class="hndle"><?php _e('Update Donation', 'give'); ?></h3>
125 125
 
126 126
 								<div class="inside">
127 127
 									<div class="give-admin-box">
@@ -134,33 +134,33 @@  discard block
 block discarded – undo
134 134
 										 *
135 135
 										 * @param int $payment_id Payment id.
136 136
 										 */
137
-										do_action( 'give_view_order_details_totals_before', $payment_id );
137
+										do_action('give_view_order_details_totals_before', $payment_id);
138 138
 										?>
139 139
 
140 140
 										<div class="give-admin-box-inside">
141 141
 											<p>
142
-												<label for="give-payment-status" class="strong"><?php _e( 'Status:', 'give' ); ?></label>&nbsp;
142
+												<label for="give-payment-status" class="strong"><?php _e('Status:', 'give'); ?></label>&nbsp;
143 143
 												<select id="give-payment-status" name="give-payment-status" class="medium-text">
144
-													<?php foreach ( give_get_payment_statuses() as $key => $status ) : ?>
145
-														<option value="<?php echo esc_attr( $key ); ?>"<?php selected( $payment->status, $key, true ); ?>><?php echo esc_html( $status ); ?></option>
144
+													<?php foreach (give_get_payment_statuses() as $key => $status) : ?>
145
+														<option value="<?php echo esc_attr($key); ?>"<?php selected($payment->status, $key, true); ?>><?php echo esc_html($status); ?></option>
146 146
 													<?php endforeach; ?>
147 147
 												</select>
148
-												<span class="give-donation-status status-<?php echo sanitize_title( $payment->status ); ?>"><span class="give-donation-status-icon"></span></span>
148
+												<span class="give-donation-status status-<?php echo sanitize_title($payment->status); ?>"><span class="give-donation-status-icon"></span></span>
149 149
 											</p>
150 150
 										</div>
151 151
 
152 152
 										<div class="give-admin-box-inside">
153 153
 											<p>
154
-												<label for="give-payment-date" class="strong"><?php _e( 'Date:', 'give' ); ?></label>&nbsp;
155
-												<input type="text" id="give-payment-date" name="give-payment-date" value="<?php echo esc_attr( date( 'm/d/Y', $payment_date ) ); ?>" class="medium-text give_datepicker"/>
154
+												<label for="give-payment-date" class="strong"><?php _e('Date:', 'give'); ?></label>&nbsp;
155
+												<input type="text" id="give-payment-date" name="give-payment-date" value="<?php echo esc_attr(date('m/d/Y', $payment_date)); ?>" class="medium-text give_datepicker"/>
156 156
 											</p>
157 157
 										</div>
158 158
 
159 159
 										<div class="give-admin-box-inside">
160 160
 											<p>
161
-												<label for="give-payment-time-hour" class="strong"><?php _e( 'Time:', 'give' ); ?></label>&nbsp;
162
-												<input type="number" step="1" max="24" id="give-payment-time-hour" name="give-payment-time-hour" value="<?php echo esc_attr( date_i18n( 'H', $payment_date ) ); ?>" class="small-text give-payment-time-hour"/>&nbsp;:&nbsp;
163
-												<input type="number" step="1" max="59" id="give-payment-time-min" name="give-payment-time-min" value="<?php echo esc_attr( date( 'i', $payment_date ) ); ?>" class="small-text give-payment-time-min"/>
161
+												<label for="give-payment-time-hour" class="strong"><?php _e('Time:', 'give'); ?></label>&nbsp;
162
+												<input type="number" step="1" max="24" id="give-payment-time-hour" name="give-payment-time-hour" value="<?php echo esc_attr(date_i18n('H', $payment_date)); ?>" class="small-text give-payment-time-hour"/>&nbsp;:&nbsp;
163
+												<input type="number" step="1" max="59" id="give-payment-time-min" name="give-payment-time-min" value="<?php echo esc_attr(date('i', $payment_date)); ?>" class="small-text give-payment-time-min"/>
164 164
 											</p>
165 165
 										</div>
166 166
 
@@ -174,14 +174,14 @@  discard block
 block discarded – undo
174 174
 										 *
175 175
 										 * @param int $payment_id Payment id.
176 176
 										 */
177
-										do_action( 'give_view_order_details_update_inner', $payment_id );
177
+										do_action('give_view_order_details_update_inner', $payment_id);
178 178
 										?>
179 179
 
180 180
 										<div class="give-order-payment give-admin-box-inside">
181 181
 											<p>
182
-												<label for="give-payment-total" class="strong"><?php _e( 'Total Donation:', 'give' ); ?></label>&nbsp;
183
-												<?php echo give_currency_symbol( $payment->currency ); ?>
184
-												&nbsp;<input id="give-payment-total" name="give-payment-total" type="text" class="small-text give-price-field" value="<?php echo esc_attr( give_format_decimal( give_donation_amount( $payment_id ), false, false ) ); ?>"/>
182
+												<label for="give-payment-total" class="strong"><?php _e('Total Donation:', 'give'); ?></label>&nbsp;
183
+												<?php echo give_currency_symbol($payment->currency); ?>
184
+												&nbsp;<input id="give-payment-total" name="give-payment-total" type="text" class="small-text give-price-field" value="<?php echo esc_attr(give_format_decimal(give_donation_amount($payment_id), false, false)); ?>"/>
185 185
 											</p>
186 186
 										</div>
187 187
 
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 										 *
194 194
 										 * @param int $payment_id Payment id.
195 195
 										 */
196
-										do_action( 'give_view_order_details_totals_after', $payment_id );
196
+										do_action('give_view_order_details_totals_after', $payment_id);
197 197
 										?>
198 198
 
199 199
 									</div>
@@ -211,14 +211,14 @@  discard block
 block discarded – undo
211 211
 									 *
212 212
 									 * @param int $payment_id Payment id.
213 213
 									 */
214
-									do_action( 'give_view_order_details_update_before', $payment_id );
214
+									do_action('give_view_order_details_update_before', $payment_id);
215 215
 									?>
216 216
 
217 217
 									<div id="major-publishing-actions">
218 218
 										<div id="publishing-action">
219
-											<input type="submit" class="button button-primary right" value="<?php esc_attr_e( 'Save Donation', 'give' ); ?>"/>
219
+											<input type="submit" class="button button-primary right" value="<?php esc_attr_e('Save Donation', 'give'); ?>"/>
220 220
 											<?php
221
-											if ( give_is_payment_complete( $payment_id ) ) {
221
+											if (give_is_payment_complete($payment_id)) {
222 222
 												echo sprintf(
223 223
 													'<a href="%1$s" id="give-resend-receipt" class="button-secondary right">%2$s</a>',
224 224
 													esc_url(
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 															)
230 230
 														)
231 231
 													),
232
-													__( 'Resend Receipt', 'give' )
232
+													__('Resend Receipt', 'give')
233 233
 												);
234 234
 											}
235 235
 											?>
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 									 *
246 246
 									 * @param int $payment_id Payment id.
247 247
 									 */
248
-									do_action( 'give_view_order_details_update_after', $payment_id );
248
+									do_action('give_view_order_details_update_after', $payment_id);
249 249
 									?>
250 250
 
251 251
 								</div>
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 
257 257
 							<div id="give-order-details" class="postbox give-order-data">
258 258
 
259
-								<h3 class="hndle"><?php _e( 'Donation Meta', 'give' ); ?></h3>
259
+								<h3 class="hndle"><?php _e('Donation Meta', 'give'); ?></h3>
260 260
 
261 261
 								<div class="inside">
262 262
 									<div class="give-admin-box">
@@ -269,45 +269,45 @@  discard block
 block discarded – undo
269 269
 										 *
270 270
 										 * @param int $payment_id Payment id.
271 271
 										 */
272
-										do_action( 'give_view_order_details_payment_meta_before', $payment_id );
272
+										do_action('give_view_order_details_payment_meta_before', $payment_id);
273 273
 
274
-										$gateway = give_get_payment_gateway( $payment_id );
275
-										if ( $gateway ) :
274
+										$gateway = give_get_payment_gateway($payment_id);
275
+										if ($gateway) :
276 276
 										?>
277 277
 											<div class="give-order-gateway give-admin-box-inside">
278 278
 												<p>
279
-													<strong><?php _e( 'Gateway:', 'give' ); ?></strong>&nbsp;
280
-													<?php echo give_get_gateway_admin_label( $gateway ); ?>
279
+													<strong><?php _e('Gateway:', 'give'); ?></strong>&nbsp;
280
+													<?php echo give_get_gateway_admin_label($gateway); ?>
281 281
 												</p>
282 282
 											</div>
283 283
 										<?php endif; ?>
284 284
 
285 285
 										<div class="give-order-payment-key give-admin-box-inside">
286 286
 											<p>
287
-												<strong><?php _e( 'Key:', 'give' ); ?></strong>&nbsp;
288
-												<?php echo give_get_payment_key( $payment_id ); ?>
287
+												<strong><?php _e('Key:', 'give'); ?></strong>&nbsp;
288
+												<?php echo give_get_payment_key($payment_id); ?>
289 289
 											</p>
290 290
 										</div>
291 291
 
292 292
 										<div class="give-order-ip give-admin-box-inside">
293 293
 											<p>
294
-												<strong><?php _e( 'IP:', 'give' ); ?></strong>&nbsp;
295
-												<?php echo esc_html( give_get_payment_user_ip( $payment_id ) ); ?>
294
+												<strong><?php _e('IP:', 'give'); ?></strong>&nbsp;
295
+												<?php echo esc_html(give_get_payment_user_ip($payment_id)); ?>
296 296
 											</p>
297 297
 										</div>
298 298
 
299
-										<?php if ( $transaction_id ) : ?>
299
+										<?php if ($transaction_id) : ?>
300 300
 											<div class="give-order-tx-id give-admin-box-inside">
301 301
 												<p>
302
-													<strong><?php _e( 'Donation ID:', 'give' ); ?></strong>&nbsp;
303
-													<?php echo apply_filters( "give_payment_details_transaction_id-{$gateway}", $transaction_id, $payment_id ); ?>
302
+													<strong><?php _e('Donation ID:', 'give'); ?></strong>&nbsp;
303
+													<?php echo apply_filters("give_payment_details_transaction_id-{$gateway}", $transaction_id, $payment_id); ?>
304 304
 												</p>
305 305
 											</div>
306 306
 										<?php endif; ?>
307 307
 
308 308
 										<div class="give-admin-box-inside">
309
-											<p><?php $purchase_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&donor=' . absint( give_get_payment_donor_id( $payment_id ) ) ); ?>
310
-												<a href="<?php echo $purchase_url; ?>"><?php _e( 'View all donations for this donor &raquo;', 'give' ); ?></a>
309
+											<p><?php $purchase_url = admin_url('edit.php?post_type=give_forms&page=give-payment-history&donor='.absint(give_get_payment_donor_id($payment_id))); ?>
310
+												<a href="<?php echo $purchase_url; ?>"><?php _e('View all donations for this donor &raquo;', 'give'); ?></a>
311 311
 											</p>
312 312
 										</div>
313 313
 
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 										 *
320 320
 										 * @param int $payment_id Payment id.
321 321
 										 */
322
-										do_action( 'give_view_order_details_payment_meta_after', $payment_id );
322
+										do_action('give_view_order_details_payment_meta_after', $payment_id);
323 323
 										?>
324 324
 
325 325
 									</div>
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 							 *
340 340
 							 * @param int $payment_id Payment id.
341 341
 							 */
342
-							do_action( 'give_view_order_details_sidebar_after', $payment_id );
342
+							do_action('give_view_order_details_sidebar_after', $payment_id);
343 343
 							?>
344 344
 
345 345
 						</div>
@@ -359,31 +359,31 @@  discard block
 block discarded – undo
359 359
 							 *
360 360
 							 * @param int $payment_id Payment id.
361 361
 							 */
362
-							do_action( 'give_view_order_details_main_before', $payment_id );
362
+							do_action('give_view_order_details_main_before', $payment_id);
363 363
 							?>
364 364
 
365 365
 							<?php $column_count = 'columns-3'; ?>
366 366
 							<div id="give-donation-overview" class="postbox <?php echo $column_count; ?>">
367
-								<h3 class="hndle"><?php _e( 'Donation Information', 'give' ); ?></h3>
367
+								<h3 class="hndle"><?php _e('Donation Information', 'give'); ?></h3>
368 368
 
369 369
 								<div class="inside">
370 370
 
371 371
 									<div class="column-container">
372 372
 										<div class="column">
373 373
 											<p>
374
-												<strong><?php _e( 'Donation Form ID:', 'give' ); ?></strong><br>
374
+												<strong><?php _e('Donation Form ID:', 'give'); ?></strong><br>
375 375
 												<?php
376
-												if ( $payment_meta['form_id'] ) :
376
+												if ($payment_meta['form_id']) :
377 377
 													printf(
378 378
 														'<a href="%1$s">#%2$s</a>',
379
-														admin_url( 'post.php?action=edit&post=' . $payment_meta['form_id'] ),
379
+														admin_url('post.php?action=edit&post='.$payment_meta['form_id']),
380 380
 														$payment_meta['form_id']
381 381
 													);
382 382
 												endif;
383 383
 												?>
384 384
 											</p>
385 385
 											<p>
386
-												<strong><?php esc_html_e( 'Donation Form Title:', 'give' ); ?></strong><br>
386
+												<strong><?php esc_html_e('Donation Form Title:', 'give'); ?></strong><br>
387 387
 												<?php
388 388
 												echo Give()->html->forms_dropdown(
389 389
 													array(
@@ -399,21 +399,21 @@  discard block
 block discarded – undo
399 399
 										</div>
400 400
 										<div class="column">
401 401
 											<p>
402
-												<strong><?php _e( 'Donation Date:', 'give' ); ?></strong><br>
403
-												<?php echo date_i18n( give_date_format(), $payment_date ); ?>
402
+												<strong><?php _e('Donation Date:', 'give'); ?></strong><br>
403
+												<?php echo date_i18n(give_date_format(), $payment_date); ?>
404 404
 											</p>
405 405
 											<p>
406
-												<strong><?php _e( 'Donation Level:', 'give' ); ?></strong><br>
406
+												<strong><?php _e('Donation Level:', 'give'); ?></strong><br>
407 407
 												<span class="give-donation-level">
408 408
 													<?php
409
-													$var_prices = give_has_variable_prices( $payment_meta['form_id'] );
410
-													if ( empty( $var_prices ) ) {
411
-														_e( 'n/a', 'give' );
409
+													$var_prices = give_has_variable_prices($payment_meta['form_id']);
410
+													if (empty($var_prices)) {
411
+														_e('n/a', 'give');
412 412
 													} else {
413 413
 														$prices_atts = array();
414
-														if ( $variable_prices = give_get_variable_prices( $payment_meta['form_id'] ) ) {
415
-															foreach ( $variable_prices as $variable_price ) {
416
-																$prices_atts[ $variable_price['_give_id']['level_id'] ] = give_format_amount( $variable_price['_give_amount'], array( 'sanitize' => false ) );
414
+														if ($variable_prices = give_get_variable_prices($payment_meta['form_id'])) {
415
+															foreach ($variable_prices as $variable_price) {
416
+																$prices_atts[$variable_price['_give_id']['level_id']] = give_format_amount($variable_price['_give_amount'], array('sanitize' => false));
417 417
 															}
418 418
 														}
419 419
 														// Variable price dropdown options.
@@ -422,12 +422,12 @@  discard block
 block discarded – undo
422 422
 															'name'             => 'give-variable-price',
423 423
 															'chosen'           => true,
424 424
 															'show_option_all'  => '',
425
-															'show_option_none' => ( '' === get_post_meta( $payment_id, '_give_payment_price_id', true ) ? __( 'None', 'give' ) : '' ),
426
-															'select_atts'      => 'data-prices=' . esc_attr( wp_json_encode( $prices_atts ) ),
425
+															'show_option_none' => ('' === get_post_meta($payment_id, '_give_payment_price_id', true) ? __('None', 'give') : ''),
426
+															'select_atts'      => 'data-prices='.esc_attr(wp_json_encode($prices_atts)),
427 427
 															'selected'         => $payment_meta['price_id'],
428 428
 														);
429 429
 														// Render variable prices select tag html.
430
-														give_get_form_variable_price_dropdown( $variable_price_dropdown_option, true );
430
+														give_get_form_variable_price_dropdown($variable_price_dropdown_option, true);
431 431
 													}
432 432
 													?>
433 433
 												</span>
@@ -435,8 +435,8 @@  discard block
 block discarded – undo
435 435
 										</div>
436 436
 										<div class="column">
437 437
 											<p>
438
-												<strong><?php esc_html_e( 'Total Donation:', 'give' ); ?></strong><br>
439
-												<?php echo give_donation_amount( $payment, true ); ?>
438
+												<strong><?php esc_html_e('Total Donation:', 'give'); ?></strong><br>
439
+												<?php echo give_donation_amount($payment, true); ?>
440 440
 											</p>
441 441
 											<p>
442 442
 												<?php
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
 												 *
450 450
 												 * @param int $payment_id Payment id.
451 451
 												 */
452
-												do_action( 'give_donation_details_thead_before', $payment_id );
452
+												do_action('give_donation_details_thead_before', $payment_id);
453 453
 
454 454
 
455 455
 												/**
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 												 *
462 462
 												 * @param int $payment_id Payment id.
463 463
 												 */
464
-												do_action( 'give_donation_details_thead_after', $payment_id );
464
+												do_action('give_donation_details_thead_after', $payment_id);
465 465
 
466 466
 												/**
467 467
 												 * Fires in order details page, in the donation-information metabox, before the body elements.
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
 												 *
473 473
 												 * @param int $payment_id Payment id.
474 474
 												 */
475
-												do_action( 'give_donation_details_tbody_before', $payment_id );
475
+												do_action('give_donation_details_tbody_before', $payment_id);
476 476
 
477 477
 												/**
478 478
 												 * Fires in order details page, in the donation-information metabox, after the body elements.
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
 												 *
484 484
 												 * @param int $payment_id Payment id.
485 485
 												 */
486
-												do_action( 'give_donation_details_tbody_after', $payment_id );
486
+												do_action('give_donation_details_tbody_after', $payment_id);
487 487
 												?>
488 488
 											</p>
489 489
 										</div>
@@ -503,58 +503,58 @@  discard block
 block discarded – undo
503 503
 							 *
504 504
 							 * @param int $payment_id Payment id.
505 505
 							 */
506
-							do_action( 'give_view_order_details_files_after', $payment_id );
506
+							do_action('give_view_order_details_files_after', $payment_id);
507 507
 							?>
508 508
 
509 509
 							<div id="give-donor-details" class="postbox">
510
-								<h3 class="hndle"><?php _e( 'Donor Details', 'give' ); ?></h3>
510
+								<h3 class="hndle"><?php _e('Donor Details', 'give'); ?></h3>
511 511
 
512 512
 								<div class="inside">
513 513
 
514
-									<?php $donor = new Give_Donor( $donor_id ); ?>
514
+									<?php $donor = new Give_Donor($donor_id); ?>
515 515
 
516 516
 									<div class="column-container donor-info">
517 517
 										<div class="column">
518 518
 											<p>
519
-												<strong><?php _e( 'Donor ID:', 'give' ); ?></strong><br>
519
+												<strong><?php _e('Donor ID:', 'give'); ?></strong><br>
520 520
 												<?php
521
-												if ( ! empty( $donor->id ) ) {
521
+												if ( ! empty($donor->id)) {
522 522
 													printf(
523 523
 														'<a href="%1$s">#%2$s</a>',
524
-														admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ),
524
+														admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id),
525 525
 														$donor->id
526 526
 													);
527 527
 												}
528 528
 												?>
529 529
 											</p>
530 530
 											<p>
531
-												<strong><?php _e( 'Donor Since:', 'give' ); ?></strong><br>
532
-												<?php echo date_i18n( give_date_format(), strtotime( $donor->date_created ) ) ?>
531
+												<strong><?php _e('Donor Since:', 'give'); ?></strong><br>
532
+												<?php echo date_i18n(give_date_format(), strtotime($donor->date_created)) ?>
533 533
 											</p>
534 534
 										</div>
535 535
 										<div class="column">
536 536
 											<p>
537
-												<strong><?php _e( 'Donor Name:', 'give' ); ?></strong><br>
537
+												<strong><?php _e('Donor Name:', 'give'); ?></strong><br>
538 538
 												<?php
539
-												$donor_billing_name = give_get_donor_name_by( $payment_id, 'donation' );
540
-												$donor_name         = give_get_donor_name_by( $donor_id, 'donor' );
539
+												$donor_billing_name = give_get_donor_name_by($payment_id, 'donation');
540
+												$donor_name         = give_get_donor_name_by($donor_id, 'donor');
541 541
 
542 542
 												// Check whether the donor name and WP_User name is same or not.
543
-												if ( sanitize_title( $donor_billing_name ) != sanitize_title( $donor_name ) ) {
544
-													echo $donor_billing_name . ' (<a href="' . esc_url( admin_url( "edit.php?post_type=give_forms&page=give-donors&view=overview&id=$donor_id" ) ) . '">' . $donor_name . '</a>)';
543
+												if (sanitize_title($donor_billing_name) != sanitize_title($donor_name)) {
544
+													echo $donor_billing_name.' (<a href="'.esc_url(admin_url("edit.php?post_type=give_forms&page=give-donors&view=overview&id=$donor_id")).'">'.$donor_name.'</a>)';
545 545
 												} else {
546 546
 													echo $donor_name;
547 547
 												}
548 548
 												?>
549 549
 											</p>
550 550
 											<p>
551
-												<strong><?php _e( 'Donor Email:', 'give' ); ?></strong><br>
551
+												<strong><?php _e('Donor Email:', 'give'); ?></strong><br>
552 552
 												<?php echo $donor->email; ?>
553 553
 											</p>
554 554
 										</div>
555 555
 										<div class="column">
556 556
 											<p>
557
-												<strong><?php _e( 'Change Donor:', 'give' ); ?></strong><br>
557
+												<strong><?php _e('Change Donor:', 'give'); ?></strong><br>
558 558
 												<?php
559 559
 												echo Give()->html->donor_dropdown(
560 560
 													array(
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
 												?>
566 566
 											</p>
567 567
 											<p>
568
-												<a href="#new" class="give-payment-new-donor"><?php _e( 'Create New Donor', 'give' ); ?></a>
568
+												<a href="#new" class="give-payment-new-donor"><?php _e('Create New Donor', 'give'); ?></a>
569 569
 											</p>
570 570
 										</div>
571 571
 									</div>
@@ -573,19 +573,19 @@  discard block
 block discarded – undo
573 573
 									<div class="column-container new-donor" style="display: none">
574 574
 										<div class="column">
575 575
 											<p>
576
-												<label for="give-new-donor-first-name"><?php _e( 'New Donor First Name:', 'give' ); ?></label>
576
+												<label for="give-new-donor-first-name"><?php _e('New Donor First Name:', 'give'); ?></label>
577 577
 												<input id="give-new-donor-first-name" type="text" name="give-new-donor-first-name" value="" class="medium-text"/>
578 578
 											</p>
579 579
 										</div>
580 580
 										<div class="column">
581 581
 											<p>
582
-												<label for="give-new-donor-last-name"><?php _e( 'New Donor Last Name:', 'give' ); ?></label>
582
+												<label for="give-new-donor-last-name"><?php _e('New Donor Last Name:', 'give'); ?></label>
583 583
 												<input id="give-new-donor-last-name" type="text" name="give-new-donor-last-name" value="" class="medium-text"/>
584 584
 											</p>
585 585
 										</div>
586 586
 										<div class="column">
587 587
 											<p>
588
-												<label for="give-new-donor-email"><?php _e( 'New Donor Email:', 'give' ); ?></label>
588
+												<label for="give-new-donor-email"><?php _e('New Donor Email:', 'give'); ?></label>
589 589
 												<input id="give-new-donor-email" type="email" name="give-new-donor-email" value="" class="medium-text"/>
590 590
 											</p>
591 591
 										</div>
@@ -593,9 +593,9 @@  discard block
 block discarded – undo
593 593
 											<p>
594 594
 												<input type="hidden" name="give-current-donor" value="<?php echo $donor->id; ?>"/>
595 595
 												<input type="hidden" id="give-new-donor" name="give-new-donor" value="0"/>
596
-												<a href="#cancel" class="give-payment-new-donor-cancel give-delete"><?php _e( 'Cancel', 'give' ); ?></a>
596
+												<a href="#cancel" class="give-payment-new-donor-cancel give-delete"><?php _e('Cancel', 'give'); ?></a>
597 597
 												<br>
598
-												<em><?php _e( 'Click "Save Donation" to create new donor.', 'give' ); ?></em>
598
+												<em><?php _e('Click "Save Donation" to create new donor.', 'give'); ?></em>
599 599
 											</p>
600 600
 										</div>
601 601
 									</div>
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
 									 * @param array $payment_meta Payment meta.
612 612
 									 * @param array $user_info    User information.
613 613
 									 */
614
-									do_action( 'give_payment_personal_details_list', $payment_meta, $user_info );
614
+									do_action('give_payment_personal_details_list', $payment_meta, $user_info);
615 615
 
616 616
 									/**
617 617
 									 * Fires on the donation details page, in the donor-details metabox.
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
 									 *
621 621
 									 * @param int $payment_id Payment id.
622 622
 									 */
623
-									do_action( 'give_payment_view_details', $payment_id );
623
+									do_action('give_payment_view_details', $payment_id);
624 624
 									?>
625 625
 
626 626
 								</div>
@@ -636,11 +636,11 @@  discard block
 block discarded – undo
636 636
 							 *
637 637
 							 * @param int $payment_id Payment id.
638 638
 							 */
639
-							do_action( 'give_view_order_details_billing_before', $payment_id );
639
+							do_action('give_view_order_details_billing_before', $payment_id);
640 640
 							?>
641 641
 
642 642
 							<div id="give-billing-details" class="postbox">
643
-								<h3 class="hndle"><?php _e( 'Billing Address', 'give' ); ?></h3>
643
+								<h3 class="hndle"><?php _e('Billing Address', 'give'); ?></h3>
644 644
 
645 645
 								<div class="inside">
646 646
 
@@ -650,9 +650,9 @@  discard block
 block discarded – undo
650 650
 											<div class="data column-container">
651 651
 
652 652
 												<?php
653
-												$address['country'] = ( ! empty( $address['country'] ) ? $address['country'] : give_get_country() );
653
+												$address['country'] = ( ! empty($address['country']) ? $address['country'] : give_get_country());
654 654
 
655
-												$address['state'] = ( ! empty( $address['state'] ) ? $address['state'] : '' );
655
+												$address['state'] = ( ! empty($address['state']) ? $address['state'] : '');
656 656
 
657 657
 												// Get the country list that does not have any states init.
658 658
 												$no_states_country = give_no_states_country_list();
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
 
661 661
 												<div class="row">
662 662
 													<div id="give-order-address-country-wrap">
663
-														<label class="order-data-address-line"><?php _e( 'Country:', 'give' ); ?></label>
663
+														<label class="order-data-address-line"><?php _e('Country:', 'give'); ?></label>
664 664
 														<?php
665 665
 														echo Give()->html->select(
666 666
 															array(
@@ -670,8 +670,8 @@  discard block
 block discarded – undo
670 670
 																'show_option_all'  => false,
671 671
 																'show_option_none' => false,
672 672
 																'chosen'           => true,
673
-																'placeholder'      => esc_attr__( 'Select a country', 'give' ),
674
-																'data'             => array( 'search-type' => 'no_ajax' ),
673
+																'placeholder'      => esc_attr__('Select a country', 'give'),
674
+																'data'             => array('search-type' => 'no_ajax'),
675 675
 															)
676 676
 														);
677 677
 														?>
@@ -680,35 +680,35 @@  discard block
 block discarded – undo
680 680
 
681 681
 												<div class="row">
682 682
 													<div class="give-wrap-address-line1">
683
-														<label for="give-payment-address-line1" class="order-data-address"><?php _e( 'Address 1:', 'give' ); ?></label>
684
-														<input id="give-payment-address-line1" type="text" name="give-payment-address[0][line1]" value="<?php echo esc_attr( $address['line1'] ); ?>" class="medium-text"/>
683
+														<label for="give-payment-address-line1" class="order-data-address"><?php _e('Address 1:', 'give'); ?></label>
684
+														<input id="give-payment-address-line1" type="text" name="give-payment-address[0][line1]" value="<?php echo esc_attr($address['line1']); ?>" class="medium-text"/>
685 685
 													</div>
686 686
 												</div>
687 687
 
688 688
 												<div class="row">
689 689
 													<div class="give-wrap-address-line2">
690
-														<label for="give-payment-address-line2" class="order-data-address-line"><?php _e( 'Address 2:', 'give' ); ?></label>
691
-														<input id="give-payment-address-line2" type="text" name="give-payment-address[0][line2]" value="<?php echo esc_attr( $address['line2'] ); ?>" class="medium-text"/>
690
+														<label for="give-payment-address-line2" class="order-data-address-line"><?php _e('Address 2:', 'give'); ?></label>
691
+														<input id="give-payment-address-line2" type="text" name="give-payment-address[0][line2]" value="<?php echo esc_attr($address['line2']); ?>" class="medium-text"/>
692 692
 													</div>
693 693
 												</div>
694 694
 
695 695
 												<div class="row">
696 696
 													<div class="give-wrap-address-city">
697
-														<label for="give-payment-address-city" class="order-data-address-line"><?php esc_html_e( 'City:', 'give' ); ?></label>
698
-														<input id="give-payment-address-city" type="text" name="give-payment-address[0][city]" value="<?php echo esc_attr( $address['city'] ); ?>" class="medium-text"/>
697
+														<label for="give-payment-address-city" class="order-data-address-line"><?php esc_html_e('City:', 'give'); ?></label>
698
+														<input id="give-payment-address-city" type="text" name="give-payment-address[0][city]" value="<?php echo esc_attr($address['city']); ?>" class="medium-text"/>
699 699
 													</div>
700 700
 												</div>
701 701
 
702 702
 												<?php
703
-												$state_exists = ( ! empty( $address['country'] ) && array_key_exists( $address['country'], $no_states_country ) ? true : false );
703
+												$state_exists = ( ! empty($address['country']) && array_key_exists($address['country'], $no_states_country) ? true : false);
704 704
 												?>
705 705
 												<div class="row">
706
-													<div class="<?php echo( ! empty( $state_exists ) ? 'column-full' : 'column' ); ?> give-column give-column-state">
707
-														<div id="give-order-address-state-wrap" class="<?php echo( ! empty( $state_exists ) ? 'give-hidden' : '' ); ?>">
708
-															<label for="give-payment-address-state" class="order-data-address-line"><?php esc_html_e( 'State / Province / County:', 'give' ); ?></label>
706
+													<div class="<?php echo( ! empty($state_exists) ? 'column-full' : 'column'); ?> give-column give-column-state">
707
+														<div id="give-order-address-state-wrap" class="<?php echo( ! empty($state_exists) ? 'give-hidden' : ''); ?>">
708
+															<label for="give-payment-address-state" class="order-data-address-line"><?php esc_html_e('State / Province / County:', 'give'); ?></label>
709 709
 															<?php
710
-															$states = give_get_states( $address['country'] );
711
-															if ( ! empty( $states ) ) {
710
+															$states = give_get_states($address['country']);
711
+															if ( ! empty($states)) {
712 712
 																echo Give()->html->select(
713 713
 																	array(
714 714
 																		'options'          => $states,
@@ -717,23 +717,23 @@  discard block
 block discarded – undo
717 717
 																		'show_option_all'  => false,
718 718
 																		'show_option_none' => false,
719 719
 																		'chosen'           => true,
720
-																		'placeholder'      => esc_attr__( 'Select a state', 'give' ),
721
-																		'data'             => array( 'search-type' => 'no_ajax' ),
720
+																		'placeholder'      => esc_attr__('Select a state', 'give'),
721
+																		'data'             => array('search-type' => 'no_ajax'),
722 722
 																	)
723 723
 																);
724 724
 															} else {
725 725
 																?>
726
-																<input id="give-payment-address-state" type="text" name="give-payment-address[0][state]" value="<?php echo esc_attr( $address['state'] ); ?>" class="medium-text"/>
726
+																<input id="give-payment-address-state" type="text" name="give-payment-address[0][state]" value="<?php echo esc_attr($address['state']); ?>" class="medium-text"/>
727 727
 																<?php
728 728
 															}
729 729
 															?>
730 730
 														</div>
731 731
 													</div>
732 732
 
733
-													<div class="<?php echo( ! empty( $state_exists ) ? 'column-full' : 'column' ); ?> give-column give-column-zip">
733
+													<div class="<?php echo( ! empty($state_exists) ? 'column-full' : 'column'); ?> give-column give-column-zip">
734 734
 														<div class="give-wrap-address-zip">
735
-															<label for="give-payment-address-zip" class="order-data-address-line"><?php _e( 'Zip / Postal Code:', 'give' ); ?></label>
736
-															<input id="give-payment-address-zip" type="text" name="give-payment-address[0][zip]" value="<?php echo esc_attr( $address['zip'] ); ?>" class="medium-text"/>
735
+															<label for="give-payment-address-zip" class="order-data-address-line"><?php _e('Zip / Postal Code:', 'give'); ?></label>
736
+															<input id="give-payment-address-zip" type="text" name="give-payment-address[0][zip]" value="<?php echo esc_attr($address['zip']); ?>" class="medium-text"/>
737 737
 														</div>
738 738
 													</div>
739 739
 												</div>
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
 									 *
753 753
 									 * @param int $payment_id Payment id.
754 754
 									 */
755
-									do_action( 'give_payment_billing_details', $payment_id );
755
+									do_action('give_payment_billing_details', $payment_id);
756 756
 									?>
757 757
 
758 758
 								</div>
@@ -768,34 +768,34 @@  discard block
 block discarded – undo
768 768
 							 *
769 769
 							 * @param int $payment_id Payment id.
770 770
 							 */
771
-							do_action( 'give_view_order_details_billing_after', $payment_id );
771
+							do_action('give_view_order_details_billing_after', $payment_id);
772 772
 							?>
773 773
 
774 774
 							<div id="give-payment-notes" class="postbox">
775
-								<h3 class="hndle"><?php _e( 'Donation Notes', 'give' ); ?></h3>
775
+								<h3 class="hndle"><?php _e('Donation Notes', 'give'); ?></h3>
776 776
 
777 777
 								<div class="inside">
778 778
 									<div id="give-payment-notes-inner">
779 779
 										<?php
780
-										$notes = give_get_payment_notes( $payment_id );
781
-										if ( ! empty( $notes ) ) {
780
+										$notes = give_get_payment_notes($payment_id);
781
+										if ( ! empty($notes)) {
782 782
 											$no_notes_display = ' style="display:none;"';
783
-											foreach ( $notes as $note ) :
783
+											foreach ($notes as $note) :
784 784
 
785
-												echo give_get_payment_note_html( $note, $payment_id );
785
+												echo give_get_payment_note_html($note, $payment_id);
786 786
 
787 787
 											endforeach;
788 788
 										} else {
789 789
 											$no_notes_display = '';
790 790
 										}
791 791
 
792
-										echo '<p class="give-no-payment-notes"' . $no_notes_display . '>' . esc_html__( 'No donation notes.', 'give' ) . '</p>';
792
+										echo '<p class="give-no-payment-notes"'.$no_notes_display.'>'.esc_html__('No donation notes.', 'give').'</p>';
793 793
 										?>
794 794
 									</div>
795 795
 									<textarea name="give-payment-note" id="give-payment-note" class="large-text"></textarea>
796 796
 
797 797
 									<div class="give-clearfix">
798
-										<button id="give-add-payment-note" class="button button-secondary button-small" data-payment-id="<?php echo absint( $payment_id ); ?>"><?php _e( 'Add Note', 'give' ); ?></button>
798
+										<button id="give-add-payment-note" class="button button-secondary button-small" data-payment-id="<?php echo absint($payment_id); ?>"><?php _e('Add Note', 'give'); ?></button>
799 799
 									</div>
800 800
 
801 801
 								</div>
@@ -811,7 +811,7 @@  discard block
 block discarded – undo
811 811
 							 *
812 812
 							 * @param int $payment_id Payment id.
813 813
 							 */
814
-							do_action( 'give_view_order_details_main_after', $payment_id );
814
+							do_action('give_view_order_details_main_after', $payment_id);
815 815
 							?>
816 816
 
817 817
 						</div>
@@ -833,11 +833,11 @@  discard block
 block discarded – undo
833 833
 		 *
834 834
 		 * @param int $payment_id Payment id.
835 835
 		 */
836
-		do_action( 'give_view_order_details_form_bottom', $payment_id );
836
+		do_action('give_view_order_details_form_bottom', $payment_id);
837 837
 
838
-		wp_nonce_field( 'give_update_payment_details_nonce' );
838
+		wp_nonce_field('give_update_payment_details_nonce');
839 839
 		?>
840
-		<input type="hidden" name="give_payment_id" value="<?php echo esc_attr( $payment_id ); ?>"/>
840
+		<input type="hidden" name="give_payment_id" value="<?php echo esc_attr($payment_id); ?>"/>
841 841
 		<input type="hidden" name="give_action" value="update_payment_details"/>
842 842
 	</form>
843 843
 	<?php
@@ -848,6 +848,6 @@  discard block
 block discarded – undo
848 848
 	 *
849 849
 	 * @param int $payment_id Payment id.
850 850
 	 */
851
-	do_action( 'give_view_order_details_after', $payment_id );
851
+	do_action('give_view_order_details_after', $payment_id);
852 852
 	?>
853 853
 </div><!-- /.wrap -->
Please login to merge, or discard this patch.
includes/admin/payments/actions.php 1 patch
Spacing   +124 added lines, -124 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,48 +25,48 @@  discard block
 block discarded – undo
25 25
  *
26 26
  * @return      void
27 27
  */
28
-function give_update_payment_details( $data ) {
28
+function give_update_payment_details($data) {
29 29
 
30
-	if ( ! current_user_can( 'edit_give_payments', $data['give_payment_id'] ) ) {
31
-		wp_die( __( 'You do not have permission to edit payments.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
30
+	if ( ! current_user_can('edit_give_payments', $data['give_payment_id'])) {
31
+		wp_die(__('You do not have permission to edit payments.', 'give'), __('Error', 'give'), array('response' => 403));
32 32
 	}
33 33
 
34
-	check_admin_referer( 'give_update_payment_details_nonce' );
34
+	check_admin_referer('give_update_payment_details_nonce');
35 35
 
36 36
 	// Retrieve the payment ID.
37
-	$payment_id = absint( $data['give_payment_id'] );
37
+	$payment_id = absint($data['give_payment_id']);
38 38
 
39 39
 	/* @var Give_Payment $payment */
40
-	$payment = new Give_Payment( $payment_id );
40
+	$payment = new Give_Payment($payment_id);
41 41
 
42 42
 	$status = $data['give-payment-status'];
43
-	$date   = sanitize_text_field( $data['give-payment-date'] );
44
-	$hour   = sanitize_text_field( $data['give-payment-time-hour'] );
43
+	$date   = sanitize_text_field($data['give-payment-date']);
44
+	$hour   = sanitize_text_field($data['give-payment-time-hour']);
45 45
 
46 46
 	// Restrict to our high and low.
47
-	if ( $hour > 23 ) {
47
+	if ($hour > 23) {
48 48
 		$hour = 23;
49
-	} elseif ( $hour < 0 ) {
49
+	} elseif ($hour < 0) {
50 50
 		$hour = 00;
51 51
 	}
52 52
 
53
-	$minute = sanitize_text_field( $data['give-payment-time-min'] );
53
+	$minute = sanitize_text_field($data['give-payment-time-min']);
54 54
 
55 55
 	// Restrict to our high and low.
56
-	if ( $minute > 59 ) {
56
+	if ($minute > 59) {
57 57
 		$minute = 59;
58
-	} elseif ( $minute < 0 ) {
58
+	} elseif ($minute < 0) {
59 59
 		$minute = 00;
60 60
 	}
61 61
 
62
-	$address = give_clean( $data['give-payment-address'][0] );
62
+	$address = give_clean($data['give-payment-address'][0]);
63 63
 
64 64
 	$curr_total = $payment->total;
65
-	$new_total  = give_maybe_sanitize_amount( ( ! empty( $data['give-payment-total'] ) ? $data['give-payment-total'] : 0 ) );
66
-	$date       = date( 'Y-m-d', strtotime( $date ) ) . ' ' . $hour . ':' . $minute . ':00';
65
+	$new_total  = give_maybe_sanitize_amount(( ! empty($data['give-payment-total']) ? $data['give-payment-total'] : 0));
66
+	$date       = date('Y-m-d', strtotime($date)).' '.$hour.':'.$minute.':00';
67 67
 
68
-	$curr_donor_id = sanitize_text_field( $data['give-current-donor'] );
69
-	$new_donor_id  = sanitize_text_field( $data['donor-id'] );
68
+	$curr_donor_id = sanitize_text_field($data['give-current-donor']);
69
+	$new_donor_id  = sanitize_text_field($data['donor-id']);
70 70
 
71 71
 	/**
72 72
 	 * Fires before updating edited donation.
@@ -76,71 +76,71 @@  discard block
 block discarded – undo
76 76
 	 *
77 77
 	 * @param int $payment_id The ID of the payment.
78 78
 	 */
79
-	do_action( 'give_update_edited_donation', $payment_id );
79
+	do_action('give_update_edited_donation', $payment_id);
80 80
 
81 81
 	$payment->date = $date;
82 82
 	$updated       = $payment->save();
83 83
 
84
-	if ( 0 === $updated ) {
85
-		wp_die( __( 'Error Updating Donation.', 'give' ), __( 'Error', 'give' ), array( 'response' => 400 ) );
84
+	if (0 === $updated) {
85
+		wp_die(__('Error Updating Donation.', 'give'), __('Error', 'give'), array('response' => 400));
86 86
 	}
87 87
 
88 88
 	$donor_changed = false;
89 89
 
90
-	if ( isset( $data['give-new-donor'] ) && $data['give-new-donor'] == '1' ) {
90
+	if (isset($data['give-new-donor']) && $data['give-new-donor'] == '1') {
91 91
 
92
-		$email      = ! empty( $data['give-new-donor-email'] ) ? sanitize_text_field( $data['give-new-donor-email'] ) : '';
93
-		$first_name = ! empty( $data['give-new-donor-first-name'] ) ? sanitize_text_field( $data['give-new-donor-first-name'] ) : '';
94
-		$last_name  = ! empty( $data['give-new-donor-last-name'] ) ? sanitize_text_field( $data['give-new-donor-last-name'] ) : '';
95
-		$names      = strip_tags( wp_unslash( trim( "{$first_name} {$last_name}" ) ) );
92
+		$email      = ! empty($data['give-new-donor-email']) ? sanitize_text_field($data['give-new-donor-email']) : '';
93
+		$first_name = ! empty($data['give-new-donor-first-name']) ? sanitize_text_field($data['give-new-donor-first-name']) : '';
94
+		$last_name  = ! empty($data['give-new-donor-last-name']) ? sanitize_text_field($data['give-new-donor-last-name']) : '';
95
+		$names      = strip_tags(wp_unslash(trim("{$first_name} {$last_name}")));
96 96
 
97
-		if ( empty( $email ) || empty( $first_name ) ) {
98
-			wp_die( __( 'New Donor requires first name and email address.', 'give' ), __( 'Error', 'give' ), array( 'response' => 400 ) );
97
+		if (empty($email) || empty($first_name)) {
98
+			wp_die(__('New Donor requires first name and email address.', 'give'), __('Error', 'give'), array('response' => 400));
99 99
 		}
100 100
 
101
-		$donor = new Give_Donor( $email );
102
-		if ( empty( $donor->id ) ) {
103
-			$donor_data = array( 'name' => $names, 'email' => $email );
104
-			$user_id       = email_exists( $email );
105
-			if ( false !== $user_id ) {
101
+		$donor = new Give_Donor($email);
102
+		if (empty($donor->id)) {
103
+			$donor_data = array('name' => $names, 'email' => $email);
104
+			$user_id = email_exists($email);
105
+			if (false !== $user_id) {
106 106
 				$donor_data['user_id'] = $user_id;
107 107
 			}
108 108
 
109
-			if ( ! $donor->create( $donor_data ) ) {
109
+			if ( ! $donor->create($donor_data)) {
110 110
 				// Failed to create the new donor, assume the previous donor.
111 111
 				$donor_changed = false;
112
-				$donor         = new Give_Donor( $curr_donor_id );
113
-				give_set_error( 'give-payment-new-donor-fail', __( 'Error creating new donor.', 'give' ) );
112
+				$donor         = new Give_Donor($curr_donor_id);
113
+				give_set_error('give-payment-new-donor-fail', __('Error creating new donor.', 'give'));
114 114
 			}
115 115
 		}
116 116
 
117 117
 		// Create and Update Donor First Name and Last Name in Meta Fields.
118
-		$donor->update_meta( '_give_donor_first_name', $first_name );
119
-		$donor->update_meta( '_give_donor_last_name', $last_name );
118
+		$donor->update_meta('_give_donor_first_name', $first_name);
119
+		$donor->update_meta('_give_donor_last_name', $last_name);
120 120
 
121 121
 		$new_donor_id = $donor->id;
122 122
 
123
-		$previous_donor = new Give_Donor( $curr_donor_id );
123
+		$previous_donor = new Give_Donor($curr_donor_id);
124 124
 
125 125
 		$donor_changed = true;
126 126
 
127
-	} elseif ( $curr_donor_id !== $new_donor_id ) {
127
+	} elseif ($curr_donor_id !== $new_donor_id) {
128 128
 
129
-		$donor = new Give_Donor( $new_donor_id );
129
+		$donor = new Give_Donor($new_donor_id);
130 130
 		$email    = $donor->email;
131 131
 		$names    = $donor->name;
132 132
 
133
-		$previous_donor = new Give_Donor( $curr_donor_id );
133
+		$previous_donor = new Give_Donor($curr_donor_id);
134 134
 
135 135
 		$donor_changed = true;
136 136
 
137 137
 	} else {
138
-		$donor = new Give_Donor( $curr_donor_id );
138
+		$donor = new Give_Donor($curr_donor_id);
139 139
 		$email    = $donor->email;
140 140
 		$names    = $donor->name;
141 141
 	}
142 142
 
143
-	if ( $donor_changed ) {
143
+	if ($donor_changed) {
144 144
 
145 145
 		// Setup first and last name from input values.
146 146
 		$first_name = $donor->get_first_name();
@@ -150,26 +150,26 @@  discard block
 block discarded – undo
150 150
 		$payment->last_name  = $last_name;
151 151
 
152 152
 		// Remove the stats and payment from the previous donor and attach it to the new donor.
153
-		$previous_donor->remove_payment( $payment_id, false );
154
-		$donor->attach_payment( $payment_id, false );
153
+		$previous_donor->remove_payment($payment_id, false);
154
+		$donor->attach_payment($payment_id, false);
155 155
 
156
-		if ( 'publish' == $status ) {
156
+		if ('publish' == $status) {
157 157
 
158 158
 			// Reduce previous user donation count and amount.
159 159
 			$previous_donor->decrease_donation_count();
160
-			$previous_donor->decrease_value( $curr_total );
160
+			$previous_donor->decrease_value($curr_total);
161 161
 
162 162
 			// If donation was completed adjust stats of new donors.
163 163
 			$donor->increase_purchase_count();
164
-			$donor->increase_value( $new_total );
164
+			$donor->increase_value($new_total);
165 165
 		}
166 166
 
167 167
 		$payment->customer_id = $donor->id;
168 168
 	} else {
169 169
 
170
-		if ( 'publish' === $status ) {
170
+		if ('publish' === $status) {
171 171
 			// Update user donation stat.
172
-			$donor->update_donation_value( $curr_total, $new_total );
172
+			$donor->update_donation_value($curr_total, $new_total);
173 173
 		}
174 174
 	}
175 175
 
@@ -180,10 +180,10 @@  discard block
 block discarded – undo
180 180
 	$payment->total      = $new_total;
181 181
 
182 182
 	// Check for payment notes.
183
-	if ( ! empty( $data['give-payment-note'] ) ) {
183
+	if ( ! empty($data['give-payment-note'])) {
184 184
 
185
-		$note = wp_kses( $data['give-payment-note'], array() );
186
-		give_insert_payment_note( $payment_id, $note );
185
+		$note = wp_kses($data['give-payment-note'], array());
186
+		give_insert_payment_note($payment_id, $note);
187 187
 
188 188
 	}
189 189
 
@@ -191,17 +191,17 @@  discard block
 block discarded – undo
191 191
 	$payment->status = $status;
192 192
 
193 193
 	// Adjust total store earnings if the payment total has been changed.
194
-	if ( $new_total !== $curr_total && 'publish' == $status ) {
194
+	if ($new_total !== $curr_total && 'publish' == $status) {
195 195
 
196
-		if ( $new_total > $curr_total ) {
196
+		if ($new_total > $curr_total) {
197 197
 			// Increase if our new total is higher.
198 198
 			$difference = $new_total - $curr_total;
199
-			give_increase_total_earnings( $difference );
199
+			give_increase_total_earnings($difference);
200 200
 
201
-		} elseif ( $curr_total > $new_total ) {
201
+		} elseif ($curr_total > $new_total) {
202 202
 			// Decrease if our new total is lower.
203 203
 			$difference = $curr_total - $new_total;
204
-			give_decrease_total_earnings( $difference );
204
+			give_decrease_total_earnings($difference);
205 205
 
206 206
 		}
207 207
 	}
@@ -209,55 +209,55 @@  discard block
 block discarded – undo
209 209
 	$payment->save();
210 210
 
211 211
 	// Get new give form ID.
212
-	$new_form_id     = absint( $data['give-payment-form-select'] );
213
-	$current_form_id = absint( $payment->get_meta( '_give_payment_form_id' ) );
212
+	$new_form_id     = absint($data['give-payment-form-select']);
213
+	$current_form_id = absint($payment->get_meta('_give_payment_form_id'));
214 214
 
215 215
 	// We are adding payment transfer code in last to remove any conflict with above functionality.
216 216
 	// For example: above code will automatically handle form stat (increase/decrease) when payment status changes.
217 217
 	// Check if user want to transfer current payment to new give form id.
218
-	if ( $new_form_id && $new_form_id != $current_form_id ) {
218
+	if ($new_form_id && $new_form_id != $current_form_id) {
219 219
 
220 220
 		// Get new give form title.
221
-		$new_form_title = get_the_title( $new_form_id );
221
+		$new_form_title = get_the_title($new_form_id);
222 222
 
223 223
 		// Update payment give form meta data.
224
-		$payment->update_meta( '_give_payment_form_id', $new_form_id );
225
-		$payment->update_meta( '_give_payment_form_title', $new_form_title );
224
+		$payment->update_meta('_give_payment_form_id', $new_form_id);
225
+		$payment->update_meta('_give_payment_form_title', $new_form_title);
226 226
 
227 227
 		// Update price id payment metadata.
228
-		if ( ! give_has_variable_prices( $new_form_id ) ) {
229
-			$payment->update_meta( '_give_payment_price_id', '' );
228
+		if ( ! give_has_variable_prices($new_form_id)) {
229
+			$payment->update_meta('_give_payment_price_id', '');
230 230
 		}
231 231
 
232 232
 		// If donation was completed, adjust stats of forms.
233
-		if ( 'publish' == $status ) {
233
+		if ('publish' == $status) {
234 234
 
235 235
 			// Decrease sale of old give form. For other payment status.
236
-			$current_form = new Give_Donate_Form( $current_form_id );
236
+			$current_form = new Give_Donate_Form($current_form_id);
237 237
 			$current_form->decrease_sales();
238
-			$current_form->decrease_earnings( $curr_total );
238
+			$current_form->decrease_earnings($curr_total);
239 239
 
240 240
 			// Increase sale of new give form.
241
-			$new_form = new Give_Donate_Form( $new_form_id );
241
+			$new_form = new Give_Donate_Form($new_form_id);
242 242
 			$new_form->increase_sales();
243
-			$new_form->increase_earnings( $new_total );
243
+			$new_form->increase_earnings($new_total);
244 244
 		}
245 245
 
246 246
 		// Re setup payment to update new meta value in object.
247
-		$payment->update_payment_setup( $payment->ID );
247
+		$payment->update_payment_setup($payment->ID);
248 248
 
249 249
 		// Update form id in payment logs.
250
-		Give()->async_process->data( array(
251
-			'data' => array( $new_form_id, $payment_id ),
250
+		Give()->async_process->data(array(
251
+			'data' => array($new_form_id, $payment_id),
252 252
 			'hook' => 'give_update_log_form_id',
253
-		) )->dispatch();
253
+		))->dispatch();
254 254
 	}
255 255
 
256 256
 	// Update price id if current form is variable form.
257 257
 	/* @var Give_Donate_Form $form */
258
-	$form = new Give_Donate_Form( $payment->form_id );
258
+	$form = new Give_Donate_Form($payment->form_id);
259 259
 
260
-	if ( isset( $data['give-variable-price'] ) && $form->has_variable_prices() ) {
260
+	if (isset($data['give-variable-price']) && $form->has_variable_prices()) {
261 261
 
262 262
 		// Get payment meta data.
263 263
 		$payment_meta = $payment->get_meta();
@@ -266,9 +266,9 @@  discard block
 block discarded – undo
266 266
 		$price_id = '';
267 267
 
268 268
 		// Get price info
269
-		if( 0 <= $data['give-variable-price'] ) {
270
-			foreach ( $form->prices as $variable_price ) {
271
-				if( $new_total === give_maybe_sanitize_amount( $variable_price['_give_amount'] ) ) {
269
+		if (0 <= $data['give-variable-price']) {
270
+			foreach ($form->prices as $variable_price) {
271
+				if ($new_total === give_maybe_sanitize_amount($variable_price['_give_amount'])) {
272 272
 					$price_info = $variable_price;
273 273
 					break;
274 274
 				}
@@ -276,15 +276,15 @@  discard block
 block discarded – undo
276 276
 		}
277 277
 
278 278
 		// Set price id.
279
-		if( ! empty( $price_info ) ) {
279
+		if ( ! empty($price_info)) {
280 280
 			$price_id = $data['give-variable-price'];
281 281
 
282
-			if( $data['give-variable-price'] !== $price_info['_give_id']['level_id'] ) {
282
+			if ($data['give-variable-price'] !== $price_info['_give_id']['level_id']) {
283 283
 				// Set price id to amount match.
284 284
 				$price_id = $price_info['_give_id']['level_id'];
285 285
 			}
286 286
 
287
-		} elseif( $form->is_custom_price_mode() ){
287
+		} elseif ($form->is_custom_price_mode()) {
288 288
 			$price_id = 'custom';
289 289
 		}
290 290
 
@@ -292,11 +292,11 @@  discard block
 block discarded – undo
292 292
 		$payment_meta['price_id'] = $price_id;
293 293
 
294 294
 		// Update payment give form meta data.
295
-		$payment->update_meta( '_give_payment_price_id', $price_id );
296
-		$payment->update_meta( '_give_payment_meta', $payment_meta );
295
+		$payment->update_meta('_give_payment_price_id', $price_id);
296
+		$payment->update_meta('_give_payment_meta', $payment_meta);
297 297
 
298 298
 		// Re setup payment to update new meta value in object.
299
-		$payment->update_payment_setup( $payment->ID );
299
+		$payment->update_payment_setup($payment->ID);
300 300
 	}
301 301
 
302 302
 	/**
@@ -307,13 +307,13 @@  discard block
 block discarded – undo
307 307
 	 *
308 308
 	 * @param int $payment_id The ID of the payment.
309 309
 	 */
310
-	do_action( 'give_updated_edited_donation', $payment_id );
310
+	do_action('give_updated_edited_donation', $payment_id);
311 311
 
312
-	wp_safe_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&give-message=payment-updated&id=' . $payment_id ) );
312
+	wp_safe_redirect(admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&give-message=payment-updated&id='.$payment_id));
313 313
 	exit;
314 314
 }
315 315
 
316
-add_action( 'give_update_payment_details', 'give_update_payment_details' );
316
+add_action('give_update_payment_details', 'give_update_payment_details');
317 317
 
318 318
 /**
319 319
  * Trigger a Donation Deletion.
@@ -324,48 +324,48 @@  discard block
 block discarded – undo
324 324
  *
325 325
  * @return void
326 326
  */
327
-function give_trigger_donation_delete( $data ) {
328
-	if ( wp_verify_nonce( $data['_wpnonce'], 'give_donation_nonce' ) ) {
327
+function give_trigger_donation_delete($data) {
328
+	if (wp_verify_nonce($data['_wpnonce'], 'give_donation_nonce')) {
329 329
 
330
-		$payment_id = absint( $data['purchase_id'] );
330
+		$payment_id = absint($data['purchase_id']);
331 331
 
332
-		if ( ! current_user_can( 'edit_give_payments', $payment_id ) ) {
333
-			wp_die( __( 'You do not have permission to edit payments.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
332
+		if ( ! current_user_can('edit_give_payments', $payment_id)) {
333
+			wp_die(__('You do not have permission to edit payments.', 'give'), __('Error', 'give'), array('response' => 403));
334 334
 		}
335 335
 
336
-		give_delete_donation( $payment_id );
337
-		wp_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&give-message=donation_deleted' ) );
336
+		give_delete_donation($payment_id);
337
+		wp_redirect(admin_url('edit.php?post_type=give_forms&page=give-payment-history&give-message=donation_deleted'));
338 338
 		give_die();
339 339
 	}
340 340
 }
341 341
 
342
-add_action( 'give_delete_payment', 'give_trigger_donation_delete' );
342
+add_action('give_delete_payment', 'give_trigger_donation_delete');
343 343
 
344 344
 /**
345 345
  * AJAX Store Donation Note
346 346
  */
347 347
 function give_ajax_store_payment_note() {
348 348
 
349
-	$payment_id = absint( $_POST['payment_id'] );
350
-	$note       = wp_kses( $_POST['note'], array() );
349
+	$payment_id = absint($_POST['payment_id']);
350
+	$note       = wp_kses($_POST['note'], array());
351 351
 
352
-	if ( ! current_user_can( 'edit_give_payments', $payment_id ) ) {
353
-		wp_die( __( 'You do not have permission to edit payments.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
352
+	if ( ! current_user_can('edit_give_payments', $payment_id)) {
353
+		wp_die(__('You do not have permission to edit payments.', 'give'), __('Error', 'give'), array('response' => 403));
354 354
 	}
355 355
 
356
-	if ( empty( $payment_id ) ) {
357
-		die( '-1' );
356
+	if (empty($payment_id)) {
357
+		die('-1');
358 358
 	}
359 359
 
360
-	if ( empty( $note ) ) {
361
-		die( '-1' );
360
+	if (empty($note)) {
361
+		die('-1');
362 362
 	}
363 363
 
364
-	$note_id = give_insert_payment_note( $payment_id, $note );
365
-	die( give_get_payment_note_html( $note_id ) );
364
+	$note_id = give_insert_payment_note($payment_id, $note);
365
+	die(give_get_payment_note_html($note_id));
366 366
 }
367 367
 
368
-add_action( 'wp_ajax_give_insert_payment_note', 'give_ajax_store_payment_note' );
368
+add_action('wp_ajax_give_insert_payment_note', 'give_ajax_store_payment_note');
369 369
 
370 370
 /**
371 371
  * Triggers a donation note deletion without ajax
@@ -376,24 +376,24 @@  discard block
 block discarded – undo
376 376
  *
377 377
  * @return void
378 378
  */
379
-function give_trigger_payment_note_deletion( $data ) {
379
+function give_trigger_payment_note_deletion($data) {
380 380
 
381
-	if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_delete_payment_note_' . $data['note_id'] ) ) {
381
+	if ( ! wp_verify_nonce($data['_wpnonce'], 'give_delete_payment_note_'.$data['note_id'])) {
382 382
 		return;
383 383
 	}
384 384
 
385
-	if ( ! current_user_can( 'edit_give_payments', $data['payment_id'] ) ) {
386
-		wp_die( __( 'You do not have permission to edit payments.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
385
+	if ( ! current_user_can('edit_give_payments', $data['payment_id'])) {
386
+		wp_die(__('You do not have permission to edit payments.', 'give'), __('Error', 'give'), array('response' => 403));
387 387
 	}
388 388
 
389
-	$edit_order_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&give-message=donation-note-deleted&id=' . absint( $data['payment_id'] ) );
389
+	$edit_order_url = admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&give-message=donation-note-deleted&id='.absint($data['payment_id']));
390 390
 
391
-	give_delete_payment_note( $data['note_id'], $data['payment_id'] );
391
+	give_delete_payment_note($data['note_id'], $data['payment_id']);
392 392
 
393
-	wp_redirect( $edit_order_url );
393
+	wp_redirect($edit_order_url);
394 394
 }
395 395
 
396
-add_action( 'give_delete_payment_note', 'give_trigger_payment_note_deletion' );
396
+add_action('give_delete_payment_note', 'give_trigger_payment_note_deletion');
397 397
 
398 398
 /**
399 399
  * Delete a payment note deletion with ajax
@@ -404,16 +404,16 @@  discard block
 block discarded – undo
404 404
  */
405 405
 function give_ajax_delete_payment_note() {
406 406
 
407
-	if ( ! current_user_can( 'edit_give_payments', $_POST['payment_id'] ) ) {
408
-		wp_die( __( 'You do not have permission to edit payments.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
407
+	if ( ! current_user_can('edit_give_payments', $_POST['payment_id'])) {
408
+		wp_die(__('You do not have permission to edit payments.', 'give'), __('Error', 'give'), array('response' => 403));
409 409
 	}
410 410
 
411
-	if ( give_delete_payment_note( $_POST['note_id'], $_POST['payment_id'] ) ) {
412
-		die( '1' );
411
+	if (give_delete_payment_note($_POST['note_id'], $_POST['payment_id'])) {
412
+		die('1');
413 413
 	} else {
414
-		die( '-1' );
414
+		die('-1');
415 415
 	}
416 416
 
417 417
 }
418 418
 
419
-add_action( 'wp_ajax_give_delete_payment_note', 'give_ajax_delete_payment_note' );
419
+add_action('wp_ajax_give_delete_payment_note', 'give_ajax_delete_payment_note');
Please login to merge, or discard this patch.
includes/user-functions.php 1 patch
Spacing   +132 added lines, -132 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
 
@@ -30,54 +30,54 @@  discard block
 block discarded – undo
30 30
  *
31 31
  * @return bool|array List of all user donations.
32 32
  */
33
-function give_get_users_donations( $user = 0, $number = 20, $pagination = false, $status = 'complete' ) {
33
+function give_get_users_donations($user = 0, $number = 20, $pagination = false, $status = 'complete') {
34 34
 
35
-	if ( empty( $user ) ) {
35
+	if (empty($user)) {
36 36
 		$user = get_current_user_id();
37 37
 	}
38 38
 
39
-	if ( 0 === $user && ! Give()->email_access->token_exists ) {
39
+	if (0 === $user && ! Give()->email_access->token_exists) {
40 40
 		return false;
41 41
 	}
42 42
 
43
-	$status = ( 'complete' === $status ) ? 'publish' : $status;
43
+	$status = ('complete' === $status) ? 'publish' : $status;
44 44
 	$paged = 1;
45 45
 
46
-	if ( $pagination ) {
47
-		if ( get_query_var( 'paged' ) ) {
48
-			$paged = get_query_var( 'paged' );
49
-		} elseif ( get_query_var( 'page' ) ) {
50
-			$paged = get_query_var( 'page' );
46
+	if ($pagination) {
47
+		if (get_query_var('paged')) {
48
+			$paged = get_query_var('paged');
49
+		} elseif (get_query_var('page')) {
50
+			$paged = get_query_var('page');
51 51
 		}
52 52
 	}
53 53
 
54
-	$args = apply_filters( 'give_get_users_donations_args', array(
54
+	$args = apply_filters('give_get_users_donations_args', array(
55 55
 		'user'    => $user,
56 56
 		'number'  => $number,
57 57
 		'status'  => $status,
58 58
 		'orderby' => 'date',
59
-	) );
59
+	));
60 60
 
61
-	if ( $pagination ) {
61
+	if ($pagination) {
62 62
 		$args['page'] = $paged;
63 63
 	} else {
64 64
 		$args['nopaging'] = true;
65 65
 	}
66 66
 
67
-	$by_user_id = is_numeric( $user ) ? true : false;
68
-	$donor   = new Give_Donor( $user, $by_user_id );
67
+	$by_user_id = is_numeric($user) ? true : false;
68
+	$donor = new Give_Donor($user, $by_user_id);
69 69
 
70
-	if ( ! empty( $donor->payment_ids ) ) {
70
+	if ( ! empty($donor->payment_ids)) {
71 71
 
72
-		unset( $args['user'] );
73
-		$args['post__in'] = array_map( 'absint', explode( ',', $donor->payment_ids ) );
72
+		unset($args['user']);
73
+		$args['post__in'] = array_map('absint', explode(',', $donor->payment_ids));
74 74
 
75 75
 	}
76 76
 
77
-	$donations = give_get_payments( apply_filters( 'give_get_users_donations_args', $args ) );
77
+	$donations = give_get_payments(apply_filters('give_get_users_donations_args', $args));
78 78
 
79 79
 	// No donations.
80
-	if ( ! $donations ) {
80
+	if ( ! $donations) {
81 81
 		return false;
82 82
 	}
83 83
 
@@ -96,65 +96,65 @@  discard block
 block discarded – undo
96 96
  *
97 97
  * @return bool|object List of unique forms donated by user
98 98
  */
99
-function give_get_users_completed_donations( $user = 0, $status = 'complete' ) {
100
-	if ( empty( $user ) ) {
99
+function give_get_users_completed_donations($user = 0, $status = 'complete') {
100
+	if (empty($user)) {
101 101
 		$user = get_current_user_id();
102 102
 	}
103 103
 
104
-	if ( empty( $user ) ) {
104
+	if (empty($user)) {
105 105
 		return false;
106 106
 	}
107 107
 
108
-	$by_user_id = is_numeric( $user ) ? true : false;
108
+	$by_user_id = is_numeric($user) ? true : false;
109 109
 
110
-	$donor = new Give_Donor( $user, $by_user_id );
110
+	$donor = new Give_Donor($user, $by_user_id);
111 111
 
112
-	if ( empty( $donor->payment_ids ) ) {
112
+	if (empty($donor->payment_ids)) {
113 113
 		return false;
114 114
 	}
115 115
 
116 116
 	// Get all the items donated.
117
-	$payment_ids    = array_reverse( explode( ',', $donor->payment_ids ) );
118
-	$limit_payments = apply_filters( 'give_users_completed_donations_payments', 50 );
119
-	if ( ! empty( $limit_payments ) ) {
120
-		$payment_ids = array_slice( $payment_ids, 0, $limit_payments );
117
+	$payment_ids    = array_reverse(explode(',', $donor->payment_ids));
118
+	$limit_payments = apply_filters('give_users_completed_donations_payments', 50);
119
+	if ( ! empty($limit_payments)) {
120
+		$payment_ids = array_slice($payment_ids, 0, $limit_payments);
121 121
 	}
122 122
 	$donation_data = array();
123
-	foreach ( $payment_ids as $payment_id ) {
124
-		$donation_data[] = give_get_payment_meta( $payment_id );
123
+	foreach ($payment_ids as $payment_id) {
124
+		$donation_data[] = give_get_payment_meta($payment_id);
125 125
 	}
126 126
 
127
-	if ( empty( $donation_data ) ) {
127
+	if (empty($donation_data)) {
128 128
 		return false;
129 129
 	}
130 130
 
131 131
 	// Grab only the post ids "form_id" of the forms donated on this order.
132 132
 	$completed_donations_ids = array();
133
-	foreach ( $donation_data as $donation_meta ) {
134
-		$completed_donations_ids[] = isset( $donation_meta['form_id'] ) ? $donation_meta['form_id'] : '';
133
+	foreach ($donation_data as $donation_meta) {
134
+		$completed_donations_ids[] = isset($donation_meta['form_id']) ? $donation_meta['form_id'] : '';
135 135
 	}
136 136
 
137
-	if ( empty( $completed_donations_ids ) ) {
137
+	if (empty($completed_donations_ids)) {
138 138
 		return false;
139 139
 	}
140 140
 
141 141
 	// Only include each donation once.
142
-	$form_ids = array_unique( $completed_donations_ids );
142
+	$form_ids = array_unique($completed_donations_ids);
143 143
 
144 144
 	// Make sure we still have some products and a first item.
145
-	if ( empty( $form_ids ) || ! isset( $form_ids[0] ) ) {
145
+	if (empty($form_ids) || ! isset($form_ids[0])) {
146 146
 		return false;
147 147
 	}
148 148
 
149
-	$post_type = get_post_type( $form_ids[0] );
149
+	$post_type = get_post_type($form_ids[0]);
150 150
 
151
-	$args = apply_filters( 'give_get_users_completed_donations_args', array(
151
+	$args = apply_filters('give_get_users_completed_donations_args', array(
152 152
 		'include'        => $form_ids,
153 153
 		'post_type'      => $post_type,
154
-		'posts_per_page' => - 1,
155
-	) );
154
+		'posts_per_page' => -1,
155
+	));
156 156
 
157
-	return apply_filters( 'give_users_completed_donations_list', get_posts( $args ) );
157
+	return apply_filters('give_users_completed_donations_list', get_posts($args));
158 158
 }
159 159
 
160 160
 
@@ -170,12 +170,12 @@  discard block
 block discarded – undo
170 170
  *
171 171
  * @return bool True if has donated, false other wise.
172 172
  */
173
-function give_has_donations( $user_id = null ) {
174
-	if ( empty( $user_id ) ) {
173
+function give_has_donations($user_id = null) {
174
+	if (empty($user_id)) {
175 175
 		$user_id = get_current_user_id();
176 176
 	}
177 177
 
178
-	if ( give_get_users_donations( $user_id, 1 ) ) {
178
+	if (give_get_users_donations($user_id, 1)) {
179 179
 		return true; // User has at least one donation.
180 180
 	}
181 181
 
@@ -196,23 +196,23 @@  discard block
 block discarded – undo
196 196
  *
197 197
  * @return array
198 198
  */
199
-function give_get_donation_stats_by_user( $user = '' ) {
199
+function give_get_donation_stats_by_user($user = '') {
200 200
 
201 201
 	$field = '';
202 202
 
203
-	if ( is_email( $user ) ) {
203
+	if (is_email($user)) {
204 204
 		$field = 'email';
205
-	} elseif ( is_numeric( $user ) ) {
205
+	} elseif (is_numeric($user)) {
206 206
 		$field = 'user_id';
207 207
 	}
208 208
 
209
-	$stats    = array();
210
-	$donor = Give()->donors->get_donor_by( $field, $user );
209
+	$stats = array();
210
+	$donor = Give()->donors->get_donor_by($field, $user);
211 211
 
212
-	if ( $donor ) {
213
-		$donor = new Give_Donor( $donor->id );
214
-		$stats['purchases']   = absint( $donor->purchase_count );
215
-		$stats['total_spent'] = give_maybe_sanitize_amount( $donor->get_total_donation_amount() );
212
+	if ($donor) {
213
+		$donor = new Give_Donor($donor->id);
214
+		$stats['purchases']   = absint($donor->purchase_count);
215
+		$stats['total_spent'] = give_maybe_sanitize_amount($donor->get_total_donation_amount());
216 216
 	}
217 217
 
218 218
 	/**
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 	 *
221 221
 	 * @since 1.7
222 222
 	 */
223
-	$stats = (array) apply_filters( 'give_donation_stats_by_user', $stats, $user );
223
+	$stats = (array) apply_filters('give_donation_stats_by_user', $stats, $user);
224 224
 
225 225
 	return $stats;
226 226
 }
@@ -238,21 +238,21 @@  discard block
 block discarded – undo
238 238
  *
239 239
  * @return int The total number of donations.
240 240
  */
241
-function give_count_donations_of_donor( $user = null ) {
241
+function give_count_donations_of_donor($user = null) {
242 242
 
243 243
 	// Logged in?
244
-	if ( empty( $user ) ) {
244
+	if (empty($user)) {
245 245
 		$user = get_current_user_id();
246 246
 	}
247 247
 
248 248
 	// Email access?
249
-	if ( empty( $user ) && Give()->email_access->token_email ) {
249
+	if (empty($user) && Give()->email_access->token_email) {
250 250
 		$user = Give()->email_access->token_email;
251 251
 	}
252 252
 
253
-	$stats = ! empty( $user ) ? give_get_donation_stats_by_user( $user ) : false;
253
+	$stats = ! empty($user) ? give_get_donation_stats_by_user($user) : false;
254 254
 
255
-	return isset( $stats['purchases'] ) ? $stats['purchases'] : 0;
255
+	return isset($stats['purchases']) ? $stats['purchases'] : 0;
256 256
 }
257 257
 
258 258
 /**
@@ -265,9 +265,9 @@  discard block
 block discarded – undo
265 265
  *
266 266
  * @return float The total amount the user has spent
267 267
  */
268
-function give_donation_total_of_user( $user = null ) {
268
+function give_donation_total_of_user($user = null) {
269 269
 
270
-	$stats = give_get_donation_stats_by_user( $user );
270
+	$stats = give_get_donation_stats_by_user($user);
271 271
 
272 272
 	return $stats['total_spent'];
273 273
 }
@@ -283,40 +283,40 @@  discard block
 block discarded – undo
283 283
  *
284 284
  * @return bool
285 285
  */
286
-function give_validate_username( $username, $form_id = 0 ) {
286
+function give_validate_username($username, $form_id = 0) {
287 287
 	$valid = true;
288 288
 
289 289
 	// Validate username.
290
-	if ( ! empty( $username ) ) {
290
+	if ( ! empty($username)) {
291 291
 
292 292
 		// Sanitize username.
293
-		$sanitized_user_name = sanitize_user( $username, false );
293
+		$sanitized_user_name = sanitize_user($username, false);
294 294
 
295 295
 		// We have an user name, check if it already exists.
296
-		if ( username_exists( $username ) ) {
296
+		if (username_exists($username)) {
297 297
 			// Username already registered.
298
-			give_set_error( 'username_unavailable', __( 'Username already taken.', 'give' ) );
298
+			give_set_error('username_unavailable', __('Username already taken.', 'give'));
299 299
 			$valid = false;
300 300
 
301 301
 			// Check if it's valid.
302
-		} elseif ( $sanitized_user_name !== $username ) {
302
+		} elseif ($sanitized_user_name !== $username) {
303 303
 			// Invalid username.
304
-			if ( is_multisite() ) {
305
-				give_set_error( 'username_invalid', __( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ) );
304
+			if (is_multisite()) {
305
+				give_set_error('username_invalid', __('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give'));
306 306
 				$valid = false;
307 307
 			} else {
308
-				give_set_error( 'username_invalid', __( 'Invalid username.', 'give' ) );
308
+				give_set_error('username_invalid', __('Invalid username.', 'give'));
309 309
 				$valid = false;
310 310
 			}
311 311
 		}
312 312
 	} else {
313 313
 		// Username is empty.
314
-		give_set_error( 'username_empty', __( 'Enter a username.', 'give' ) );
314
+		give_set_error('username_empty', __('Enter a username.', 'give'));
315 315
 		$valid = false;
316 316
 
317 317
 		// Check if guest checkout is disable for form.
318
-		if ( $form_id && give_logged_in_only( $form_id ) ) {
319
-			give_set_error( 'registration_required', __( 'You must register or login to complete your donation.', 'give' ) );
318
+		if ($form_id && give_logged_in_only($form_id)) {
319
+			give_set_error('registration_required', __('You must register or login to complete your donation.', 'give'));
320 320
 			$valid = false;
321 321
 		}
322 322
 	}
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 	 *
331 331
 	 * @since 1.8
332 332
 	 */
333
-	$valid = (bool) apply_filters( 'give_validate_username', $valid, $username, $form_id );
333
+	$valid = (bool) apply_filters('give_validate_username', $valid, $username, $form_id);
334 334
 
335 335
 	return $valid;
336 336
 }
@@ -346,30 +346,30 @@  discard block
 block discarded – undo
346 346
  *
347 347
  * @return bool
348 348
  */
349
-function give_validate_user_email( $email, $registering_new_user = false ) {
349
+function give_validate_user_email($email, $registering_new_user = false) {
350 350
 	$valid = true;
351 351
 
352
-	if ( empty( $email ) ) {
352
+	if (empty($email)) {
353 353
 		// No email.
354
-		give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) );
354
+		give_set_error('email_empty', __('Enter an email.', 'give'));
355 355
 		$valid = false;
356 356
 
357
-	} elseif ( email_exists( $email ) ) {
357
+	} elseif (email_exists($email)) {
358 358
 		// Email already exists.
359
-		give_set_error( 'email_exists', __( 'Email already exists.', 'give' ) );
359
+		give_set_error('email_exists', __('Email already exists.', 'give'));
360 360
 		$valid = false;
361 361
 
362
-	} elseif ( ! is_email( $email ) ) {
362
+	} elseif ( ! is_email($email)) {
363 363
 		// Validate email.
364
-		give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) );
364
+		give_set_error('email_invalid', __('Invalid email.', 'give'));
365 365
 		$valid = false;
366 366
 
367
-	} elseif ( $registering_new_user ) {
367
+	} elseif ($registering_new_user) {
368 368
 
369 369
 		// If donor email is not primary.
370
-		if ( ! email_exists( $email ) && give_donor_email_exists( $email ) && give_is_additional_email( $email ) ) {
370
+		if ( ! email_exists($email) && give_donor_email_exists($email) && give_is_additional_email($email)) {
371 371
 			// Check if email exists.
372
-			give_set_error( 'email_used', __( 'The email address provided is already active for another user.', 'give' ) );
372
+			give_set_error('email_used', __('The email address provided is already active for another user.', 'give'));
373 373
 			$valid = false;
374 374
 		}
375 375
 	}
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 	 *
384 384
 	 * @since 1.8
385 385
 	 */
386
-	$valid = (bool) apply_filters( 'give_validate_user_email', $valid, $email, $registering_new_user );
386
+	$valid = (bool) apply_filters('give_validate_user_email', $valid, $email, $registering_new_user);
387 387
 
388 388
 	return $valid;
389 389
 }
@@ -399,34 +399,34 @@  discard block
 block discarded – undo
399 399
  *
400 400
  * @return bool
401 401
  */
402
-function give_validate_user_password( $password = '', $confirm_password = '', $registering_new_user = false ) {
402
+function give_validate_user_password($password = '', $confirm_password = '', $registering_new_user = false) {
403 403
 	$valid = true;
404 404
 
405 405
 	// Passwords Validation For New Donors Only.
406
-	if ( $registering_new_user ) {
406
+	if ($registering_new_user) {
407 407
 		// Password or confirmation missing.
408
-		if ( ! $password ) {
408
+		if ( ! $password) {
409 409
 			// The password is invalid.
410
-			give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) );
410
+			give_set_error('password_empty', __('Enter a password.', 'give'));
411 411
 			$valid = false;
412
-		} elseif ( ! $confirm_password ) {
412
+		} elseif ( ! $confirm_password) {
413 413
 			// Confirmation password is invalid.
414
-			give_set_error( 'confirmation_empty', __( 'Enter the password confirmation.', 'give' ) );
414
+			give_set_error('confirmation_empty', __('Enter the password confirmation.', 'give'));
415 415
 			$valid = false;
416 416
 		}
417 417
 	}
418 418
 	// Passwords Validation For New Donors as well as Existing Donors.
419
-	if ( $password || $confirm_password ) {
420
-		if ( strlen( $password ) < 6 || strlen( $confirm_password ) < 6 ) {
419
+	if ($password || $confirm_password) {
420
+		if (strlen($password) < 6 || strlen($confirm_password) < 6) {
421 421
 			// Seems Weak Password.
422
-			give_set_error( 'password_weak', __( 'Passwords should have at least 6 characters.', 'give' ) );
422
+			give_set_error('password_weak', __('Passwords should have at least 6 characters.', 'give'));
423 423
 			$valid = false;
424 424
 		}
425
-		if ( $password && $confirm_password ) {
425
+		if ($password && $confirm_password) {
426 426
 			// Verify confirmation matches.
427
-			if ( $password !== $confirm_password ) {
427
+			if ($password !== $confirm_password) {
428 428
 				// Passwords do not match.
429
-				give_set_error( 'password_mismatch', __( 'Passwords you entered do not match. Please try again.', 'give' ) );
429
+				give_set_error('password_mismatch', __('Passwords you entered do not match. Please try again.', 'give'));
430 430
 				$valid = false;
431 431
 			}
432 432
 		}
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
 	 *
443 443
 	 * @since 1.8
444 444
 	 */
445
-	$valid = (bool) apply_filters( 'give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user );
445
+	$valid = (bool) apply_filters('give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user);
446 446
 
447 447
 	return $valid;
448 448
 }
@@ -471,8 +471,8 @@  discard block
 block discarded – undo
471 471
  *
472 472
  * @return array The donor's address, if any
473 473
  */
474
-function give_get_donor_address( $donor_id = null, $args = array() ) {
475
-	if ( empty( $donor_id ) ) {
474
+function give_get_donor_address($donor_id = null, $args = array()) {
475
+	if (empty($donor_id)) {
476 476
 		$donor_id = get_current_user_id();
477 477
 	}
478 478
 
@@ -493,34 +493,34 @@  discard block
 block discarded – undo
493 493
 	);
494 494
 
495 495
 	// Backward compatibility for user id param.
496
-	$by_user_id = get_user_by( 'id', $donor_id ) ? true : false;
496
+	$by_user_id = get_user_by('id', $donor_id) ? true : false;
497 497
 
498 498
 	// Backward compatibility.
499
-	if( ! give_has_upgrade_completed( 'v20_upgrades_user_address' ) && $by_user_id ){
499
+	if ( ! give_has_upgrade_completed('v20_upgrades_user_address') && $by_user_id) {
500 500
 		return wp_parse_args(
501
-			(array) get_user_meta( $donor_id, '_give_user_address', true ),
501
+			(array) get_user_meta($donor_id, '_give_user_address', true),
502 502
 			$default_address
503 503
 		);
504 504
 	}
505 505
 
506
-	$donor = new Give_Donor( $donor_id, $by_user_id );
506
+	$donor = new Give_Donor($donor_id, $by_user_id);
507 507
 
508 508
 
509 509
 	if (
510 510
 		! $donor->id ||
511
-		empty( $donor->address ) ||
512
-		! array_key_exists( $args['address_type'], $donor->address )
511
+		empty($donor->address) ||
512
+		! array_key_exists($args['address_type'], $donor->address)
513 513
 	) {
514 514
 		return $default_address;
515 515
 	}
516 516
 
517
-	switch ( true ){
518
-		case is_string( end( $donor->address[ $args['address_type'] ] ) ) :
519
-			$address = wp_parse_args( $donor->address[ $args['address_type'] ], $default_address );
517
+	switch (true) {
518
+		case is_string(end($donor->address[$args['address_type']])) :
519
+			$address = wp_parse_args($donor->address[$args['address_type']], $default_address);
520 520
 			break;
521 521
 
522
-		case is_array( end( $donor->address[ $args['address_type'] ] ) ) :
523
-			$address = wp_parse_args( array_shift( $donor->address[ $args['address_type'] ] ), $default_address );
522
+		case is_array(end($donor->address[$args['address_type']])) :
523
+			$address = wp_parse_args(array_shift($donor->address[$args['address_type']]), $default_address);
524 524
 			break;
525 525
 	}
526 526
 
@@ -540,17 +540,17 @@  discard block
 block discarded – undo
540 540
  *
541 541
  * @return void
542 542
  */
543
-function give_new_user_notification( $user_id = 0, $user_data = array() ) {
543
+function give_new_user_notification($user_id = 0, $user_data = array()) {
544 544
 	// Bailout.
545
-	if ( empty( $user_id ) || empty( $user_data ) ) {
545
+	if (empty($user_id) || empty($user_data)) {
546 546
 		return;
547 547
 	}
548 548
 
549
-	do_action( 'give_new-donor-register_email_notification', $user_id, $user_data );
550
-	do_action( 'give_donor-register_email_notification', $user_id, $user_data );
549
+	do_action('give_new-donor-register_email_notification', $user_id, $user_data);
550
+	do_action('give_donor-register_email_notification', $user_id, $user_data);
551 551
 }
552 552
 
553
-add_action( 'give_insert_user', 'give_new_user_notification', 10, 2 );
553
+add_action('give_insert_user', 'give_new_user_notification', 10, 2);
554 554
 
555 555
 
556 556
 /**
@@ -566,36 +566,36 @@  discard block
 block discarded – undo
566 566
  *
567 567
  * @return string
568 568
  */
569
-function give_get_donor_name_by( $id = 0, $from = 'donation' ) {
569
+function give_get_donor_name_by($id = 0, $from = 'donation') {
570 570
 
571 571
 	// ID shouldn't be empty.
572
-	if ( empty( $id ) ) {
572
+	if (empty($id)) {
573 573
 		return '';
574 574
 	}
575 575
 
576 576
 	$name = '';
577 577
 
578
-	switch ( $from ) {
578
+	switch ($from) {
579 579
 
580 580
 		case 'donation':
581
-			$donation_info = new Give_Payment( $id );
582
-			$first_name    = $donation_info->get_meta( '_give_donor_billing_first_name', true );
583
-			$last_name     = $donation_info->get_meta( '_give_donor_billing_last_name', true );
581
+			$donation_info = new Give_Payment($id);
582
+			$first_name    = $donation_info->get_meta('_give_donor_billing_first_name', true);
583
+			$last_name     = $donation_info->get_meta('_give_donor_billing_last_name', true);
584 584
 
585
-			$name = trim( "{$first_name} {$last_name}" );
585
+			$name = trim("{$first_name} {$last_name}");
586 586
 
587 587
 			break;
588 588
 
589 589
 		case 'donor':
590 590
 
591
-			$donor = new Give_Donor( $id );
591
+			$donor = new Give_Donor($id);
592 592
 			$name = $donor->name;
593 593
 
594 594
 			break;
595 595
 
596 596
 	}
597 597
 
598
-	return trim( $name );
598
+	return trim($name);
599 599
 
600 600
 }
601 601
 
@@ -608,8 +608,8 @@  discard block
 block discarded – undo
608 608
  *
609 609
  * @return boolean  The user's ID on success, and false on failure.
610 610
  */
611
-function give_donor_email_exists( $email ) {
612
-	if ( Give()->donors->get_donor_by( 'email', $email ) ) {
611
+function give_donor_email_exists($email) {
612
+	if (Give()->donors->get_donor_by('email', $email)) {
613 613
 		return true;
614 614
 	}
615 615
 	return false;
@@ -624,14 +624,14 @@  discard block
 block discarded – undo
624 624
  *
625 625
  * @return bool
626 626
  */
627
-function give_is_additional_email( $email ) {
627
+function give_is_additional_email($email) {
628 628
 	global $wpdb;
629 629
 
630 630
 	$meta_table = Give()->donor_meta->table_name;
631 631
 	$meta_type  = Give()->donor_meta->meta_type;
632
-	$donor_id   = $wpdb->get_var( $wpdb->prepare( "SELECT {$meta_type}_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $email ) );
632
+	$donor_id   = $wpdb->get_var($wpdb->prepare("SELECT {$meta_type}_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $email));
633 633
 
634
-	if ( empty( $donor_id ) ) {
634
+	if (empty($donor_id)) {
635 635
 		return false;
636 636
 	}
637 637
 
Please login to merge, or discard this patch.
includes/api/class-give-api.php 2 patches
Spacing   +521 added lines, -521 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
 
@@ -141,27 +141,27 @@  discard block
 block discarded – undo
141 141
 			'v1' => 'GIVE_API_V1',
142 142
 		);
143 143
 
144
-		foreach ( $this->get_versions() as $version => $class ) {
145
-			require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api-' . $version . '.php';
144
+		foreach ($this->get_versions() as $version => $class) {
145
+			require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api-'.$version.'.php';
146 146
 		}
147 147
 
148
-		add_action( 'init', array( $this, 'add_endpoint' ) );
149
-		add_action( 'wp', array( $this, 'process_query' ), - 1 );
150
-		add_filter( 'query_vars', array( $this, 'query_vars' ) );
151
-		add_action( 'show_user_profile', array( $this, 'user_key_field' ) );
152
-		add_action( 'edit_user_profile', array( $this, 'user_key_field' ) );
153
-		add_action( 'personal_options_update', array( $this, 'generate_api_key' ) );
154
-		add_action( 'edit_user_profile_update', array( $this, 'generate_api_key' ) );
155
-		add_action( 'give_process_api_key', array( $this, 'process_api_key' ) );
148
+		add_action('init', array($this, 'add_endpoint'));
149
+		add_action('wp', array($this, 'process_query'), - 1);
150
+		add_filter('query_vars', array($this, 'query_vars'));
151
+		add_action('show_user_profile', array($this, 'user_key_field'));
152
+		add_action('edit_user_profile', array($this, 'user_key_field'));
153
+		add_action('personal_options_update', array($this, 'generate_api_key'));
154
+		add_action('edit_user_profile_update', array($this, 'generate_api_key'));
155
+		add_action('give_process_api_key', array($this, 'process_api_key'));
156 156
 
157 157
 		// Setup a backwards compatibility check for user API Keys
158
-		add_filter( 'get_user_metadata', array( $this, 'api_key_backwards_compat' ), 10, 4 );
158
+		add_filter('get_user_metadata', array($this, 'api_key_backwards_compat'), 10, 4);
159 159
 
160 160
 		// Determine if JSON_PRETTY_PRINT is available
161
-		$this->pretty_print = defined( 'JSON_PRETTY_PRINT' ) ? JSON_PRETTY_PRINT : null;
161
+		$this->pretty_print = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : null;
162 162
 
163 163
 		// Allow API request logging to be turned off
164
-		$this->log_requests = apply_filters( 'give_api_log_requests', $this->log_requests );
164
+		$this->log_requests = apply_filters('give_api_log_requests', $this->log_requests);
165 165
 
166 166
 		// Setup Give_Payment_Stats instance
167 167
 		$this->stats = new Give_Payment_Stats();
@@ -179,17 +179,17 @@  discard block
 block discarded – undo
179 179
 	 *
180 180
 	 * @return mixed
181 181
 	 */
182
-	public function __call( $name, $arguments ) {
182
+	public function __call($name, $arguments) {
183 183
 		$deprecated_function_arr = array(
184 184
 			'get_customers',
185 185
 		);
186 186
 
187
-		if ( in_array( $name, $deprecated_function_arr, true ) ) {
188
-			switch ( $name ) {
187
+		if (in_array($name, $deprecated_function_arr, true)) {
188
+			switch ($name) {
189 189
 				case 'get_customers':
190
-					$args = ! empty( $arguments[0] ) ? $arguments[0] : array();
190
+					$args = ! empty($arguments[0]) ? $arguments[0] : array();
191 191
 
192
-					return $this->get_donors( $args );
192
+					return $this->get_donors($args);
193 193
 			}
194 194
 		}
195 195
 	}
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 	 * @since  1.1
203 203
 	 */
204 204
 	public function add_endpoint() {
205
-		add_rewrite_endpoint( 'give-api', EP_ALL );
205
+		add_rewrite_endpoint('give-api', EP_ALL);
206 206
 	}
207 207
 
208 208
 	/**
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 	 *
216 216
 	 * @return string[] $vars New query vars
217 217
 	 */
218
-	public function query_vars( $vars ) {
218
+	public function query_vars($vars) {
219 219
 
220 220
 		$vars[] = 'token';
221 221
 		$vars[] = 'key';
@@ -266,11 +266,11 @@  discard block
 block discarded – undo
266 266
 	 */
267 267
 	public function get_default_version() {
268 268
 
269
-		$version = get_option( 'give_default_api_version' );
269
+		$version = get_option('give_default_api_version');
270 270
 
271
-		if ( defined( 'GIVE_API_VERSION' ) ) {
271
+		if (defined('GIVE_API_VERSION')) {
272 272
 			$version = GIVE_API_VERSION;
273
-		} elseif ( ! $version ) {
273
+		} elseif ( ! $version) {
274 274
 			$version = 'v1';
275 275
 		}
276 276
 
@@ -291,14 +291,14 @@  discard block
 block discarded – undo
291 291
 
292 292
 		$version = $wp_query->query_vars['give-api'];
293 293
 
294
-		if ( strpos( $version, '/' ) ) {
294
+		if (strpos($version, '/')) {
295 295
 
296
-			$version = explode( '/', $version );
297
-			$version = strtolower( $version[0] );
296
+			$version = explode('/', $version);
297
+			$version = strtolower($version[0]);
298 298
 
299
-			$wp_query->query_vars['give-api'] = str_replace( $version . '/', '', $wp_query->query_vars['give-api'] );
299
+			$wp_query->query_vars['give-api'] = str_replace($version.'/', '', $wp_query->query_vars['give-api']);
300 300
 
301
-			if ( array_key_exists( $version, $this->versions ) ) {
301
+			if (array_key_exists($version, $this->versions)) {
302 302
 
303 303
 				$this->queried_version = $version;
304 304
 
@@ -334,16 +334,16 @@  discard block
 block discarded – undo
334 334
 		$this->override = false;
335 335
 
336 336
 		// Make sure we have both user and api key
337
-		if ( ! empty( $wp_query->query_vars['give-api'] ) && ( $wp_query->query_vars['give-api'] !== 'forms' || ! empty( $wp_query->query_vars['token'] ) ) ) {
337
+		if ( ! empty($wp_query->query_vars['give-api']) && ($wp_query->query_vars['give-api'] !== 'forms' || ! empty($wp_query->query_vars['token']))) {
338 338
 
339
-			if ( empty( $wp_query->query_vars['token'] ) || empty( $wp_query->query_vars['key'] ) ) {
339
+			if (empty($wp_query->query_vars['token']) || empty($wp_query->query_vars['key'])) {
340 340
 				$this->missing_auth();
341 341
 
342 342
 				return false;
343 343
 			}
344 344
 
345 345
 			// Retrieve the user by public API key and ensure they exist
346
-			if ( ! ( $user = $this->get_user( $wp_query->query_vars['key'] ) ) ) {
346
+			if ( ! ($user = $this->get_user($wp_query->query_vars['key']))) {
347 347
 
348 348
 				$this->invalid_key();
349 349
 
@@ -351,11 +351,11 @@  discard block
 block discarded – undo
351 351
 
352 352
 			} else {
353 353
 
354
-				$token  = urldecode( $wp_query->query_vars['token'] );
355
-				$secret = $this->get_user_secret_key( $user );
356
-				$public = urldecode( $wp_query->query_vars['key'] );
354
+				$token  = urldecode($wp_query->query_vars['token']);
355
+				$secret = $this->get_user_secret_key($user);
356
+				$public = urldecode($wp_query->query_vars['key']);
357 357
 
358
-				if ( hash_equals( md5( $secret . $public ), $token ) ) {
358
+				if (hash_equals(md5($secret.$public), $token)) {
359 359
 					$this->is_valid_request = true;
360 360
 				} else {
361 361
 					$this->invalid_auth();
@@ -364,9 +364,9 @@  discard block
 block discarded – undo
364 364
 				}
365 365
 
366 366
 			}
367
-		} elseif ( ! empty( $wp_query->query_vars['give-api'] ) && $wp_query->query_vars['give-api'] === 'forms' ) {
367
+		} elseif ( ! empty($wp_query->query_vars['give-api']) && $wp_query->query_vars['give-api'] === 'forms') {
368 368
 			$this->is_valid_request = true;
369
-			$wp_query->set( 'key', 'public' );
369
+			$wp_query->set('key', 'public');
370 370
 		}
371 371
 	}
372 372
 
@@ -382,25 +382,25 @@  discard block
 block discarded – undo
382 382
 	 *
383 383
 	 * @return bool if user ID is found, false otherwise
384 384
 	 */
385
-	public function get_user( $key = '' ) {
385
+	public function get_user($key = '') {
386 386
 		global $wpdb, $wp_query;
387 387
 
388
-		if ( empty( $key ) ) {
389
-			$key = urldecode( $wp_query->query_vars['key'] );
388
+		if (empty($key)) {
389
+			$key = urldecode($wp_query->query_vars['key']);
390 390
 		}
391 391
 
392
-		if ( empty( $key ) ) {
392
+		if (empty($key)) {
393 393
 			return false;
394 394
 		}
395 395
 
396
-		$user = Give_Cache::get( md5( 'give_api_user_' . $key ), true );
396
+		$user = Give_Cache::get(md5('give_api_user_'.$key), true);
397 397
 
398
-		if ( false === $user ) {
399
-			$user = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key ) );
400
-			Give_Cache::set( md5( 'give_api_user_' . $key ), $user, DAY_IN_SECONDS, true );
398
+		if (false === $user) {
399
+			$user = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key));
400
+			Give_Cache::set(md5('give_api_user_'.$key), $user, DAY_IN_SECONDS, true);
401 401
 		}
402 402
 
403
-		if ( $user != null ) {
403
+		if ($user != null) {
404 404
 			$this->user_id = $user;
405 405
 
406 406
 			return $user;
@@ -416,19 +416,19 @@  discard block
 block discarded – undo
416 416
 	 *
417 417
 	 * @return mixed|null|string
418 418
 	 */
419
-	public function get_user_public_key( $user_id = 0 ) {
419
+	public function get_user_public_key($user_id = 0) {
420 420
 		global $wpdb;
421 421
 
422
-		if ( empty( $user_id ) ) {
422
+		if (empty($user_id)) {
423 423
 			return '';
424 424
 		}
425 425
 
426
-		$cache_key       = md5( 'give_api_user_public_key' . $user_id );
427
-		$user_public_key = Give_Cache::get( $cache_key, true );
426
+		$cache_key       = md5('give_api_user_public_key'.$user_id);
427
+		$user_public_key = Give_Cache::get($cache_key, true);
428 428
 
429
-		if ( empty( $user_public_key ) ) {
430
-			$user_public_key = $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_public_key' AND user_id = %d", $user_id ) );
431
-			Give_Cache::set( $cache_key, $user_public_key, HOUR_IN_SECONDS, true );
429
+		if (empty($user_public_key)) {
430
+			$user_public_key = $wpdb->get_var($wpdb->prepare("SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_public_key' AND user_id = %d", $user_id));
431
+			Give_Cache::set($cache_key, $user_public_key, HOUR_IN_SECONDS, true);
432 432
 		}
433 433
 
434 434
 		return $user_public_key;
@@ -441,19 +441,19 @@  discard block
 block discarded – undo
441 441
 	 *
442 442
 	 * @return mixed|null|string
443 443
 	 */
444
-	public function get_user_secret_key( $user_id = 0 ) {
444
+	public function get_user_secret_key($user_id = 0) {
445 445
 		global $wpdb;
446 446
 
447
-		if ( empty( $user_id ) ) {
447
+		if (empty($user_id)) {
448 448
 			return '';
449 449
 		}
450 450
 
451
-		$cache_key       = md5( 'give_api_user_secret_key' . $user_id );
452
-		$user_secret_key = Give_Cache::get( $cache_key, true );
451
+		$cache_key       = md5('give_api_user_secret_key'.$user_id);
452
+		$user_secret_key = Give_Cache::get($cache_key, true);
453 453
 
454
-		if ( empty( $user_secret_key ) ) {
455
-			$user_secret_key = $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_secret_key' AND user_id = %d", $user_id ) );
456
-			Give_Cache::set( $cache_key, $user_secret_key, HOUR_IN_SECONDS, true );
454
+		if (empty($user_secret_key)) {
455
+			$user_secret_key = $wpdb->get_var($wpdb->prepare("SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_secret_key' AND user_id = %d", $user_id));
456
+			Give_Cache::set($cache_key, $user_secret_key, HOUR_IN_SECONDS, true);
457 457
 		}
458 458
 
459 459
 		return $user_secret_key;
@@ -469,10 +469,10 @@  discard block
 block discarded – undo
469 469
 	 */
470 470
 	private function missing_auth() {
471 471
 		$error          = array();
472
-		$error['error'] = __( 'You must specify both a token and API key.', 'give' );
472
+		$error['error'] = __('You must specify both a token and API key.', 'give');
473 473
 
474 474
 		$this->data = $error;
475
-		$this->output( 401 );
475
+		$this->output(401);
476 476
 	}
477 477
 
478 478
 	/**
@@ -486,10 +486,10 @@  discard block
 block discarded – undo
486 486
 	 */
487 487
 	private function invalid_auth() {
488 488
 		$error          = array();
489
-		$error['error'] = __( 'Your request could not be authenticated.', 'give' );
489
+		$error['error'] = __('Your request could not be authenticated.', 'give');
490 490
 
491 491
 		$this->data = $error;
492
-		$this->output( 403 );
492
+		$this->output(403);
493 493
 	}
494 494
 
495 495
 	/**
@@ -503,10 +503,10 @@  discard block
 block discarded – undo
503 503
 	 */
504 504
 	private function invalid_key() {
505 505
 		$error          = array();
506
-		$error['error'] = __( 'Invalid API key.', 'give' );
506
+		$error['error'] = __('Invalid API key.', 'give');
507 507
 
508 508
 		$this->data = $error;
509
-		$this->output( 403 );
509
+		$this->output(403);
510 510
 	}
511 511
 
512 512
 	/**
@@ -519,10 +519,10 @@  discard block
 block discarded – undo
519 519
 	 */
520 520
 	private function invalid_version() {
521 521
 		$error          = array();
522
-		$error['error'] = __( 'Invalid API version.', 'give' );
522
+		$error['error'] = __('Invalid API version.', 'give');
523 523
 
524 524
 		$this->data = $error;
525
-		$this->output( 404 );
525
+		$this->output(404);
526 526
 	}
527 527
 
528 528
 	/**
@@ -538,10 +538,10 @@  discard block
 block discarded – undo
538 538
 		global $wp_query;
539 539
 
540 540
 		// Start logging how long the request takes for logging
541
-		$before = microtime( true );
541
+		$before = microtime(true);
542 542
 
543 543
 		// Check for give-api var. Get out if not present
544
-		if ( empty( $wp_query->query_vars['give-api'] ) ) {
544
+		if (empty($wp_query->query_vars['give-api'])) {
545 545
 			return;
546 546
 		}
547 547
 
@@ -555,45 +555,45 @@  discard block
 block discarded – undo
555 555
 		$this->validate_request();
556 556
 
557 557
 		// Only proceed if no errors have been noted
558
-		if ( ! $this->is_valid_request ) {
558
+		if ( ! $this->is_valid_request) {
559 559
 			return;
560 560
 		}
561 561
 
562
-		if ( ! defined( 'GIVE_DOING_API' ) ) {
563
-			define( 'GIVE_DOING_API', true );
562
+		if ( ! defined('GIVE_DOING_API')) {
563
+			define('GIVE_DOING_API', true);
564 564
 		}
565 565
 
566 566
 		$data         = array();
567 567
 		$this->routes = new $this->versions[$this->get_queried_version()];
568 568
 		$this->routes->validate_request();
569 569
 
570
-		switch ( $this->endpoint ) :
570
+		switch ($this->endpoint) :
571 571
 
572 572
 			case 'stats' :
573 573
 
574
-				$data = $this->routes->get_stats( array(
575
-					'type'      => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null,
576
-					'form'      => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null,
577
-					'date'      => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null,
578
-					'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null,
579
-					'enddate'   => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null,
580
-				) );
574
+				$data = $this->routes->get_stats(array(
575
+					'type'      => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null,
576
+					'form'      => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null,
577
+					'date'      => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null,
578
+					'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null,
579
+					'enddate'   => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null,
580
+				));
581 581
 
582 582
 				break;
583 583
 
584 584
 			case 'forms' :
585 585
 
586
-				$form = isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null;
586
+				$form = isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null;
587 587
 
588
-				$data = $this->routes->get_forms( $form );
588
+				$data = $this->routes->get_forms($form);
589 589
 
590 590
 				break;
591 591
 
592 592
 			case 'donors' :
593 593
 
594
-				$donor = isset( $wp_query->query_vars['donor'] ) ? $wp_query->query_vars['donor'] : null;
594
+				$donor = isset($wp_query->query_vars['donor']) ? $wp_query->query_vars['donor'] : null;
595 595
 
596
-				$data = $this->routes->get_donors( $donor );
596
+				$data = $this->routes->get_donors($donor);
597 597
 
598 598
 				break;
599 599
 
@@ -606,26 +606,26 @@  discard block
 block discarded – undo
606 606
 				 * @params date startdate | required when date = range and format to be YYYYMMDD (i.e. 20170524)
607 607
 				 * @params date enddate | required when date = range and format to be YYYYMMDD (i.e. 20170524)
608 608
 				 */
609
-				$data = $this->routes->get_recent_donations( array(
610
-					'id'        => isset( $wp_query->query_vars['id'] ) ? $wp_query->query_vars['id'] : null,
611
-					'date'      => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null,
612
-					'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null,
613
-					'enddate'   => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null,
614
-				) );
609
+				$data = $this->routes->get_recent_donations(array(
610
+					'id'        => isset($wp_query->query_vars['id']) ? $wp_query->query_vars['id'] : null,
611
+					'date'      => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null,
612
+					'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null,
613
+					'enddate'   => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null,
614
+				));
615 615
 
616 616
 				break;
617 617
 
618 618
 		endswitch;
619 619
 
620 620
 		// Allow extensions to setup their own return data
621
-		$this->data = apply_filters( 'give_api_output_data', $data, $this->endpoint, $this );
621
+		$this->data = apply_filters('give_api_output_data', $data, $this->endpoint, $this);
622 622
 
623
-		$after                       = microtime( true );
624
-		$request_time                = ( $after - $before );
623
+		$after                       = microtime(true);
624
+		$request_time                = ($after - $before);
625 625
 		$this->data['request_speed'] = $request_time;
626 626
 
627 627
 		// Log this API request, if enabled. We log it here because we have access to errors.
628
-		$this->log_request( $this->data );
628
+		$this->log_request($this->data);
629 629
 
630 630
 		// Send out data to the output function
631 631
 		$this->output();
@@ -655,25 +655,25 @@  discard block
 block discarded – undo
655 655
 		global $wp_query;
656 656
 
657 657
 		// Whitelist our query options
658
-		$accepted = apply_filters( 'give_api_valid_query_modes', array(
658
+		$accepted = apply_filters('give_api_valid_query_modes', array(
659 659
 			'stats',
660 660
 			'forms',
661 661
 			'donors',
662 662
 			'donations',
663
-		) );
663
+		));
664 664
 
665
-		$query = isset( $wp_query->query_vars['give-api'] ) ? $wp_query->query_vars['give-api'] : null;
666
-		$query = str_replace( $this->queried_version . '/', '', $query );
665
+		$query = isset($wp_query->query_vars['give-api']) ? $wp_query->query_vars['give-api'] : null;
666
+		$query = str_replace($this->queried_version.'/', '', $query);
667 667
 
668 668
 		$error = array();
669 669
 
670 670
 		// Make sure our query is valid
671
-		if ( ! in_array( $query, $accepted ) ) {
672
-			$error['error'] = __( 'Invalid query.', 'give' );
671
+		if ( ! in_array($query, $accepted)) {
672
+			$error['error'] = __('Invalid query.', 'give');
673 673
 
674 674
 			$this->data = $error;
675 675
 			// 400 is Bad Request
676
-			$this->output( 400 );
676
+			$this->output(400);
677 677
 		}
678 678
 
679 679
 		$this->endpoint = $query;
@@ -690,7 +690,7 @@  discard block
 block discarded – undo
690 690
 	public function get_paged() {
691 691
 		global $wp_query;
692 692
 
693
-		return isset( $wp_query->query_vars['page'] ) ? $wp_query->query_vars['page'] : 1;
693
+		return isset($wp_query->query_vars['page']) ? $wp_query->query_vars['page'] : 1;
694 694
 	}
695 695
 
696 696
 
@@ -705,13 +705,13 @@  discard block
 block discarded – undo
705 705
 	public function per_page() {
706 706
 		global $wp_query;
707 707
 
708
-		$per_page = isset( $wp_query->query_vars['number'] ) ? $wp_query->query_vars['number'] : 10;
708
+		$per_page = isset($wp_query->query_vars['number']) ? $wp_query->query_vars['number'] : 10;
709 709
 
710
-		if ( $per_page < 0 && $this->get_query_mode() == 'donors' ) {
710
+		if ($per_page < 0 && $this->get_query_mode() == 'donors') {
711 711
 			$per_page = 99999999;
712 712
 		} // End if().
713 713
 
714
-		return apply_filters( 'give_api_results_per_page', $per_page );
714
+		return apply_filters('give_api_results_per_page', $per_page);
715 715
 	}
716 716
 
717 717
 	/**
@@ -724,7 +724,7 @@  discard block
 block discarded – undo
724 724
 	 *
725 725
 	 * @return array $dates
726 726
 	 */
727
-	public function get_dates( $args = array() ) {
727
+	public function get_dates($args = array()) {
728 728
 		$dates = array();
729 729
 
730 730
 		$defaults = array(
@@ -735,60 +735,60 @@  discard block
 block discarded – undo
735 735
 			'enddate'   => null,
736 736
 		);
737 737
 
738
-		$args = wp_parse_args( $args, $defaults );
738
+		$args = wp_parse_args($args, $defaults);
739 739
 
740
-		$current_time = current_time( 'timestamp' );
740
+		$current_time = current_time('timestamp');
741 741
 
742
-		if ( 'range' === $args['date'] ) {
743
-			$startdate          = strtotime( $args['startdate'] );
744
-			$enddate            = strtotime( $args['enddate'] );
745
-			$dates['day_start'] = date( 'd', $startdate );
746
-			$dates['day_end']   = date( 'd', $enddate );
747
-			$dates['m_start']   = date( 'n', $startdate );
748
-			$dates['m_end']     = date( 'n', $enddate );
749
-			$dates['year']      = date( 'Y', $startdate );
750
-			$dates['year_end']  = date( 'Y', $enddate );
742
+		if ('range' === $args['date']) {
743
+			$startdate          = strtotime($args['startdate']);
744
+			$enddate            = strtotime($args['enddate']);
745
+			$dates['day_start'] = date('d', $startdate);
746
+			$dates['day_end']   = date('d', $enddate);
747
+			$dates['m_start']   = date('n', $startdate);
748
+			$dates['m_end']     = date('n', $enddate);
749
+			$dates['year']      = date('Y', $startdate);
750
+			$dates['year_end']  = date('Y', $enddate);
751 751
 		} else {
752 752
 			// Modify dates based on predefined ranges
753
-			switch ( $args['date'] ) :
753
+			switch ($args['date']) :
754 754
 
755 755
 				case 'this_month' :
756 756
 					$dates['day']     = null;
757
-					$dates['m_start'] = date( 'n', $current_time );
758
-					$dates['m_end']   = date( 'n', $current_time );
759
-					$dates['year']    = date( 'Y', $current_time );
757
+					$dates['m_start'] = date('n', $current_time);
758
+					$dates['m_end']   = date('n', $current_time);
759
+					$dates['year']    = date('Y', $current_time);
760 760
 					break;
761 761
 
762 762
 				case 'last_month' :
763 763
 					$dates['day']     = null;
764
-					$dates['m_start'] = date( 'n', $current_time ) == 1 ? 12 : date( 'n', $current_time ) - 1;
764
+					$dates['m_start'] = date('n', $current_time) == 1 ? 12 : date('n', $current_time) - 1;
765 765
 					$dates['m_end']   = $dates['m_start'];
766
-					$dates['year']    = date( 'n', $current_time ) == 1 ? date( 'Y', $current_time ) - 1 : date( 'Y', $current_time );
766
+					$dates['year']    = date('n', $current_time) == 1 ? date('Y', $current_time) - 1 : date('Y', $current_time);
767 767
 					break;
768 768
 
769 769
 				case 'today' :
770
-					$dates['day']     = date( 'd', $current_time );
771
-					$dates['m_start'] = date( 'n', $current_time );
772
-					$dates['m_end']   = date( 'n', $current_time );
773
-					$dates['year']    = date( 'Y', $current_time );
770
+					$dates['day']     = date('d', $current_time);
771
+					$dates['m_start'] = date('n', $current_time);
772
+					$dates['m_end']   = date('n', $current_time);
773
+					$dates['year']    = date('Y', $current_time);
774 774
 					break;
775 775
 
776 776
 				case 'yesterday' :
777 777
 
778
-					$year  = date( 'Y', $current_time );
779
-					$month = date( 'n', $current_time );
780
-					$day   = date( 'd', $current_time );
778
+					$year  = date('Y', $current_time);
779
+					$month = date('n', $current_time);
780
+					$day   = date('d', $current_time);
781 781
 
782
-					if ( $month == 1 && $day == 1 ) {
782
+					if ($month == 1 && $day == 1) {
783 783
 
784
-						$year  -= 1;
784
+						$year -= 1;
785 785
 						$month = 12;
786
-						$day   = cal_days_in_month( CAL_GREGORIAN, $month, $year );
786
+						$day   = cal_days_in_month(CAL_GREGORIAN, $month, $year);
787 787
 
788
-					} elseif ( $month > 1 && $day == 1 ) {
788
+					} elseif ($month > 1 && $day == 1) {
789 789
 
790 790
 						$month -= 1;
791
-						$day   = cal_days_in_month( CAL_GREGORIAN, $month, $year );
791
+						$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
792 792
 
793 793
 					} else {
794 794
 
@@ -804,65 +804,65 @@  discard block
 block discarded – undo
804 804
 					break;
805 805
 
806 806
 				case 'this_quarter' :
807
-					$month_now = date( 'n', $current_time );
807
+					$month_now = date('n', $current_time);
808 808
 
809 809
 					$dates['day'] = null;
810 810
 
811
-					if ( $month_now <= 3 ) {
811
+					if ($month_now <= 3) {
812 812
 
813 813
 						$dates['m_start'] = 1;
814 814
 						$dates['m_end']   = 3;
815
-						$dates['year']    = date( 'Y', $current_time );
815
+						$dates['year']    = date('Y', $current_time);
816 816
 
817
-					} elseif ( $month_now <= 6 ) {
817
+					} elseif ($month_now <= 6) {
818 818
 
819 819
 						$dates['m_start'] = 4;
820 820
 						$dates['m_end']   = 6;
821
-						$dates['year']    = date( 'Y', $current_time );
821
+						$dates['year']    = date('Y', $current_time);
822 822
 
823
-					} elseif ( $month_now <= 9 ) {
823
+					} elseif ($month_now <= 9) {
824 824
 
825 825
 						$dates['m_start'] = 7;
826 826
 						$dates['m_end']   = 9;
827
-						$dates['year']    = date( 'Y', $current_time );
827
+						$dates['year']    = date('Y', $current_time);
828 828
 
829 829
 					} else {
830 830
 
831 831
 						$dates['m_start'] = 10;
832 832
 						$dates['m_end']   = 12;
833
-						$dates['year']    = date( 'Y', $current_time );
833
+						$dates['year']    = date('Y', $current_time);
834 834
 
835 835
 					}
836 836
 					break;
837 837
 
838 838
 				case 'last_quarter' :
839
-					$month_now = date( 'n', $current_time );
839
+					$month_now = date('n', $current_time);
840 840
 
841 841
 					$dates['day'] = null;
842 842
 
843
-					if ( $month_now <= 3 ) {
843
+					if ($month_now <= 3) {
844 844
 
845 845
 						$dates['m_start'] = 10;
846 846
 						$dates['m_end']   = 12;
847
-						$dates['year']    = date( 'Y', $current_time ) - 1; // Previous year
847
+						$dates['year']    = date('Y', $current_time) - 1; // Previous year
848 848
 
849
-					} elseif ( $month_now <= 6 ) {
849
+					} elseif ($month_now <= 6) {
850 850
 
851 851
 						$dates['m_start'] = 1;
852 852
 						$dates['m_end']   = 3;
853
-						$dates['year']    = date( 'Y', $current_time );
853
+						$dates['year']    = date('Y', $current_time);
854 854
 
855
-					} elseif ( $month_now <= 9 ) {
855
+					} elseif ($month_now <= 9) {
856 856
 
857 857
 						$dates['m_start'] = 4;
858 858
 						$dates['m_end']   = 6;
859
-						$dates['year']    = date( 'Y', $current_time );
859
+						$dates['year']    = date('Y', $current_time);
860 860
 
861 861
 					} else {
862 862
 
863 863
 						$dates['m_start'] = 7;
864 864
 						$dates['m_end']   = 9;
865
-						$dates['year']    = date( 'Y', $current_time );
865
+						$dates['year']    = date('Y', $current_time);
866 866
 
867 867
 					}
868 868
 					break;
@@ -871,14 +871,14 @@  discard block
 block discarded – undo
871 871
 					$dates['day']     = null;
872 872
 					$dates['m_start'] = null;
873 873
 					$dates['m_end']   = null;
874
-					$dates['year']    = date( 'Y', $current_time );
874
+					$dates['year']    = date('Y', $current_time);
875 875
 					break;
876 876
 
877 877
 				case 'last_year' :
878 878
 					$dates['day']     = null;
879 879
 					$dates['m_start'] = null;
880 880
 					$dates['m_end']   = null;
881
-					$dates['year']    = date( 'Y', $current_time ) - 1;
881
+					$dates['year']    = date('Y', $current_time) - 1;
882 882
 					break;
883 883
 
884 884
 			endswitch;
@@ -891,7 +891,7 @@  discard block
 block discarded – undo
891 891
 		 *
892 892
 		 * @param array $dates The dates used for retrieving earnings.
893 893
 		 */
894
-		return apply_filters( 'give_api_stat_dates', $dates );
894
+		return apply_filters('give_api_stat_dates', $dates);
895 895
 	}
896 896
 
897 897
 	/**
@@ -905,84 +905,84 @@  discard block
 block discarded – undo
905 905
 	 *
906 906
 	 * @return array $donors Multidimensional array of the donors.
907 907
 	 */
908
-	public function get_donors( $donor = null ) {
908
+	public function get_donors($donor = null) {
909 909
 
910 910
 		$donors = array();
911 911
 		$error  = array();
912
-		if ( ! user_can( $this->user_id, 'view_give_sensitive_data' ) && ! $this->override ) {
912
+		if ( ! user_can($this->user_id, 'view_give_sensitive_data') && ! $this->override) {
913 913
 			return $donors;
914 914
 		}
915 915
 
916 916
 		$paged    = $this->get_paged();
917 917
 		$per_page = $this->per_page();
918
-		$offset   = $per_page * ( $paged - 1 );
918
+		$offset   = $per_page * ($paged - 1);
919 919
 
920
-		if ( is_numeric( $donor ) ) {
920
+		if (is_numeric($donor)) {
921 921
 			$field = 'id';
922 922
 		} else {
923 923
 			$field = 'email';
924 924
 		}
925 925
 
926
-		$donor_query = Give()->donors->get_donors( array(
926
+		$donor_query = Give()->donors->get_donors(array(
927 927
 			'number' => $per_page,
928 928
 			'offset' => $offset,
929 929
 			$field   => $donor,
930
-		) );
930
+		));
931 931
 		$donor_count = 0;
932 932
 
933
-		if ( $donor_query ) {
933
+		if ($donor_query) {
934 934
 
935
-			foreach ( $donor_query as $donor_obj ) {
935
+			foreach ($donor_query as $donor_obj) {
936 936
 
937
-				$names      = explode( ' ', $donor_obj->name );
938
-				$first_name = ! empty( $names[0] ) ? $names[0] : '';
937
+				$names      = explode(' ', $donor_obj->name);
938
+				$first_name = ! empty($names[0]) ? $names[0] : '';
939 939
 				$last_name  = '';
940
-				if ( ! empty( $names[1] ) ) {
941
-					unset( $names[0] );
942
-					$last_name = implode( ' ', $names );
940
+				if ( ! empty($names[1])) {
941
+					unset($names[0]);
942
+					$last_name = implode(' ', $names);
943 943
 				}
944 944
 
945
-				$donors['donors'][ $donor_count ]['info']['user_id']      = '';
946
-				$donors['donors'][ $donor_count ]['info']['username']     = '';
947
-				$donors['donors'][ $donor_count ]['info']['display_name'] = '';
948
-				$donors['donors'][ $donor_count ]['info']['donor_id']     = $donor_obj->id;
949
-				$donors['donors'][ $donor_count ]['info']['first_name']   = $first_name;
950
-				$donors['donors'][ $donor_count ]['info']['last_name']    = $last_name;
951
-				$donors['donors'][ $donor_count ]['info']['email']        = $donor_obj->email;
945
+				$donors['donors'][$donor_count]['info']['user_id']      = '';
946
+				$donors['donors'][$donor_count]['info']['username']     = '';
947
+				$donors['donors'][$donor_count]['info']['display_name'] = '';
948
+				$donors['donors'][$donor_count]['info']['donor_id']     = $donor_obj->id;
949
+				$donors['donors'][$donor_count]['info']['first_name']   = $first_name;
950
+				$donors['donors'][$donor_count]['info']['last_name']    = $last_name;
951
+				$donors['donors'][$donor_count]['info']['email']        = $donor_obj->email;
952 952
 
953
-				if ( ! empty( $donor_obj->user_id ) ) {
953
+				if ( ! empty($donor_obj->user_id)) {
954 954
 
955
-					$user_data = get_userdata( $donor_obj->user_id );
955
+					$user_data = get_userdata($donor_obj->user_id);
956 956
 
957 957
 					// Donor with registered account.
958
-					$donors['donors'][ $donor_count ]['info']['user_id']      = $donor_obj->user_id;
959
-					$donors['donors'][ $donor_count ]['info']['username']     = $user_data->user_login;
960
-					$donors['donors'][ $donor_count ]['info']['display_name'] = $user_data->display_name;
958
+					$donors['donors'][$donor_count]['info']['user_id']      = $donor_obj->user_id;
959
+					$donors['donors'][$donor_count]['info']['username']     = $user_data->user_login;
960
+					$donors['donors'][$donor_count]['info']['display_name'] = $user_data->display_name;
961 961
 
962 962
 				}
963 963
 
964
-				$donors['donors'][ $donor_count ]['stats']['total_donations'] = $donor_obj->purchase_count;
965
-				$donors['donors'][ $donor_count ]['stats']['total_spent']     = $donor_obj->purchase_value;
964
+				$donors['donors'][$donor_count]['stats']['total_donations'] = $donor_obj->purchase_count;
965
+				$donors['donors'][$donor_count]['stats']['total_spent']     = $donor_obj->purchase_value;
966 966
 
967 967
 				/** @var $donor \Give_Donor */
968
-				$donor = new Give_Donor( $donor_obj->id );
968
+				$donor = new Give_Donor($donor_obj->id);
969 969
 
970 970
 				// Get donor's addresses.
971
-				$donors['donors'][ $donor_count ]['address'] = $donor->address;
971
+				$donors['donors'][$donor_count]['address'] = $donor->address;
972 972
 
973
-				$donor_count ++;
973
+				$donor_count++;
974 974
 
975 975
 			}
976
-		} elseif ( $donor ) {
976
+		} elseif ($donor) {
977 977
 
978 978
 			$error['error'] = sprintf( /* translators: %s: donor */
979
-				__( 'Donor %s not found.', 'give' ), $donor );
979
+				__('Donor %s not found.', 'give'), $donor );
980 980
 
981 981
 			return $error;
982 982
 
983 983
 		} else {
984 984
 
985
-			$error['error'] = __( 'No donors found.', 'give' );
985
+			$error['error'] = __('No donors found.', 'give');
986 986
 
987 987
 			return $error;
988 988
 
@@ -1001,37 +1001,37 @@  discard block
 block discarded – undo
1001 1001
 	 *
1002 1002
 	 * @return array $donors Multidimensional array of the forms.
1003 1003
 	 */
1004
-	public function get_forms( $form = null ) {
1004
+	public function get_forms($form = null) {
1005 1005
 
1006 1006
 		$forms = array();
1007 1007
 		$error = array();
1008 1008
 
1009
-		if ( $form == null ) {
1009
+		if ($form == null) {
1010 1010
 			$forms['forms'] = array();
1011 1011
 
1012
-			$form_list = get_posts( array(
1012
+			$form_list = get_posts(array(
1013 1013
 				'post_type'        => 'give_forms',
1014 1014
 				'posts_per_page'   => $this->per_page(),
1015 1015
 				'suppress_filters' => true,
1016 1016
 				'paged'            => $this->get_paged(),
1017
-			) );
1017
+			));
1018 1018
 
1019
-			if ( $form_list ) {
1019
+			if ($form_list) {
1020 1020
 				$i = 0;
1021
-				foreach ( $form_list as $form_info ) {
1022
-					$forms['forms'][ $i ] = $this->get_form_data( $form_info );
1023
-					$i ++;
1021
+				foreach ($form_list as $form_info) {
1022
+					$forms['forms'][$i] = $this->get_form_data($form_info);
1023
+					$i++;
1024 1024
 				}
1025 1025
 			}
1026 1026
 		} else {
1027
-			if ( get_post_type( $form ) == 'give_forms' ) {
1028
-				$form_info = get_post( $form );
1027
+			if (get_post_type($form) == 'give_forms') {
1028
+				$form_info = get_post($form);
1029 1029
 
1030
-				$forms['forms'][0] = $this->get_form_data( $form_info );
1030
+				$forms['forms'][0] = $this->get_form_data($form_info);
1031 1031
 
1032 1032
 			} else {
1033 1033
 				$error['error'] = sprintf( /* translators: %s: form */
1034
-					__( 'Form %s not found.', 'give' ), $form );
1034
+					__('Form %s not found.', 'give'), $form );
1035 1035
 
1036 1036
 				return $error;
1037 1037
 			}
@@ -1049,7 +1049,7 @@  discard block
 block discarded – undo
1049 1049
 	 *
1050 1050
 	 * @return array                Array of post data to return back in the API.
1051 1051
 	 */
1052
-	private function get_form_data( $form_info ) {
1052
+	private function get_form_data($form_info) {
1053 1053
 
1054 1054
 		$form = array();
1055 1055
 
@@ -1059,60 +1059,60 @@  discard block
 block discarded – undo
1059 1059
 		$form['info']['create_date']   = $form_info->post_date;
1060 1060
 		$form['info']['modified_date'] = $form_info->post_modified;
1061 1061
 		$form['info']['status']        = $form_info->post_status;
1062
-		$form['info']['link']          = html_entity_decode( $form_info->guid );
1063
-		$form['info']['content']       = give_get_meta( $form_info->ID, '_give_form_content', true );
1064
-		$form['info']['thumbnail']     = wp_get_attachment_url( get_post_thumbnail_id( $form_info->ID ) );
1062
+		$form['info']['link']          = html_entity_decode($form_info->guid);
1063
+		$form['info']['content']       = give_get_meta($form_info->ID, '_give_form_content', true);
1064
+		$form['info']['thumbnail']     = wp_get_attachment_url(get_post_thumbnail_id($form_info->ID));
1065 1065
 
1066
-		if ( give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ) ) {
1067
-			$form['info']['category'] = get_the_terms( $form_info, 'give_forms_category' );
1068
-			$form['info']['tags']     = get_the_terms( $form_info, 'give_forms_tag' );
1066
+		if (give_is_setting_enabled(give_get_option('categories', 'disabled'))) {
1067
+			$form['info']['category'] = get_the_terms($form_info, 'give_forms_category');
1068
+			$form['info']['tags']     = get_the_terms($form_info, 'give_forms_tag');
1069 1069
 		}
1070
-		if ( give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) ) ) {
1071
-			$form['info']['tags'] = get_the_terms( $form_info, 'give_forms_tag' );
1070
+		if (give_is_setting_enabled(give_get_option('tags', 'disabled'))) {
1071
+			$form['info']['tags'] = get_the_terms($form_info, 'give_forms_tag');
1072 1072
 		}
1073 1073
 
1074 1074
 		// Check whether any goal is to be achieved for the donation form.
1075
-		$goal_option = give_get_meta( $form_info->ID, '_give_goal_option', true );
1076
-		$goal_amount = give_get_meta( $form_info->ID, '_give_set_goal', true );
1077
-		if ( give_is_setting_enabled( $goal_option ) && $goal_amount ) {
1078
-			$total_income                         = give_get_form_earnings_stats( $form_info->ID );
1079
-			$goal_percentage_completed            = ( $total_income < $goal_amount ) ? round( ( $total_income / $goal_amount ) * 100, 2 ) : 100;
1080
-			$form['goal']['amount']               = isset( $goal_amount ) ? $goal_amount : '';
1081
-			$form['goal']['percentage_completed'] = isset( $goal_percentage_completed ) ? $goal_percentage_completed : '';
1075
+		$goal_option = give_get_meta($form_info->ID, '_give_goal_option', true);
1076
+		$goal_amount = give_get_meta($form_info->ID, '_give_set_goal', true);
1077
+		if (give_is_setting_enabled($goal_option) && $goal_amount) {
1078
+			$total_income                         = give_get_form_earnings_stats($form_info->ID);
1079
+			$goal_percentage_completed            = ($total_income < $goal_amount) ? round(($total_income / $goal_amount) * 100, 2) : 100;
1080
+			$form['goal']['amount']               = isset($goal_amount) ? $goal_amount : '';
1081
+			$form['goal']['percentage_completed'] = isset($goal_percentage_completed) ? $goal_percentage_completed : '';
1082 1082
 		}
1083 1083
 
1084
-		if ( user_can( $this->user_id, 'view_give_reports' ) || $this->override ) {
1085
-			$form['stats']['total']['donations']           = give_get_form_sales_stats( $form_info->ID );
1086
-			$form['stats']['total']['earnings']            = give_get_form_earnings_stats( $form_info->ID );
1087
-			$form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales( $form_info->ID );
1088
-			$form['stats']['monthly_average']['earnings']  = give_get_average_monthly_form_earnings( $form_info->ID );
1084
+		if (user_can($this->user_id, 'view_give_reports') || $this->override) {
1085
+			$form['stats']['total']['donations']           = give_get_form_sales_stats($form_info->ID);
1086
+			$form['stats']['total']['earnings']            = give_get_form_earnings_stats($form_info->ID);
1087
+			$form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales($form_info->ID);
1088
+			$form['stats']['monthly_average']['earnings']  = give_get_average_monthly_form_earnings($form_info->ID);
1089 1089
 		}
1090 1090
 
1091 1091
 		$counter = 0;
1092
-		if ( give_has_variable_prices( $form_info->ID ) ) {
1093
-			foreach ( give_get_variable_prices( $form_info->ID ) as $price ) {
1094
-				$counter ++;
1092
+		if (give_has_variable_prices($form_info->ID)) {
1093
+			foreach (give_get_variable_prices($form_info->ID) as $price) {
1094
+				$counter++;
1095 1095
 				// multi-level item
1096
-				$level                                     = isset( $price['_give_text'] ) ? $price['_give_text'] : 'level-' . $counter;
1097
-				$form['pricing'][ sanitize_key( $level ) ] = $price['_give_amount'];
1096
+				$level                                     = isset($price['_give_text']) ? $price['_give_text'] : 'level-'.$counter;
1097
+				$form['pricing'][sanitize_key($level)] = $price['_give_amount'];
1098 1098
 
1099 1099
 			}
1100 1100
 		} else {
1101
-			$form['pricing']['amount'] = give_get_form_price( $form_info->ID );
1101
+			$form['pricing']['amount'] = give_get_form_price($form_info->ID);
1102 1102
 		}
1103 1103
 
1104
-		if ( user_can( $this->user_id, 'view_give_sensitive_data' ) || $this->override ) {
1104
+		if (user_can($this->user_id, 'view_give_sensitive_data') || $this->override) {
1105 1105
 
1106 1106
 			/**
1107 1107
 			 * Fires when generating API sensitive data.
1108 1108
 			 *
1109 1109
 			 * @since 1.1
1110 1110
 			 */
1111
-			do_action( 'give_api_sensitive_data' );
1111
+			do_action('give_api_sensitive_data');
1112 1112
 
1113 1113
 		}
1114 1114
 
1115
-		return apply_filters( 'give_api_forms_form', $form );
1115
+		return apply_filters('give_api_forms_form', $form);
1116 1116
 
1117 1117
 	}
1118 1118
 
@@ -1127,7 +1127,7 @@  discard block
 block discarded – undo
1127 1127
 	 *
1128 1128
 	 * @return array
1129 1129
 	 */
1130
-	public function get_stats( $args = array() ) {
1130
+	public function get_stats($args = array()) {
1131 1131
 		$defaults = array(
1132 1132
 			'type'      => null,
1133 1133
 			'form'      => null,
@@ -1136,9 +1136,9 @@  discard block
 block discarded – undo
1136 1136
 			'enddate'   => null,
1137 1137
 		);
1138 1138
 
1139
-		$args = wp_parse_args( $args, $defaults );
1139
+		$args = wp_parse_args($args, $defaults);
1140 1140
 
1141
-		$dates = $this->get_dates( $args );
1141
+		$dates = $this->get_dates($args);
1142 1142
 
1143 1143
 		$stats     = array();
1144 1144
 		$earnings  = array(
@@ -1149,40 +1149,40 @@  discard block
 block discarded – undo
1149 1149
 		);
1150 1150
 		$error     = array();
1151 1151
 
1152
-		if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) {
1152
+		if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) {
1153 1153
 			return $stats;
1154 1154
 		}
1155 1155
 
1156
-		if ( $args['type'] == 'donations' ) {
1156
+		if ($args['type'] == 'donations') {
1157 1157
 
1158
-			if ( $args['form'] == null ) {
1159
-				if ( $args['date'] == null ) {
1158
+			if ($args['form'] == null) {
1159
+				if ($args['date'] == null) {
1160 1160
 					$donations = $this->get_default_sales_stats();
1161
-				} elseif ( $args['date'] === 'range' ) {
1161
+				} elseif ($args['date'] === 'range') {
1162 1162
 					// Return donations for a date range.
1163 1163
 					// Ensure the end date is later than the start date.
1164
-					if ( $args['enddate'] < $args['startdate'] ) {
1165
-						$error['error'] = __( 'The end date must be later than the start date.', 'give' );
1164
+					if ($args['enddate'] < $args['startdate']) {
1165
+						$error['error'] = __('The end date must be later than the start date.', 'give');
1166 1166
 					}
1167 1167
 
1168 1168
 					// Ensure both the start and end date are specified
1169
-					if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) {
1170
-						$error['error'] = __( 'Invalid or no date range specified.', 'give' );
1169
+					if (empty($args['startdate']) || empty($args['enddate'])) {
1170
+						$error['error'] = __('Invalid or no date range specified.', 'give');
1171 1171
 					}
1172 1172
 
1173 1173
 					$total = 0;
1174 1174
 
1175 1175
 					// Loop through the years
1176 1176
 					$y = $dates['year'];
1177
-					while ( $y <= $dates['year_end'] ) :
1177
+					while ($y <= $dates['year_end']) :
1178 1178
 
1179
-						if ( $dates['year'] == $dates['year_end'] ) {
1179
+						if ($dates['year'] == $dates['year_end']) {
1180 1180
 							$month_start = $dates['m_start'];
1181 1181
 							$month_end   = $dates['m_end'];
1182
-						} elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) {
1182
+						} elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) {
1183 1183
 							$month_start = $dates['m_start'];
1184 1184
 							$month_end   = 12;
1185
-						} elseif ( $y == $dates['year_end'] ) {
1185
+						} elseif ($y == $dates['year_end']) {
1186 1186
 							$month_start = 1;
1187 1187
 							$month_end   = $dates['m_end'];
1188 1188
 						} else {
@@ -1191,116 +1191,116 @@  discard block
 block discarded – undo
1191 1191
 						}
1192 1192
 
1193 1193
 						$i = $month_start;
1194
-						while ( $i <= $month_end ) :
1194
+						while ($i <= $month_end) :
1195 1195
 
1196
-							if ( $i == $dates['m_start'] ) {
1196
+							if ($i == $dates['m_start']) {
1197 1197
 								$d = $dates['day_start'];
1198 1198
 							} else {
1199 1199
 								$d = 1;
1200 1200
 							}
1201 1201
 
1202
-							if ( $i == $dates['m_end'] ) {
1202
+							if ($i == $dates['m_end']) {
1203 1203
 								$num_of_days = $dates['day_end'];
1204 1204
 							} else {
1205
-								$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
1205
+								$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
1206 1206
 							}
1207 1207
 
1208
-							while ( $d <= $num_of_days ) :
1209
-								$sale_count = give_get_sales_by_date( $d, $i, $y );
1210
-								$date_key   = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) );
1211
-								if ( ! isset( $donations['sales'][ $date_key ] ) ) {
1212
-									$donations['sales'][ $date_key ] = 0;
1208
+							while ($d <= $num_of_days) :
1209
+								$sale_count = give_get_sales_by_date($d, $i, $y);
1210
+								$date_key   = date('Ymd', strtotime($y.'/'.$i.'/'.$d));
1211
+								if ( ! isset($donations['sales'][$date_key])) {
1212
+									$donations['sales'][$date_key] = 0;
1213 1213
 								}
1214
-								$donations['sales'][ $date_key ] += $sale_count;
1214
+								$donations['sales'][$date_key] += $sale_count;
1215 1215
 								$total                           += $sale_count;
1216
-								$d ++;
1216
+								$d++;
1217 1217
 							endwhile;
1218
-							$i ++;
1218
+							$i++;
1219 1219
 						endwhile;
1220 1220
 
1221
-						$y ++;
1221
+						$y++;
1222 1222
 					endwhile;
1223 1223
 
1224 1224
 					$donations['totals'] = $total;
1225 1225
 				} else {
1226
-					if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) {
1226
+					if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') {
1227 1227
 						$donations_count = 0;
1228 1228
 
1229 1229
 						// Loop through the months
1230 1230
 						$month = $dates['m_start'];
1231 1231
 
1232
-						while ( $month <= $dates['m_end'] ) :
1233
-							$donations_count += give_get_sales_by_date( null, $month, $dates['year'] );
1234
-							$month ++;
1232
+						while ($month <= $dates['m_end']) :
1233
+							$donations_count += give_get_sales_by_date(null, $month, $dates['year']);
1234
+							$month++;
1235 1235
 						endwhile;
1236 1236
 
1237
-						$donations['donations'][ $args['date'] ] = $donations_count;
1237
+						$donations['donations'][$args['date']] = $donations_count;
1238 1238
 					} else {
1239
-						$donations['donations'][ $args['date'] ] = give_get_sales_by_date( $dates['day'], $dates['m_start'], $dates['year'] );
1239
+						$donations['donations'][$args['date']] = give_get_sales_by_date($dates['day'], $dates['m_start'], $dates['year']);
1240 1240
 					}
1241 1241
 				}// End if().
1242
-			} elseif ( $args['form'] == 'all' ) {
1243
-				$forms = get_posts( array(
1242
+			} elseif ($args['form'] == 'all') {
1243
+				$forms = get_posts(array(
1244 1244
 					'post_type' => 'give_forms',
1245 1245
 					'nopaging'  => true,
1246
-				) );
1247
-				$i     = 0;
1248
-				foreach ( $forms as $form_info ) {
1249
-					$donations['donations'][ $i ] = array(
1250
-						$form_info->post_name => give_get_form_sales_stats( $form_info->ID ),
1246
+				));
1247
+				$i = 0;
1248
+				foreach ($forms as $form_info) {
1249
+					$donations['donations'][$i] = array(
1250
+						$form_info->post_name => give_get_form_sales_stats($form_info->ID),
1251 1251
 					);
1252
-					$i ++;
1252
+					$i++;
1253 1253
 				}
1254 1254
 			} else {
1255
-				if ( get_post_type( $args['form'] ) == 'give_forms' ) {
1256
-					$form_info                 = get_post( $args['form'] );
1255
+				if (get_post_type($args['form']) == 'give_forms') {
1256
+					$form_info                 = get_post($args['form']);
1257 1257
 					$donations['donations'][0] = array(
1258
-						$form_info->post_name => give_get_form_sales_stats( $args['form'] ),
1258
+						$form_info->post_name => give_get_form_sales_stats($args['form']),
1259 1259
 					);
1260 1260
 				} else {
1261 1261
 					$error['error'] = sprintf( /* translators: %s: form */
1262
-						__( 'Form %s not found.', 'give' ), $args['form'] );
1262
+						__('Form %s not found.', 'give'), $args['form'] );
1263 1263
 				}
1264 1264
 			}// End if().
1265 1265
 
1266
-			if ( ! empty( $error ) ) {
1266
+			if ( ! empty($error)) {
1267 1267
 				return $error;
1268 1268
 			}
1269 1269
 
1270 1270
 			return $donations;
1271 1271
 
1272
-		} elseif ( $args['type'] == 'earnings' ) {
1273
-			if ( $args['form'] == null ) {
1274
-				if ( $args['date'] == null ) {
1272
+		} elseif ($args['type'] == 'earnings') {
1273
+			if ($args['form'] == null) {
1274
+				if ($args['date'] == null) {
1275 1275
 					$earnings = $this->get_default_earnings_stats();
1276
-				} elseif ( $args['date'] === 'range' ) {
1276
+				} elseif ($args['date'] === 'range') {
1277 1277
 					// Return sales for a date range
1278 1278
 					// Ensure the end date is later than the start date
1279
-					if ( $args['enddate'] < $args['startdate'] ) {
1280
-						$error['error'] = __( 'The end date must be later than the start date.', 'give' );
1279
+					if ($args['enddate'] < $args['startdate']) {
1280
+						$error['error'] = __('The end date must be later than the start date.', 'give');
1281 1281
 					}
1282 1282
 
1283 1283
 					// Ensure both the start and end date are specified
1284
-					if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) {
1285
-						$error['error'] = __( 'Invalid or no date range specified.', 'give' );
1284
+					if (empty($args['startdate']) || empty($args['enddate'])) {
1285
+						$error['error'] = __('Invalid or no date range specified.', 'give');
1286 1286
 					}
1287 1287
 
1288 1288
 					$total = (float) 0.00;
1289 1289
 
1290 1290
 					// Loop through the years
1291 1291
 					$y = $dates['year'];
1292
-					if ( ! isset( $earnings['earnings'] ) ) {
1292
+					if ( ! isset($earnings['earnings'])) {
1293 1293
 						$earnings['earnings'] = array();
1294 1294
 					}
1295
-					while ( $y <= $dates['year_end'] ) :
1295
+					while ($y <= $dates['year_end']) :
1296 1296
 
1297
-						if ( $dates['year'] == $dates['year_end'] ) {
1297
+						if ($dates['year'] == $dates['year_end']) {
1298 1298
 							$month_start = $dates['m_start'];
1299 1299
 							$month_end   = $dates['m_end'];
1300
-						} elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) {
1300
+						} elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) {
1301 1301
 							$month_start = $dates['m_start'];
1302 1302
 							$month_end   = 12;
1303
-						} elseif ( $y == $dates['year_end'] ) {
1303
+						} elseif ($y == $dates['year_end']) {
1304 1304
 							$month_start = 1;
1305 1305
 							$month_end   = $dates['m_end'];
1306 1306
 						} else {
@@ -1309,94 +1309,94 @@  discard block
 block discarded – undo
1309 1309
 						}
1310 1310
 
1311 1311
 						$i = $month_start;
1312
-						while ( $i <= $month_end ) :
1312
+						while ($i <= $month_end) :
1313 1313
 
1314
-							if ( $i == $dates['m_start'] ) {
1314
+							if ($i == $dates['m_start']) {
1315 1315
 								$d = $dates['day_start'];
1316 1316
 							} else {
1317 1317
 								$d = 1;
1318 1318
 							}
1319 1319
 
1320
-							if ( $i == $dates['m_end'] ) {
1320
+							if ($i == $dates['m_end']) {
1321 1321
 								$num_of_days = $dates['day_end'];
1322 1322
 							} else {
1323
-								$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
1323
+								$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
1324 1324
 							}
1325 1325
 
1326
-							while ( $d <= $num_of_days ) :
1327
-								$earnings_stat = give_get_earnings_by_date( $d, $i, $y );
1328
-								$date_key      = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) );
1329
-								if ( ! isset( $earnings['earnings'][ $date_key ] ) ) {
1330
-									$earnings['earnings'][ $date_key ] = 0;
1326
+							while ($d <= $num_of_days) :
1327
+								$earnings_stat = give_get_earnings_by_date($d, $i, $y);
1328
+								$date_key      = date('Ymd', strtotime($y.'/'.$i.'/'.$d));
1329
+								if ( ! isset($earnings['earnings'][$date_key])) {
1330
+									$earnings['earnings'][$date_key] = 0;
1331 1331
 								}
1332
-								$earnings['earnings'][ $date_key ] += $earnings_stat;
1332
+								$earnings['earnings'][$date_key] += $earnings_stat;
1333 1333
 								$total                             += $earnings_stat;
1334
-								$d ++;
1334
+								$d++;
1335 1335
 							endwhile;
1336 1336
 
1337
-							$i ++;
1337
+							$i++;
1338 1338
 						endwhile;
1339 1339
 
1340
-						$y ++;
1340
+						$y++;
1341 1341
 					endwhile;
1342 1342
 
1343 1343
 					$earnings['totals'] = $total;
1344 1344
 				} else {
1345
-					if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) {
1345
+					if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') {
1346 1346
 						$earnings_count = (float) 0.00;
1347 1347
 
1348 1348
 						// Loop through the months
1349 1349
 						$month = $dates['m_start'];
1350 1350
 
1351
-						while ( $month <= $dates['m_end'] ) :
1352
-							$earnings_count += give_get_earnings_by_date( null, $month, $dates['year'] );
1353
-							$month ++;
1351
+						while ($month <= $dates['m_end']) :
1352
+							$earnings_count += give_get_earnings_by_date(null, $month, $dates['year']);
1353
+							$month++;
1354 1354
 						endwhile;
1355 1355
 
1356
-						$earnings['earnings'][ $args['date'] ] = $earnings_count;
1356
+						$earnings['earnings'][$args['date']] = $earnings_count;
1357 1357
 					} else {
1358
-						$earnings['earnings'][ $args['date'] ] = give_get_earnings_by_date( $dates['day'], $dates['m_start'], $dates['year'] );
1358
+						$earnings['earnings'][$args['date']] = give_get_earnings_by_date($dates['day'], $dates['m_start'], $dates['year']);
1359 1359
 					}
1360 1360
 				}// End if().
1361
-			} elseif ( $args['form'] == 'all' ) {
1362
-				$forms = get_posts( array(
1361
+			} elseif ($args['form'] == 'all') {
1362
+				$forms = get_posts(array(
1363 1363
 					'post_type' => 'give_forms',
1364 1364
 					'nopaging'  => true,
1365
-				) );
1365
+				));
1366 1366
 
1367 1367
 				$i = 0;
1368
-				foreach ( $forms as $form_info ) {
1369
-					$earnings['earnings'][ $i ] = array(
1370
-						$form_info->post_name => give_get_form_earnings_stats( $form_info->ID ),
1368
+				foreach ($forms as $form_info) {
1369
+					$earnings['earnings'][$i] = array(
1370
+						$form_info->post_name => give_get_form_earnings_stats($form_info->ID),
1371 1371
 					);
1372
-					$i ++;
1372
+					$i++;
1373 1373
 				}
1374 1374
 			} else {
1375
-				if ( get_post_type( $args['form'] ) == 'give_forms' ) {
1376
-					$form_info               = get_post( $args['form'] );
1375
+				if (get_post_type($args['form']) == 'give_forms') {
1376
+					$form_info               = get_post($args['form']);
1377 1377
 					$earnings['earnings'][0] = array(
1378
-						$form_info->post_name => give_get_form_earnings_stats( $args['form'] ),
1378
+						$form_info->post_name => give_get_form_earnings_stats($args['form']),
1379 1379
 					);
1380 1380
 				} else {
1381 1381
 					$error['error'] = sprintf( /* translators: %s: form */
1382
-						__( 'Form %s not found.', 'give' ), $args['form'] );
1382
+						__('Form %s not found.', 'give'), $args['form'] );
1383 1383
 				}
1384 1384
 			}// End if().
1385 1385
 
1386
-			if ( ! empty( $error ) ) {
1386
+			if ( ! empty($error)) {
1387 1387
 				return $error;
1388 1388
 			}
1389 1389
 
1390 1390
 			return $earnings;
1391
-		} elseif ( $args['type'] == 'donors' ) {
1391
+		} elseif ($args['type'] == 'donors') {
1392 1392
 			$donors                             = new Give_DB_Donors();
1393 1393
 			$stats['donations']['total_donors'] = $donors->count();
1394 1394
 
1395 1395
 			return $stats;
1396 1396
 
1397
-		} elseif ( empty( $args['type'] ) ) {
1398
-			$stats = array_merge( $stats, $this->get_default_sales_stats() );
1399
-			$stats = array_merge( $stats, $this->get_default_earnings_stats() );
1397
+		} elseif (empty($args['type'])) {
1398
+			$stats = array_merge($stats, $this->get_default_sales_stats());
1399
+			$stats = array_merge($stats, $this->get_default_earnings_stats());
1400 1400
 
1401 1401
 			return array(
1402 1402
 				'stats' => $stats,
@@ -1414,7 +1414,7 @@  discard block
 block discarded – undo
1414 1414
 	 *
1415 1415
 	 * @return array
1416 1416
 	 */
1417
-	public function get_recent_donations( $args = array() ) {
1417
+	public function get_recent_donations($args = array()) {
1418 1418
 		global $wp_query;
1419 1419
 
1420 1420
 		$defaults = array(
@@ -1424,33 +1424,33 @@  discard block
 block discarded – undo
1424 1424
 			'enddate'   => null,
1425 1425
 		);
1426 1426
 
1427
-		$args = wp_parse_args( $args, $defaults );
1427
+		$args = wp_parse_args($args, $defaults);
1428 1428
 
1429 1429
 		$donations = array();
1430 1430
 
1431
-		if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) {
1431
+		if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) {
1432 1432
 			return $donations;
1433 1433
 		}
1434 1434
 
1435
-		if ( isset( $wp_query->query_vars['id'] ) ) {
1435
+		if (isset($wp_query->query_vars['id'])) {
1436 1436
 			$query   = array();
1437
-			$query[] = new Give_Payment( $wp_query->query_vars['id'] );
1438
-		} elseif ( isset( $wp_query->query_vars['purchasekey'] ) ) {
1437
+			$query[] = new Give_Payment($wp_query->query_vars['id']);
1438
+		} elseif (isset($wp_query->query_vars['purchasekey'])) {
1439 1439
 			$query   = array();
1440
-			$query[] = give_get_payment_by( 'key', $wp_query->query_vars['purchasekey'] );
1441
-		} elseif ( isset( $wp_query->query_vars['email'] ) ) {
1442
-			$args  = array(
1440
+			$query[] = give_get_payment_by('key', $wp_query->query_vars['purchasekey']);
1441
+		} elseif (isset($wp_query->query_vars['email'])) {
1442
+			$args = array(
1443 1443
 				'fields'     => 'ids',
1444 1444
 				'meta_key'   => '_give_payment_donor_email',
1445 1445
 				'meta_value' => $wp_query->query_vars['email'],
1446 1446
 				'number'     => $this->per_page(),
1447 1447
 				'page'       => $this->get_paged(),
1448 1448
 			);
1449
-			$query = give_get_payments( $args );
1450
-		} elseif ( isset( $wp_query->query_vars['date'] ) ) {
1449
+			$query = give_get_payments($args);
1450
+		} elseif (isset($wp_query->query_vars['date'])) {
1451 1451
 
1452
-			$current_time = current_time( 'timestamp' );
1453
-			$dates        = $this->get_dates( $args );
1452
+			$current_time = current_time('timestamp');
1453
+			$dates        = $this->get_dates($args);
1454 1454
 			$start_date   = '';
1455 1455
 			$end_date     = '';
1456 1456
 
@@ -1463,27 +1463,27 @@  discard block
 block discarded – undo
1463 1463
 			 * @params date startdate | required when date = range and format to be YYYYMMDD (i.e. 20170524)
1464 1464
 			 * @params date enddate | required when date = range and format to be YYYYMMDD (i.e. 20170524)
1465 1465
 			 */
1466
-			switch ( $wp_query->query_vars['date'] ) {
1466
+			switch ($wp_query->query_vars['date']) {
1467 1467
 
1468 1468
 				case 'today':
1469 1469
 
1470 1470
 					// Set and Format Start and End Date to be date of today.
1471
-					$start_date = $end_date = date( 'Y/m/d', $current_time );
1471
+					$start_date = $end_date = date('Y/m/d', $current_time);
1472 1472
 
1473 1473
 					break;
1474 1474
 
1475 1475
 				case 'yesterday':
1476 1476
 
1477 1477
 					// Set and Format Start and End Date to be date of yesterday.
1478
-					$start_date = $end_date = date( 'Y/m', $current_time ) . '/' . ( date( 'd', $current_time ) - 1 );
1478
+					$start_date = $end_date = date('Y/m', $current_time).'/'.(date('d', $current_time) - 1);
1479 1479
 
1480 1480
 					break;
1481 1481
 
1482 1482
 				case 'range':
1483 1483
 
1484 1484
 					// Format Start Date and End Date for filtering payment based on date range.
1485
-					$start_date = $dates['year'] . '/' . $dates['m_start'] . '/' . $dates['day_start'];
1486
-					$end_date   = $dates['year_end'] . '/' . $dates['m_end'] . '/' . $dates['day_end'];
1485
+					$start_date = $dates['year'].'/'.$dates['m_start'].'/'.$dates['day_start'];
1486
+					$end_date   = $dates['year_end'].'/'.$dates['m_end'].'/'.$dates['day_end'];
1487 1487
 
1488 1488
 					break;
1489 1489
 
@@ -1497,22 +1497,22 @@  discard block
 block discarded – undo
1497 1497
 				'page'       => $this->get_paged(),
1498 1498
 			);
1499 1499
 
1500
-			$query = give_get_payments( $args );
1500
+			$query = give_get_payments($args);
1501 1501
 		} else {
1502 1502
 			$args  = array(
1503 1503
 				'fields' => 'ids',
1504 1504
 				'number' => $this->per_page(),
1505 1505
 				'page'   => $this->get_paged(),
1506 1506
 			);
1507
-			$query = give_get_payments( $args );
1507
+			$query = give_get_payments($args);
1508 1508
 		}// End if().
1509 1509
 
1510
-		if ( $query ) {
1510
+		if ($query) {
1511 1511
 			$i = 0;
1512
-			foreach ( $query as $payment ) {
1512
+			foreach ($query as $payment) {
1513 1513
 
1514
-				if ( is_numeric( $payment ) ) {
1515
-					$payment      = new Give_Payment( $payment );
1514
+				if (is_numeric($payment)) {
1515
+					$payment      = new Give_Payment($payment);
1516 1516
 					$payment_meta = $payment->get_meta();
1517 1517
 					$user_info    = $payment->user_info;
1518 1518
 				}
@@ -1520,43 +1520,43 @@  discard block
 block discarded – undo
1520 1520
 				$payment_meta = $payment->get_meta();
1521 1521
 				$user_info    = $payment->user_info;
1522 1522
 
1523
-				$first_name = isset( $user_info['first_name'] ) ? $user_info['first_name'] : '';
1524
-				$last_name  = isset( $user_info['last_name'] ) ? $user_info['last_name'] : '';
1525
-
1526
-				$donations['donations'][ $i ]['ID']             = $payment->number;
1527
-				$donations['donations'][ $i ]['transaction_id'] = $payment->transaction_id;
1528
-				$donations['donations'][ $i ]['key']            = $payment->key;
1529
-				$donations['donations'][ $i ]['total']          = $payment->total;
1530
-				$donations['donations'][ $i ]['status']         = give_get_payment_status( $payment, true );
1531
-				$donations['donations'][ $i ]['gateway']        = $payment->gateway;
1532
-				$donations['donations'][ $i ]['name']           = $first_name . ' ' . $last_name;
1533
-				$donations['donations'][ $i ]['fname']          = $first_name;
1534
-				$donations['donations'][ $i ]['lname']          = $last_name;
1535
-				$donations['donations'][ $i ]['email']          = $payment->email;
1536
-				$donations['donations'][ $i ]['date']           = $payment->date;
1537
-				$donations['donations'][ $i ]['payment_meta']   = array();
1538
-
1539
-				$form_id  = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : $payment_meta;
1540
-				$price    = isset( $payment_meta['form_id'] ) ? give_get_form_price( $payment_meta['form_id'] ) : false;
1541
-				$price_id = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null;
1542
-
1543
-				$donations['donations'][ $i ]['form']['id']    = $form_id;
1544
-				$donations['donations'][ $i ]['form']['name']  = get_the_title( $payment_meta['form_id'] );
1545
-				$donations['donations'][ $i ]['form']['price'] = $price;
1546
-
1547
-				if ( give_has_variable_prices( $form_id ) ) {
1548
-					if ( isset( $payment_meta['price_id'] ) ) {
1549
-						$price_name                                         = give_get_price_option_name( $form_id, $payment_meta['price_id'], $payment->ID );
1550
-						$donations['donations'][ $i ]['form']['price_name'] = $price_name;
1551
-						$donations['donations'][ $i ]['form']['price_id']   = $price_id;
1552
-						$donations['donations'][ $i ]['form']['price']      = give_get_price_option_amount( $form_id, $price_id );
1523
+				$first_name = isset($user_info['first_name']) ? $user_info['first_name'] : '';
1524
+				$last_name  = isset($user_info['last_name']) ? $user_info['last_name'] : '';
1525
+
1526
+				$donations['donations'][$i]['ID']             = $payment->number;
1527
+				$donations['donations'][$i]['transaction_id'] = $payment->transaction_id;
1528
+				$donations['donations'][$i]['key']            = $payment->key;
1529
+				$donations['donations'][$i]['total']          = $payment->total;
1530
+				$donations['donations'][$i]['status']         = give_get_payment_status($payment, true);
1531
+				$donations['donations'][$i]['gateway']        = $payment->gateway;
1532
+				$donations['donations'][$i]['name']           = $first_name.' '.$last_name;
1533
+				$donations['donations'][$i]['fname']          = $first_name;
1534
+				$donations['donations'][$i]['lname']          = $last_name;
1535
+				$donations['donations'][$i]['email']          = $payment->email;
1536
+				$donations['donations'][$i]['date']           = $payment->date;
1537
+				$donations['donations'][$i]['payment_meta']   = array();
1538
+
1539
+				$form_id  = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : $payment_meta;
1540
+				$price    = isset($payment_meta['form_id']) ? give_get_form_price($payment_meta['form_id']) : false;
1541
+				$price_id = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null;
1542
+
1543
+				$donations['donations'][$i]['form']['id']    = $form_id;
1544
+				$donations['donations'][$i]['form']['name']  = get_the_title($payment_meta['form_id']);
1545
+				$donations['donations'][$i]['form']['price'] = $price;
1546
+
1547
+				if (give_has_variable_prices($form_id)) {
1548
+					if (isset($payment_meta['price_id'])) {
1549
+						$price_name                                         = give_get_price_option_name($form_id, $payment_meta['price_id'], $payment->ID);
1550
+						$donations['donations'][$i]['form']['price_name'] = $price_name;
1551
+						$donations['donations'][$i]['form']['price_id']   = $price_id;
1552
+						$donations['donations'][$i]['form']['price']      = give_get_price_option_amount($form_id, $price_id);
1553 1553
 
1554 1554
 					}
1555 1555
 				}
1556 1556
 
1557
-				if( ! empty( $payment_meta ) ) {
1557
+				if ( ! empty($payment_meta)) {
1558 1558
 					// Add custom meta to API
1559
-					foreach ( $payment_meta as $meta_key => $meta_value ) {
1559
+					foreach ($payment_meta as $meta_key => $meta_value) {
1560 1560
 
1561 1561
 						$exceptions = array(
1562 1562
 							'form_title',
@@ -1569,20 +1569,20 @@  discard block
 block discarded – undo
1569 1569
 						);
1570 1570
 
1571 1571
 						// Don't clutter up results with dupes
1572
-						if ( in_array( $meta_key, $exceptions ) ) {
1572
+						if (in_array($meta_key, $exceptions)) {
1573 1573
 							continue;
1574 1574
 						}
1575 1575
 
1576
-						$donations['donations'][ $i ]['payment_meta'][ $meta_key ] = $meta_value;
1576
+						$donations['donations'][$i]['payment_meta'][$meta_key] = $meta_value;
1577 1577
 
1578 1578
 					}
1579 1579
 				}
1580 1580
 
1581
-				$i ++;
1581
+				$i++;
1582 1582
 			}// End foreach().
1583 1583
 		}// End if().
1584 1584
 
1585
-		return apply_filters( 'give_api_donations_endpoint', $donations );
1585
+		return apply_filters('give_api_donations_endpoint', $donations);
1586 1586
 	}
1587 1587
 
1588 1588
 	/**
@@ -1598,9 +1598,9 @@  discard block
 block discarded – undo
1598 1598
 	public function get_output_format() {
1599 1599
 		global $wp_query;
1600 1600
 
1601
-		$format = isset( $wp_query->query_vars['format'] ) ? $wp_query->query_vars['format'] : 'json';
1601
+		$format = isset($wp_query->query_vars['format']) ? $wp_query->query_vars['format'] : 'json';
1602 1602
 
1603
-		return apply_filters( 'give_api_output_format', $format );
1603
+		return apply_filters('give_api_output_format', $format);
1604 1604
 	}
1605 1605
 
1606 1606
 
@@ -1616,8 +1616,8 @@  discard block
 block discarded – undo
1616 1616
 	 *
1617 1617
 	 * @return void
1618 1618
 	 */
1619
-	private function log_request( $data = array() ) {
1620
-		if ( ! $this->log_requests ) {
1619
+	private function log_request($data = array()) {
1620
+		if ( ! $this->log_requests) {
1621 1621
 			return;
1622 1622
 		}
1623 1623
 
@@ -1628,37 +1628,37 @@  discard block
 block discarded – undo
1628 1628
 
1629 1629
 		$query = array(
1630 1630
 			'give-api'    => $wp_query->query_vars['give-api'],
1631
-			'key'         => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null,
1632
-			'token'       => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null,
1633
-			'query'       => isset( $wp_query->query_vars['query'] ) ? $wp_query->query_vars['query'] : null,
1634
-			'type'        => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null,
1635
-			'form'        => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null,
1636
-			'donor'       => isset( $wp_query->query_vars['donor'] ) ? $wp_query->query_vars['donor'] : null,
1637
-			'date'        => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null,
1638
-			'startdate'   => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null,
1639
-			'enddate'     => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null,
1640
-			'id'          => isset( $wp_query->query_vars['id'] ) ? $wp_query->query_vars['id'] : null,
1641
-			'purchasekey' => isset( $wp_query->query_vars['purchasekey'] ) ? $wp_query->query_vars['purchasekey'] : null,
1642
-			'email'       => isset( $wp_query->query_vars['email'] ) ? $wp_query->query_vars['email'] : null,
1631
+			'key'         => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null,
1632
+			'token'       => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null,
1633
+			'query'       => isset($wp_query->query_vars['query']) ? $wp_query->query_vars['query'] : null,
1634
+			'type'        => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null,
1635
+			'form'        => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null,
1636
+			'donor'       => isset($wp_query->query_vars['donor']) ? $wp_query->query_vars['donor'] : null,
1637
+			'date'        => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null,
1638
+			'startdate'   => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null,
1639
+			'enddate'     => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null,
1640
+			'id'          => isset($wp_query->query_vars['id']) ? $wp_query->query_vars['id'] : null,
1641
+			'purchasekey' => isset($wp_query->query_vars['purchasekey']) ? $wp_query->query_vars['purchasekey'] : null,
1642
+			'email'       => isset($wp_query->query_vars['email']) ? $wp_query->query_vars['email'] : null,
1643 1643
 		);
1644 1644
 
1645 1645
 		$log_data = array(
1646 1646
 			'log_type'     => 'api_request',
1647
-			'post_excerpt' => http_build_query( $query ),
1648
-			'post_content' => ! empty( $data['error'] ) ? $data['error'] : '',
1647
+			'post_excerpt' => http_build_query($query),
1648
+			'post_content' => ! empty($data['error']) ? $data['error'] : '',
1649 1649
 		);
1650 1650
 
1651 1651
 		$log_meta = array(
1652
-			'api_query'  => http_build_query( $query ),
1652
+			'api_query'  => http_build_query($query),
1653 1653
 			'request_ip' => give_get_ip(),
1654 1654
 			'user'       => $this->user_id,
1655
-			'key'        => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null,
1656
-			'token'      => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null,
1655
+			'key'        => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null,
1656
+			'token'      => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null,
1657 1657
 			'time'       => $data['request_speed'],
1658 1658
 			'version'    => $this->get_queried_version(),
1659 1659
 		);
1660 1660
 
1661
-		Give()->logs->insert_log( $log_data, $log_meta );
1661
+		Give()->logs->insert_log($log_data, $log_meta);
1662 1662
 	}
1663 1663
 
1664 1664
 
@@ -1682,11 +1682,11 @@  discard block
 block discarded – undo
1682 1682
 	 *
1683 1683
 	 * @param int       $status_code
1684 1684
 	 */
1685
-	public function output( $status_code = 200 ) {
1685
+	public function output($status_code = 200) {
1686 1686
 
1687 1687
 		$format = $this->get_output_format();
1688 1688
 
1689
-		status_header( $status_code );
1689
+		status_header($status_code);
1690 1690
 
1691 1691
 		/**
1692 1692
 		 * Fires before outputting the API.
@@ -1697,25 +1697,25 @@  discard block
 block discarded – undo
1697 1697
 		 * @param Give_API $this   The Give_API object.
1698 1698
 		 * @param string   $format Output format, XML or JSON. Default is JSON.
1699 1699
 		 */
1700
-		do_action( 'give_api_output_before', $this->data, $this, $format );
1700
+		do_action('give_api_output_before', $this->data, $this, $format);
1701 1701
 
1702
-		switch ( $format ) :
1702
+		switch ($format) :
1703 1703
 
1704 1704
 			case 'xml' :
1705 1705
 
1706
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/array2xml.php';
1707
-				$xml = Array2XML::createXML( 'give', $this->data );
1706
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/array2xml.php';
1707
+				$xml = Array2XML::createXML('give', $this->data);
1708 1708
 				echo $xml->saveXML();
1709 1709
 
1710 1710
 				break;
1711 1711
 
1712 1712
 			case 'json' :
1713 1713
 
1714
-				header( 'Content-Type: application/json' );
1715
-				if ( ! empty( $this->pretty_print ) ) {
1716
-					echo json_encode( $this->data, $this->pretty_print );
1714
+				header('Content-Type: application/json');
1715
+				if ( ! empty($this->pretty_print)) {
1716
+					echo json_encode($this->data, $this->pretty_print);
1717 1717
 				} else {
1718
-					echo json_encode( $this->data );
1718
+					echo json_encode($this->data);
1719 1719
 				}
1720 1720
 
1721 1721
 				break;
@@ -1730,7 +1730,7 @@  discard block
 block discarded – undo
1730 1730
 				 * @param array    $data Response data to return.
1731 1731
 				 * @param Give_API $this The Give_API object.
1732 1732
 				 */
1733
-				do_action( "give_api_output_{$format}", $this->data, $this );
1733
+				do_action("give_api_output_{$format}", $this->data, $this);
1734 1734
 
1735 1735
 				break;
1736 1736
 
@@ -1745,7 +1745,7 @@  discard block
 block discarded – undo
1745 1745
 		 * @param Give_API $this   The Give_API object.
1746 1746
 		 * @param string   $format Output format, XML or JSON. Default is JSON.
1747 1747
 		 */
1748
-		do_action( 'give_api_output_after', $this->data, $this, $format );
1748
+		do_action('give_api_output_after', $this->data, $this, $format);
1749 1749
 
1750 1750
 		give_die();
1751 1751
 	}
@@ -1762,41 +1762,41 @@  discard block
 block discarded – undo
1762 1762
 	 *
1763 1763
 	 * @return void
1764 1764
 	 */
1765
-	function user_key_field( $user ) {
1765
+	function user_key_field($user) {
1766 1766
 
1767
-		if ( ( give_get_option( 'api_allow_user_keys', false ) || current_user_can( 'manage_give_settings' ) ) && current_user_can( 'edit_user', $user->ID ) ) {
1767
+		if ((give_get_option('api_allow_user_keys', false) || current_user_can('manage_give_settings')) && current_user_can('edit_user', $user->ID)) {
1768 1768
 
1769
-			$user = get_userdata( $user->ID );
1769
+			$user = get_userdata($user->ID);
1770 1770
 			?>
1771 1771
 			<table class="form-table">
1772 1772
 				<tbody>
1773 1773
 				<tr>
1774 1774
 					<th>
1775
-						<?php _e( 'Give API Keys', 'give' ); ?>
1775
+						<?php _e('Give API Keys', 'give'); ?>
1776 1776
 					</th>
1777 1777
 					<td>
1778 1778
 						<?php
1779
-						$public_key = $this->get_user_public_key( $user->ID );
1780
-						$secret_key = $this->get_user_secret_key( $user->ID );
1779
+						$public_key = $this->get_user_public_key($user->ID);
1780
+						$secret_key = $this->get_user_secret_key($user->ID);
1781 1781
 						?>
1782
-						<?php if ( empty( $user->give_user_public_key ) ) { ?>
1782
+						<?php if (empty($user->give_user_public_key)) { ?>
1783 1783
 							<input name="give_set_api_key" type="checkbox" id="give_set_api_key" />
1784
-							<span class="description"><?php _e( 'Generate API Key', 'give' ); ?></span>
1784
+							<span class="description"><?php _e('Generate API Key', 'give'); ?></span>
1785 1785
 						<?php } else { ?>
1786
-							<strong style="display:inline-block; width: 125px;"><?php _e( 'Public key:', 'give' ); ?>
1786
+							<strong style="display:inline-block; width: 125px;"><?php _e('Public key:', 'give'); ?>
1787 1787
 								&nbsp;</strong>
1788
-							<input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr( $public_key ); ?>" />
1788
+							<input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr($public_key); ?>" />
1789 1789
 							<br />
1790
-							<strong style="display:inline-block; width: 125px;"><?php _e( 'Secret key:', 'give' ); ?>
1790
+							<strong style="display:inline-block; width: 125px;"><?php _e('Secret key:', 'give'); ?>
1791 1791
 								&nbsp;</strong>
1792
-							<input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr( $secret_key ); ?>" />
1792
+							<input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr($secret_key); ?>" />
1793 1793
 							<br />
1794
-							<strong style="display:inline-block; width: 125px;"><?php _e( 'Token:', 'give' ); ?>
1794
+							<strong style="display:inline-block; width: 125px;"><?php _e('Token:', 'give'); ?>
1795 1795
 								&nbsp;</strong>
1796
-							<input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr( $this->get_token( $user->ID ) ); ?>" />
1796
+							<input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr($this->get_token($user->ID)); ?>" />
1797 1797
 							<br />
1798 1798
 							<input name="give_revoke_api_key" type="checkbox" id="give_revoke_api_key" />
1799
-							<span class="description"><label for="give_revoke_api_key"><?php _e( 'Revoke API Keys', 'give' ); ?></label></span>
1799
+							<span class="description"><label for="give_revoke_api_key"><?php _e('Revoke API Keys', 'give'); ?></label></span>
1800 1800
 						<?php } ?>
1801 1801
 					</td>
1802 1802
 				</tr>
@@ -1815,61 +1815,61 @@  discard block
 block discarded – undo
1815 1815
 	 *
1816 1816
 	 * @return void
1817 1817
 	 */
1818
-	public function process_api_key( $args ) {
1818
+	public function process_api_key($args) {
1819 1819
 
1820
-		if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'give-api-nonce' ) ) {
1821
-			wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ), array(
1820
+		if ( ! wp_verify_nonce($_REQUEST['_wpnonce'], 'give-api-nonce')) {
1821
+			wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'), array(
1822 1822
 				'response' => 403,
1823
-			) );
1823
+			));
1824 1824
 		}
1825 1825
 
1826
-		if ( empty( $args['user_id'] ) ) {
1827
-			wp_die( __( 'User ID Required.', 'give' ), __( 'Error', 'give' ), array(
1826
+		if (empty($args['user_id'])) {
1827
+			wp_die(__('User ID Required.', 'give'), __('Error', 'give'), array(
1828 1828
 				'response' => 401,
1829
-			) );
1829
+			));
1830 1830
 		}
1831 1831
 
1832
-		if ( is_numeric( $args['user_id'] ) ) {
1833
-			$user_id = isset( $args['user_id'] ) ? absint( $args['user_id'] ) : get_current_user_id();
1832
+		if (is_numeric($args['user_id'])) {
1833
+			$user_id = isset($args['user_id']) ? absint($args['user_id']) : get_current_user_id();
1834 1834
 		} else {
1835
-			$userdata = get_user_by( 'login', $args['user_id'] );
1835
+			$userdata = get_user_by('login', $args['user_id']);
1836 1836
 			$user_id  = $userdata->ID;
1837 1837
 		}
1838
-		$process = isset( $args['give_api_process'] ) ? strtolower( $args['give_api_process'] ) : false;
1838
+		$process = isset($args['give_api_process']) ? strtolower($args['give_api_process']) : false;
1839 1839
 
1840
-		if ( $user_id == get_current_user_id() && ! give_get_option( 'allow_user_api_keys' ) && ! current_user_can( 'manage_give_settings' ) ) {
1841
-			wp_die( sprintf( /* translators: %s: process */
1842
-				__( 'You do not have permission to %s API keys for this user.', 'give' ), $process ), __( 'Error', 'give' ), array(
1840
+		if ($user_id == get_current_user_id() && ! give_get_option('allow_user_api_keys') && ! current_user_can('manage_give_settings')) {
1841
+			wp_die(sprintf( /* translators: %s: process */
1842
+				__('You do not have permission to %s API keys for this user.', 'give'), $process ), __('Error', 'give'), array(
1843 1843
 				'response' => 403,
1844
-			) );
1845
-		} elseif ( ! current_user_can( 'manage_give_settings' ) ) {
1846
-			wp_die( sprintf( /* translators: %s: process */
1847
-				__( 'You do not have permission to %s API keys for this user.', 'give' ), $process ), __( 'Error', 'give' ), array(
1844
+			));
1845
+		} elseif ( ! current_user_can('manage_give_settings')) {
1846
+			wp_die(sprintf( /* translators: %s: process */
1847
+				__('You do not have permission to %s API keys for this user.', 'give'), $process ), __('Error', 'give'), array(
1848 1848
 				'response' => 403,
1849
-			) );
1849
+			));
1850 1850
 		}
1851 1851
 
1852
-		switch ( $process ) {
1852
+		switch ($process) {
1853 1853
 			case 'generate':
1854
-				if ( $this->generate_api_key( $user_id ) ) {
1855
-					Give_Cache::delete( Give_Cache::get_key( 'give_total_api_keys' ) );
1856
-					wp_redirect( add_query_arg( 'give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) );
1854
+				if ($this->generate_api_key($user_id)) {
1855
+					Give_Cache::delete(Give_Cache::get_key('give_total_api_keys'));
1856
+					wp_redirect(add_query_arg('give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-tools&tab=api'));
1857 1857
 					exit();
1858 1858
 				} else {
1859
-					wp_redirect( add_query_arg( 'give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) );
1859
+					wp_redirect(add_query_arg('give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-tools&tab=api'));
1860 1860
 					exit();
1861 1861
 				}
1862 1862
 				break;
1863 1863
 			case 'regenerate':
1864
-				$this->generate_api_key( $user_id, true );
1865
-				Give_Cache::delete( Give_Cache::get_key( 'give_total_api_keys' ) );
1866
-				wp_redirect( add_query_arg( 'give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) );
1864
+				$this->generate_api_key($user_id, true);
1865
+				Give_Cache::delete(Give_Cache::get_key('give_total_api_keys'));
1866
+				wp_redirect(add_query_arg('give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-tools&tab=api'));
1867 1867
 				exit();
1868 1868
 				break;
1869 1869
 			case 'revoke':
1870
-				$this->revoke_api_key( $user_id );
1871
-				Give_Cache::delete( Give_Cache::get_key( 'give_total_api_keys' ) );
1872
-				wp_redirect( add_query_arg( 'give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) );
1870
+				$this->revoke_api_key($user_id);
1871
+				Give_Cache::delete(Give_Cache::get_key('give_total_api_keys'));
1872
+				wp_redirect(add_query_arg('give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-tools&tab=api'));
1873 1873
 				exit();
1874 1874
 				break;
1875 1875
 			default;
@@ -1888,59 +1888,59 @@  discard block
 block discarded – undo
1888 1888
 	 *
1889 1889
 	 * @return boolean True if (re)generated successfully, false otherwise.
1890 1890
 	 */
1891
-	public function generate_api_key( $user_id = 0, $regenerate = false ) {
1891
+	public function generate_api_key($user_id = 0, $regenerate = false) {
1892 1892
 
1893 1893
 		// Bail out, if user doesn't exists.
1894
-		if ( empty( $user_id ) ) {
1894
+		if (empty($user_id)) {
1895 1895
 			return false;
1896 1896
 		}
1897 1897
 
1898
-		$user = get_userdata( $user_id );
1898
+		$user = get_userdata($user_id);
1899 1899
 
1900 1900
 		// Bail Out, if user object doesn't exists.
1901
-		if ( ! $user ) {
1901
+		if ( ! $user) {
1902 1902
 			return false;
1903 1903
 		}
1904 1904
 
1905 1905
 		$new_public_key = '';
1906 1906
 		$new_secret_key = '';
1907 1907
 
1908
-		if( ! empty( $_POST['from'] ) && 'profile' === $_POST['from'] ) {
1908
+		if ( ! empty($_POST['from']) && 'profile' === $_POST['from']) {
1909 1909
 			// For User Profile Page.
1910
-			if( ! empty( $_POST['give_set_api_key'] ) ) {
1910
+			if ( ! empty($_POST['give_set_api_key'])) {
1911 1911
 				// Generate API Key from User Profile page.
1912
-				$new_public_key = $this->generate_public_key( $user->user_email );
1913
-				$new_secret_key = $this->generate_private_key( $user->ID );
1914
-			} elseif ( ! empty( $_POST['give_revoke_api_key'] ) ) {
1912
+				$new_public_key = $this->generate_public_key($user->user_email);
1913
+				$new_secret_key = $this->generate_private_key($user->ID);
1914
+			} elseif ( ! empty($_POST['give_revoke_api_key'])) {
1915 1915
 				// Revoke API Key from User Profile page.
1916
-				$this->revoke_api_key( $user->ID );
1916
+				$this->revoke_api_key($user->ID);
1917 1917
 			} else {
1918 1918
 				return false;
1919 1919
 			}
1920 1920
 		} else {
1921 1921
 			// For Tools > API page.
1922
-			$public_key = $this->get_user_public_key( $user_id );
1922
+			$public_key = $this->get_user_public_key($user_id);
1923 1923
 
1924
-			if ( empty( $public_key ) && ! $regenerate ) {
1924
+			if (empty($public_key) && ! $regenerate) {
1925 1925
 				// Generating API for first time.
1926
-				$new_public_key = $this->generate_public_key( $user->user_email );
1927
-				$new_secret_key = $this->generate_private_key( $user->ID );
1928
-			} elseif ( $public_key && $regenerate ) {
1926
+				$new_public_key = $this->generate_public_key($user->user_email);
1927
+				$new_secret_key = $this->generate_private_key($user->ID);
1928
+			} elseif ($public_key && $regenerate) {
1929 1929
 				// API Key already exists and Regenerating API Key.
1930
-				$this->revoke_api_key( $user->ID );
1931
-				$new_public_key = $this->generate_public_key( $user->user_email );
1932
-				$new_secret_key = $this->generate_private_key( $user->ID );
1933
-			} elseif ( ! empty( $public_key ) && ! $regenerate ) {
1930
+				$this->revoke_api_key($user->ID);
1931
+				$new_public_key = $this->generate_public_key($user->user_email);
1932
+				$new_secret_key = $this->generate_private_key($user->ID);
1933
+			} elseif ( ! empty($public_key) && ! $regenerate) {
1934 1934
 				// Doing nothing, when API Key exists but still try to generate again instead of regenerating.
1935 1935
 				return false;
1936 1936
 			} else {
1937 1937
 				// Revoke API Key.
1938
-				$this->revoke_api_key( $user->ID );
1938
+				$this->revoke_api_key($user->ID);
1939 1939
 			}
1940 1940
 		}
1941 1941
 
1942
-		update_user_meta( $user_id, $new_public_key, 'give_user_public_key' );
1943
-		update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' );
1942
+		update_user_meta($user_id, $new_public_key, 'give_user_public_key');
1943
+		update_user_meta($user_id, $new_secret_key, 'give_user_secret_key');
1944 1944
 
1945 1945
 		return true;
1946 1946
 	}
@@ -1955,26 +1955,26 @@  discard block
 block discarded – undo
1955 1955
 	 *
1956 1956
 	 * @return bool
1957 1957
 	 */
1958
-	public function revoke_api_key( $user_id = 0 ) {
1958
+	public function revoke_api_key($user_id = 0) {
1959 1959
 
1960
-		if ( empty( $user_id ) ) {
1960
+		if (empty($user_id)) {
1961 1961
 			return false;
1962 1962
 		}
1963 1963
 
1964
-		$user = get_userdata( $user_id );
1964
+		$user = get_userdata($user_id);
1965 1965
 
1966
-		if ( ! $user ) {
1966
+		if ( ! $user) {
1967 1967
 			return false;
1968 1968
 		}
1969 1969
 
1970
-		$public_key = $this->get_user_public_key( $user_id );
1971
-		$secret_key = $this->get_user_secret_key( $user_id );
1972
-		if ( ! empty( $public_key ) ) {
1973
-			Give_Cache::delete( Give_Cache::get_key( md5( 'give_api_user_' . $public_key ) ) );
1974
-			Give_Cache::delete( Give_Cache::get_key( md5( 'give_api_user_public_key' . $user_id ) ) );
1975
-			Give_Cache::delete( Give_Cache::get_key( md5( 'give_api_user_secret_key' . $user_id ) ) );
1976
-			delete_user_meta( $user_id, $public_key );
1977
-			delete_user_meta( $user_id, $secret_key );
1970
+		$public_key = $this->get_user_public_key($user_id);
1971
+		$secret_key = $this->get_user_secret_key($user_id);
1972
+		if ( ! empty($public_key)) {
1973
+			Give_Cache::delete(Give_Cache::get_key(md5('give_api_user_'.$public_key)));
1974
+			Give_Cache::delete(Give_Cache::get_key(md5('give_api_user_public_key'.$user_id)));
1975
+			Give_Cache::delete(Give_Cache::get_key(md5('give_api_user_secret_key'.$user_id)));
1976
+			delete_user_meta($user_id, $public_key);
1977
+			delete_user_meta($user_id, $secret_key);
1978 1978
 		} else {
1979 1979
 			return false;
1980 1980
 		}
@@ -1996,9 +1996,9 @@  discard block
 block discarded – undo
1996 1996
 	 *
1997 1997
 	 * @return string
1998 1998
 	 */
1999
-	private function generate_public_key( $user_email = '' ) {
2000
-		$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
2001
-		$public   = hash( 'md5', $user_email . $auth_key . date( 'U' ) );
1999
+	private function generate_public_key($user_email = '') {
2000
+		$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
2001
+		$public   = hash('md5', $user_email.$auth_key.date('U'));
2002 2002
 
2003 2003
 		return $public;
2004 2004
 	}
@@ -2013,9 +2013,9 @@  discard block
 block discarded – undo
2013 2013
 	 *
2014 2014
 	 * @return string
2015 2015
 	 */
2016
-	private function generate_private_key( $user_id = 0 ) {
2017
-		$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
2018
-		$secret   = hash( 'md5', $user_id . $auth_key . date( 'U' ) );
2016
+	private function generate_private_key($user_id = 0) {
2017
+		$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
2018
+		$secret   = hash('md5', $user_id.$auth_key.date('U'));
2019 2019
 
2020 2020
 		return $secret;
2021 2021
 	}
@@ -2030,8 +2030,8 @@  discard block
 block discarded – undo
2030 2030
 	 *
2031 2031
 	 * @return string
2032 2032
 	 */
2033
-	public function get_token( $user_id = 0 ) {
2034
-		return hash( 'md5', $this->get_user_secret_key( $user_id ) . $this->get_user_public_key( $user_id ) );
2033
+	public function get_token($user_id = 0) {
2034
+		return hash('md5', $this->get_user_secret_key($user_id).$this->get_user_public_key($user_id));
2035 2035
 	}
2036 2036
 
2037 2037
 	/**
@@ -2045,9 +2045,9 @@  discard block
 block discarded – undo
2045 2045
 
2046 2046
 		// Default sales return
2047 2047
 		$donations                               = array();
2048
-		$donations['donations']['today']         = $this->stats->get_sales( 0, 'today' );
2049
-		$donations['donations']['current_month'] = $this->stats->get_sales( 0, 'this_month' );
2050
-		$donations['donations']['last_month']    = $this->stats->get_sales( 0, 'last_month' );
2048
+		$donations['donations']['today']         = $this->stats->get_sales(0, 'today');
2049
+		$donations['donations']['current_month'] = $this->stats->get_sales(0, 'this_month');
2050
+		$donations['donations']['last_month']    = $this->stats->get_sales(0, 'last_month');
2051 2051
 		$donations['donations']['totals']        = give_get_total_donations();
2052 2052
 
2053 2053
 		return $donations;
@@ -2064,9 +2064,9 @@  discard block
 block discarded – undo
2064 2064
 
2065 2065
 		// Default earnings return
2066 2066
 		$earnings                              = array();
2067
-		$earnings['earnings']['today']         = $this->stats->get_earnings( 0, 'today' );
2068
-		$earnings['earnings']['current_month'] = $this->stats->get_earnings( 0, 'this_month' );
2069
-		$earnings['earnings']['last_month']    = $this->stats->get_earnings( 0, 'last_month' );
2067
+		$earnings['earnings']['today']         = $this->stats->get_earnings(0, 'today');
2068
+		$earnings['earnings']['current_month'] = $this->stats->get_earnings(0, 'this_month');
2069
+		$earnings['earnings']['last_month']    = $this->stats->get_earnings(0, 'last_month');
2070 2070
 		$earnings['earnings']['totals']        = give_get_total_earnings();
2071 2071
 
2072 2072
 		return $earnings;
@@ -2086,25 +2086,25 @@  discard block
 block discarded – undo
2086 2086
 	 *
2087 2087
 	 * @return string            The API key/secret for the user supplied
2088 2088
 	 */
2089
-	public function api_key_backwards_compat( $check, $object_id, $meta_key, $single ) {
2089
+	public function api_key_backwards_compat($check, $object_id, $meta_key, $single) {
2090 2090
 
2091
-		if ( $meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key' ) {
2091
+		if ($meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key') {
2092 2092
 			return $check;
2093 2093
 		}
2094 2094
 
2095 2095
 		$return = $check;
2096 2096
 
2097
-		switch ( $meta_key ) {
2097
+		switch ($meta_key) {
2098 2098
 			case 'give_user_public_key':
2099
-				$return = Give()->api->get_user_public_key( $object_id );
2099
+				$return = Give()->api->get_user_public_key($object_id);
2100 2100
 				break;
2101 2101
 			case 'give_user_secret_key':
2102
-				$return = Give()->api->get_user_secret_key( $object_id );
2102
+				$return = Give()->api->get_user_secret_key($object_id);
2103 2103
 				break;
2104 2104
 		}
2105 2105
 
2106
-		if ( ! $single ) {
2107
-			$return = array( $return );
2106
+		if ( ! $single) {
2107
+			$return = array($return);
2108 2108
 		}
2109 2109
 
2110 2110
 		return $return;
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 	 * @uses   Give_API::invalid_key()
327 327
 	 * @uses   Give_API::invalid_auth()
328 328
 	 * @since  1.1
329
-	 * @return bool
329
+	 * @return false|null
330 330
 	 */
331 331
 	private function validate_request() {
332 332
 		global $wp_query;
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
 	 *
723 723
 	 * @param array $args Arguments to override defaults
724 724
 	 *
725
-	 * @return array $dates
725
+	 * @return integer|null $dates
726 726
 	 */
727 727
 	public function get_dates( $args = array() ) {
728 728
 		$dates = array();
Please login to merge, or discard this patch.
includes/class-give-gravatars.php 1 patch
Spacing   +94 added lines, -94 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
 
@@ -62,51 +62,51 @@  discard block
 block discarded – undo
62 62
 	 *
63 63
 	 * @return bool If the gravatar exists or not
64 64
 	 */
65
-	public function validate_gravatar( $id_or_email ) {
65
+	public function validate_gravatar($id_or_email) {
66 66
 		//id or email code borrowed from wp-includes/pluggable.php
67 67
 		$email = '';
68
-		if ( is_numeric( $id_or_email ) ) {
68
+		if (is_numeric($id_or_email)) {
69 69
 			$id   = (int) $id_or_email;
70
-			$user = get_userdata( $id );
71
-			if ( $user ) {
70
+			$user = get_userdata($id);
71
+			if ($user) {
72 72
 				$email = $user->user_email;
73 73
 			}
74
-		} elseif ( is_object( $id_or_email ) ) {
74
+		} elseif (is_object($id_or_email)) {
75 75
 			// No avatar for pingbacks or trackbacks
76
-			$allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) );
77
-			if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) ) {
76
+			$allowed_comment_types = apply_filters('get_avatar_comment_types', array('comment'));
77
+			if ( ! empty($id_or_email->comment_type) && ! in_array($id_or_email->comment_type, (array) $allowed_comment_types)) {
78 78
 				return false;
79 79
 			}
80 80
 
81
-			if ( ! empty( $id_or_email->user_id ) ) {
81
+			if ( ! empty($id_or_email->user_id)) {
82 82
 				$id   = (int) $id_or_email->user_id;
83
-				$user = get_userdata( $id );
84
-				if ( $user ) {
83
+				$user = get_userdata($id);
84
+				if ($user) {
85 85
 					$email = $user->user_email;
86 86
 				}
87
-			} elseif ( ! empty( $id_or_email->comment_author_email ) ) {
87
+			} elseif ( ! empty($id_or_email->comment_author_email)) {
88 88
 				$email = $id_or_email->comment_author_email;
89 89
 			}
90 90
 		} else {
91 91
 			$email = $id_or_email;
92 92
 		}
93 93
 
94
-		$hashkey = md5( strtolower( trim( $email ) ) );
95
-		$uri     = 'http://www.gravatar.com/avatar/' . $hashkey . '?d=404';
94
+		$hashkey = md5(strtolower(trim($email)));
95
+		$uri     = 'http://www.gravatar.com/avatar/'.$hashkey.'?d=404';
96 96
 
97
-		$data = Give_Cache::get_group( $hashkey );
97
+		$data = Give_Cache::get_group($hashkey);
98 98
 
99
-		if ( is_null( $data ) ) {
100
-			$response = wp_remote_head( $uri );
101
-			if ( is_wp_error( $response ) ) {
99
+		if (is_null($data)) {
100
+			$response = wp_remote_head($uri);
101
+			if (is_wp_error($response)) {
102 102
 				$data = 'not200';
103 103
 			} else {
104 104
 				$data = $response['response']['code'];
105 105
 			}
106
-			Give_Cache::set_group( $hashkey, $data, $group = '', $expire = 60 * 5 );
106
+			Give_Cache::set_group($hashkey, $data, $group = '', $expire = 60 * 5);
107 107
 
108 108
 		}
109
-		if ( $data == '200' ) {
109
+		if ($data == '200') {
110 110
 			return true;
111 111
 		} else {
112 112
 			return false;
@@ -123,15 +123,15 @@  discard block
 block discarded – undo
123 123
 	 *
124 124
 	 * @return array        IDs if logs, false otherwise
125 125
 	 */
126
-	public function get_log_ids( $form_id = '' ) {
126
+	public function get_log_ids($form_id = '') {
127 127
 		// get log for this form
128
-		$logs = Give()->logs->get_logs( $form_id );
128
+		$logs = Give()->logs->get_logs($form_id);
129 129
 
130
-		if ( $logs ) {
130
+		if ($logs) {
131 131
 			$log_ids = array();
132 132
 
133 133
 			// make an array with all the donor IDs
134
-			foreach ( $logs as $log ) {
134
+			foreach ($logs as $log) {
135 135
 				$log_ids[] = $log->ID;
136 136
 			}
137 137
 
@@ -152,51 +152,51 @@  discard block
 block discarded – undo
152 152
 	 *
153 153
 	 * @return mixed
154 154
 	 */
155
-	public function get_payment_ids( $form_id = '' ) {
155
+	public function get_payment_ids($form_id = '') {
156 156
 
157 157
 		$give_options = give_get_settings();
158 158
 
159
-		$log_ids = $this->get_log_ids( $form_id );
159
+		$log_ids = $this->get_log_ids($form_id);
160 160
 
161
-		if ( $log_ids ) {
161
+		if ($log_ids) {
162 162
 
163 163
 			$payment_ids = array();
164 164
 
165
-			foreach ( $log_ids as $id ) {
165
+			foreach ($log_ids as $id) {
166 166
 				// get the payment ID for each corresponding log ID
167
-				$payment_ids[] = give_get_meta( $id, '_give_log_payment_id', true );
167
+				$payment_ids[] = give_get_meta($id, '_give_log_payment_id', true);
168 168
 			}
169 169
 
170 170
 			// remove donors who have donated more than once so we can have unique avatars
171 171
 			$unique_emails = array();
172 172
 
173
-			foreach ( $payment_ids as $key => $id ) {
173
+			foreach ($payment_ids as $key => $id) {
174 174
 
175
-				$email = give_get_meta( $id, '_give_payment_donor_email', true );
175
+				$email = give_get_meta($id, '_give_payment_donor_email', true);
176 176
 
177
-				if ( isset ( $give_options['give_donors_gravatars_has_gravatar_account'] ) ) {
178
-					if ( ! $this->validate_gravatar( $email ) ) {
177
+				if (isset ($give_options['give_donors_gravatars_has_gravatar_account'])) {
178
+					if ( ! $this->validate_gravatar($email)) {
179 179
 						continue;
180 180
 					}
181 181
 				}
182 182
 
183
-				$unique_emails[ $id ] = give_get_meta( $id, '_give_payment_donor_email', true );
183
+				$unique_emails[$id] = give_get_meta($id, '_give_payment_donor_email', true);
184 184
 
185 185
 			}
186 186
 
187 187
 			$unique_ids = array();
188 188
 
189 189
 			// strip duplicate emails
190
-			$unique_emails = array_unique( $unique_emails );
190
+			$unique_emails = array_unique($unique_emails);
191 191
 
192 192
 			// convert the unique IDs back into simple array
193
-			foreach ( $unique_emails as $id => $email ) {
193
+			foreach ($unique_emails as $id => $email) {
194 194
 				$unique_ids[] = $id;
195 195
 			}
196 196
 
197 197
 			// randomize the payment IDs if enabled
198
-			if ( isset( $give_options['give_donors_gravatars_random_gravatars'] ) ) {
199
-				shuffle( $unique_ids );
198
+			if (isset($give_options['give_donors_gravatars_random_gravatars'])) {
199
+				shuffle($unique_ids);
200 200
 			}
201 201
 
202 202
 			// return our unique IDs
@@ -217,22 +217,22 @@  discard block
 block discarded – undo
217 217
 	 *
218 218
 	 * @return string
219 219
 	 */
220
-	public function gravatars( $form_id = false, $title = '' ) {
220
+	public function gravatars($form_id = false, $title = '') {
221 221
 
222 222
 		// unique $payment_ids 
223
-		$payment_ids = $this->get_payment_ids( $form_id );
223
+		$payment_ids = $this->get_payment_ids($form_id);
224 224
 
225 225
 		$give_options = give_get_settings();
226 226
 
227 227
 		// return if no ID
228
-		if ( ! $form_id ) {
228
+		if ( ! $form_id) {
229 229
 			return;
230 230
 		}
231 231
 
232 232
 		// minimum amount of donations before showing gravatars
233 233
 		// if the number of items in array is not greater or equal to the number specified, then exit
234
-		if ( isset( $give_options['give_donors_gravatars_min_purchases_required'] ) && '' != $give_options['give_donors_gravatars_min_purchases_required'] ) {
235
-			if ( ! ( count( $payment_ids ) >= $give_options['give_donors_gravatars_min_purchases_required'] ) ) {
234
+		if (isset($give_options['give_donors_gravatars_min_purchases_required']) && '' != $give_options['give_donors_gravatars_min_purchases_required']) {
235
+			if ( ! (count($payment_ids) >= $give_options['give_donors_gravatars_min_purchases_required'])) {
236 236
 				return;
237 237
 			}
238 238
 		}
@@ -243,28 +243,28 @@  discard block
 block discarded – undo
243 243
 		echo '<div id="give-purchase-gravatars">';
244 244
 
245 245
 
246
-		if ( isset ( $title ) ) {
246
+		if (isset ($title)) {
247 247
 
248
-			if ( $title ) {
249
-				echo apply_filters( 'give_donors_gravatars_title', '<h3 class="give-gravatars-title">' . esc_attr( $title ) . '</h3>' );
250
-			} elseif ( isset( $give_options['give_donors_gravatars_heading'] ) ) {
251
-				echo apply_filters( 'give_donors_gravatars_title', '<h3 class="give-gravatars-title">' . esc_attr( $give_options['give_donors_gravatars_heading'] ) . '</h2>' );
248
+			if ($title) {
249
+				echo apply_filters('give_donors_gravatars_title', '<h3 class="give-gravatars-title">'.esc_attr($title).'</h3>');
250
+			} elseif (isset($give_options['give_donors_gravatars_heading'])) {
251
+				echo apply_filters('give_donors_gravatars_title', '<h3 class="give-gravatars-title">'.esc_attr($give_options['give_donors_gravatars_heading']).'</h2>');
252 252
 			}
253 253
 
254 254
 		}
255 255
 		echo '<ul class="give-purchase-gravatars-list">';
256 256
 		$i = 0;
257 257
 
258
-		if ( $payment_ids ) {
259
-			foreach ( $payment_ids as $id ) {
258
+		if ($payment_ids) {
259
+			foreach ($payment_ids as $id) {
260 260
 
261 261
 				// Give saves a blank option even when the control is turned off, hence the extra check
262
-				if ( isset( $give_options['give_donors_gravatars_maximum_number'] ) && '' != $give_options['give_donors_gravatars_maximum_number'] && $i == $give_options['give_donors_gravatars_maximum_number'] ) {
262
+				if (isset($give_options['give_donors_gravatars_maximum_number']) && '' != $give_options['give_donors_gravatars_maximum_number'] && $i == $give_options['give_donors_gravatars_maximum_number']) {
263 263
 					continue;
264 264
 				}
265 265
 
266 266
 				// get the payment meta
267
-				$payment_meta = give_get_meta( $id, '_give_payment_meta', true );
267
+				$payment_meta = give_get_meta($id, '_give_payment_meta', true);
268 268
 
269 269
 				$user_info = $payment_meta['user_info'];
270 270
 
@@ -272,21 +272,21 @@  discard block
 block discarded – undo
272 272
 				$name = $user_info['first_name'];
273 273
 
274 274
 				// get donor's email
275
-				$email = give_get_meta( $id, '_give_payment_donor_email', true );
275
+				$email = give_get_meta($id, '_give_payment_donor_email', true);
276 276
 
277 277
 				// set gravatar size and provide filter
278
-				$size = isset( $give_options['give_donors_gravatars_gravatar_size'] ) ? apply_filters( 'give_donors_gravatars_gravatar_size', $give_options['give_donors_gravatars_gravatar_size'] ) : '';
278
+				$size = isset($give_options['give_donors_gravatars_gravatar_size']) ? apply_filters('give_donors_gravatars_gravatar_size', $give_options['give_donors_gravatars_gravatar_size']) : '';
279 279
 
280 280
 				// default image
281
-				$default_image = apply_filters( 'give_donors_gravatars_gravatar_default_image', false );
281
+				$default_image = apply_filters('give_donors_gravatars_gravatar_default_image', false);
282 282
 
283 283
 				// assemble output
284 284
 				$output .= '<li>';
285 285
 
286
-				$output .= get_avatar( $email, $size, $default_image, $name );
286
+				$output .= get_avatar($email, $size, $default_image, $name);
287 287
 				$output .= '</li>';
288 288
 
289
-				$i ++;
289
+				$i++;
290 290
 
291 291
 			} // end foreach
292 292
 		}
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 		echo '</ul>';
296 296
 		echo '</div>';
297 297
 
298
-		return apply_filters( 'give_donors_gravatars', ob_get_clean() );
298
+		return apply_filters('give_donors_gravatars', ob_get_clean());
299 299
 	}
300 300
 
301 301
 	/**
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 	 * @return void
308 308
 	 */
309 309
 	public function register_widget() {
310
-		register_widget( 'Give_Donors_Gravatars_Widget' );
310
+		register_widget('Give_Donors_Gravatars_Widget');
311 311
 	}
312 312
 
313 313
 	/**
@@ -321,19 +321,19 @@  discard block
 block discarded – undo
321 321
 	 *
322 322
 	 * @return string
323 323
 	 */
324
-	public function shortcode( $atts, $content = null ) {
324
+	public function shortcode($atts, $content = null) {
325 325
 
326
-		$atts = shortcode_atts( array(
326
+		$atts = shortcode_atts(array(
327 327
 			'id'    => '',
328 328
 			'title' => ''
329
-		), $atts, 'give_donors_gravatars' );
329
+		), $atts, 'give_donors_gravatars');
330 330
 
331 331
 		// if no ID is passed on single give_forms pages, get the correct ID
332
-		if ( is_singular( 'give_forms' ) ) {
332
+		if (is_singular('give_forms')) {
333 333
 			$id = get_the_ID();
334 334
 		}
335 335
 
336
-		$content = $this->gravatars( $atts['id'], $atts['title'] );
336
+		$content = $this->gravatars($atts['id'], $atts['title']);
337 337
 
338 338
 		return $content;
339 339
 
@@ -349,56 +349,56 @@  discard block
 block discarded – undo
349 349
 	 *
350 350
 	 * @return array           Gravatar settings.
351 351
 	 */
352
-	public function settings( $settings ) {
352
+	public function settings($settings) {
353 353
 
354 354
 		$give_gravatar_settings = array(
355 355
 			array(
356
-				'name' => esc_html__( 'Donator Gravatars', 'give' ),
356
+				'name' => esc_html__('Donator Gravatars', 'give'),
357 357
 				'desc' => '<hr>',
358 358
 				'id'   => 'give_title',
359 359
 				'type' => 'give_title'
360 360
 			),
361 361
 			array(
362
-				'name' => esc_html__( 'Heading', 'give' ),
363
-				'desc' => esc_html__( 'The heading to display above the Gravatars.', 'give' ),
362
+				'name' => esc_html__('Heading', 'give'),
363
+				'desc' => esc_html__('The heading to display above the Gravatars.', 'give'),
364 364
 				'type' => 'text',
365 365
 				'id'   => 'give_donors_gravatars_heading'
366 366
 			),
367 367
 			array(
368
-				'name'    => esc_html__( 'Gravatar Size', 'give' ),
369
-				'desc'    => esc_html__( 'The size of each Gravatar in pixels (512px maximum).', 'give' ),
368
+				'name'    => esc_html__('Gravatar Size', 'give'),
369
+				'desc'    => esc_html__('The size of each Gravatar in pixels (512px maximum).', 'give'),
370 370
 				'type'    => 'text_small',
371 371
 				'id'      => 'give_donors_gravatars_gravatar_size',
372 372
 				'default' => '64'
373 373
 			),
374 374
 			array(
375
-				'name' => esc_html__( 'Minimum Unique Donations Required', 'give' ),
376
-				'desc' => esc_html__( 'The minimum number of unique donations a form must have before the Gravatars are shown. Leave blank for no minimum.', 'give' ),
375
+				'name' => esc_html__('Minimum Unique Donations Required', 'give'),
376
+				'desc' => esc_html__('The minimum number of unique donations a form must have before the Gravatars are shown. Leave blank for no minimum.', 'give'),
377 377
 				'type' => 'text_small',
378 378
 				'id'   => 'give_donors_gravatars_min_purchases_required',
379 379
 			),
380 380
 			array(
381
-				'name'    => esc_html__( 'Maximum Gravatars To Show', 'give' ),
382
-				'desc'    => esc_html__( 'The maximum number of gravatars to show. Leave blank for no limit.', 'give' ),
381
+				'name'    => esc_html__('Maximum Gravatars To Show', 'give'),
382
+				'desc'    => esc_html__('The maximum number of gravatars to show. Leave blank for no limit.', 'give'),
383 383
 				'type'    => 'text',
384 384
 				'id'      => 'give_donors_gravatars_maximum_number',
385 385
 				'default' => '20',
386 386
 			),
387 387
 			array(
388
-				'name' => esc_html__( 'Gravatar Visibility', 'give' ),
389
-				'desc' => esc_html__( 'Show only donors with a Gravatar account.', 'give' ),
388
+				'name' => esc_html__('Gravatar Visibility', 'give'),
389
+				'desc' => esc_html__('Show only donors with a Gravatar account.', 'give'),
390 390
 				'id'   => 'give_donors_gravatars_has_gravatar_account',
391 391
 				'type' => 'checkbox',
392 392
 			),
393 393
 			array(
394
-				'name' => esc_html__( 'Randomize Gravatars', 'give' ),
395
-				'desc' => esc_html__( 'Randomize the Gravatars.', 'give' ),
394
+				'name' => esc_html__('Randomize Gravatars', 'give'),
395
+				'desc' => esc_html__('Randomize the Gravatars.', 'give'),
396 396
 				'id'   => 'give_donors_gravatars_random_gravatars',
397 397
 				'type' => 'checkbox',
398 398
 			),
399 399
 		);
400 400
 
401
-		return array_merge( $settings, $give_gravatar_settings );
401
+		return array_merge($settings, $give_gravatar_settings);
402 402
 	}
403 403
 
404 404
 }
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
 		// widget settings
425 425
 		$widget_ops = array(
426 426
 			'classname'   => 'give-donors-gravatars',
427
-			'description' => esc_html__( 'Displays gravatars of people who have donated using your your form. Will only show on the single form page.', 'give' ),
427
+			'description' => esc_html__('Displays gravatars of people who have donated using your your form. Will only show on the single form page.', 'give'),
428 428
 		);
429 429
 
430 430
 		// widget control settings
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 		// create the widget
438 438
 		parent::__construct(
439 439
 			'give_donors_gravatars_widget',
440
-			esc_html__( 'Give Donors Gravatars', 'give' ),
440
+			esc_html__('Give Donors Gravatars', 'give'),
441 441
 			$widget_ops,
442 442
 			$control_ops
443 443
 		);
@@ -457,29 +457,29 @@  discard block
 block discarded – undo
457 457
 	 *
458 458
 	 * @return void
459 459
 	 */
460
-	public function widget( $args, $instance ) {
460
+	public function widget($args, $instance) {
461 461
 
462 462
 		//@TODO: Don't extract it!!!
463
-		extract( $args );
463
+		extract($args);
464 464
 
465
-		if ( ! is_singular( 'give_forms' ) ) {
465
+		if ( ! is_singular('give_forms')) {
466 466
 			return;
467 467
 		}
468 468
 
469 469
 		// Variables from widget settings
470
-		$title = apply_filters( 'widget_title', $instance['title'] );
470
+		$title = apply_filters('widget_title', $instance['title']);
471 471
 
472 472
 		// Used by themes. Opens the widget
473 473
 		echo $before_widget;
474 474
 
475 475
 		// Display the widget title
476
-		if ( $title ) {
477
-			echo $before_title . $title . $after_title;
476
+		if ($title) {
477
+			echo $before_title.$title.$after_title;
478 478
 		}
479 479
 
480 480
 		$gravatars = new Give_Donors_Gravatars();
481 481
 
482
-		echo $gravatars->gravatars( get_the_ID(), null ); // remove title
482
+		echo $gravatars->gravatars(get_the_ID(), null); // remove title
483 483
 
484 484
 		// Used by themes. Closes the widget
485 485
 		echo $after_widget;
@@ -499,11 +499,11 @@  discard block
 block discarded – undo
499 499
 	 *
500 500
 	 * @return array Updated settings to save.
501 501
 	 */
502
-	public function update( $new_instance, $old_instance ) {
502
+	public function update($new_instance, $old_instance) {
503 503
 
504 504
 		$instance = $old_instance;
505 505
 
506
-		$instance['title'] = strip_tags( $new_instance['title'] );
506
+		$instance['title'] = strip_tags($new_instance['title']);
507 507
 
508 508
 		return $instance;
509 509
 
@@ -521,19 +521,19 @@  discard block
 block discarded – undo
521 521
 	 *
522 522
 	 * @return void
523 523
 	 */
524
-	public function form( $instance ) {
524
+	public function form($instance) {
525 525
 
526 526
 		// Set up some default widget settings.
527 527
 		$defaults = array(
528 528
 			'title' => '',
529 529
 		);
530 530
 
531
-		$instance = wp_parse_args( (array) $instance, $defaults ); ?>
531
+		$instance = wp_parse_args((array) $instance, $defaults); ?>
532 532
 
533 533
 		<!-- Title -->
534 534
 		<p>
535
-			<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'give' ) ?></label>
536
-			<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $instance['title']; ?>" />
535
+			<label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('Title:', 'give') ?></label>
536
+			<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $instance['title']; ?>" />
537 537
 		</p>
538 538
 
539 539
 		<?php
Please login to merge, or discard this patch.
includes/class-give-cron.php 1 patch
Spacing   +19 added lines, -19 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
 
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	 * @return static
52 52
 	 */
53 53
 	public static function get_instance() {
54
-		if ( null === static::$instance ) {
54
+		if (null === static::$instance) {
55 55
 			self::$instance = new static();
56 56
 			self::$instance->setup();
57 57
 		}
@@ -66,8 +66,8 @@  discard block
 block discarded – undo
66 66
 	 * @since 1.8.13
67 67
 	 */
68 68
 	private function setup() {
69
-		add_filter( 'cron_schedules', array( self::$instance, '__add_schedules' ) );
70
-		add_action( 'wp', array( self::$instance, '__schedule_events' ) );
69
+		add_filter('cron_schedules', array(self::$instance, '__add_schedules'));
70
+		add_action('wp', array(self::$instance, '__schedule_events'));
71 71
 	}
72 72
 
73 73
 	/**
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
 	 *
81 81
 	 * @return array            An array of non-default cron schedules.
82 82
 	 */
83
-	public function __add_schedules( $schedules = array() ) {
83
+	public function __add_schedules($schedules = array()) {
84 84
 		// Adds once weekly to the existing schedules.
85 85
 		$schedules['weekly'] = array(
86 86
 			'interval' => 604800,
87
-			'display'  => __( 'Once Weekly', 'give' ),
87
+			'display'  => __('Once Weekly', 'give'),
88 88
 		);
89 89
 
90 90
 		return $schedules;
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
 	 * @return void
113 113
 	 */
114 114
 	private function weekly_events() {
115
-		if ( ! wp_next_scheduled( 'give_weekly_scheduled_events' ) ) {
116
-			wp_schedule_event( current_time( 'timestamp' ), 'weekly', 'give_weekly_scheduled_events' );
115
+		if ( ! wp_next_scheduled('give_weekly_scheduled_events')) {
116
+			wp_schedule_event(current_time('timestamp'), 'weekly', 'give_weekly_scheduled_events');
117 117
 		}
118 118
 	}
119 119
 
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
 	 * @return void
127 127
 	 */
128 128
 	private function daily_events() {
129
-		if ( ! wp_next_scheduled( 'give_daily_scheduled_events' ) ) {
130
-			wp_schedule_event( current_time( 'timestamp' ), 'daily', 'give_daily_scheduled_events' );
129
+		if ( ! wp_next_scheduled('give_daily_scheduled_events')) {
130
+			wp_schedule_event(current_time('timestamp'), 'daily', 'give_daily_scheduled_events');
131 131
 		}
132 132
 	}
133 133
 
@@ -141,8 +141,8 @@  discard block
 block discarded – undo
141 141
 	 *
142 142
 	 * @return string
143 143
 	 */
144
-	public static function get_cron_action( $type = 'weekly' ) {
145
-		switch ( $type ) {
144
+	public static function get_cron_action($type = 'weekly') {
145
+		switch ($type) {
146 146
 			case 'daily':
147 147
 				$cron_action = 'give_daily_scheduled_events';
148 148
 				break;
@@ -164,9 +164,9 @@  discard block
 block discarded – undo
164 164
 	 * @param        $action
165 165
 	 * @param string $type
166 166
 	 */
167
-	private static function add_event( $action, $type = 'weekly' ) {
168
-		$cron_event = self::get_cron_action( $type );
169
-		add_action( $cron_event, $action );
167
+	private static function add_event($action, $type = 'weekly') {
168
+		$cron_event = self::get_cron_action($type);
169
+		add_action($cron_event, $action);
170 170
 	}
171 171
 
172 172
 	/**
@@ -177,8 +177,8 @@  discard block
 block discarded – undo
177 177
 	 *
178 178
 	 * @param $action
179 179
 	 */
180
-	public static function add_weekly_event( $action ) {
181
-		self::add_event( $action, 'weekly' );
180
+	public static function add_weekly_event($action) {
181
+		self::add_event($action, 'weekly');
182 182
 	}
183 183
 
184 184
 	/**
@@ -189,8 +189,8 @@  discard block
 block discarded – undo
189 189
 	 *
190 190
 	 * @param $action
191 191
 	 */
192
-	public static function add_daily_event( $action ) {
193
-		self::add_event( $action, 'daily' );
192
+	public static function add_daily_event($action) {
193
+		self::add_event($action, 'daily');
194 194
 	}
195 195
 }
196 196
 
Please login to merge, or discard this patch.
includes/class-give-db.php 1 patch
Spacing   +53 added lines, -53 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
 
@@ -98,16 +98,16 @@  discard block
 block discarded – undo
98 98
 	 *
99 99
 	 * @return object
100 100
 	 */
101
-	public function get( $row_id ) {
101
+	public function get($row_id) {
102 102
 		/* @var WPDB $wpdb */
103 103
 		global $wpdb;
104 104
 
105 105
 		// Bailout.
106
-		if ( empty( $row_id ) ) {
106
+		if (empty($row_id)) {
107 107
 			return null;
108 108
 		}
109 109
 
110
-		return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) );
110
+		return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id));
111 111
 	}
112 112
 
113 113
 	/**
@@ -121,18 +121,18 @@  discard block
 block discarded – undo
121 121
 	 *
122 122
 	 * @return object
123 123
 	 */
124
-	public function get_by( $column, $row_id ) {
124
+	public function get_by($column, $row_id) {
125 125
 		/* @var WPDB $wpdb */
126 126
 		global $wpdb;
127 127
 
128 128
 		// Bailout.
129
-		if ( empty( $column ) || empty( $row_id ) ) {
129
+		if (empty($column) || empty($row_id)) {
130 130
 			return null;
131 131
 		}
132 132
 
133
-		$column = esc_sql( $column );
133
+		$column = esc_sql($column);
134 134
 
135
-		return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id ) );
135
+		return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id));
136 136
 	}
137 137
 
138 138
 	/**
@@ -146,18 +146,18 @@  discard block
 block discarded – undo
146 146
 	 *
147 147
 	 * @return string      Column value.
148 148
 	 */
149
-	public function get_column( $column, $row_id ) {
149
+	public function get_column($column, $row_id) {
150 150
 		/* @var WPDB $wpdb */
151 151
 		global $wpdb;
152 152
 
153 153
 		// Bailout.
154
-		if ( empty( $column ) || empty( $row_id ) ) {
154
+		if (empty($column) || empty($row_id)) {
155 155
 			return null;
156 156
 		}
157 157
 
158
-		$column = esc_sql( $column );
158
+		$column = esc_sql($column);
159 159
 
160
-		return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) );
160
+		return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id));
161 161
 	}
162 162
 
163 163
 	/**
@@ -172,19 +172,19 @@  discard block
 block discarded – undo
172 172
 	 *
173 173
 	 * @return string
174 174
 	 */
175
-	public function get_column_by( $column, $column_where, $column_value ) {
175
+	public function get_column_by($column, $column_where, $column_value) {
176 176
 		/* @var WPDB $wpdb */
177 177
 		global $wpdb;
178 178
 
179 179
 		// Bailout.
180
-		if ( empty( $column ) || empty( $column_where ) || empty( $column_value ) ) {
180
+		if (empty($column) || empty($column_where) || empty($column_value)) {
181 181
 			return null;
182 182
 		}
183 183
 
184
-		$column_where = esc_sql( $column_where );
185
-		$column       = esc_sql( $column );
184
+		$column_where = esc_sql($column_where);
185
+		$column       = esc_sql($column);
186 186
 
187
-		return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value ) );
187
+		return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value));
188 188
 	}
189 189
 
190 190
 	/**
@@ -198,12 +198,12 @@  discard block
 block discarded – undo
198 198
 	 *
199 199
 	 * @return int
200 200
 	 */
201
-	public function insert( $data, $type = '' ) {
201
+	public function insert($data, $type = '') {
202 202
 		/* @var WPDB $wpdb */
203 203
 		global $wpdb;
204 204
 
205 205
 		// Set default values.
206
-		$data = wp_parse_args( $data, $this->get_column_defaults() );
206
+		$data = wp_parse_args($data, $this->get_column_defaults());
207 207
 
208 208
 		/**
209 209
 		 * Fires before inserting data to the database.
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 		 *
213 213
 		 * @param array $data
214 214
 		 */
215
-		do_action( "give_pre_insert_{$type}", $data );
215
+		do_action("give_pre_insert_{$type}", $data);
216 216
 
217 217
 		// Initialise column format array
218 218
 		$column_formats = $this->get_columns();
@@ -221,13 +221,13 @@  discard block
 block discarded – undo
221 221
 		// $data = array_change_key_case( $data );
222 222
 
223 223
 		// White list columns
224
-		$data = array_intersect_key( $data, $column_formats );
224
+		$data = array_intersect_key($data, $column_formats);
225 225
 
226 226
 		// Reorder $column_formats to match the order of columns given in $data
227
-		$data_keys      = array_keys( $data );
228
-		$column_formats = array_merge( array_flip( $data_keys ), $column_formats );
227
+		$data_keys      = array_keys($data);
228
+		$column_formats = array_merge(array_flip($data_keys), $column_formats);
229 229
 
230
-		$wpdb->insert( $this->table_name, $data, $column_formats );
230
+		$wpdb->insert($this->table_name, $data, $column_formats);
231 231
 
232 232
 		/**
233 233
 		 * Fires after inserting data to the database.
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 		 * @param int   $insert_id
238 238
 		 * @param array $data
239 239
 		 */
240
-		do_action( "give_post_insert_{$type}", $wpdb->insert_id, $data );
240
+		do_action("give_post_insert_{$type}", $wpdb->insert_id, $data);
241 241
 
242 242
 		return $wpdb->insert_id;
243 243
 	}
@@ -254,18 +254,18 @@  discard block
 block discarded – undo
254 254
 	 *
255 255
 	 * @return bool
256 256
 	 */
257
-	public function update( $row_id, $data = array(), $where = '' ) {
257
+	public function update($row_id, $data = array(), $where = '') {
258 258
 		/* @var WPDB $wpdb */
259 259
 		global $wpdb;
260 260
 
261 261
 		// Row ID must be positive integer
262
-		$row_id = absint( $row_id );
262
+		$row_id = absint($row_id);
263 263
 
264
-		if ( empty( $row_id ) ) {
264
+		if (empty($row_id)) {
265 265
 			return false;
266 266
 		}
267 267
 
268
-		if ( empty( $where ) ) {
268
+		if (empty($where)) {
269 269
 			$where = $this->primary_key;
270 270
 		}
271 271
 
@@ -273,16 +273,16 @@  discard block
 block discarded – undo
273 273
 		$column_formats = $this->get_columns();
274 274
 
275 275
 		// Force fields to lower case
276
-		$data = array_change_key_case( $data );
276
+		$data = array_change_key_case($data);
277 277
 
278 278
 		// White list columns
279
-		$data = array_intersect_key( $data, $column_formats );
279
+		$data = array_intersect_key($data, $column_formats);
280 280
 
281 281
 		// Reorder $column_formats to match the order of columns given in $data
282
-		$data_keys      = array_keys( $data );
283
-		$column_formats = array_merge( array_flip( $data_keys ), $column_formats );
282
+		$data_keys      = array_keys($data);
283
+		$column_formats = array_merge(array_flip($data_keys), $column_formats);
284 284
 
285
-		if ( false === $wpdb->update( $this->table_name, $data, array( $where => $row_id ), $column_formats ) ) {
285
+		if (false === $wpdb->update($this->table_name, $data, array($where => $row_id), $column_formats)) {
286 286
 			return false;
287 287
 		}
288 288
 
@@ -299,18 +299,18 @@  discard block
 block discarded – undo
299 299
 	 *
300 300
 	 * @return bool
301 301
 	 */
302
-	public function delete( $row_id = 0 ) {
302
+	public function delete($row_id = 0) {
303 303
 		/* @var WPDB $wpdb */
304 304
 		global $wpdb;
305 305
 
306 306
 		// Row ID must be positive integer
307
-		$row_id = absint( $row_id );
307
+		$row_id = absint($row_id);
308 308
 
309
-		if ( empty( $row_id ) ) {
309
+		if (empty($row_id)) {
310 310
 			return false;
311 311
 		}
312 312
 
313
-		if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id ) ) ) {
313
+		if (false === $wpdb->query($wpdb->prepare("DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id))) {
314 314
 			return false;
315 315
 		}
316 316
 
@@ -327,13 +327,13 @@  discard block
 block discarded – undo
327 327
 	 *
328 328
 	 * @return bool          If the table name exists.
329 329
 	 */
330
-	public function table_exists( $table ) {
330
+	public function table_exists($table) {
331 331
 		/* @var WPDB $wpdb */
332 332
 		global $wpdb;
333 333
 
334
-		$table = sanitize_text_field( $table );
334
+		$table = sanitize_text_field($table);
335 335
 
336
-		return $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table ) ) === $table;
336
+		return $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE '%s'", $table)) === $table;
337 337
 	}
338 338
 
339 339
 	/**
@@ -347,16 +347,16 @@  discard block
 block discarded – undo
347 347
 	 *
348 348
 	 * @return bool
349 349
 	 */
350
-	public function does_column_exist( $column_name ) {
350
+	public function does_column_exist($column_name) {
351 351
 
352 352
 		global $wpdb;
353 353
 
354
-		$column = $wpdb->get_results( $wpdb->prepare(
354
+		$column = $wpdb->get_results($wpdb->prepare(
355 355
 			"SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = %s AND TABLE_NAME = %s AND COLUMN_NAME = %s ",
356 356
 			DB_NAME, $this->table_name, $column_name
357
-		) );
357
+		));
358 358
 
359
-		if ( ! empty( $column ) ) {
359
+		if ( ! empty($column)) {
360 360
 			return true;
361 361
 		}
362 362
 
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
 	 * @return bool Returns if the customers table was installed and upgrade routine run.
373 373
 	 */
374 374
 	public function installed() {
375
-		return $this->table_exists( $this->table_name );
375
+		return $this->table_exists($this->table_name);
376 376
 	}
377 377
 
378 378
 	/**
@@ -382,8 +382,8 @@  discard block
 block discarded – undo
382 382
 	 * @access public
383 383
 	 */
384 384
 	public function register_table() {
385
-		$current_version = get_option( $this->table_name . '_db_version' );
386
-		if ( ! $current_version || version_compare( $current_version, $this->version, '<' ) ) {
385
+		$current_version = get_option($this->table_name.'_db_version');
386
+		if ( ! $current_version || version_compare($current_version, $this->version, '<')) {
387 387
 			$this->create_table();
388 388
 		}
389 389
 	}
@@ -408,23 +408,23 @@  discard block
 block discarded – undo
408 408
 	 *
409 409
 	 * @return int|bool                The normalized log ID or false if it's found to not be valid.
410 410
 	 */
411
-	public function sanitize_id( $id ) {
412
-		if ( ! is_numeric( $id ) ) {
411
+	public function sanitize_id($id) {
412
+		if ( ! is_numeric($id)) {
413 413
 			return false;
414 414
 		}
415 415
 
416 416
 		$id = (int) $id;
417 417
 
418 418
 		// We were given a non positive number.
419
-		if ( absint( $id ) !== $id ) {
419
+		if (absint($id) !== $id) {
420 420
 			return false;
421 421
 		}
422 422
 
423
-		if ( empty( $id ) ) {
423
+		if (empty($id)) {
424 424
 			return false;
425 425
 		}
426 426
 
427
-		return absint( $id );
427
+		return absint($id);
428 428
 
429 429
 	}
430 430
 }
Please login to merge, or discard this patch.