Completed
Pull Request — master (#420)
by Valerio
05:57
created
includes/admin/reporting/graphing.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -576,7 +576,7 @@
 block discarded – undo
576 576
  * selected date-range (if any)
577 577
  *
578 578
  * @since 1.0
579
- * @return array
579
+ * @return integer|null
580 580
  */
581 581
 function give_get_report_dates() {
582 582
 	$dates = array();
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Graphing Functions
4
- *
5
- * @package     Give
6
- * @subpackage  Admin/Reports
7
- * @copyright   Copyright (c) 2015, WordImpress
8
- * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
- * @since       1.0
10
- */
3
+	 * Graphing Functions
4
+	 *
5
+	 * @package     Give
6
+	 * @subpackage  Admin/Reports
7
+	 * @copyright   Copyright (c) 2015, WordImpress
8
+	 * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
+	 * @since       1.0
10
+	 */
11 11
 
12 12
 // Exit if accessed directly
13 13
 if ( ! defined( 'ABSPATH' ) ) {
Please login to merge, or discard this patch.
Spacing   +243 added lines, -243 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	$dates = give_get_report_dates();
26 26
 
27 27
 	// Determine graph options
28
-	switch ( $dates['range'] ) :
28
+	switch ($dates['range']) :
29 29
 		case 'today' :
30 30
 		case 'yesterday' :
31 31
 			$day_by_day = true;
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 			$day_by_day = false;
38 38
 			break;
39 39
 		case 'other' :
40
-			if ( $dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year'] && ( $dates['m_start'] != '12' && $dates['m_end'] != '1' ) ) {
40
+			if ($dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year'] && ($dates['m_start'] != '12' && $dates['m_end'] != '1')) {
41 41
 				$day_by_day = false;
42 42
 			} else {
43 43
 				$day_by_day = true;
@@ -49,61 +49,61 @@  discard block
 block discarded – undo
49 49
 	endswitch;
50 50
 
51 51
 	$earnings_totals = 0.00; // Total earnings for time period shown
52
-	$sales_totals    = 0;            // Total sales for time period shown
52
+	$sales_totals    = 0; // Total sales for time period shown
53 53
 
54 54
 	$earnings_data = array();
55 55
 	$sales_data    = array();
56 56
 
57
-	if ( $dates['range'] == 'today' || $dates['range'] == 'yesterday' ) {
57
+	if ($dates['range'] == 'today' || $dates['range'] == 'yesterday') {
58 58
 		// Hour by hour
59 59
 		$hour  = 1;
60
-		$month = date( 'n', current_time( 'timestamp' ) );
61
-		while ( $hour <= 23 ) :
60
+		$month = date('n', current_time('timestamp'));
61
+		while ($hour <= 23) :
62 62
 
63
-			$sales    = give_get_sales_by_date( $dates['day'], $month, $dates['year'], $hour );
64
-			$earnings = give_get_earnings_by_date( $dates['day'], $month, $dates['year'], $hour );
63
+			$sales    = give_get_sales_by_date($dates['day'], $month, $dates['year'], $hour);
64
+			$earnings = give_get_earnings_by_date($dates['day'], $month, $dates['year'], $hour);
65 65
 
66 66
 			$sales_totals += $sales;
67 67
 			$earnings_totals += $earnings;
68 68
 
69
-			$date            = mktime( $hour, 0, 0, $month, $dates['day'], $dates['year'] ) * 1000;
70
-			$sales_data[]    = array( $date, $sales );
71
-			$earnings_data[] = array( $date, $earnings );
69
+			$date            = mktime($hour, 0, 0, $month, $dates['day'], $dates['year']) * 1000;
70
+			$sales_data[]    = array($date, $sales);
71
+			$earnings_data[] = array($date, $earnings);
72 72
 
73
-			$hour ++;
73
+			$hour++;
74 74
 		endwhile;
75 75
 
76
-	} elseif ( $dates['range'] == 'this_week' || $dates['range'] == 'last_week' ) {
76
+	} elseif ($dates['range'] == 'this_week' || $dates['range'] == 'last_week') {
77 77
 
78 78
 		// Day by day
79 79
 		$day     = $dates['day'];
80 80
 		$day_end = $dates['day_end'];
81 81
 		$month   = $dates['m_start'];
82
-		while ( $day <= $day_end ) :
83
-			$sales = give_get_sales_by_date( $day, $month, $dates['year'] );
82
+		while ($day <= $day_end) :
83
+			$sales = give_get_sales_by_date($day, $month, $dates['year']);
84 84
 			$sales_totals += $sales;
85 85
 
86
-			$earnings = give_get_earnings_by_date( $day, $month, $dates['year'] );
86
+			$earnings = give_get_earnings_by_date($day, $month, $dates['year']);
87 87
 			$earnings_totals += $earnings;
88 88
 
89
-			$date            = mktime( 0, 0, 0, $month, $day, $dates['year'] ) * 1000;
90
-			$sales_data[]    = array( $date, $sales );
91
-			$earnings_data[] = array( $date, $earnings );
92
-			$day ++;
89
+			$date            = mktime(0, 0, 0, $month, $day, $dates['year']) * 1000;
90
+			$sales_data[]    = array($date, $sales);
91
+			$earnings_data[] = array($date, $earnings);
92
+			$day++;
93 93
 		endwhile;
94 94
 
95 95
 	} else {
96 96
 
97 97
 		$y = $dates['year'];
98
-		while ( $y <= $dates['year_end'] ) :
98
+		while ($y <= $dates['year_end']) :
99 99
 
100
-			if ( $dates['year'] == $dates['year_end'] ) {
100
+			if ($dates['year'] == $dates['year_end']) {
101 101
 				$month_start = $dates['m_start'];
102 102
 				$month_end   = $dates['m_end'];
103
-			} elseif ( $y == $dates['year'] ) {
103
+			} elseif ($y == $dates['year']) {
104 104
 				$month_start = $dates['m_start'];
105 105
 				$month_end   = 12;
106
-			} elseif ( $y == $dates['year_end'] ) {
106
+			} elseif ($y == $dates['year_end']) {
107 107
 				$month_start = 1;
108 108
 				$month_end   = $dates['m_end'];
109 109
 			} else {
@@ -112,48 +112,48 @@  discard block
 block discarded – undo
112 112
 			}
113 113
 
114 114
 			$i = $month_start;
115
-			while ( $i <= $month_end ) :
115
+			while ($i <= $month_end) :
116 116
 
117
-				if ( $day_by_day ) :
117
+				if ($day_by_day) :
118 118
 
119
-					if ( $i == $month_end ) {
119
+					if ($i == $month_end) {
120 120
 
121 121
 						$num_of_days = $dates['day_end'];
122 122
 
123 123
 					} else {
124 124
 
125
-						$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
125
+						$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
126 126
 
127 127
 					}
128 128
 
129 129
 					$d = $dates['day'];
130 130
 
131
-					while ( $d <= $num_of_days ) :
131
+					while ($d <= $num_of_days) :
132 132
 
133
-						$sales = give_get_sales_by_date( $d, $i, $y );
133
+						$sales = give_get_sales_by_date($d, $i, $y);
134 134
 						$sales_totals += $sales;
135 135
 
136
-						$earnings = give_get_earnings_by_date( $d, $i, $y );
136
+						$earnings = give_get_earnings_by_date($d, $i, $y);
137 137
 						$earnings_totals += $earnings;
138 138
 
139
-						$date            = mktime( 0, 0, 0, $i, $d, $y ) * 1000;
140
-						$sales_data[]    = array( $date, $sales );
141
-						$earnings_data[] = array( $date, $earnings );
142
-						$d ++;
139
+						$date            = mktime(0, 0, 0, $i, $d, $y) * 1000;
140
+						$sales_data[]    = array($date, $sales);
141
+						$earnings_data[] = array($date, $earnings);
142
+						$d++;
143 143
 
144 144
 					endwhile;
145 145
 
146 146
 				else :
147 147
 
148
-					$sales = give_get_sales_by_date( null, $i, $y );
148
+					$sales = give_get_sales_by_date(null, $i, $y);
149 149
 					$sales_totals += $sales;
150 150
 
151
-					$earnings = give_get_earnings_by_date( null, $i, $y );
151
+					$earnings = give_get_earnings_by_date(null, $i, $y);
152 152
 					$earnings_totals += $earnings;
153 153
 
154
-					if ( $i == $month_end ) {
154
+					if ($i == $month_end) {
155 155
 
156
-						$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
156
+						$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
157 157
 
158 158
 					} else {
159 159
 
@@ -161,24 +161,24 @@  discard block
 block discarded – undo
161 161
 
162 162
 					}
163 163
 
164
-					$date            = mktime( 0, 0, 0, $i, $num_of_days, $y ) * 1000;
165
-					$sales_data[]    = array( $date, $sales );
166
-					$earnings_data[] = array( $date, $earnings );
164
+					$date            = mktime(0, 0, 0, $i, $num_of_days, $y) * 1000;
165
+					$sales_data[]    = array($date, $sales);
166
+					$earnings_data[] = array($date, $earnings);
167 167
 
168 168
 				endif;
169 169
 
170
-				$i ++;
170
+				$i++;
171 171
 
172 172
 			endwhile;
173 173
 
174
-			$y ++;
174
+			$y++;
175 175
 		endwhile;
176 176
 
177 177
 	}
178 178
 
179 179
 	$data = array(
180
-		__( 'Income', 'give' )    => $earnings_data,
181
-		__( 'Donations', 'give' ) => $sales_data
180
+		__('Income', 'give')    => $earnings_data,
181
+		__('Donations', 'give') => $sales_data
182 182
 	);
183 183
 
184 184
 	// start our own output buffer
@@ -190,12 +190,12 @@  discard block
 block discarded – undo
190 190
 			<div class="postbox">
191 191
 				<div class="inside">
192 192
 					<?php
193
-					$graph = new Give_Graph( $data );
194
-					$graph->set( 'x_mode', 'time' );
195
-					$graph->set( 'multiple_y_axes', true );
193
+					$graph = new Give_Graph($data);
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
 					?>
@@ -206,32 +206,32 @@  discard block
 block discarded – undo
206 206
 				<tbody>
207 207
 				<tr>
208 208
 					<td class="row-title">
209
-						<label for="tablecell"><?php _e( 'Total income for period: ', 'give' ); ?></label></td>
210
-					<td><?php echo give_currency_filter( give_format_amount( $earnings_totals ) ); ?></td>
209
+						<label for="tablecell"><?php _e('Total income for period: ', 'give'); ?></label></td>
210
+					<td><?php echo give_currency_filter(give_format_amount($earnings_totals)); ?></td>
211 211
 				</tr>
212 212
 				<tr class="alternate">
213 213
 					<td class="row-title">
214
-						<label for="tablecell"><?php _e( 'Total donations for period shown: ', 'give' ); ?></label>
214
+						<label for="tablecell"><?php _e('Total donations for period shown: ', 'give'); ?></label>
215 215
 					</td>
216
-					<td><?php echo give_format_amount( $sales_totals, false ); ?></td>
216
+					<td><?php echo give_format_amount($sales_totals, false); ?></td>
217 217
 				</tr>
218
-				<?php if ( 'this_month' == $dates['range'] ) : ?>
218
+				<?php if ('this_month' == $dates['range']) : ?>
219 219
 					<tr>
220 220
 						<td class="row-title">
221
-							<label for="tablecell"><?php _e( 'Estimated monthly income: ', 'give' ); ?></label>
221
+							<label for="tablecell"><?php _e('Estimated monthly income: ', 'give'); ?></label>
222 222
 						</td>
223
-						<td><?php echo give_currency_filter( give_format_amount( $estimated['earnings'] ) ); ?></td>
223
+						<td><?php echo give_currency_filter(give_format_amount($estimated['earnings'])); ?></td>
224 224
 					</tr>
225 225
 					<tr class="alternate">
226 226
 						<td class="row-title">
227
-							<label for="tablecell"><?php _e( 'Estimated monthly donations: ', 'give' ); ?></label>
227
+							<label for="tablecell"><?php _e('Estimated monthly donations: ', 'give'); ?></label>
228 228
 						</td>
229
-						<td><?php echo give_format_amount( $estimated['sales'], false ); ?></td>
229
+						<td><?php echo give_format_amount($estimated['sales'], false); ?></td>
230 230
 					</tr>
231 231
 				<?php endif; ?>
232 232
 			</table>
233 233
 
234
-			<?php do_action( 'give_reports_graph_additional_stats' ); ?>
234
+			<?php do_action('give_reports_graph_additional_stats'); ?>
235 235
 
236 236
 		</div>
237 237
 	</div>
@@ -249,12 +249,12 @@  discard block
 block discarded – undo
249 249
  * @since 1.0
250 250
  * @return void
251 251
  */
252
-function give_reports_graph_of_form( $form_id = 0 ) {
252
+function give_reports_graph_of_form($form_id = 0) {
253 253
 	// Retrieve the queried dates
254 254
 	$dates = give_get_report_dates();
255 255
 
256 256
 	// Determine graph options
257
-	switch ( $dates['range'] ) :
257
+	switch ($dates['range']) :
258 258
 		case 'today' :
259 259
 		case 'yesterday' :
260 260
 			$day_by_day = true;
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 			$day_by_day = false;
273 273
 			break;
274 274
 		case 'other' :
275
-			if ( $dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year'] ) {
275
+			if ($dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year']) {
276 276
 				$day_by_day = false;
277 277
 			} else {
278 278
 				$day_by_day = true;
@@ -284,75 +284,75 @@  discard block
 block discarded – undo
284 284
 	endswitch;
285 285
 
286 286
 	$earnings_totals = (float) 0.00; // Total earnings for time period shown
287
-	$sales_totals    = 0;            // Total sales for time period shown
287
+	$sales_totals    = 0; // Total sales for time period shown
288 288
 
289 289
 	$earnings_data = array();
290 290
 	$sales_data    = array();
291 291
 	$stats         = new Give_Payment_Stats;
292 292
 
293
-	if ( $dates['range'] == 'today' || $dates['range'] == 'yesterday' ) {
293
+	if ($dates['range'] == 'today' || $dates['range'] == 'yesterday') {
294 294
 
295 295
 		// Hour by hour
296 296
 		$month  = $dates['m_start'];
297 297
 		$hour   = 1;
298 298
 		$minute = 0;
299 299
 		$second = 0;
300
-		while ( $hour <= 23 ) :
300
+		while ($hour <= 23) :
301 301
 
302
-			if ( $hour == 23 ) {
302
+			if ($hour == 23) {
303 303
 				$minute = $second = 59;
304 304
 			}
305 305
 
306
-			$date     = mktime( $hour, $minute, $second, $month, $dates['day'], $dates['year'] );
307
-			$date_end = mktime( $hour + 1, $minute, $second, $month, $dates['day'], $dates['year'] );
306
+			$date     = mktime($hour, $minute, $second, $month, $dates['day'], $dates['year']);
307
+			$date_end = mktime($hour + 1, $minute, $second, $month, $dates['day'], $dates['year']);
308 308
 
309
-			$sales = $stats->get_sales( $form_id, $date, $date_end );
309
+			$sales = $stats->get_sales($form_id, $date, $date_end);
310 310
 			$sales_totals += $sales;
311 311
 
312
-			$earnings = $stats->get_earnings( $form_id, $date, $date_end );
312
+			$earnings = $stats->get_earnings($form_id, $date, $date_end);
313 313
 			$earnings_totals += $earnings;
314 314
 
315
-			$sales_data[]    = array( $date * 1000, $sales );
316
-			$earnings_data[] = array( $date * 1000, $earnings );
315
+			$sales_data[]    = array($date * 1000, $sales);
316
+			$earnings_data[] = array($date * 1000, $earnings);
317 317
 
318
-			$hour ++;
318
+			$hour++;
319 319
 		endwhile;
320 320
 
321
-	} elseif ( $dates['range'] == 'this_week' || $dates['range'] == 'last_week' ) {
321
+	} elseif ($dates['range'] == 'this_week' || $dates['range'] == 'last_week') {
322 322
 
323 323
 		//Day by day
324 324
 		$day     = $dates['day'];
325 325
 		$day_end = $dates['day_end'];
326 326
 		$month   = $dates['m_start'];
327
-		while ( $day <= $day_end ) :
327
+		while ($day <= $day_end) :
328 328
 
329
-			$date     = mktime( 0, 0, 0, $month, $day, $dates['year'] );
330
-			$date_end = mktime( 0, 0, 0, $month, $day + 1, $dates['year'] );
331
-			$sales    = $stats->get_sales( $form_id, $date, $date_end );
329
+			$date     = mktime(0, 0, 0, $month, $day, $dates['year']);
330
+			$date_end = mktime(0, 0, 0, $month, $day + 1, $dates['year']);
331
+			$sales    = $stats->get_sales($form_id, $date, $date_end);
332 332
 			$sales_totals += $sales;
333 333
 
334
-			$earnings = $stats->get_earnings( $form_id, $date, $date_end );
334
+			$earnings = $stats->get_earnings($form_id, $date, $date_end);
335 335
 			$earnings_totals += $earnings;
336 336
 
337
-			$sales_data[]    = array( $date * 1000, $sales );
338
-			$earnings_data[] = array( $date * 1000, $earnings );
337
+			$sales_data[]    = array($date * 1000, $sales);
338
+			$earnings_data[] = array($date * 1000, $earnings);
339 339
 
340
-			$day ++;
340
+			$day++;
341 341
 		endwhile;
342 342
 
343 343
 	} else {
344 344
 
345 345
 		$y = $dates['year'];
346 346
 
347
-		while ( $y <= $dates['year_end'] ) :
347
+		while ($y <= $dates['year_end']) :
348 348
 
349 349
 			$last_year = false;
350 350
 
351
-			if ( $dates['year'] == $dates['year_end'] ) {
351
+			if ($dates['year'] == $dates['year_end']) {
352 352
 				$month_start = $dates['m_start'];
353 353
 				$month_end   = $dates['m_end'];
354 354
 				$last_year   = true;
355
-			} elseif ( $y == $dates['year'] ) {
355
+			} elseif ($y == $dates['year']) {
356 356
 				$month_start = $dates['m_start'];
357 357
 				$month_end   = 12;
358 358
 			} else {
@@ -361,79 +361,79 @@  discard block
 block discarded – undo
361 361
 			}
362 362
 
363 363
 			$i = $month_start;
364
-			while ( $i <= $month_end ) :
364
+			while ($i <= $month_end) :
365 365
 
366
-				if ( $day_by_day ) :
366
+				if ($day_by_day) :
367 367
 
368
-					if ( $i == $month_end && $last_year ) {
368
+					if ($i == $month_end && $last_year) {
369 369
 
370 370
 						$num_of_days = $dates['day_end'];
371 371
 
372 372
 					} else {
373 373
 
374
-						$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
374
+						$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
375 375
 
376 376
 					}
377 377
 
378 378
 					$d = $dates['day'];
379
-					while ( $d <= $num_of_days ) :
379
+					while ($d <= $num_of_days) :
380 380
 
381
-						$date     = mktime( 0, 0, 0, $i, $d, $y );
382
-						$end_date = mktime( 23, 59, 59, $i, $d, $y );
381
+						$date     = mktime(0, 0, 0, $i, $d, $y);
382
+						$end_date = mktime(23, 59, 59, $i, $d, $y);
383 383
 
384
-						$sales = $stats->get_sales( $form_id, $date, $end_date );
384
+						$sales = $stats->get_sales($form_id, $date, $end_date);
385 385
 						$sales_totals += $sales;
386 386
 
387
-						$earnings = $stats->get_earnings( $form_id, $date, $end_date );
387
+						$earnings = $stats->get_earnings($form_id, $date, $end_date);
388 388
 						$earnings_totals += $earnings;
389 389
 
390
-						$sales_data[]    = array( $date * 1000, $sales );
391
-						$earnings_data[] = array( $date * 1000, $earnings );
392
-						$d ++;
390
+						$sales_data[]    = array($date * 1000, $sales);
391
+						$earnings_data[] = array($date * 1000, $earnings);
392
+						$d++;
393 393
 
394 394
 					endwhile;
395 395
 
396 396
 				else :
397 397
 
398
-					$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
398
+					$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
399 399
 
400
-					$date     = mktime( 0, 0, 0, $i, 1, $y );
401
-					$end_date = mktime( 23, 59, 59, $i, $num_of_days, $y );
400
+					$date     = mktime(0, 0, 0, $i, 1, $y);
401
+					$end_date = mktime(23, 59, 59, $i, $num_of_days, $y);
402 402
 
403
-					$sales = $stats->get_sales( $form_id, $date, $end_date );
403
+					$sales = $stats->get_sales($form_id, $date, $end_date);
404 404
 					$sales_totals += $sales;
405 405
 
406
-					$earnings = $stats->get_earnings( $form_id, $date, $end_date );
406
+					$earnings = $stats->get_earnings($form_id, $date, $end_date);
407 407
 					$earnings_totals += $earnings;
408 408
 
409
-					$sales_data[]    = array( $date * 1000, $sales );
410
-					$earnings_data[] = array( $date * 1000, $earnings );
409
+					$sales_data[]    = array($date * 1000, $sales);
410
+					$earnings_data[] = array($date * 1000, $earnings);
411 411
 				endif;
412 412
 
413
-				$i ++;
413
+				$i++;
414 414
 
415 415
 			endwhile;
416 416
 
417
-			$y ++;
417
+			$y++;
418 418
 		endwhile;
419 419
 
420 420
 	}
421 421
 
422 422
 	$data = array(
423
-		__( 'Income', 'give' )    => $earnings_data,
424
-		__( 'Donations', 'give' ) => $sales_data
423
+		__('Income', 'give')    => $earnings_data,
424
+		__('Donations', 'give') => $sales_data
425 425
 	);
426 426
 
427 427
 	?>
428
-	<h3><span><?php printf( __( 'Income Over Time for %s', 'give' ), get_the_title( $form_id ) ); ?></span></h3>
428
+	<h3><span><?php printf(__('Income Over Time for %s', 'give'), get_the_title($form_id)); ?></span></h3>
429 429
 
430 430
 	<div class="metabox-holder" style="padding-top: 0;">
431 431
 		<div class="postbox">
432 432
 			<div class="inside">
433 433
 				<?php
434
-				$graph = new Give_Graph( $data );
435
-				$graph->set( 'x_mode', 'time' );
436
-				$graph->set( 'multiple_y_axes', true );
434
+				$graph = new Give_Graph($data);
435
+				$graph->set('x_mode', 'time');
436
+				$graph->set('multiple_y_axes', true);
437 437
 				$graph->display();
438 438
 				?>
439 439
 			</div>
@@ -443,26 +443,26 @@  discard block
 block discarded – undo
443 443
 			<tbody>
444 444
 			<tr>
445 445
 				<td class="row-title">
446
-					<label for="tablecell"><?php _e( 'Total income for period: ', 'give' ); ?></label></td>
447
-				<td><?php echo give_currency_filter( give_format_amount( $earnings_totals ) ); ?></td>
446
+					<label for="tablecell"><?php _e('Total income for period: ', 'give'); ?></label></td>
447
+				<td><?php echo give_currency_filter(give_format_amount($earnings_totals)); ?></td>
448 448
 			</tr>
449 449
 			<tr class="alternate">
450 450
 				<td class="row-title">
451
-					<label for="tablecell"><?php _e( 'Total donations for period: ', 'give' ); ?></label>
451
+					<label for="tablecell"><?php _e('Total donations for period: ', 'give'); ?></label>
452 452
 				</td>
453 453
 				<td><?php echo $sales_totals; ?></td>
454 454
 			</tr>
455 455
 			<tr>
456 456
 				<td class="row-title">
457
-					<label for="tablecell"><?php _e( 'Average monthly income: %s', 'give' ); ?></label>
457
+					<label for="tablecell"><?php _e('Average monthly income: %s', 'give'); ?></label>
458 458
 				</td>
459
-				<td><?php echo give_currency_filter( give_format_amount( give_get_average_monthly_form_earnings( $form_id ) ) ); ?></td>
459
+				<td><?php echo give_currency_filter(give_format_amount(give_get_average_monthly_form_earnings($form_id))); ?></td>
460 460
 			</tr>
461 461
 			<tr class="alternate">
462 462
 				<td class="row-title">
463
-					<label for="tablecell"><?php _e( 'Average monthly donations: %s', 'give' ); ?></label>
463
+					<label for="tablecell"><?php _e('Average monthly donations: %s', 'give'); ?></label>
464 464
 				</td>
465
-				<td><?php echo number_format( give_get_average_monthly_form_sales( $form_id ), 0 ); ?></td>
465
+				<td><?php echo number_format(give_get_average_monthly_form_sales($form_id), 0); ?></td>
466 466
 			</tr>
467 467
 			</tbody>
468 468
 		</table>
@@ -479,30 +479,30 @@  discard block
 block discarded – undo
479 479
  * @return void
480 480
  */
481 481
 function give_reports_graph_controls() {
482
-	$date_options = apply_filters( 'give_report_date_options', array(
483
-		'today'        => __( 'Today', 'give' ),
484
-		'yesterday'    => __( 'Yesterday', 'give' ),
485
-		'this_week'    => __( 'This Week', 'give' ),
486
-		'last_week'    => __( 'Last Week', 'give' ),
487
-		'this_month'   => __( 'This Month', 'give' ),
488
-		'last_month'   => __( 'Last Month', 'give' ),
489
-		'this_quarter' => __( 'This Quarter', 'give' ),
490
-		'last_quarter' => __( 'Last Quarter', 'give' ),
491
-		'this_year'    => __( 'This Year', 'give' ),
492
-		'last_year'    => __( 'Last Year', 'give' ),
493
-		'other'        => __( 'Custom', 'give' )
494
-	) );
482
+	$date_options = apply_filters('give_report_date_options', array(
483
+		'today'        => __('Today', 'give'),
484
+		'yesterday'    => __('Yesterday', 'give'),
485
+		'this_week'    => __('This Week', 'give'),
486
+		'last_week'    => __('Last Week', 'give'),
487
+		'this_month'   => __('This Month', 'give'),
488
+		'last_month'   => __('Last Month', 'give'),
489
+		'this_quarter' => __('This Quarter', 'give'),
490
+		'last_quarter' => __('Last Quarter', 'give'),
491
+		'this_year'    => __('This Year', 'give'),
492
+		'last_year'    => __('Last Year', 'give'),
493
+		'other'        => __('Custom', 'give')
494
+	));
495 495
 
496 496
 	$dates   = give_get_report_dates();
497 497
 	$display = $dates['range'] == 'other' ? '' : 'style="display:none;"';
498 498
 	$view    = give_get_reporting_view();
499 499
 
500
-	if ( empty( $dates['day_end'] ) ) {
501
-		$dates['day_end'] = cal_days_in_month( CAL_GREGORIAN, date( 'n' ), date( 'Y' ) );
500
+	if (empty($dates['day_end'])) {
501
+		$dates['day_end'] = cal_days_in_month(CAL_GREGORIAN, date('n'), date('Y'));
502 502
 	}
503 503
 
504 504
 	//echo '<pre>'; print_r( $dates ); echo '</pre>';
505
-	do_action( 'give_report_graph_controls_before' );
505
+	do_action('give_report_graph_controls_before');
506 506
 	?>
507 507
 	<form id="give-graphs-filter" method="get" class="alignright">
508 508
 		<div class="tablenav top alignright">
@@ -510,53 +510,53 @@  discard block
 block discarded – undo
510 510
 
511 511
 				<input type="hidden" name="post_type" value="give_forms" />
512 512
 				<input type="hidden" name="page" value="give-reports" />
513
-				<input type="hidden" name="view" value="<?php echo esc_attr( $view ); ?>" />
513
+				<input type="hidden" name="view" value="<?php echo esc_attr($view); ?>" />
514 514
 
515
-				<?php if ( isset( $_GET['form-id'] ) ) : ?>
516
-					<input type="hidden" name="form-id" value="<?php echo absint( $_GET['form-id'] ); ?>" />
515
+				<?php if (isset($_GET['form-id'])) : ?>
516
+					<input type="hidden" name="form-id" value="<?php echo absint($_GET['form-id']); ?>" />
517 517
 				<?php endif; ?>
518 518
 
519 519
 				<div id="give-graphs-date-options-wrap" class="alignright">
520 520
 					<select id="give-graphs-date-options" name="range">
521
-						<?php foreach ( $date_options as $key => $option ) : ?>
522
-							<option value="<?php echo esc_attr( $key ); ?>"<?php selected( $key, $dates['range'] ); ?>><?php echo esc_html( $option ); ?></option>
521
+						<?php foreach ($date_options as $key => $option) : ?>
522
+							<option value="<?php echo esc_attr($key); ?>"<?php selected($key, $dates['range']); ?>><?php echo esc_html($option); ?></option>
523 523
 						<?php endforeach; ?>
524 524
 					</select>
525 525
 
526
-					<input type="submit" class="button-secondary" value="<?php _e( 'Filter', 'give' ); ?>" />
526
+					<input type="submit" class="button-secondary" value="<?php _e('Filter', 'give'); ?>" />
527 527
 				</div>
528 528
 
529 529
 				<div id="give-date-range-options" <?php echo $display; ?>>
530
-					<span><?php _e( 'From', 'give' ); ?>&nbsp;</span>
530
+					<span><?php _e('From', 'give'); ?>&nbsp;</span>
531 531
 					<select id="give-graphs-month-start" name="m_start">
532
-						<?php for ( $i = 1; $i <= 12; $i ++ ) : ?>
533
-							<option value="<?php echo absint( $i ); ?>" <?php selected( $i, $dates['m_start'] ); ?>><?php echo give_month_num_to_name( $i ); ?></option>
532
+						<?php for ($i = 1; $i <= 12; $i++) : ?>
533
+							<option value="<?php echo absint($i); ?>" <?php selected($i, $dates['m_start']); ?>><?php echo give_month_num_to_name($i); ?></option>
534 534
 						<?php endfor; ?>
535 535
 					</select>
536 536
 					<select id="give-graphs-day-start" name="day">
537
-						<?php for ( $i = 1; $i <= 31; $i ++ ) : ?>
538
-							<option value="<?php echo absint( $i ); ?>" <?php selected( $i, $dates['day'] ); ?>><?php echo $i; ?></option>
537
+						<?php for ($i = 1; $i <= 31; $i++) : ?>
538
+							<option value="<?php echo absint($i); ?>" <?php selected($i, $dates['day']); ?>><?php echo $i; ?></option>
539 539
 						<?php endfor; ?>
540 540
 					</select>
541 541
 					<select id="give-graphs-year-start" name="year">
542
-						<?php for ( $i = 2007; $i <= date( 'Y' ); $i ++ ) : ?>
543
-							<option value="<?php echo absint( $i ); ?>" <?php selected( $i, $dates['year'] ); ?>><?php echo $i; ?></option>
542
+						<?php for ($i = 2007; $i <= date('Y'); $i++) : ?>
543
+							<option value="<?php echo absint($i); ?>" <?php selected($i, $dates['year']); ?>><?php echo $i; ?></option>
544 544
 						<?php endfor; ?>
545 545
 					</select>
546
-					<span><?php _e( 'To', 'give' ); ?>&nbsp;</span>
546
+					<span><?php _e('To', 'give'); ?>&nbsp;</span>
547 547
 					<select id="give-graphs-month-end" name="m_end">
548
-						<?php for ( $i = 1; $i <= 12; $i ++ ) : ?>
549
-							<option value="<?php echo absint( $i ); ?>" <?php selected( $i, $dates['m_end'] ); ?>><?php echo give_month_num_to_name( $i ); ?></option>
548
+						<?php for ($i = 1; $i <= 12; $i++) : ?>
549
+							<option value="<?php echo absint($i); ?>" <?php selected($i, $dates['m_end']); ?>><?php echo give_month_num_to_name($i); ?></option>
550 550
 						<?php endfor; ?>
551 551
 					</select>
552 552
 					<select id="give-graphs-day-end" name="day_end">
553
-						<?php for ( $i = 1; $i <= 31; $i ++ ) : ?>
554
-							<option value="<?php echo absint( $i ); ?>" <?php selected( $i, $dates['day_end'] ); ?>><?php echo $i; ?></option>
553
+						<?php for ($i = 1; $i <= 31; $i++) : ?>
554
+							<option value="<?php echo absint($i); ?>" <?php selected($i, $dates['day_end']); ?>><?php echo $i; ?></option>
555 555
 						<?php endfor; ?>
556 556
 					</select>
557 557
 					<select id="give-graphs-year-end" name="year_end">
558
-						<?php for ( $i = 2007; $i <= date( 'Y' ); $i ++ ) : ?>
559
-							<option value="<?php echo absint( $i ); ?>" <?php selected( $i, $dates['year_end'] ); ?>><?php echo $i; ?></option>
558
+						<?php for ($i = 2007; $i <= date('Y'); $i++) : ?>
559
+							<option value="<?php echo absint($i); ?>" <?php selected($i, $dates['year_end']); ?>><?php echo $i; ?></option>
560 560
 						<?php endfor; ?>
561 561
 					</select>
562 562
 				</div>
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
 		</div>
567 567
 	</form>
568 568
 	<?php
569
-	do_action( 'give_report_graph_controls_after' );
569
+	do_action('give_report_graph_controls_after');
570 570
 }
571 571
 
572 572
 /**
@@ -581,65 +581,65 @@  discard block
 block discarded – undo
581 581
 function give_get_report_dates() {
582 582
 	$dates = array();
583 583
 
584
-	$current_time = current_time( 'timestamp' );
584
+	$current_time = current_time('timestamp');
585 585
 
586
-	$dates['range']    = isset( $_GET['range'] ) ? $_GET['range'] : 'this_month';
587
-	$dates['year']     = isset( $_GET['year'] ) ? $_GET['year'] : date( 'Y' );
588
-	$dates['year_end'] = isset( $_GET['year_end'] ) ? $_GET['year_end'] : date( 'Y' );
589
-	$dates['m_start']  = isset( $_GET['m_start'] ) ? $_GET['m_start'] : 1;
590
-	$dates['m_end']    = isset( $_GET['m_end'] ) ? $_GET['m_end'] : 12;
591
-	$dates['day']      = isset( $_GET['day'] ) ? $_GET['day'] : 1;
592
-	$dates['day_end']  = isset( $_GET['day_end'] ) ? $_GET['day_end'] : cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] );
586
+	$dates['range']    = isset($_GET['range']) ? $_GET['range'] : 'this_month';
587
+	$dates['year']     = isset($_GET['year']) ? $_GET['year'] : date('Y');
588
+	$dates['year_end'] = isset($_GET['year_end']) ? $_GET['year_end'] : date('Y');
589
+	$dates['m_start']  = isset($_GET['m_start']) ? $_GET['m_start'] : 1;
590
+	$dates['m_end']    = isset($_GET['m_end']) ? $_GET['m_end'] : 12;
591
+	$dates['day']      = isset($_GET['day']) ? $_GET['day'] : 1;
592
+	$dates['day_end']  = isset($_GET['day_end']) ? $_GET['day_end'] : cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']);
593 593
 
594 594
 	// Modify dates based on predefined ranges
595
-	switch ( $dates['range'] ) :
595
+	switch ($dates['range']) :
596 596
 
597 597
 		case 'this_month' :
598
-			$dates['m_start']  = date( 'n', $current_time );
599
-			$dates['m_end']    = date( 'n', $current_time );
598
+			$dates['m_start']  = date('n', $current_time);
599
+			$dates['m_end']    = date('n', $current_time);
600 600
 			$dates['day']      = 1;
601
-			$dates['day_end']  = cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] );
602
-			$dates['year']     = date( 'Y' );
603
-			$dates['year_end'] = date( 'Y' );
601
+			$dates['day_end']  = cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']);
602
+			$dates['year']     = date('Y');
603
+			$dates['year_end'] = date('Y');
604 604
 			break;
605 605
 
606 606
 		case 'last_month' :
607
-			if ( date( 'n' ) == 1 ) {
607
+			if (date('n') == 1) {
608 608
 				$dates['m_start']  = 12;
609 609
 				$dates['m_end']    = 12;
610
-				$dates['year']     = date( 'Y', $current_time ) - 1;
611
-				$dates['year_end'] = date( 'Y', $current_time ) - 1;
610
+				$dates['year']     = date('Y', $current_time) - 1;
611
+				$dates['year_end'] = date('Y', $current_time) - 1;
612 612
 			} else {
613
-				$dates['m_start']  = date( 'n' ) - 1;
614
-				$dates['m_end']    = date( 'n' ) - 1;
613
+				$dates['m_start']  = date('n') - 1;
614
+				$dates['m_end']    = date('n') - 1;
615 615
 				$dates['year_end'] = $dates['year'];
616 616
 			}
617
-			$dates['day_end'] = cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] );
617
+			$dates['day_end'] = cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']);
618 618
 			break;
619 619
 
620 620
 		case 'today' :
621
-			$dates['day']     = date( 'd', $current_time );
622
-			$dates['m_start'] = date( 'n', $current_time );
623
-			$dates['m_end']   = date( 'n', $current_time );
624
-			$dates['year']    = date( 'Y', $current_time );
621
+			$dates['day']     = date('d', $current_time);
622
+			$dates['m_start'] = date('n', $current_time);
623
+			$dates['m_end']   = date('n', $current_time);
624
+			$dates['year']    = date('Y', $current_time);
625 625
 			break;
626 626
 
627 627
 		case 'yesterday' :
628 628
 
629
-			$year  = date( 'Y', $current_time );
630
-			$month = date( 'n', $current_time );
631
-			$day   = date( 'd', $current_time );
629
+			$year  = date('Y', $current_time);
630
+			$month = date('n', $current_time);
631
+			$day   = date('d', $current_time);
632 632
 
633
-			if ( $month == 1 && $day == 1 ) {
633
+			if ($month == 1 && $day == 1) {
634 634
 
635 635
 				$year -= 1;
636 636
 				$month = 12;
637
-				$day   = cal_days_in_month( CAL_GREGORIAN, $month, $year );
637
+				$day   = cal_days_in_month(CAL_GREGORIAN, $month, $year);
638 638
 
639
-			} elseif ( $month > 1 && $day == 1 ) {
639
+			} elseif ($month > 1 && $day == 1) {
640 640
 
641 641
 				$month -= 1;
642
-				$day = cal_days_in_month( CAL_GREGORIAN, $month, $year );
642
+				$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
643 643
 
644 644
 			} else {
645 645
 
@@ -655,91 +655,91 @@  discard block
 block discarded – undo
655 655
 			break;
656 656
 
657 657
 		case 'this_week' :
658
-			$dates['day'] = date( 'd', $current_time - ( date( 'w', $current_time ) - 1 ) * 60 * 60 * 24 ) - 1;
659
-			$dates['day'] += get_option( 'start_of_week' );
658
+			$dates['day'] = date('d', $current_time - (date('w', $current_time) - 1) * 60 * 60 * 24) - 1;
659
+			$dates['day'] += get_option('start_of_week');
660 660
 			$dates['day_end'] = $dates['day'] + 6;
661
-			$dates['m_start'] = date( 'n', $current_time );
662
-			$dates['m_end']   = date( 'n', $current_time );
663
-			$dates['year']    = date( 'Y', $current_time );
661
+			$dates['m_start'] = date('n', $current_time);
662
+			$dates['m_end']   = date('n', $current_time);
663
+			$dates['year']    = date('Y', $current_time);
664 664
 			break;
665 665
 
666 666
 		case 'last_week' :
667
-			$dates['day'] = date( 'd', $current_time - ( date( 'w' ) - 1 ) * 60 * 60 * 24 ) - 8;
668
-			$dates['day'] += get_option( 'start_of_week' );
667
+			$dates['day'] = date('d', $current_time - (date('w') - 1) * 60 * 60 * 24) - 8;
668
+			$dates['day'] += get_option('start_of_week');
669 669
 			$dates['day_end'] = $dates['day'] + 6;
670
-			$dates['year']    = date( 'Y' );
671
-
672
-			if ( date( 'j', $current_time ) <= 7 ) {
673
-				$dates['m_start'] = date( 'n', $current_time ) - 1;
674
-				$dates['m_end']   = date( 'n', $current_time ) - 1;
675
-				if ( $dates['m_start'] <= 1 ) {
676
-					$dates['year']     = date( 'Y', $current_time ) - 1;
677
-					$dates['year_end'] = date( 'Y', $current_time ) - 1;
670
+			$dates['year']    = date('Y');
671
+
672
+			if (date('j', $current_time) <= 7) {
673
+				$dates['m_start'] = date('n', $current_time) - 1;
674
+				$dates['m_end']   = date('n', $current_time) - 1;
675
+				if ($dates['m_start'] <= 1) {
676
+					$dates['year']     = date('Y', $current_time) - 1;
677
+					$dates['year_end'] = date('Y', $current_time) - 1;
678 678
 				}
679 679
 			} else {
680
-				$dates['m_start'] = date( 'n', $current_time );
681
-				$dates['m_end']   = date( 'n', $current_time );
680
+				$dates['m_start'] = date('n', $current_time);
681
+				$dates['m_end']   = date('n', $current_time);
682 682
 			}
683 683
 			break;
684 684
 
685 685
 		case 'this_quarter' :
686
-			$month_now = date( 'n', $current_time );
686
+			$month_now = date('n', $current_time);
687 687
 
688
-			if ( $month_now <= 3 ) {
688
+			if ($month_now <= 3) {
689 689
 
690 690
 				$dates['m_start'] = 1;
691 691
 				$dates['m_end']   = 4;
692
-				$dates['year']    = date( 'Y', $current_time );
692
+				$dates['year']    = date('Y', $current_time);
693 693
 
694
-			} else if ( $month_now <= 6 ) {
694
+			} else if ($month_now <= 6) {
695 695
 
696 696
 				$dates['m_start'] = 4;
697 697
 				$dates['m_end']   = 7;
698
-				$dates['year']    = date( 'Y', $current_time );
698
+				$dates['year']    = date('Y', $current_time);
699 699
 
700
-			} else if ( $month_now <= 9 ) {
700
+			} else if ($month_now <= 9) {
701 701
 
702 702
 				$dates['m_start'] = 7;
703 703
 				$dates['m_end']   = 10;
704
-				$dates['year']    = date( 'Y', $current_time );
704
+				$dates['year']    = date('Y', $current_time);
705 705
 
706 706
 			} else {
707 707
 
708 708
 				$dates['m_start']  = 10;
709 709
 				$dates['m_end']    = 1;
710
-				$dates['year']     = date( 'Y', $current_time );
711
-				$dates['year_end'] = date( 'Y', $current_time ) + 1;
710
+				$dates['year']     = date('Y', $current_time);
711
+				$dates['year_end'] = date('Y', $current_time) + 1;
712 712
 
713 713
 			}
714 714
 			break;
715 715
 
716 716
 		case 'last_quarter' :
717
-			$month_now = date( 'n' );
717
+			$month_now = date('n');
718 718
 
719
-			if ( $month_now <= 3 ) {
719
+			if ($month_now <= 3) {
720 720
 
721 721
 				$dates['m_start']  = 10;
722 722
 				$dates['m_end']    = 12;
723
-				$dates['year']     = date( 'Y', $current_time ) - 1; // Previous year
724
-				$dates['year_end'] = date( 'Y', $current_time ) - 1; // Previous year
723
+				$dates['year']     = date('Y', $current_time) - 1; // Previous year
724
+				$dates['year_end'] = date('Y', $current_time) - 1; // Previous year
725 725
 
726
-			} else if ( $month_now <= 6 ) {
726
+			} else if ($month_now <= 6) {
727 727
 
728 728
 				$dates['m_start'] = 1;
729 729
 				$dates['m_end']   = 3;
730
-				$dates['year']    = date( 'Y', $current_time );
730
+				$dates['year']    = date('Y', $current_time);
731 731
 
732
-			} else if ( $month_now <= 9 ) {
732
+			} else if ($month_now <= 9) {
733 733
 
734 734
 				$dates['m_start'] = 4;
735 735
 				$dates['m_end']   = 6;
736
-				$dates['year']    = date( 'Y', $current_time );
736
+				$dates['year']    = date('Y', $current_time);
737 737
 
738 738
 			} else {
739 739
 
740 740
 				$dates['m_start'] = 7;
741 741
 				$dates['m_end']   = 9;
742
-				$dates['year']    = date( 'Y', $current_time );
742
+				$dates['year']    = date('Y', $current_time);
743 743
 
744 744
 			}
745 745
 			break;
@@ -747,19 +747,19 @@  discard block
 block discarded – undo
747 747
 		case 'this_year' :
748 748
 			$dates['m_start'] = 1;
749 749
 			$dates['m_end']   = 12;
750
-			$dates['year']    = date( 'Y', $current_time );
750
+			$dates['year']    = date('Y', $current_time);
751 751
 			break;
752 752
 
753 753
 		case 'last_year' :
754 754
 			$dates['m_start']  = 1;
755 755
 			$dates['m_end']    = 12;
756
-			$dates['year']     = date( 'Y', $current_time ) - 1;
757
-			$dates['year_end'] = date( 'Y', $current_time ) - 1;
756
+			$dates['year']     = date('Y', $current_time) - 1;
757
+			$dates['year_end'] = date('Y', $current_time) - 1;
758 758
 			break;
759 759
 
760 760
 	endswitch;
761 761
 
762
-	return apply_filters( 'give_report_dates', $dates );
762
+	return apply_filters('give_report_dates', $dates);
763 763
 }
764 764
 
765 765
 /**
@@ -769,17 +769,17 @@  discard block
 block discarded – undo
769 769
  *
770 770
  * @param $data
771 771
  */
772
-function give_parse_report_dates( $data ) {
772
+function give_parse_report_dates($data) {
773 773
 	$dates = give_get_report_dates();
774 774
 
775 775
 	$view = give_get_reporting_view();
776
-	$id   = isset( $_GET['form-id'] ) ? $_GET['form-id'] : null;
776
+	$id   = isset($_GET['form-id']) ? $_GET['form-id'] : null;
777 777
 
778
-	wp_redirect( add_query_arg( $dates, admin_url( 'edit.php?post_type=give_forms&page=give-reports&view=' . esc_attr( $view ) . '&form-id=' . absint( $id ) ) ) );
778
+	wp_redirect(add_query_arg($dates, admin_url('edit.php?post_type=give_forms&page=give-reports&view='.esc_attr($view).'&form-id='.absint($id))));
779 779
 	give_die();
780 780
 }
781 781
 
782
-add_action( 'give_filter_reports', 'give_parse_report_dates' );
782
+add_action('give_filter_reports', 'give_parse_report_dates');
783 783
 
784 784
 
785 785
 /**
@@ -789,16 +789,16 @@  discard block
 block discarded – undo
789 789
  */
790 790
 function give_reports_refresh_button() {
791 791
 
792
-	$url = wp_nonce_url( add_query_arg( array(
792
+	$url = wp_nonce_url(add_query_arg(array(
793 793
 		'give_action'  => 'refresh_reports_transients',
794 794
 		'give-message' => 'refreshed-reports'
795
-	) ), 'give-refresh-reports' );
795
+	)), 'give-refresh-reports');
796 796
 
797
-	echo '<a href="' . $url . '" data-tooltip="' . __( 'Clicking this will clear the reports cache.', 'give' ) . '" data-tooltip-my-position="right center"  data-tooltip-target-position="left center" class="button alignright give-refresh-reports-button give-tooltip">' . __( 'Refresh Reports', 'give' ) . '</a>';
797
+	echo '<a href="'.$url.'" data-tooltip="'.__('Clicking this will clear the reports cache.', 'give').'" data-tooltip-my-position="right center"  data-tooltip-target-position="left center" class="button alignright give-refresh-reports-button give-tooltip">'.__('Refresh Reports', 'give').'</a>';
798 798
 
799 799
 }
800 800
 
801
-add_action( 'give_reports_graph_additional_stats', 'give_reports_refresh_button' );
801
+add_action('give_reports_graph_additional_stats', 'give_reports_refresh_button');
802 802
 
803 803
 /**
804 804
  * Trigger the refresh of reports transients
@@ -809,18 +809,18 @@  discard block
 block discarded – undo
809 809
  *
810 810
  * @return void
811 811
  */
812
-function give_run_refresh_reports_transients( $data ) {
812
+function give_run_refresh_reports_transients($data) {
813 813
 
814
-	if ( ! wp_verify_nonce( $data['_wpnonce'], 'give-refresh-reports' ) ) {
814
+	if ( ! wp_verify_nonce($data['_wpnonce'], 'give-refresh-reports')) {
815 815
 		return;
816 816
 	}
817 817
 
818 818
 	//Delete transients
819
-	delete_transient( 'give_estimated_monthly_stats' );
820
-	delete_transient( 'give_earnings_total' );
821
-	delete_transient( md5( 'give_earnings_this_monththis_month' ) );
822
-	delete_transient( md5( 'give_earnings_todaytoday' ) );
819
+	delete_transient('give_estimated_monthly_stats');
820
+	delete_transient('give_earnings_total');
821
+	delete_transient(md5('give_earnings_this_monththis_month'));
822
+	delete_transient(md5('give_earnings_todaytoday'));
823 823
 
824 824
 }
825 825
 
826
-add_action( 'give_refresh_reports_transients', 'give_run_refresh_reports_transients' );
827 826
\ No newline at end of file
827
+add_action('give_refresh_reports_transients', 'give_run_refresh_reports_transients');
828 828
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -143,9 +143,11 @@  discard block
 block discarded – undo
143 143
 
144 144
 					endwhile;
145 145
 
146
-				else :
146
+				else {
147
+					:
147 148
 
148 149
 					$sales = give_get_sales_by_date( null, $i, $y );
150
+				}
149 151
 					$sales_totals += $sales;
150 152
 
151 153
 					$earnings = give_get_earnings_by_date( null, $i, $y );
@@ -393,9 +395,11 @@  discard block
 block discarded – undo
393 395
 
394 396
 					endwhile;
395 397
 
396
-				else :
398
+				else {
399
+					:
397 400
 
398 401
 					$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
402
+				}
399 403
 
400 404
 					$date     = mktime( 0, 0, 0, $i, 1, $y );
401 405
 					$end_date = mktime( 23, 59, 59, $i, $num_of_days, $y );
Please login to merge, or discard this patch.
includes/admin/shortcodes/abstract-shortcode-generator.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	/**
105 105
 	 * Define the shortcode attribute fields
106 106
 	 *
107
-	 * @return false|array
107
+	 * @return boolean
108 108
 	 *
109 109
 	 * @since 1.0
110 110
 	 */
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	/**
117 117
 	 * Generate the shortcode dialog fields
118 118
 	 *
119
-	 * @param array $defined_fields
119
+	 * @param boolean $defined_fields
120 120
 	 *
121 121
 	 * @return array
122 122
 	 *
Please login to merge, or discard this patch.
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Shortcode Dialog Generator abstract class
4
- *
5
- * @package     Give
6
- * @subpackage  Admin
7
- * @author      Paul Ryley
8
- * @copyright   Copyright (c) 2015, WordImpress
9
- * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
10
- * @version     1.0
11
- * @since       1.3.0
12
- */
3
+	 * Shortcode Dialog Generator abstract class
4
+	 *
5
+	 * @package     Give
6
+	 * @subpackage  Admin
7
+	 * @author      Paul Ryley
8
+	 * @copyright   Copyright (c) 2015, WordImpress
9
+	 * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
10
+	 * @version     1.0
11
+	 * @since       1.3.0
12
+	 */
13 13
 
14 14
 defined( 'ABSPATH' ) or exit;
15 15
 
@@ -246,8 +246,8 @@  discard block
 block discarded – undo
246 246
 
247 247
 			// do not reindex array!
248 248
 			$field['options'] = array(
249
-				                    '' => ( $field['placeholder'] ? $field['placeholder'] : sprintf( '– %s –', __( 'Select', 'give' ) ) ),
250
-			                    ) + $field['options'];
249
+									'' => ( $field['placeholder'] ? $field['placeholder'] : sprintf( '– %s –', __( 'Select', 'give' ) ) ),
250
+								) + $field['options'];
251 251
 
252 252
 			foreach ( $field['options'] as $value => $text ) {
253 253
 				$new_listbox['values'][] = array(
Please login to merge, or discard this patch.
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  * @since       1.3.0
12 12
  */
13 13
 
14
-defined( 'ABSPATH' ) or exit;
14
+defined('ABSPATH') or exit;
15 15
 
16 16
 abstract class Give_Shortcode_Generator {
17 17
 
@@ -57,12 +57,12 @@  discard block
 block discarded – undo
57 57
 	 *
58 58
 	 * @since 1.0
59 59
 	 */
60
-	public function __construct( $shortcode ) {
60
+	public function __construct($shortcode) {
61 61
 
62 62
 
63 63
 		$this->shortcode_tag = $shortcode;
64 64
 
65
-		add_action( 'admin_init', array( $this, 'init' ) );
65
+		add_action('admin_init', array($this, 'init'));
66 66
 
67 67
 	}
68 68
 
@@ -72,9 +72,9 @@  discard block
 block discarded – undo
72 72
 	 */
73 73
 	public function init() {
74 74
 
75
-		if ( $this->shortcode_tag ) {
75
+		if ($this->shortcode_tag) {
76 76
 
77
-			$this->self = get_class( $this );
77
+			$this->self = get_class($this);
78 78
 
79 79
 			$this->errors   = array();
80 80
 			$this->required = array();
@@ -83,16 +83,16 @@  discard block
 block discarded – undo
83 83
 			$fields = $this->get_fields();
84 84
 
85 85
 			$defaults = array(
86
-				'btn_close' => __( 'Close', 'give' ),
87
-				'btn_okay'  => __( 'Insert Shortcode', 'give' ),
86
+				'btn_close' => __('Close', 'give'),
87
+				'btn_okay'  => __('Insert Shortcode', 'give'),
88 88
 				'errors'    => $this->errors,
89 89
 				'fields'    => $fields,
90
-				'label'     => '[' . $this->shortcode_tag . ']',
90
+				'label'     => '['.$this->shortcode_tag.']',
91 91
 				'required'  => $this->required,
92
-				'title'     => __( 'Insert Shortcode', 'give' ),
92
+				'title'     => __('Insert Shortcode', 'give'),
93 93
 			);
94 94
 
95
-			Give_Shortcode_Button::$shortcodes[ $this->shortcode_tag ] = wp_parse_args( $this->shortcode, $defaults );
95
+			Give_Shortcode_Button::$shortcodes[$this->shortcode_tag] = wp_parse_args($this->shortcode, $defaults);
96 96
 
97 97
 			//
98 98
 
@@ -122,13 +122,13 @@  discard block
 block discarded – undo
122 122
 	 *
123 123
 	 * @since 1.0
124 124
 	 */
125
-	protected function generate_fields( $defined_fields ) {
125
+	protected function generate_fields($defined_fields) {
126 126
 
127 127
 		$fields = array();
128 128
 
129
-		if ( is_array( $defined_fields ) ) {
129
+		if (is_array($defined_fields)) {
130 130
 
131
-			foreach ( $defined_fields as $field ) {
131
+			foreach ($defined_fields as $field) {
132 132
 
133 133
 				$defaults = array(
134 134
 					'label'       => false,
@@ -139,14 +139,14 @@  discard block
 block discarded – undo
139 139
 					'type'        => '',
140 140
 				);
141 141
 
142
-				$field  = wp_parse_args( (array) $field, $defaults );
143
-				$method = 'generate_' . strtolower( $field['type'] );
142
+				$field  = wp_parse_args((array) $field, $defaults);
143
+				$method = 'generate_'.strtolower($field['type']);
144 144
 
145
-				if ( method_exists( $this, $method ) ) {
145
+				if (method_exists($this, $method)) {
146 146
 
147
-					$field = call_user_func( array( $this, $method ), $field );
147
+					$field = call_user_func(array($this, $method), $field);
148 148
 
149
-					if ( $field ) {
149
+					if ($field) {
150 150
 						$fields[] = $field;
151 151
 					}
152 152
 				}
@@ -166,22 +166,22 @@  discard block
 block discarded – undo
166 166
 	protected function get_fields() {
167 167
 
168 168
 		$defined_fields   = $this->define_fields();
169
-		$generated_fields = $this->generate_fields( $defined_fields );
169
+		$generated_fields = $this->generate_fields($defined_fields);
170 170
 
171 171
 		$errors = array();
172 172
 
173
-		if ( ! empty( $this->errors ) ) {
174
-			foreach ( $this->required as $name => $alert ) {
175
-				if ( false === array_search( $name, array_column( $generated_fields, 'name' ) ) ) {
173
+		if ( ! empty($this->errors)) {
174
+			foreach ($this->required as $name => $alert) {
175
+				if (false === array_search($name, array_column($generated_fields, 'name'))) {
176 176
 
177
-					$errors[] = $this->errors[ $name ];
177
+					$errors[] = $this->errors[$name];
178 178
 				}
179 179
 			}
180 180
 
181 181
 			$this->errors = $errors;
182 182
 		}
183 183
 
184
-		if ( ! empty( $errors ) ) {
184
+		if ( ! empty($errors)) {
185 185
 
186 186
 			return $errors;
187 187
 		}
@@ -198,9 +198,9 @@  discard block
 block discarded – undo
198 198
 	 *
199 199
 	 * @since 1.0
200 200
 	 */
201
-	protected function generate_container( $field ) {
201
+	protected function generate_container($field) {
202 202
 
203
-		if ( array_key_exists( 'html', $field ) ) {
203
+		if (array_key_exists('html', $field)) {
204 204
 
205 205
 			return array(
206 206
 				'type' => $field['type'],
@@ -220,36 +220,36 @@  discard block
 block discarded – undo
220 220
 	 *
221 221
 	 * @since 1.0
222 222
 	 */
223
-	protected function generate_listbox( $field ) {
223
+	protected function generate_listbox($field) {
224 224
 
225
-		$listbox = shortcode_atts( array(
225
+		$listbox = shortcode_atts(array(
226 226
 			'label'    => '',
227 227
 			'minWidth' => '',
228 228
 			'name'     => false,
229 229
 			'tooltip'  => '',
230 230
 			'type'     => '',
231 231
 			'value'    => '',
232
-		), $field );
232
+		), $field);
233 233
 
234
-		if ( $this->validate( $field ) ) {
234
+		if ($this->validate($field)) {
235 235
 
236 236
 			$new_listbox = array();
237 237
 
238
-			foreach ( $listbox as $key => $value ) {
238
+			foreach ($listbox as $key => $value) {
239 239
 
240
-				if ( $key == 'value' && empty( $value ) ) {
241
-					$new_listbox[ $key ] = $listbox['name'];
242
-				} else if ( $value ) {
243
-					$new_listbox[ $key ] = $value;
240
+				if ($key == 'value' && empty($value)) {
241
+					$new_listbox[$key] = $listbox['name'];
242
+				} else if ($value) {
243
+					$new_listbox[$key] = $value;
244 244
 				}
245 245
 			}
246 246
 
247 247
 			// do not reindex array!
248 248
 			$field['options'] = array(
249
-				                    '' => ( $field['placeholder'] ? $field['placeholder'] : sprintf( '– %s –', __( 'Select', 'give' ) ) ),
249
+				                    '' => ($field['placeholder'] ? $field['placeholder'] : sprintf('– %s –', __('Select', 'give'))),
250 250
 			                    ) + $field['options'];
251 251
 
252
-			foreach ( $field['options'] as $value => $text ) {
252
+			foreach ($field['options'] as $value => $text) {
253 253
 				$new_listbox['values'][] = array(
254 254
 					'text'  => $text,
255 255
 					'value' => $value,
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 	 *
272 272
 	 * @since 1.0
273 273
 	 */
274
-	protected function generate_post( $field ) {
274
+	protected function generate_post($field) {
275 275
 
276 276
 		$args = array(
277 277
 			'post_type'      => 'post',
@@ -280,23 +280,23 @@  discard block
 block discarded – undo
280 280
 			'posts_per_page' => 30,
281 281
 		);
282 282
 
283
-		$args    = wp_parse_args( (array) $field['query_args'], $args );
284
-		$posts   = get_posts( $args );
283
+		$args    = wp_parse_args((array) $field['query_args'], $args);
284
+		$posts   = get_posts($args);
285 285
 		$options = array();
286 286
 
287
-		if ( $posts ) {
288
-			foreach ( $posts as $post ) {
289
-				$options[ absint( $post->ID ) ] = esc_html( $post->post_title );
287
+		if ($posts) {
288
+			foreach ($posts as $post) {
289
+				$options[absint($post->ID)] = esc_html($post->post_title);
290 290
 			}
291 291
 
292 292
 			$field['type']    = 'listbox';
293 293
 			$field['options'] = $options;
294 294
 
295
-			return $this->generate_listbox( $field );
295
+			return $this->generate_listbox($field);
296 296
 		}
297 297
 
298 298
 		// perform validation here before returning false
299
-		$this->validate( $field );
299
+		$this->validate($field);
300 300
 
301 301
 		return false;
302 302
 	}
@@ -310,9 +310,9 @@  discard block
 block discarded – undo
310 310
 	 *
311 311
 	 * @since 1.0
312 312
 	 */
313
-	protected function generate_textbox( $field ) {
313
+	protected function generate_textbox($field) {
314 314
 
315
-		$textbox = shortcode_atts( array(
315
+		$textbox = shortcode_atts(array(
316 316
 			'label'     => '',
317 317
 			'maxLength' => '',
318 318
 			'minHeight' => '',
@@ -322,10 +322,10 @@  discard block
 block discarded – undo
322 322
 			'tooltip'   => '',
323 323
 			'type'      => '',
324 324
 			'value'     => '',
325
-		), $field );
325
+		), $field);
326 326
 
327
-		if ( $this->validate( $field ) ) {
328
-			return array_filter( $textbox, array( $this, 'return_textbox_value' ) );
327
+		if ($this->validate($field)) {
328
+			return array_filter($textbox, array($this, 'return_textbox_value'));
329 329
 		}
330 330
 
331 331
 		return false;
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
 	 *
339 339
 	 * @return bool
340 340
 	 */
341
-	function return_textbox_value( $value ) {
341
+	function return_textbox_value($value) {
342 342
 		return $value !== '';
343 343
 	}
344 344
 
@@ -354,9 +354,9 @@  discard block
 block discarded – undo
354 354
 	 *
355 355
 	 * @since 1.0
356 356
 	 */
357
-	protected function validate( $field ) {
357
+	protected function validate($field) {
358 358
 
359
-		extract( shortcode_atts(
359
+		extract(shortcode_atts(
360 360
 				array(
361 361
 					'name'     => false,
362 362
 					'required' => false,
@@ -364,34 +364,34 @@  discard block
 block discarded – undo
364 364
 				), $field )
365 365
 		);
366 366
 
367
-		if ( $name ) {
367
+		if ($name) {
368 368
 
369
-			if ( isset( $required['error'] ) ) {
369
+			if (isset($required['error'])) {
370 370
 
371 371
 				$error = array(
372 372
 					'type' => 'container',
373 373
 					'html' => $required['error'],
374 374
 				);
375 375
 
376
-				$this->errors[ $name ] = $this->generate_container( $error );
376
+				$this->errors[$name] = $this->generate_container($error);
377 377
 			}
378 378
 
379
-			if ( ! ! $required || is_array( $required ) ) {
379
+			if ( ! ! $required || is_array($required)) {
380 380
 
381
-				$alert = __( 'Some of the Shortcode options are required.', 'give' );
381
+				$alert = __('Some of the Shortcode options are required.', 'give');
382 382
 
383
-				if ( isset( $required['alert'] ) ) {
383
+				if (isset($required['alert'])) {
384 384
 
385 385
 					$alert = $required['alert'];
386 386
 
387
-				} else if ( ! empty( $label ) ) {
387
+				} else if ( ! empty($label)) {
388 388
 
389
-					$alert = sprintf( __( 'The "%s" option is required.', 'give' ),
390
-						str_replace( ':', '', $label )
389
+					$alert = sprintf(__('The "%s" option is required.', 'give'),
390
+						str_replace(':', '', $label)
391 391
 					);
392 392
 				}
393 393
 
394
-				$this->required[ $name ] = $alert;
394
+				$this->required[$name] = $alert;
395 395
 			}
396 396
 
397 397
 			return true;
Please login to merge, or discard this patch.
includes/api/class-give-api.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 	 *
212 212
 	 * @access public
213 213
 	 * @since  1.1
214
-	 * @return array
214
+	 * @return string
215 215
 	 */
216 216
 	public function get_versions() {
217 217
 		return $this->versions;
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
 	 *
663 663
 	 * @param array $args Arguments to override defaults
664 664
 	 *
665
-	 * @return array $dates
665
+	 * @return integer|null $dates
666 666
 	 */
667 667
 	public function get_dates( $args = array() ) {
668 668
 		$dates = array();
@@ -1712,7 +1712,7 @@  discard block
 block discarded – undo
1712 1712
 	 *
1713 1713
 	 * @param int $user_id User ID of user to revoke key for
1714 1714
 	 *
1715
-	 * @return string
1715
+	 * @return boolean
1716 1716
 	 */
1717 1717
 	public function revoke_api_key( $user_id = 0 ) {
1718 1718
 
Please login to merge, or discard this patch.
Spacing   +468 added lines, -468 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
 
@@ -139,24 +139,24 @@  discard block
 block discarded – undo
139 139
 			'v1' => 'GIVE_API_V1',
140 140
 		);
141 141
 
142
-		foreach ( $this->get_versions() as $version => $class ) {
143
-			require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api-' . $version . '.php';
142
+		foreach ($this->get_versions() as $version => $class) {
143
+			require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api-'.$version.'.php';
144 144
 		}
145 145
 
146
-		add_action( 'init', array( $this, 'add_endpoint' ) );
147
-		add_action( 'template_redirect', array( $this, 'process_query' ), - 1 );
148
-		add_filter( 'query_vars', array( $this, 'query_vars' ) );
149
-		add_action( 'show_user_profile', array( $this, 'user_key_field' ) );
150
-		add_action( 'edit_user_profile', array( $this, 'user_key_field' ) );
151
-		add_action( 'personal_options_update', array( $this, 'update_key' ) );
152
-		add_action( 'edit_user_profile_update', array( $this, 'update_key' ) );
153
-		add_action( 'give_process_api_key', array( $this, 'process_api_key' ) );
146
+		add_action('init', array($this, 'add_endpoint'));
147
+		add_action('template_redirect', array($this, 'process_query'), - 1);
148
+		add_filter('query_vars', array($this, 'query_vars'));
149
+		add_action('show_user_profile', array($this, 'user_key_field'));
150
+		add_action('edit_user_profile', array($this, 'user_key_field'));
151
+		add_action('personal_options_update', array($this, 'update_key'));
152
+		add_action('edit_user_profile_update', array($this, 'update_key'));
153
+		add_action('give_process_api_key', array($this, 'process_api_key'));
154 154
 
155 155
 		// Determine if JSON_PRETTY_PRINT is available
156
-		$this->pretty_print = defined( 'JSON_PRETTY_PRINT' ) ? JSON_PRETTY_PRINT : null;
156
+		$this->pretty_print = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : null;
157 157
 
158 158
 		// Allow API request logging to be turned off
159
-		$this->log_requests = apply_filters( 'give_api_log_requests', $this->log_requests );
159
+		$this->log_requests = apply_filters('give_api_log_requests', $this->log_requests);
160 160
 
161 161
 		// Setup Give_Payment_Stats instance
162 162
 		$this->stats = new Give_Payment_Stats;
@@ -172,8 +172,8 @@  discard block
 block discarded – undo
172 172
 	 *
173 173
 	 * @since  1.1
174 174
 	 */
175
-	public function add_endpoint( $rewrite_rules ) {
176
-		add_rewrite_endpoint( 'give-api', EP_ALL );
175
+	public function add_endpoint($rewrite_rules) {
176
+		add_rewrite_endpoint('give-api', EP_ALL);
177 177
 	}
178 178
 
179 179
 	/**
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 	 *
187 187
 	 * @return string[] $vars New query vars
188 188
 	 */
189
-	public function query_vars( $vars ) {
189
+	public function query_vars($vars) {
190 190
 
191 191
 		$vars[] = 'token';
192 192
 		$vars[] = 'key';
@@ -237,11 +237,11 @@  discard block
 block discarded – undo
237 237
 	 */
238 238
 	public function get_default_version() {
239 239
 
240
-		$version = get_option( 'give_default_api_version' );
240
+		$version = get_option('give_default_api_version');
241 241
 
242
-		if ( defined( 'GIVE_API_VERSION' ) ) {
242
+		if (defined('GIVE_API_VERSION')) {
243 243
 			$version = GIVE_API_VERSION;
244
-		} elseif ( ! $version ) {
244
+		} elseif ( ! $version) {
245 245
 			$version = 'v1';
246 246
 		}
247 247
 
@@ -262,14 +262,14 @@  discard block
 block discarded – undo
262 262
 
263 263
 		$version = $wp_query->query_vars['give-api'];
264 264
 
265
-		if ( strpos( $version, '/' ) ) {
265
+		if (strpos($version, '/')) {
266 266
 
267
-			$version = explode( '/', $version );
268
-			$version = strtolower( $version[0] );
267
+			$version = explode('/', $version);
268
+			$version = strtolower($version[0]);
269 269
 
270
-			$wp_query->query_vars['give-api'] = str_replace( $version . '/', '', $wp_query->query_vars['give-api'] );
270
+			$wp_query->query_vars['give-api'] = str_replace($version.'/', '', $wp_query->query_vars['give-api']);
271 271
 
272
-			if ( array_key_exists( $version, $this->versions ) ) {
272
+			if (array_key_exists($version, $this->versions)) {
273 273
 
274 274
 				$this->queried_version = $version;
275 275
 
@@ -306,35 +306,35 @@  discard block
 block discarded – undo
306 306
 		$this->override = false;
307 307
 
308 308
 		// Make sure we have both user and api key
309
-		if ( ! empty( $wp_query->query_vars['give-api'] ) && ( $wp_query->query_vars['give-api'] != 'forms' || ! empty( $wp_query->query_vars['token'] ) ) ) {
309
+		if ( ! empty($wp_query->query_vars['give-api']) && ($wp_query->query_vars['give-api'] != 'forms' || ! empty($wp_query->query_vars['token']))) {
310 310
 
311
-			if ( empty( $wp_query->query_vars['token'] ) || empty( $wp_query->query_vars['key'] ) ) {
311
+			if (empty($wp_query->query_vars['token']) || empty($wp_query->query_vars['key'])) {
312 312
 				$this->missing_auth();
313 313
 			}
314 314
 
315 315
 			// Auth was provided, include the upgrade routine so we can use the fallback api checks
316
-			require GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php';
316
+			require GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php';
317 317
 
318 318
 			// Retrieve the user by public API key and ensure they exist
319
-			if ( ! ( $user = $this->get_user( $wp_query->query_vars['key'] ) ) ) {
319
+			if ( ! ($user = $this->get_user($wp_query->query_vars['key']))) {
320 320
 
321 321
 				$this->invalid_key();
322 322
 
323 323
 			} else {
324 324
 
325
-				$token  = urldecode( $wp_query->query_vars['token'] );
326
-				$secret = $this->get_user_secret_key( $user );
327
-				$public = urldecode( $wp_query->query_vars['key'] );
325
+				$token  = urldecode($wp_query->query_vars['token']);
326
+				$secret = $this->get_user_secret_key($user);
327
+				$public = urldecode($wp_query->query_vars['key']);
328 328
 
329
-				if ( hash_equals( md5( $secret . $public ), $token ) ) {
329
+				if (hash_equals(md5($secret.$public), $token)) {
330 330
 					$this->is_valid_request = true;
331 331
 				} else {
332 332
 					$this->invalid_auth();
333 333
 				}
334 334
 			}
335
-		} elseif ( ! empty( $wp_query->query_vars['give-api'] ) && $wp_query->query_vars['give-api'] == 'forms' ) {
335
+		} elseif ( ! empty($wp_query->query_vars['give-api']) && $wp_query->query_vars['give-api'] == 'forms') {
336 336
 			$this->is_valid_request = true;
337
-			$wp_query->set( 'key', 'public' );
337
+			$wp_query->set('key', 'public');
338 338
 		}
339 339
 	}
340 340
 
@@ -350,25 +350,25 @@  discard block
 block discarded – undo
350 350
 	 *
351 351
 	 * @return bool if user ID is found, false otherwise
352 352
 	 */
353
-	public function get_user( $key = '' ) {
353
+	public function get_user($key = '') {
354 354
 		global $wpdb, $wp_query;
355 355
 
356
-		if ( empty( $key ) ) {
357
-			$key = urldecode( $wp_query->query_vars['key'] );
356
+		if (empty($key)) {
357
+			$key = urldecode($wp_query->query_vars['key']);
358 358
 		}
359 359
 
360
-		if ( empty( $key ) ) {
360
+		if (empty($key)) {
361 361
 			return false;
362 362
 		}
363 363
 
364
-		$user = get_transient( md5( 'give_api_user_' . $key ) );
364
+		$user = get_transient(md5('give_api_user_'.$key));
365 365
 
366
-		if ( false === $user ) {
367
-			$user = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key ) );
368
-			set_transient( md5( 'give_api_user_' . $key ), $user, DAY_IN_SECONDS );
366
+		if (false === $user) {
367
+			$user = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key));
368
+			set_transient(md5('give_api_user_'.$key), $user, DAY_IN_SECONDS);
369 369
 		}
370 370
 
371
-		if ( $user != null ) {
371
+		if ($user != null) {
372 372
 			$this->user_id = $user;
373 373
 
374 374
 			return $user;
@@ -377,37 +377,37 @@  discard block
 block discarded – undo
377 377
 		return false;
378 378
 	}
379 379
 
380
-	public function get_user_public_key( $user_id = 0 ) {
380
+	public function get_user_public_key($user_id = 0) {
381 381
 		global $wpdb;
382 382
 
383
-		if ( empty( $user_id ) ) {
383
+		if (empty($user_id)) {
384 384
 			return '';
385 385
 		}
386 386
 
387
-		$cache_key       = md5( 'give_api_user_public_key' . $user_id );
388
-		$user_public_key = get_transient( $cache_key );
387
+		$cache_key       = md5('give_api_user_public_key'.$user_id);
388
+		$user_public_key = get_transient($cache_key);
389 389
 
390
-		if ( empty( $user_public_key ) ) {
391
-			$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 ) );
392
-			set_transient( $cache_key, $user_public_key, HOUR_IN_SECONDS );
390
+		if (empty($user_public_key)) {
391
+			$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));
392
+			set_transient($cache_key, $user_public_key, HOUR_IN_SECONDS);
393 393
 		}
394 394
 
395 395
 		return $user_public_key;
396 396
 	}
397 397
 
398
-	public function get_user_secret_key( $user_id = 0 ) {
398
+	public function get_user_secret_key($user_id = 0) {
399 399
 		global $wpdb;
400 400
 
401
-		if ( empty( $user_id ) ) {
401
+		if (empty($user_id)) {
402 402
 			return '';
403 403
 		}
404 404
 
405
-		$cache_key       = md5( 'give_api_user_secret_key' . $user_id );
406
-		$user_secret_key = get_transient( $cache_key );
405
+		$cache_key       = md5('give_api_user_secret_key'.$user_id);
406
+		$user_secret_key = get_transient($cache_key);
407 407
 
408
-		if ( empty( $user_secret_key ) ) {
409
-			$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 ) );
410
-			set_transient( $cache_key, $user_secret_key, HOUR_IN_SECONDS );
408
+		if (empty($user_secret_key)) {
409
+			$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));
410
+			set_transient($cache_key, $user_secret_key, HOUR_IN_SECONDS);
411 411
 		}
412 412
 
413 413
 		return $user_secret_key;
@@ -423,10 +423,10 @@  discard block
 block discarded – undo
423 423
 	 */
424 424
 	private function missing_auth() {
425 425
 		$error          = array();
426
-		$error['error'] = __( 'You must specify both a token and API key!', 'give' );
426
+		$error['error'] = __('You must specify both a token and API key!', 'give');
427 427
 
428 428
 		$this->data = $error;
429
-		$this->output( 401 );
429
+		$this->output(401);
430 430
 	}
431 431
 
432 432
 	/**
@@ -440,10 +440,10 @@  discard block
 block discarded – undo
440 440
 	 */
441 441
 	private function invalid_auth() {
442 442
 		$error          = array();
443
-		$error['error'] = __( 'Your request could not be authenticated!', 'give' );
443
+		$error['error'] = __('Your request could not be authenticated!', 'give');
444 444
 
445 445
 		$this->data = $error;
446
-		$this->output( 401 );
446
+		$this->output(401);
447 447
 	}
448 448
 
449 449
 	/**
@@ -457,10 +457,10 @@  discard block
 block discarded – undo
457 457
 	 */
458 458
 	private function invalid_key() {
459 459
 		$error          = array();
460
-		$error['error'] = __( 'Invalid API key!', 'give' );
460
+		$error['error'] = __('Invalid API key!', 'give');
461 461
 
462 462
 		$this->data = $error;
463
-		$this->output( 401 );
463
+		$this->output(401);
464 464
 	}
465 465
 
466 466
 	/**
@@ -473,10 +473,10 @@  discard block
 block discarded – undo
473 473
 	 */
474 474
 	private function invalid_version() {
475 475
 		$error          = array();
476
-		$error['error'] = __( 'Invalid API version!', 'give' );
476
+		$error['error'] = __('Invalid API version!', 'give');
477 477
 
478 478
 		$this->data = $error;
479
-		$this->output( 404 );
479
+		$this->output(404);
480 480
 	}
481 481
 
482 482
 	/**
@@ -492,10 +492,10 @@  discard block
 block discarded – undo
492 492
 		global $wp_query;
493 493
 
494 494
 		// Start logging how long the request takes for logging
495
-		$before = microtime( true );
495
+		$before = microtime(true);
496 496
 
497 497
 		// Check for give-api var. Get out if not present
498
-		if ( empty( $wp_query->query_vars['give-api'] ) ) {
498
+		if (empty($wp_query->query_vars['give-api'])) {
499 499
 			return;
500 500
 		}
501 501
 
@@ -509,44 +509,44 @@  discard block
 block discarded – undo
509 509
 		$this->validate_request();
510 510
 
511 511
 		// Only proceed if no errors have been noted
512
-		if ( ! $this->is_valid_request ) {
512
+		if ( ! $this->is_valid_request) {
513 513
 			return;
514 514
 		}
515 515
 
516
-		if ( ! defined( 'GIVE_DOING_API' ) ) {
517
-			define( 'GIVE_DOING_API', true );
516
+		if ( ! defined('GIVE_DOING_API')) {
517
+			define('GIVE_DOING_API', true);
518 518
 		}
519 519
 
520 520
 		$data         = array();
521 521
 		$this->routes = new $this->versions[$this->get_queried_version()];
522 522
 
523
-		switch ( $this->endpoint ) :
523
+		switch ($this->endpoint) :
524 524
 
525 525
 			case 'stats' :
526 526
 
527
-				$data = $this->routes->get_stats( array(
528
-					'type'      => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null,
529
-					'form'      => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null,
530
-					'date'      => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null,
531
-					'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null,
532
-					'enddate'   => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null
533
-				) );
527
+				$data = $this->routes->get_stats(array(
528
+					'type'      => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null,
529
+					'form'      => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null,
530
+					'date'      => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null,
531
+					'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null,
532
+					'enddate'   => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null
533
+				));
534 534
 
535 535
 				break;
536 536
 
537 537
 			case 'forms' :
538 538
 
539
-				$form = isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null;
539
+				$form = isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null;
540 540
 
541
-				$data = $this->routes->get_forms( $form );
541
+				$data = $this->routes->get_forms($form);
542 542
 
543 543
 				break;
544 544
 
545 545
 			case 'donors' :
546 546
 
547
-				$customer = isset( $wp_query->query_vars['donor'] ) ? $wp_query->query_vars['donor'] : null;
547
+				$customer = isset($wp_query->query_vars['donor']) ? $wp_query->query_vars['donor'] : null;
548 548
 
549
-				$data = $this->routes->get_customers( $customer );
549
+				$data = $this->routes->get_customers($customer);
550 550
 
551 551
 				break;
552 552
 
@@ -559,14 +559,14 @@  discard block
 block discarded – undo
559 559
 		endswitch;
560 560
 
561 561
 		// Allow extensions to setup their own return data
562
-		$this->data = apply_filters( 'give_api_output_data', $data, $this->endpoint, $this );
562
+		$this->data = apply_filters('give_api_output_data', $data, $this->endpoint, $this);
563 563
 
564
-		$after                       = microtime( true );
565
-		$request_time                = ( $after - $before );
564
+		$after                       = microtime(true);
565
+		$request_time                = ($after - $before);
566 566
 		$this->data['request_speed'] = $request_time;
567 567
 
568 568
 		// Log this API request, if enabled. We log it here because we have access to errors.
569
-		$this->log_request( $this->data );
569
+		$this->log_request($this->data);
570 570
 
571 571
 		// Send out data to the output function
572 572
 		$this->output();
@@ -596,21 +596,21 @@  discard block
 block discarded – undo
596 596
 		global $wp_query;
597 597
 
598 598
 		// Whitelist our query options
599
-		$accepted = apply_filters( 'give_api_valid_query_modes', array(
599
+		$accepted = apply_filters('give_api_valid_query_modes', array(
600 600
 			'stats',
601 601
 			'forms',
602 602
 			'donors',
603 603
 			'donations'
604
-		) );
604
+		));
605 605
 
606
-		$query = isset( $wp_query->query_vars['give-api'] ) ? $wp_query->query_vars['give-api'] : null;
607
-		$query = str_replace( $this->queried_version . '/', '', $query );
606
+		$query = isset($wp_query->query_vars['give-api']) ? $wp_query->query_vars['give-api'] : null;
607
+		$query = str_replace($this->queried_version.'/', '', $query);
608 608
 
609 609
 		$error = array();
610 610
 
611 611
 		// Make sure our query is valid
612
-		if ( ! in_array( $query, $accepted ) ) {
613
-			$error['error'] = __( 'Invalid query!', 'give' );
612
+		if ( ! in_array($query, $accepted)) {
613
+			$error['error'] = __('Invalid query!', 'give');
614 614
 
615 615
 			$this->data = $error;
616 616
 			$this->output();
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
 	public function get_paged() {
631 631
 		global $wp_query;
632 632
 
633
-		return isset( $wp_query->query_vars['page'] ) ? $wp_query->query_vars['page'] : 1;
633
+		return isset($wp_query->query_vars['page']) ? $wp_query->query_vars['page'] : 1;
634 634
 	}
635 635
 
636 636
 
@@ -645,13 +645,13 @@  discard block
 block discarded – undo
645 645
 	public function per_page() {
646 646
 		global $wp_query;
647 647
 
648
-		$per_page = isset( $wp_query->query_vars['number'] ) ? $wp_query->query_vars['number'] : 10;
648
+		$per_page = isset($wp_query->query_vars['number']) ? $wp_query->query_vars['number'] : 10;
649 649
 
650
-		if ( $per_page < 0 && $this->get_query_mode() == 'donors' ) {
650
+		if ($per_page < 0 && $this->get_query_mode() == 'donors') {
651 651
 			$per_page = 99999999;
652 652
 		} // Customers query doesn't support -1
653 653
 
654
-		return apply_filters( 'give_api_results_per_page', $per_page );
654
+		return apply_filters('give_api_results_per_page', $per_page);
655 655
 	}
656 656
 
657 657
 	/**
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
 	 *
665 665
 	 * @return array $dates
666 666
 	 */
667
-	public function get_dates( $args = array() ) {
667
+	public function get_dates($args = array()) {
668 668
 		$dates = array();
669 669
 
670 670
 		$defaults = array(
@@ -675,60 +675,60 @@  discard block
 block discarded – undo
675 675
 			'enddate'   => null
676 676
 		);
677 677
 
678
-		$args = wp_parse_args( $args, $defaults );
678
+		$args = wp_parse_args($args, $defaults);
679 679
 
680
-		$current_time = current_time( 'timestamp' );
680
+		$current_time = current_time('timestamp');
681 681
 
682
-		if ( 'range' === $args['date'] ) {
683
-			$startdate          = strtotime( $args['startdate'] );
684
-			$enddate            = strtotime( $args['enddate'] );
685
-			$dates['day_start'] = date( 'd', $startdate );
686
-			$dates['day_end']   = date( 'd', $enddate );
687
-			$dates['m_start']   = date( 'n', $startdate );
688
-			$dates['m_end']     = date( 'n', $enddate );
689
-			$dates['year']      = date( 'Y', $startdate );
690
-			$dates['year_end']  = date( 'Y', $enddate );
682
+		if ('range' === $args['date']) {
683
+			$startdate          = strtotime($args['startdate']);
684
+			$enddate            = strtotime($args['enddate']);
685
+			$dates['day_start'] = date('d', $startdate);
686
+			$dates['day_end']   = date('d', $enddate);
687
+			$dates['m_start']   = date('n', $startdate);
688
+			$dates['m_end']     = date('n', $enddate);
689
+			$dates['year']      = date('Y', $startdate);
690
+			$dates['year_end']  = date('Y', $enddate);
691 691
 		} else {
692 692
 			// Modify dates based on predefined ranges
693
-			switch ( $args['date'] ) :
693
+			switch ($args['date']) :
694 694
 
695 695
 				case 'this_month' :
696 696
 					$dates['day']     = null;
697
-					$dates['m_start'] = date( 'n', $current_time );
698
-					$dates['m_end']   = date( 'n', $current_time );
699
-					$dates['year']    = date( 'Y', $current_time );
697
+					$dates['m_start'] = date('n', $current_time);
698
+					$dates['m_end']   = date('n', $current_time);
699
+					$dates['year']    = date('Y', $current_time);
700 700
 					break;
701 701
 
702 702
 				case 'last_month' :
703 703
 					$dates['day']     = null;
704
-					$dates['m_start'] = date( 'n', $current_time ) == 1 ? 12 : date( 'n', $current_time ) - 1;
704
+					$dates['m_start'] = date('n', $current_time) == 1 ? 12 : date('n', $current_time) - 1;
705 705
 					$dates['m_end']   = $dates['m_start'];
706
-					$dates['year']    = date( 'n', $current_time ) == 1 ? date( 'Y', $current_time ) - 1 : date( 'Y', $current_time );
706
+					$dates['year']    = date('n', $current_time) == 1 ? date('Y', $current_time) - 1 : date('Y', $current_time);
707 707
 					break;
708 708
 
709 709
 				case 'today' :
710
-					$dates['day']     = date( 'd', $current_time );
711
-					$dates['m_start'] = date( 'n', $current_time );
712
-					$dates['m_end']   = date( 'n', $current_time );
713
-					$dates['year']    = date( 'Y', $current_time );
710
+					$dates['day']     = date('d', $current_time);
711
+					$dates['m_start'] = date('n', $current_time);
712
+					$dates['m_end']   = date('n', $current_time);
713
+					$dates['year']    = date('Y', $current_time);
714 714
 					break;
715 715
 
716 716
 				case 'yesterday' :
717 717
 
718
-					$year  = date( 'Y', $current_time );
719
-					$month = date( 'n', $current_time );
720
-					$day   = date( 'd', $current_time );
718
+					$year  = date('Y', $current_time);
719
+					$month = date('n', $current_time);
720
+					$day   = date('d', $current_time);
721 721
 
722
-					if ( $month == 1 && $day == 1 ) {
722
+					if ($month == 1 && $day == 1) {
723 723
 
724 724
 						$year -= 1;
725 725
 						$month = 12;
726
-						$day   = cal_days_in_month( CAL_GREGORIAN, $month, $year );
726
+						$day   = cal_days_in_month(CAL_GREGORIAN, $month, $year);
727 727
 
728
-					} elseif ( $month > 1 && $day == 1 ) {
728
+					} elseif ($month > 1 && $day == 1) {
729 729
 
730 730
 						$month -= 1;
731
-						$day = cal_days_in_month( CAL_GREGORIAN, $month, $year );
731
+						$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
732 732
 
733 733
 					} else {
734 734
 
@@ -744,65 +744,65 @@  discard block
 block discarded – undo
744 744
 					break;
745 745
 
746 746
 				case 'this_quarter' :
747
-					$month_now = date( 'n', $current_time );
747
+					$month_now = date('n', $current_time);
748 748
 
749 749
 					$dates['day'] = null;
750 750
 
751
-					if ( $month_now <= 3 ) {
751
+					if ($month_now <= 3) {
752 752
 
753 753
 						$dates['m_start'] = 1;
754 754
 						$dates['m_end']   = 3;
755
-						$dates['year']    = date( 'Y', $current_time );
755
+						$dates['year']    = date('Y', $current_time);
756 756
 
757
-					} else if ( $month_now <= 6 ) {
757
+					} else if ($month_now <= 6) {
758 758
 
759 759
 						$dates['m_start'] = 4;
760 760
 						$dates['m_end']   = 6;
761
-						$dates['year']    = date( 'Y', $current_time );
761
+						$dates['year']    = date('Y', $current_time);
762 762
 
763
-					} else if ( $month_now <= 9 ) {
763
+					} else if ($month_now <= 9) {
764 764
 
765 765
 						$dates['m_start'] = 7;
766 766
 						$dates['m_end']   = 9;
767
-						$dates['year']    = date( 'Y', $current_time );
767
+						$dates['year']    = date('Y', $current_time);
768 768
 
769 769
 					} else {
770 770
 
771 771
 						$dates['m_start'] = 10;
772 772
 						$dates['m_end']   = 12;
773
-						$dates['year']    = date( 'Y', $current_time );
773
+						$dates['year']    = date('Y', $current_time);
774 774
 
775 775
 					}
776 776
 					break;
777 777
 
778 778
 				case 'last_quarter' :
779
-					$month_now = date( 'n', $current_time );
779
+					$month_now = date('n', $current_time);
780 780
 
781 781
 					$dates['day'] = null;
782 782
 
783
-					if ( $month_now <= 3 ) {
783
+					if ($month_now <= 3) {
784 784
 
785 785
 						$dates['m_start'] = 10;
786 786
 						$dates['m_end']   = 12;
787
-						$dates['year']    = date( 'Y', $current_time ) - 1; // Previous year
787
+						$dates['year']    = date('Y', $current_time) - 1; // Previous year
788 788
 
789
-					} else if ( $month_now <= 6 ) {
789
+					} else if ($month_now <= 6) {
790 790
 
791 791
 						$dates['m_start'] = 1;
792 792
 						$dates['m_end']   = 3;
793
-						$dates['year']    = date( 'Y', $current_time );
793
+						$dates['year']    = date('Y', $current_time);
794 794
 
795
-					} else if ( $month_now <= 9 ) {
795
+					} else if ($month_now <= 9) {
796 796
 
797 797
 						$dates['m_start'] = 4;
798 798
 						$dates['m_end']   = 6;
799
-						$dates['year']    = date( 'Y', $current_time );
799
+						$dates['year']    = date('Y', $current_time);
800 800
 
801 801
 					} else {
802 802
 
803 803
 						$dates['m_start'] = 7;
804 804
 						$dates['m_end']   = 9;
805
-						$dates['year']    = date( 'Y', $current_time );
805
+						$dates['year']    = date('Y', $current_time);
806 806
 
807 807
 					}
808 808
 					break;
@@ -811,14 +811,14 @@  discard block
 block discarded – undo
811 811
 					$dates['day']     = null;
812 812
 					$dates['m_start'] = null;
813 813
 					$dates['m_end']   = null;
814
-					$dates['year']    = date( 'Y', $current_time );
814
+					$dates['year']    = date('Y', $current_time);
815 815
 					break;
816 816
 
817 817
 				case 'last_year' :
818 818
 					$dates['day']     = null;
819 819
 					$dates['m_start'] = null;
820 820
 					$dates['m_end']   = null;
821
-					$dates['year']    = date( 'Y', $current_time ) - 1;
821
+					$dates['year']    = date('Y', $current_time) - 1;
822 822
 					break;
823 823
 
824 824
 			endswitch;
@@ -832,7 +832,7 @@  discard block
 block discarded – undo
832 832
 		 * @param object $dates The dates used for retreiving earnings/donations
833 833
 		 */
834 834
 
835
-		return apply_filters( 'give_api_stat_dates', $dates );
835
+		return apply_filters('give_api_stat_dates', $dates);
836 836
 	}
837 837
 
838 838
 	/**
@@ -847,11 +847,11 @@  discard block
 block discarded – undo
847 847
 	 *
848 848
 	 * @return array $customers Multidimensional array of the customers
849 849
 	 */
850
-	public function get_customers( $customer = null ) {
850
+	public function get_customers($customer = null) {
851 851
 
852 852
 		$customers = array();
853 853
 		$error     = array();
854
-		if ( ! user_can( $this->user_id, 'view_give_sensitive_data' ) && ! $this->override ) {
854
+		if ( ! user_can($this->user_id, 'view_give_sensitive_data') && ! $this->override) {
855 855
 			return $customers;
856 856
 		}
857 857
 
@@ -859,68 +859,68 @@  discard block
 block discarded – undo
859 859
 
860 860
 		$paged    = $this->get_paged();
861 861
 		$per_page = $this->per_page();
862
-		$offset   = $per_page * ( $paged - 1 );
862
+		$offset   = $per_page * ($paged - 1);
863 863
 
864
-		if ( is_numeric( $customer ) ) {
864
+		if (is_numeric($customer)) {
865 865
 			$field = 'id';
866 866
 		} else {
867 867
 			$field = 'email';
868 868
 		}
869 869
 
870
-		$customer_query = Give()->customers->get_customers( array(
870
+		$customer_query = Give()->customers->get_customers(array(
871 871
 			'number' => $per_page,
872 872
 			'offset' => $offset,
873 873
 			$field   => $customer
874
-		) );
874
+		));
875 875
 		$customer_count = 0;
876 876
 
877
-		if ( $customer_query ) {
877
+		if ($customer_query) {
878 878
 
879
-			foreach ( $customer_query as $customer_obj ) {
879
+			foreach ($customer_query as $customer_obj) {
880 880
 
881
-				$names      = explode( ' ', $customer_obj->name );
882
-				$first_name = ! empty( $names[0] ) ? $names[0] : '';
881
+				$names      = explode(' ', $customer_obj->name);
882
+				$first_name = ! empty($names[0]) ? $names[0] : '';
883 883
 				$last_name  = '';
884
-				if ( ! empty( $names[1] ) ) {
885
-					unset( $names[0] );
886
-					$last_name = implode( ' ', $names );
884
+				if ( ! empty($names[1])) {
885
+					unset($names[0]);
886
+					$last_name = implode(' ', $names);
887 887
 				}
888 888
 
889
-				$customers['donors'][ $customer_count ]['info']['user_id']      = '';
890
-				$customers['donors'][ $customer_count ]['info']['username']     = '';
891
-				$customers['donors'][ $customer_count ]['info']['display_name'] = '';
892
-				$customers['donors'][ $customer_count ]['info']['customer_id']  = $customer_obj->id;
893
-				$customers['donors'][ $customer_count ]['info']['first_name']   = $first_name;
894
-				$customers['donors'][ $customer_count ]['info']['last_name']    = $last_name;
895
-				$customers['donors'][ $customer_count ]['info']['email']        = $customer_obj->email;
889
+				$customers['donors'][$customer_count]['info']['user_id']      = '';
890
+				$customers['donors'][$customer_count]['info']['username']     = '';
891
+				$customers['donors'][$customer_count]['info']['display_name'] = '';
892
+				$customers['donors'][$customer_count]['info']['customer_id']  = $customer_obj->id;
893
+				$customers['donors'][$customer_count]['info']['first_name']   = $first_name;
894
+				$customers['donors'][$customer_count]['info']['last_name']    = $last_name;
895
+				$customers['donors'][$customer_count]['info']['email']        = $customer_obj->email;
896 896
 
897
-				if ( ! empty( $customer_obj->user_id ) ) {
897
+				if ( ! empty($customer_obj->user_id)) {
898 898
 
899
-					$user_data = get_userdata( $customer_obj->user_id );
899
+					$user_data = get_userdata($customer_obj->user_id);
900 900
 
901 901
 					// Customer with registered account
902
-					$customers['donors'][ $customer_count ]['info']['user_id']      = $customer_obj->user_id;
903
-					$customers['donors'][ $customer_count ]['info']['username']     = $user_data->user_login;
904
-					$customers['donors'][ $customer_count ]['info']['display_name'] = $user_data->display_name;
902
+					$customers['donors'][$customer_count]['info']['user_id']      = $customer_obj->user_id;
903
+					$customers['donors'][$customer_count]['info']['username']     = $user_data->user_login;
904
+					$customers['donors'][$customer_count]['info']['display_name'] = $user_data->display_name;
905 905
 
906 906
 				}
907 907
 
908
-				$customers['donors'][ $customer_count ]['stats']['total_donations'] = $customer_obj->purchase_count;
909
-				$customers['donors'][ $customer_count ]['stats']['total_spent']     = $customer_obj->purchase_value;
908
+				$customers['donors'][$customer_count]['stats']['total_donations'] = $customer_obj->purchase_count;
909
+				$customers['donors'][$customer_count]['stats']['total_spent']     = $customer_obj->purchase_value;
910 910
 
911
-				$customer_count ++;
911
+				$customer_count++;
912 912
 
913 913
 			}
914 914
 
915
-		} elseif ( $customer ) {
915
+		} elseif ($customer) {
916 916
 
917
-			$error['error'] = sprintf( __( 'Donor %s not found!', 'give' ), $customer );
917
+			$error['error'] = sprintf(__('Donor %s not found!', 'give'), $customer);
918 918
 
919 919
 			return $error;
920 920
 
921 921
 		} else {
922 922
 
923
-			$error['error'] = __( 'No donors found!', 'give' );
923
+			$error['error'] = __('No donors found!', 'give');
924 924
 
925 925
 			return $error;
926 926
 
@@ -939,36 +939,36 @@  discard block
 block discarded – undo
939 939
 	 *
940 940
 	 * @return array $customers Multidimensional array of the forms
941 941
 	 */
942
-	public function get_forms( $form = null ) {
942
+	public function get_forms($form = null) {
943 943
 
944 944
 		$forms = array();
945 945
 		$error = array();
946 946
 
947
-		if ( $form == null ) {
947
+		if ($form == null) {
948 948
 			$forms['forms'] = array();
949 949
 
950
-			$form_list = get_posts( array(
950
+			$form_list = get_posts(array(
951 951
 				'post_type'        => 'give_forms',
952 952
 				'posts_per_page'   => $this->per_page(),
953 953
 				'suppress_filters' => true,
954 954
 				'paged'            => $this->get_paged()
955
-			) );
955
+			));
956 956
 
957
-			if ( $form_list ) {
957
+			if ($form_list) {
958 958
 				$i = 0;
959
-				foreach ( $form_list as $form_info ) {
960
-					$forms['forms'][ $i ] = $this->get_form_data( $form_info );
961
-					$i ++;
959
+				foreach ($form_list as $form_info) {
960
+					$forms['forms'][$i] = $this->get_form_data($form_info);
961
+					$i++;
962 962
 				}
963 963
 			}
964 964
 		} else {
965
-			if ( get_post_type( $form ) == 'give_forms' ) {
966
-				$form_info = get_post( $form );
965
+			if (get_post_type($form) == 'give_forms') {
966
+				$form_info = get_post($form);
967 967
 
968
-				$forms['forms'][0] = $this->get_form_data( $form_info );
968
+				$forms['forms'][0] = $this->get_form_data($form_info);
969 969
 
970 970
 			} else {
971
-				$error['error'] = sprintf( __( 'Form %s not found!', 'give' ), $form );
971
+				$error['error'] = sprintf(__('Form %s not found!', 'give'), $form);
972 972
 
973 973
 				return $error;
974 974
 			}
@@ -986,7 +986,7 @@  discard block
 block discarded – undo
986 986
 	 *
987 987
 	 * @return array                Array of post data to return back in the API
988 988
 	 */
989
-	private function get_form_data( $form_info ) {
989
+	private function get_form_data($form_info) {
990 990
 
991 991
 		$form = array();
992 992
 
@@ -996,45 +996,45 @@  discard block
 block discarded – undo
996 996
 		$form['info']['create_date']   = $form_info->post_date;
997 997
 		$form['info']['modified_date'] = $form_info->post_modified;
998 998
 		$form['info']['status']        = $form_info->post_status;
999
-		$form['info']['link']          = html_entity_decode( $form_info->guid );
1000
-		$form['info']['content']       = get_post_meta( $form_info->ID, '_give_form_content', true );
1001
-		$form['info']['thumbnail']     = wp_get_attachment_url( get_post_thumbnail_id( $form_info->ID ) );
999
+		$form['info']['link']          = html_entity_decode($form_info->guid);
1000
+		$form['info']['content']       = get_post_meta($form_info->ID, '_give_form_content', true);
1001
+		$form['info']['thumbnail']     = wp_get_attachment_url(get_post_thumbnail_id($form_info->ID));
1002 1002
 
1003
-		if ( give_get_option( 'enable_categories' ) == 'on' ) {
1004
-			$form['info']['category'] = get_the_terms( $form_info, 'give_forms_category' );
1005
-			$form['info']['tags']     = get_the_terms( $form_info, 'give_forms_tag' );
1003
+		if (give_get_option('enable_categories') == 'on') {
1004
+			$form['info']['category'] = get_the_terms($form_info, 'give_forms_category');
1005
+			$form['info']['tags']     = get_the_terms($form_info, 'give_forms_tag');
1006 1006
 		}
1007
-		if ( give_get_option( 'enable_tags' ) == 'on' ) {
1008
-			$form['info']['tags'] = get_the_terms( $form_info, 'give_forms_tag' );
1007
+		if (give_get_option('enable_tags') == 'on') {
1008
+			$form['info']['tags'] = get_the_terms($form_info, 'give_forms_tag');
1009 1009
 		}
1010 1010
 
1011
-		if ( user_can( $this->user_id, 'view_give_reports' ) || $this->override ) {
1012
-			$form['stats']['total']['donations']           = give_get_form_sales_stats( $form_info->ID );
1013
-			$form['stats']['total']['earnings']            = give_get_form_earnings_stats( $form_info->ID );
1014
-			$form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales( $form_info->ID );
1015
-			$form['stats']['monthly_average']['earnings']  = give_get_average_monthly_form_earnings( $form_info->ID );
1011
+		if (user_can($this->user_id, 'view_give_reports') || $this->override) {
1012
+			$form['stats']['total']['donations']           = give_get_form_sales_stats($form_info->ID);
1013
+			$form['stats']['total']['earnings']            = give_get_form_earnings_stats($form_info->ID);
1014
+			$form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales($form_info->ID);
1015
+			$form['stats']['monthly_average']['earnings']  = give_get_average_monthly_form_earnings($form_info->ID);
1016 1016
 		}
1017 1017
 
1018 1018
 		$counter = 0;
1019
-		if ( give_has_variable_prices( $form_info->ID ) ) {
1020
-			foreach ( give_get_variable_prices( $form_info->ID ) as $price ) {
1021
-				$counter ++;
1019
+		if (give_has_variable_prices($form_info->ID)) {
1020
+			foreach (give_get_variable_prices($form_info->ID) as $price) {
1021
+				$counter++;
1022 1022
 				//muli-level item
1023
-				$level = isset( $price['_give_text'] ) ? $price['_give_text'] : 'level-' . $counter;
1024
-				$form['pricing'][ sanitize_key( $level ) ] = $price['_give_amount'];
1023
+				$level = isset($price['_give_text']) ? $price['_give_text'] : 'level-'.$counter;
1024
+				$form['pricing'][sanitize_key($level)] = $price['_give_amount'];
1025 1025
 
1026 1026
 			}
1027 1027
 		} else {
1028
-			$form['pricing']['amount'] = give_get_form_price( $form_info->ID );
1028
+			$form['pricing']['amount'] = give_get_form_price($form_info->ID);
1029 1029
 		}
1030 1030
 
1031
-		if ( user_can( $this->user_id, 'view_give_sensitive_data' ) || $this->override ) {
1031
+		if (user_can($this->user_id, 'view_give_sensitive_data') || $this->override) {
1032 1032
 
1033 1033
 			//Sensitive data here
1034 1034
 
1035 1035
 		}
1036 1036
 
1037
-		return apply_filters( 'give_api_forms_form', $form );
1037
+		return apply_filters('give_api_forms_form', $form);
1038 1038
 		die();
1039 1039
 	}
1040 1040
 
@@ -1049,7 +1049,7 @@  discard block
 block discarded – undo
1049 1049
 	 *
1050 1050
 	 * @return array
1051 1051
 	 */
1052
-	public function get_stats( $args = array() ) {
1052
+	public function get_stats($args = array()) {
1053 1053
 		$defaults = array(
1054 1054
 			'type'      => null,
1055 1055
 			'form'      => null,
@@ -1058,9 +1058,9 @@  discard block
 block discarded – undo
1058 1058
 			'enddate'   => null
1059 1059
 		);
1060 1060
 
1061
-		$args = wp_parse_args( $args, $defaults );
1061
+		$args = wp_parse_args($args, $defaults);
1062 1062
 
1063
-		$dates = $this->get_dates( $args );
1063
+		$dates = $this->get_dates($args);
1064 1064
 
1065 1065
 		$stats     = array();
1066 1066
 		$earnings  = array(
@@ -1071,41 +1071,41 @@  discard block
 block discarded – undo
1071 1071
 		);
1072 1072
 		$error     = array();
1073 1073
 
1074
-		if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) {
1074
+		if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) {
1075 1075
 			return $stats;
1076 1076
 		}
1077 1077
 
1078
-		if ( $args['type'] == 'donations' ) {
1078
+		if ($args['type'] == 'donations') {
1079 1079
 
1080
-			if ( $args['form'] == null ) {
1081
-				if ( $args['date'] == null ) {
1080
+			if ($args['form'] == null) {
1081
+				if ($args['date'] == null) {
1082 1082
 					$sales = $this->get_default_sales_stats();
1083
-				} elseif ( $args['date'] === 'range' ) {
1083
+				} elseif ($args['date'] === 'range') {
1084 1084
 					// Return sales for a date range
1085 1085
 
1086 1086
 					// Ensure the end date is later than the start date
1087
-					if ( $args['enddate'] < $args['startdate'] ) {
1088
-						$error['error'] = __( 'The end date must be later than the start date!', 'give' );
1087
+					if ($args['enddate'] < $args['startdate']) {
1088
+						$error['error'] = __('The end date must be later than the start date!', 'give');
1089 1089
 					}
1090 1090
 
1091 1091
 					// Ensure both the start and end date are specified
1092
-					if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) {
1093
-						$error['error'] = __( 'Invalid or no date range specified!', 'give' );
1092
+					if (empty($args['startdate']) || empty($args['enddate'])) {
1093
+						$error['error'] = __('Invalid or no date range specified!', 'give');
1094 1094
 					}
1095 1095
 
1096 1096
 					$total = 0;
1097 1097
 
1098 1098
 					// Loop through the years
1099 1099
 					$y = $dates['year'];
1100
-					while ( $y <= $dates['year_end'] ) :
1100
+					while ($y <= $dates['year_end']) :
1101 1101
 
1102
-						if ( $dates['year'] == $dates['year_end'] ) {
1102
+						if ($dates['year'] == $dates['year_end']) {
1103 1103
 							$month_start = $dates['m_start'];
1104 1104
 							$month_end   = $dates['m_end'];
1105
-						} elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) {
1105
+						} elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) {
1106 1106
 							$month_start = $dates['m_start'];
1107 1107
 							$month_end   = 12;
1108
-						} elseif ( $y == $dates['year_end'] ) {
1108
+						} elseif ($y == $dates['year_end']) {
1109 1109
 							$month_start = 1;
1110 1110
 							$month_end   = $dates['m_end'];
1111 1111
 						} else {
@@ -1114,109 +1114,109 @@  discard block
 block discarded – undo
1114 1114
 						}
1115 1115
 
1116 1116
 						$i = $month_start;
1117
-						while ( $i <= $month_end ) :
1117
+						while ($i <= $month_end) :
1118 1118
 
1119
-							if ( $i == $dates['m_start'] ) {
1119
+							if ($i == $dates['m_start']) {
1120 1120
 								$d = $dates['day_start'];
1121 1121
 							} else {
1122 1122
 								$d = 1;
1123 1123
 							}
1124 1124
 
1125
-							if ( $i == $dates['m_end'] ) {
1125
+							if ($i == $dates['m_end']) {
1126 1126
 								$num_of_days = $dates['day_end'];
1127 1127
 							} else {
1128
-								$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
1128
+								$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
1129 1129
 							}
1130 1130
 
1131
-							while ( $d <= $num_of_days ) :
1132
-								$sale_count = give_get_sales_by_date( $d, $i, $y );
1133
-								$date_key   = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) );
1134
-								if ( ! isset( $sales['sales'][ $date_key ] ) ) {
1135
-									$sales['sales'][ $date_key ] = 0;
1131
+							while ($d <= $num_of_days) :
1132
+								$sale_count = give_get_sales_by_date($d, $i, $y);
1133
+								$date_key   = date('Ymd', strtotime($y.'/'.$i.'/'.$d));
1134
+								if ( ! isset($sales['sales'][$date_key])) {
1135
+									$sales['sales'][$date_key] = 0;
1136 1136
 								}
1137
-								$sales['sales'][ $date_key ] += $sale_count;
1137
+								$sales['sales'][$date_key] += $sale_count;
1138 1138
 								$total += $sale_count;
1139
-								$d ++;
1139
+								$d++;
1140 1140
 							endwhile;
1141
-							$i ++;
1141
+							$i++;
1142 1142
 						endwhile;
1143 1143
 
1144
-						$y ++;
1144
+						$y++;
1145 1145
 					endwhile;
1146 1146
 
1147 1147
 					$sales['totals'] = $total;
1148 1148
 				} else {
1149
-					if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) {
1149
+					if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') {
1150 1150
 						$sales_count = 0;
1151 1151
 
1152 1152
 						// Loop through the months
1153 1153
 						$month = $dates['m_start'];
1154 1154
 
1155
-						while ( $month <= $dates['m_end'] ) :
1156
-							$sales_count += give_get_sales_by_date( null, $month, $dates['year'] );
1157
-							$month ++;
1155
+						while ($month <= $dates['m_end']) :
1156
+							$sales_count += give_get_sales_by_date(null, $month, $dates['year']);
1157
+							$month++;
1158 1158
 						endwhile;
1159 1159
 
1160
-						$sales['donations'][ $args['date'] ] = $sales_count;
1160
+						$sales['donations'][$args['date']] = $sales_count;
1161 1161
 					} else {
1162
-						$sales['donations'][ $args['date'] ] = give_get_sales_by_date( $dates['day'], $dates['m_start'], $dates['year'] );
1162
+						$sales['donations'][$args['date']] = give_get_sales_by_date($dates['day'], $dates['m_start'], $dates['year']);
1163 1163
 					}
1164 1164
 				}
1165
-			} elseif ( $args['form'] == 'all' ) {
1166
-				$forms = get_posts( array( 'post_type' => 'give_forms', 'nopaging' => true ) );
1165
+			} elseif ($args['form'] == 'all') {
1166
+				$forms = get_posts(array('post_type' => 'give_forms', 'nopaging' => true));
1167 1167
 				$i     = 0;
1168
-				foreach ( $forms as $form_info ) {
1169
-					$sales['donations'][ $i ] = array( $form_info->post_name => give_get_form_sales_stats( $form_info->ID ) );
1170
-					$i ++;
1168
+				foreach ($forms as $form_info) {
1169
+					$sales['donations'][$i] = array($form_info->post_name => give_get_form_sales_stats($form_info->ID));
1170
+					$i++;
1171 1171
 				}
1172 1172
 			} else {
1173
-				if ( get_post_type( $args['form'] ) == 'give_forms' ) {
1174
-					$form_info             = get_post( $args['form'] );
1175
-					$sales['donations'][0] = array( $form_info->post_name => give_get_form_sales_stats( $args['form'] ) );
1173
+				if (get_post_type($args['form']) == 'give_forms') {
1174
+					$form_info             = get_post($args['form']);
1175
+					$sales['donations'][0] = array($form_info->post_name => give_get_form_sales_stats($args['form']));
1176 1176
 				} else {
1177
-					$error['error'] = sprintf( __( 'Product %s not found!', 'give' ), $args['form'] );
1177
+					$error['error'] = sprintf(__('Product %s not found!', 'give'), $args['form']);
1178 1178
 				}
1179 1179
 			}
1180 1180
 
1181
-			if ( ! empty( $error ) ) {
1181
+			if ( ! empty($error)) {
1182 1182
 				return $error;
1183 1183
 			}
1184 1184
 
1185 1185
 			return $sales;
1186 1186
 
1187
-		} elseif ( $args['type'] == 'earnings' ) {
1188
-			if ( $args['form'] == null ) {
1189
-				if ( $args['date'] == null ) {
1187
+		} elseif ($args['type'] == 'earnings') {
1188
+			if ($args['form'] == null) {
1189
+				if ($args['date'] == null) {
1190 1190
 					$earnings = $this->get_default_earnings_stats();
1191
-				} elseif ( $args['date'] === 'range' ) {
1191
+				} elseif ($args['date'] === 'range') {
1192 1192
 					// Return sales for a date range
1193 1193
 
1194 1194
 					// Ensure the end date is later than the start date
1195
-					if ( $args['enddate'] < $args['startdate'] ) {
1196
-						$error['error'] = __( 'The end date must be later than the start date!', 'give' );
1195
+					if ($args['enddate'] < $args['startdate']) {
1196
+						$error['error'] = __('The end date must be later than the start date!', 'give');
1197 1197
 					}
1198 1198
 
1199 1199
 					// Ensure both the start and end date are specified
1200
-					if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) {
1201
-						$error['error'] = __( 'Invalid or no date range specified!', 'give' );
1200
+					if (empty($args['startdate']) || empty($args['enddate'])) {
1201
+						$error['error'] = __('Invalid or no date range specified!', 'give');
1202 1202
 					}
1203 1203
 
1204 1204
 					$total = (float) 0.00;
1205 1205
 
1206 1206
 					// Loop through the years
1207 1207
 					$y = $dates['year'];
1208
-					if ( ! isset( $earnings['earnings'] ) ) {
1208
+					if ( ! isset($earnings['earnings'])) {
1209 1209
 						$earnings['earnings'] = array();
1210 1210
 					}
1211
-					while ( $y <= $dates['year_end'] ) :
1211
+					while ($y <= $dates['year_end']) :
1212 1212
 
1213
-						if ( $dates['year'] == $dates['year_end'] ) {
1213
+						if ($dates['year'] == $dates['year_end']) {
1214 1214
 							$month_start = $dates['m_start'];
1215 1215
 							$month_end   = $dates['m_end'];
1216
-						} elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) {
1216
+						} elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) {
1217 1217
 							$month_start = $dates['m_start'];
1218 1218
 							$month_end   = 12;
1219
-						} elseif ( $y == $dates['year_end'] ) {
1219
+						} elseif ($y == $dates['year_end']) {
1220 1220
 							$month_start = 1;
1221 1221
 							$month_end   = $dates['m_end'];
1222 1222
 						} else {
@@ -1225,88 +1225,88 @@  discard block
 block discarded – undo
1225 1225
 						}
1226 1226
 
1227 1227
 						$i = $month_start;
1228
-						while ( $i <= $month_end ) :
1228
+						while ($i <= $month_end) :
1229 1229
 
1230
-							if ( $i == $dates['m_start'] ) {
1230
+							if ($i == $dates['m_start']) {
1231 1231
 								$d = $dates['day_start'];
1232 1232
 							} else {
1233 1233
 								$d = 1;
1234 1234
 							}
1235 1235
 
1236
-							if ( $i == $dates['m_end'] ) {
1236
+							if ($i == $dates['m_end']) {
1237 1237
 								$num_of_days = $dates['day_end'];
1238 1238
 							} else {
1239
-								$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
1239
+								$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
1240 1240
 							}
1241 1241
 
1242
-							while ( $d <= $num_of_days ) :
1243
-								$earnings_stat = give_get_earnings_by_date( $d, $i, $y );
1244
-								$date_key      = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) );
1245
-								if ( ! isset( $earnings['earnings'][ $date_key ] ) ) {
1246
-									$earnings['earnings'][ $date_key ] = 0;
1242
+							while ($d <= $num_of_days) :
1243
+								$earnings_stat = give_get_earnings_by_date($d, $i, $y);
1244
+								$date_key      = date('Ymd', strtotime($y.'/'.$i.'/'.$d));
1245
+								if ( ! isset($earnings['earnings'][$date_key])) {
1246
+									$earnings['earnings'][$date_key] = 0;
1247 1247
 								}
1248
-								$earnings['earnings'][ $date_key ] += $earnings_stat;
1248
+								$earnings['earnings'][$date_key] += $earnings_stat;
1249 1249
 								$total += $earnings_stat;
1250
-								$d ++;
1250
+								$d++;
1251 1251
 							endwhile;
1252 1252
 
1253
-							$i ++;
1253
+							$i++;
1254 1254
 						endwhile;
1255 1255
 
1256
-						$y ++;
1256
+						$y++;
1257 1257
 					endwhile;
1258 1258
 
1259 1259
 					$earnings['totals'] = $total;
1260 1260
 				} else {
1261
-					if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) {
1261
+					if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') {
1262 1262
 						$earnings_count = (float) 0.00;
1263 1263
 
1264 1264
 						// Loop through the months
1265 1265
 						$month = $dates['m_start'];
1266 1266
 
1267
-						while ( $month <= $dates['m_end'] ) :
1268
-							$earnings_count += give_get_earnings_by_date( null, $month, $dates['year'] );
1269
-							$month ++;
1267
+						while ($month <= $dates['m_end']) :
1268
+							$earnings_count += give_get_earnings_by_date(null, $month, $dates['year']);
1269
+							$month++;
1270 1270
 						endwhile;
1271 1271
 
1272
-						$earnings['earnings'][ $args['date'] ] = $earnings_count;
1272
+						$earnings['earnings'][$args['date']] = $earnings_count;
1273 1273
 					} else {
1274
-						$earnings['earnings'][ $args['date'] ] = give_get_earnings_by_date( $dates['day'], $dates['m_start'], $dates['year'] );
1274
+						$earnings['earnings'][$args['date']] = give_get_earnings_by_date($dates['day'], $dates['m_start'], $dates['year']);
1275 1275
 					}
1276 1276
 				}
1277
-			} elseif ( $args['form'] == 'all' ) {
1278
-				$forms = get_posts( array( 'post_type' => 'give_forms', 'nopaging' => true ) );
1277
+			} elseif ($args['form'] == 'all') {
1278
+				$forms = get_posts(array('post_type' => 'give_forms', 'nopaging' => true));
1279 1279
 
1280 1280
 				$i = 0;
1281
-				foreach ( $forms as $form_info ) {
1282
-					$earnings['earnings'][ $i ] = array( $form_info->post_name => give_get_form_earnings_stats( $form_info->ID ) );
1283
-					$i ++;
1281
+				foreach ($forms as $form_info) {
1282
+					$earnings['earnings'][$i] = array($form_info->post_name => give_get_form_earnings_stats($form_info->ID));
1283
+					$i++;
1284 1284
 				}
1285 1285
 			} else {
1286
-				if ( get_post_type( $args['form'] ) == 'give_forms' ) {
1287
-					$form_info               = get_post( $args['form'] );
1288
-					$earnings['earnings'][0] = array( $form_info->post_name => give_get_form_earnings_stats( $args['form'] ) );
1286
+				if (get_post_type($args['form']) == 'give_forms') {
1287
+					$form_info               = get_post($args['form']);
1288
+					$earnings['earnings'][0] = array($form_info->post_name => give_get_form_earnings_stats($args['form']));
1289 1289
 				} else {
1290
-					$error['error'] = sprintf( __( 'Form %s not found!', 'give' ), $args['form'] );
1290
+					$error['error'] = sprintf(__('Form %s not found!', 'give'), $args['form']);
1291 1291
 				}
1292 1292
 			}
1293 1293
 
1294
-			if ( ! empty( $error ) ) {
1294
+			if ( ! empty($error)) {
1295 1295
 				return $error;
1296 1296
 			}
1297 1297
 
1298 1298
 			return $earnings;
1299
-		} elseif ( $args['type'] == 'donors' ) {
1299
+		} elseif ($args['type'] == 'donors') {
1300 1300
 			$customers                          = new Give_DB_Customers();
1301 1301
 			$stats['donations']['total_donors'] = $customers->count();
1302 1302
 
1303 1303
 			return $stats;
1304 1304
 
1305
-		} elseif ( empty( $args['type'] ) ) {
1306
-			$stats = array_merge( $stats, $this->get_default_sales_stats() );
1307
-			$stats = array_merge( $stats, $this->get_default_earnings_stats() );
1305
+		} elseif (empty($args['type'])) {
1306
+			$stats = array_merge($stats, $this->get_default_sales_stats());
1307
+			$stats = array_merge($stats, $this->get_default_earnings_stats());
1308 1308
 
1309
-			return array( 'stats' => $stats );
1309
+			return array('stats' => $stats);
1310 1310
 		}
1311 1311
 	}
1312 1312
 
@@ -1322,71 +1322,71 @@  discard block
 block discarded – undo
1322 1322
 
1323 1323
 		$sales = array();
1324 1324
 
1325
-		if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) {
1325
+		if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) {
1326 1326
 			return $sales;
1327 1327
 		}
1328 1328
 
1329
-		if ( isset( $wp_query->query_vars['id'] ) ) {
1329
+		if (isset($wp_query->query_vars['id'])) {
1330 1330
 			$query   = array();
1331
-			$query[] = give_get_payment_by( 'id', $wp_query->query_vars['id'] );
1332
-		} elseif ( isset( $wp_query->query_vars['purchasekey'] ) ) {
1331
+			$query[] = give_get_payment_by('id', $wp_query->query_vars['id']);
1332
+		} elseif (isset($wp_query->query_vars['purchasekey'])) {
1333 1333
 			$query   = array();
1334
-			$query[] = give_get_payment_by( 'key', $wp_query->query_vars['purchasekey'] );
1335
-		} elseif ( isset( $wp_query->query_vars['email'] ) ) {
1336
-			$query = give_get_payments( array(
1334
+			$query[] = give_get_payment_by('key', $wp_query->query_vars['purchasekey']);
1335
+		} elseif (isset($wp_query->query_vars['email'])) {
1336
+			$query = give_get_payments(array(
1337 1337
 				'meta_key'   => '_give_payment_user_email',
1338 1338
 				'meta_value' => $wp_query->query_vars['email'],
1339 1339
 				'number'     => $this->per_page(),
1340 1340
 				'page'       => $this->get_paged(),
1341 1341
 				'status'     => 'publish'
1342
-			) );
1342
+			));
1343 1343
 		} else {
1344
-			$query = give_get_payments( array(
1344
+			$query = give_get_payments(array(
1345 1345
 				'number' => $this->per_page(),
1346 1346
 				'page'   => $this->get_paged(),
1347 1347
 				'status' => 'publish'
1348
-			) );
1348
+			));
1349 1349
 		}
1350 1350
 
1351
-		if ( $query ) {
1351
+		if ($query) {
1352 1352
 			$i = 0;
1353
-			foreach ( $query as $payment ) {
1354
-				$payment_meta = give_get_payment_meta( $payment->ID );
1355
-				$user_info    = give_get_payment_meta_user_info( $payment->ID );
1356
-				$first_name   = isset( $user_info['first_name'] ) ? $user_info['first_name'] : '';
1357
-				$last_name    = isset( $user_info['last_name'] ) ? $user_info['last_name'] : '';
1358
-
1359
-				$sales['donations'][ $i ]['ID']             = give_get_payment_number( $payment->ID );
1360
-				$sales['donations'][ $i ]['transaction_id'] = give_get_payment_transaction_id( $payment->ID );
1361
-				$sales['donations'][ $i ]['key']            = give_get_payment_key( $payment->ID );
1362
-				$sales['donations'][ $i ]['total']          = give_get_payment_amount( $payment->ID );
1363
-				$sales['donations'][ $i ]['gateway']        = give_get_payment_gateway( $payment->ID );
1364
-				$sales['donations'][ $i ]['name']           = $first_name . ' ' . $last_name;
1365
-				$sales['donations'][ $i ]['fname']          = $first_name;
1366
-				$sales['donations'][ $i ]['lname']          = $last_name;
1367
-				$sales['donations'][ $i ]['email']          = give_get_payment_user_email( $payment->ID );
1368
-				$sales['donations'][ $i ]['date']           = $payment->post_date;
1369
-
1370
-				$form_id  = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : $payment_meta;
1371
-				$price    = isset( $payment_meta['form_id'] ) ? give_get_form_price( $payment_meta['form_id'] ) : false;
1372
-				$price_id = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null;
1373
-
1374
-				$sales['donations'][ $i ]['form']['id']    = $form_id;
1375
-				$sales['donations'][ $i ]['form']['name']  = get_the_title( $payment_meta['form_id'] );
1376
-				$sales['donations'][ $i ]['form']['price'] = $price;
1377
-
1378
-				if ( give_has_variable_prices( $form_id ) ) {
1379
-					if ( isset( $payment_meta['price_id'] ) ) {
1380
-						$price_name                                     = give_get_price_option_name( $form_id, $payment_meta['price_id'], $payment->ID );
1381
-						$sales['donations'][ $i ]['form']['price_name'] = $price_name;
1382
-						$sales['donations'][ $i ]['form']['price_id']   = $price_id;
1383
-						$sales['donations'][ $i ]['form']['price']      = give_get_price_option_amount( $form_id, $price_id );
1353
+			foreach ($query as $payment) {
1354
+				$payment_meta = give_get_payment_meta($payment->ID);
1355
+				$user_info    = give_get_payment_meta_user_info($payment->ID);
1356
+				$first_name   = isset($user_info['first_name']) ? $user_info['first_name'] : '';
1357
+				$last_name    = isset($user_info['last_name']) ? $user_info['last_name'] : '';
1358
+
1359
+				$sales['donations'][$i]['ID']             = give_get_payment_number($payment->ID);
1360
+				$sales['donations'][$i]['transaction_id'] = give_get_payment_transaction_id($payment->ID);
1361
+				$sales['donations'][$i]['key']            = give_get_payment_key($payment->ID);
1362
+				$sales['donations'][$i]['total']          = give_get_payment_amount($payment->ID);
1363
+				$sales['donations'][$i]['gateway']        = give_get_payment_gateway($payment->ID);
1364
+				$sales['donations'][$i]['name']           = $first_name.' '.$last_name;
1365
+				$sales['donations'][$i]['fname']          = $first_name;
1366
+				$sales['donations'][$i]['lname']          = $last_name;
1367
+				$sales['donations'][$i]['email']          = give_get_payment_user_email($payment->ID);
1368
+				$sales['donations'][$i]['date']           = $payment->post_date;
1369
+
1370
+				$form_id  = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : $payment_meta;
1371
+				$price    = isset($payment_meta['form_id']) ? give_get_form_price($payment_meta['form_id']) : false;
1372
+				$price_id = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null;
1373
+
1374
+				$sales['donations'][$i]['form']['id']    = $form_id;
1375
+				$sales['donations'][$i]['form']['name']  = get_the_title($payment_meta['form_id']);
1376
+				$sales['donations'][$i]['form']['price'] = $price;
1377
+
1378
+				if (give_has_variable_prices($form_id)) {
1379
+					if (isset($payment_meta['price_id'])) {
1380
+						$price_name                                     = give_get_price_option_name($form_id, $payment_meta['price_id'], $payment->ID);
1381
+						$sales['donations'][$i]['form']['price_name'] = $price_name;
1382
+						$sales['donations'][$i]['form']['price_id']   = $price_id;
1383
+						$sales['donations'][$i]['form']['price']      = give_get_price_option_amount($form_id, $price_id);
1384 1384
 
1385 1385
 					}
1386 1386
 				}
1387 1387
 
1388 1388
 				//Add custom meta to API
1389
-				foreach ( $payment_meta as $meta_key => $meta_value ) {
1389
+				foreach ($payment_meta as $meta_key => $meta_value) {
1390 1390
 
1391 1391
 					$exceptions = array(
1392 1392
 						'form_title',
@@ -1399,19 +1399,19 @@  discard block
 block discarded – undo
1399 1399
 					);
1400 1400
 
1401 1401
 					//Don't clutter up results with dupes
1402
-					if ( in_array( $meta_key, $exceptions ) ) {
1402
+					if (in_array($meta_key, $exceptions)) {
1403 1403
 						continue;
1404 1404
 					}
1405 1405
 
1406
-					$sales['donations'][ $i ]['payment_meta'][ $meta_key ] = $meta_value;
1406
+					$sales['donations'][$i]['payment_meta'][$meta_key] = $meta_value;
1407 1407
 
1408 1408
 				}
1409 1409
 
1410
-				$i ++;
1410
+				$i++;
1411 1411
 			}
1412 1412
 		}
1413 1413
 
1414
-		return apply_filters( 'give_api_donations_endpoint', $sales );
1414
+		return apply_filters('give_api_donations_endpoint', $sales);
1415 1415
 	}
1416 1416
 
1417 1417
 	/**
@@ -1426,9 +1426,9 @@  discard block
 block discarded – undo
1426 1426
 	public function get_output_format() {
1427 1427
 		global $wp_query;
1428 1428
 
1429
-		$format = isset( $wp_query->query_vars['format'] ) ? $wp_query->query_vars['format'] : 'json';
1429
+		$format = isset($wp_query->query_vars['format']) ? $wp_query->query_vars['format'] : 'json';
1430 1430
 
1431
-		return apply_filters( 'give_api_output_format', $format );
1431
+		return apply_filters('give_api_output_format', $format);
1432 1432
 	}
1433 1433
 
1434 1434
 
@@ -1444,8 +1444,8 @@  discard block
 block discarded – undo
1444 1444
 	 *
1445 1445
 	 * @return void
1446 1446
 	 */
1447
-	private function log_request( $data = array() ) {
1448
-		if ( ! $this->log_requests ) {
1447
+	private function log_request($data = array()) {
1448
+		if ( ! $this->log_requests) {
1449 1449
 			return;
1450 1450
 		}
1451 1451
 
@@ -1453,36 +1453,36 @@  discard block
 block discarded – undo
1453 1453
 
1454 1454
 		$query = array(
1455 1455
 			'give-api'    => $wp_query->query_vars['give-api'],
1456
-			'key'         => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null,
1457
-			'token'       => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null,
1458
-			'query'       => isset( $wp_query->query_vars['query'] ) ? $wp_query->query_vars['query'] : null,
1459
-			'type'        => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null,
1460
-			'form'        => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null,
1461
-			'customer'    => isset( $wp_query->query_vars['customer'] ) ? $wp_query->query_vars['customer'] : null,
1462
-			'date'        => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null,
1463
-			'startdate'   => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null,
1464
-			'enddate'     => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null,
1465
-			'id'          => isset( $wp_query->query_vars['id'] ) ? $wp_query->query_vars['id'] : null,
1466
-			'purchasekey' => isset( $wp_query->query_vars['purchasekey'] ) ? $wp_query->query_vars['purchasekey'] : null,
1467
-			'email'       => isset( $wp_query->query_vars['email'] ) ? $wp_query->query_vars['email'] : null,
1456
+			'key'         => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null,
1457
+			'token'       => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null,
1458
+			'query'       => isset($wp_query->query_vars['query']) ? $wp_query->query_vars['query'] : null,
1459
+			'type'        => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null,
1460
+			'form'        => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null,
1461
+			'customer'    => isset($wp_query->query_vars['customer']) ? $wp_query->query_vars['customer'] : null,
1462
+			'date'        => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null,
1463
+			'startdate'   => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null,
1464
+			'enddate'     => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null,
1465
+			'id'          => isset($wp_query->query_vars['id']) ? $wp_query->query_vars['id'] : null,
1466
+			'purchasekey' => isset($wp_query->query_vars['purchasekey']) ? $wp_query->query_vars['purchasekey'] : null,
1467
+			'email'       => isset($wp_query->query_vars['email']) ? $wp_query->query_vars['email'] : null,
1468 1468
 		);
1469 1469
 
1470 1470
 		$log_data = array(
1471 1471
 			'log_type'     => 'api_request',
1472
-			'post_excerpt' => http_build_query( $query ),
1473
-			'post_content' => ! empty( $data['error'] ) ? $data['error'] : '',
1472
+			'post_excerpt' => http_build_query($query),
1473
+			'post_content' => ! empty($data['error']) ? $data['error'] : '',
1474 1474
 		);
1475 1475
 
1476 1476
 		$log_meta = array(
1477 1477
 			'request_ip' => give_get_ip(),
1478 1478
 			'user'       => $this->user_id,
1479
-			'key'        => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null,
1480
-			'token'      => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null,
1479
+			'key'        => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null,
1480
+			'token'      => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null,
1481 1481
 			'time'       => $data['request_speed'],
1482 1482
 			'version'    => $this->get_queried_version()
1483 1483
 		);
1484 1484
 
1485
-		$give_logs->insert_log( $log_data, $log_meta );
1485
+		$give_logs->insert_log($log_data, $log_meta);
1486 1486
 	}
1487 1487
 
1488 1488
 
@@ -1506,32 +1506,32 @@  discard block
 block discarded – undo
1506 1506
 	 *
1507 1507
 	 * @param int $status_code
1508 1508
 	 */
1509
-	public function output( $status_code = 200 ) {
1509
+	public function output($status_code = 200) {
1510 1510
 		global $wp_query;
1511 1511
 
1512 1512
 		$format = $this->get_output_format();
1513 1513
 
1514
-		status_header( $status_code );
1514
+		status_header($status_code);
1515 1515
 
1516
-		do_action( 'give_api_output_before', $this->data, $this, $format );
1516
+		do_action('give_api_output_before', $this->data, $this, $format);
1517 1517
 
1518
-		switch ( $format ) :
1518
+		switch ($format) :
1519 1519
 
1520 1520
 			case 'xml' :
1521 1521
 
1522
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/array2xml.php';
1523
-				$xml = Array2XML::createXML( 'give', $this->data );
1522
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/array2xml.php';
1523
+				$xml = Array2XML::createXML('give', $this->data);
1524 1524
 				echo $xml->saveXML();
1525 1525
 
1526 1526
 				break;
1527 1527
 
1528 1528
 			case 'json' :
1529 1529
 
1530
-				header( 'Content-Type: application/json' );
1531
-				if ( ! empty( $this->pretty_print ) ) {
1532
-					echo json_encode( $this->data, $this->pretty_print );
1530
+				header('Content-Type: application/json');
1531
+				if ( ! empty($this->pretty_print)) {
1532
+					echo json_encode($this->data, $this->pretty_print);
1533 1533
 				} else {
1534
-					echo json_encode( $this->data );
1534
+					echo json_encode($this->data);
1535 1535
 				}
1536 1536
 
1537 1537
 				break;
@@ -1540,13 +1540,13 @@  discard block
 block discarded – undo
1540 1540
 			default :
1541 1541
 
1542 1542
 				// Allow other formats to be added via extensions
1543
-				do_action( 'give_api_output_' . $format, $this->data, $this );
1543
+				do_action('give_api_output_'.$format, $this->data, $this);
1544 1544
 
1545 1545
 				break;
1546 1546
 
1547 1547
 		endswitch;
1548 1548
 
1549
-		do_action( 'give_api_output_after', $this->data, $this, $format );
1549
+		do_action('give_api_output_after', $this->data, $this, $format);
1550 1550
 
1551 1551
 		give_die();
1552 1552
 	}
@@ -1563,36 +1563,36 @@  discard block
 block discarded – undo
1563 1563
 	 *
1564 1564
 	 * @return void
1565 1565
 	 */
1566
-	function user_key_field( $user ) {
1567
-		if ( ( give_get_option( 'api_allow_user_keys', false ) || current_user_can( 'manage_give_settings' ) ) && current_user_can( 'edit_user', $user->ID ) ) {
1568
-			$user = get_userdata( $user->ID );
1566
+	function user_key_field($user) {
1567
+		if ((give_get_option('api_allow_user_keys', false) || current_user_can('manage_give_settings')) && current_user_can('edit_user', $user->ID)) {
1568
+			$user = get_userdata($user->ID);
1569 1569
 			?>
1570 1570
 			<table class="form-table">
1571 1571
 				<tbody>
1572 1572
 				<tr>
1573 1573
 					<th>
1574
-						<?php _e( 'Give API Keys', 'give' ); ?>
1574
+						<?php _e('Give API Keys', 'give'); ?>
1575 1575
 					</th>
1576 1576
 					<td>
1577 1577
 						<?php
1578
-						$public_key = $this->get_user_public_key( $user->ID );
1579
-						$secret_key = $this->get_user_secret_key( $user->ID );
1578
+						$public_key = $this->get_user_public_key($user->ID);
1579
+						$secret_key = $this->get_user_secret_key($user->ID);
1580 1580
 						?>
1581
-						<?php if ( empty( $user->give_user_public_key ) ) { ?>
1581
+						<?php if (empty($user->give_user_public_key)) { ?>
1582 1582
 							<input name="give_set_api_key" type="checkbox" id="give_set_api_key" value="0" />
1583
-							<span class="description"><?php _e( 'Generate API Key', 'give' ); ?></span>
1583
+							<span class="description"><?php _e('Generate API Key', 'give'); ?></span>
1584 1584
 						<?php } else { ?>
1585
-							<strong style="display:inline-block; width: 125px;"><?php _e( 'Public key:', 'give' ); ?>&nbsp;</strong>
1586
-							<input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr( $public_key ); ?>" />
1585
+							<strong style="display:inline-block; width: 125px;"><?php _e('Public key:', 'give'); ?>&nbsp;</strong>
1586
+							<input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr($public_key); ?>" />
1587 1587
 							<br />
1588
-							<strong style="display:inline-block; width: 125px;"><?php _e( 'Secret key:', 'give' ); ?>&nbsp;</strong>
1589
-							<input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr( $secret_key ); ?>" />
1588
+							<strong style="display:inline-block; width: 125px;"><?php _e('Secret key:', 'give'); ?>&nbsp;</strong>
1589
+							<input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr($secret_key); ?>" />
1590 1590
 							<br />
1591
-							<strong style="display:inline-block; width: 125px;"><?php _e( 'Token:', 'give' ); ?>&nbsp;</strong>
1592
-							<input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr( $this->get_token( $user->ID ) ); ?>" />
1591
+							<strong style="display:inline-block; width: 125px;"><?php _e('Token:', 'give'); ?>&nbsp;</strong>
1592
+							<input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr($this->get_token($user->ID)); ?>" />
1593 1593
 							<br />
1594 1594
 							<input name="give_set_api_key" type="checkbox" id="give_set_api_key" value="0" />
1595
-							<span class="description"><label for="give_set_api_key"><?php _e( 'Revoke API Keys', 'give' ); ?></label></span>
1595
+							<span class="description"><label for="give_set_api_key"><?php _e('Revoke API Keys', 'give'); ?></label></span>
1596 1596
 						<?php } ?>
1597 1597
 					</td>
1598 1598
 				</tr>
@@ -1611,49 +1611,49 @@  discard block
 block discarded – undo
1611 1611
 	 *
1612 1612
 	 * @return void
1613 1613
 	 */
1614
-	public function process_api_key( $args ) {
1614
+	public function process_api_key($args) {
1615 1615
 
1616
-		if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'give-api-nonce' ) ) {
1616
+		if ( ! wp_verify_nonce($_REQUEST['_wpnonce'], 'give-api-nonce')) {
1617 1617
 
1618
-			wp_die( __( 'Nonce verification failed', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
1618
+			wp_die(__('Nonce verification failed', 'give'), __('Error', 'give'), array('response' => 403));
1619 1619
 
1620 1620
 		}
1621 1621
 
1622
-		if ( is_numeric( $args['user_id'] ) ) {
1623
-			$user_id = isset( $args['user_id'] ) ? absint( $args['user_id'] ) : get_current_user_id();
1622
+		if (is_numeric($args['user_id'])) {
1623
+			$user_id = isset($args['user_id']) ? absint($args['user_id']) : get_current_user_id();
1624 1624
 		} else {
1625
-			$userdata = get_user_by( 'login', $args['user_id'] );
1625
+			$userdata = get_user_by('login', $args['user_id']);
1626 1626
 			$user_id  = $userdata->ID;
1627 1627
 		}
1628
-		$process = isset( $args['give_api_process'] ) ? strtolower( $args['give_api_process'] ) : false;
1628
+		$process = isset($args['give_api_process']) ? strtolower($args['give_api_process']) : false;
1629 1629
 
1630
-		if ( $user_id == get_current_user_id() && ! give_get_option( 'allow_user_api_keys' ) && ! current_user_can( 'manage_give_settings' ) ) {
1631
-			wp_die( sprintf( __( 'You do not have permission to %s API keys for this user', 'give' ), $process ), __( 'Error', 'give' ), array( 'response' => 403 ) );
1632
-		} elseif ( ! current_user_can( 'manage_give_settings' ) ) {
1633
-			wp_die( sprintf( __( 'You do not have permission to %s API keys for this user', 'give' ), $process ), __( 'Error', 'give' ), array( 'response' => 403 ) );
1630
+		if ($user_id == get_current_user_id() && ! give_get_option('allow_user_api_keys') && ! current_user_can('manage_give_settings')) {
1631
+			wp_die(sprintf(__('You do not have permission to %s API keys for this user', 'give'), $process), __('Error', 'give'), array('response' => 403));
1632
+		} elseif ( ! current_user_can('manage_give_settings')) {
1633
+			wp_die(sprintf(__('You do not have permission to %s API keys for this user', 'give'), $process), __('Error', 'give'), array('response' => 403));
1634 1634
 		}
1635 1635
 
1636
-		switch ( $process ) {
1636
+		switch ($process) {
1637 1637
 			case 'generate':
1638
-				if ( $this->generate_api_key( $user_id ) ) {
1639
-					delete_transient( 'give-total-api-keys' );
1640
-					wp_redirect( add_query_arg( 'give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) );
1638
+				if ($this->generate_api_key($user_id)) {
1639
+					delete_transient('give-total-api-keys');
1640
+					wp_redirect(add_query_arg('give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-settings&tab=api'));
1641 1641
 					exit();
1642 1642
 				} else {
1643
-					wp_redirect( add_query_arg( 'give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) );
1643
+					wp_redirect(add_query_arg('give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-settings&tab=api'));
1644 1644
 					exit();
1645 1645
 				}
1646 1646
 				break;
1647 1647
 			case 'regenerate':
1648
-				$this->generate_api_key( $user_id, true );
1649
-				delete_transient( 'give-total-api-keys' );
1650
-				wp_redirect( add_query_arg( 'give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) );
1648
+				$this->generate_api_key($user_id, true);
1649
+				delete_transient('give-total-api-keys');
1650
+				wp_redirect(add_query_arg('give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-settings&tab=api'));
1651 1651
 				exit();
1652 1652
 				break;
1653 1653
 			case 'revoke':
1654
-				$this->revoke_api_key( $user_id );
1655
-				delete_transient( 'give-total-api-keys' );
1656
-				wp_redirect( add_query_arg( 'give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) );
1654
+				$this->revoke_api_key($user_id);
1655
+				delete_transient('give-total-api-keys');
1656
+				wp_redirect(add_query_arg('give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-settings&tab=api'));
1657 1657
 				exit();
1658 1658
 				break;
1659 1659
 			default;
@@ -1672,34 +1672,34 @@  discard block
 block discarded – undo
1672 1672
 	 *
1673 1673
 	 * @return boolean True if (re)generated succesfully, false otherwise.
1674 1674
 	 */
1675
-	public function generate_api_key( $user_id = 0, $regenerate = false ) {
1675
+	public function generate_api_key($user_id = 0, $regenerate = false) {
1676 1676
 
1677
-		if ( empty( $user_id ) ) {
1677
+		if (empty($user_id)) {
1678 1678
 			return false;
1679 1679
 		}
1680 1680
 
1681
-		$user = get_userdata( $user_id );
1681
+		$user = get_userdata($user_id);
1682 1682
 
1683
-		if ( ! $user ) {
1683
+		if ( ! $user) {
1684 1684
 			return false;
1685 1685
 		}
1686 1686
 
1687
-		$public_key = $this->get_user_public_key( $user_id );
1688
-		$secret_key = $this->get_user_secret_key( $user_id );
1687
+		$public_key = $this->get_user_public_key($user_id);
1688
+		$secret_key = $this->get_user_secret_key($user_id);
1689 1689
 
1690
-		if ( empty( $public_key ) || $regenerate == true ) {
1691
-			$new_public_key = $this->generate_public_key( $user->user_email );
1692
-			$new_secret_key = $this->generate_private_key( $user->ID );
1690
+		if (empty($public_key) || $regenerate == true) {
1691
+			$new_public_key = $this->generate_public_key($user->user_email);
1692
+			$new_secret_key = $this->generate_private_key($user->ID);
1693 1693
 		} else {
1694 1694
 			return false;
1695 1695
 		}
1696 1696
 
1697
-		if ( $regenerate == true ) {
1698
-			$this->revoke_api_key( $user->ID );
1697
+		if ($regenerate == true) {
1698
+			$this->revoke_api_key($user->ID);
1699 1699
 		}
1700 1700
 
1701
-		update_user_meta( $user_id, $new_public_key, 'give_user_public_key' );
1702
-		update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' );
1701
+		update_user_meta($user_id, $new_public_key, 'give_user_public_key');
1702
+		update_user_meta($user_id, $new_secret_key, 'give_user_secret_key');
1703 1703
 
1704 1704
 		return true;
1705 1705
 	}
@@ -1714,28 +1714,28 @@  discard block
 block discarded – undo
1714 1714
 	 *
1715 1715
 	 * @return string
1716 1716
 	 */
1717
-	public function revoke_api_key( $user_id = 0 ) {
1717
+	public function revoke_api_key($user_id = 0) {
1718 1718
 
1719
-		if ( empty( $user_id ) ) {
1719
+		if (empty($user_id)) {
1720 1720
 			return false;
1721 1721
 		}
1722 1722
 
1723
-		$user = get_userdata( $user_id );
1723
+		$user = get_userdata($user_id);
1724 1724
 
1725
-		if ( ! $user ) {
1725
+		if ( ! $user) {
1726 1726
 			return false;
1727 1727
 		}
1728 1728
 
1729
-		$public_key = $this->get_user_public_key( $user_id );
1730
-		$secret_key = $this->get_user_secret_key( $user_id );
1729
+		$public_key = $this->get_user_public_key($user_id);
1730
+		$secret_key = $this->get_user_secret_key($user_id);
1731 1731
 
1732 1732
 
1733
-		if ( ! empty( $public_key ) ) {
1734
-			delete_transient( md5( 'give_api_user_' . $public_key ) );
1735
-			delete_transient( md5( 'give_api_user_public_key' . $user_id ) );
1736
-			delete_transient( md5( 'give_api_user_secret_key' . $user_id ) );
1737
-			delete_user_meta( $user_id, $public_key );
1738
-			delete_user_meta( $user_id, $secret_key );
1733
+		if ( ! empty($public_key)) {
1734
+			delete_transient(md5('give_api_user_'.$public_key));
1735
+			delete_transient(md5('give_api_user_public_key'.$user_id));
1736
+			delete_transient(md5('give_api_user_secret_key'.$user_id));
1737
+			delete_user_meta($user_id, $public_key);
1738
+			delete_user_meta($user_id, $secret_key);
1739 1739
 		} else {
1740 1740
 			return false;
1741 1741
 		}
@@ -1760,22 +1760,22 @@  discard block
 block discarded – undo
1760 1760
 	 *
1761 1761
 	 * @return void
1762 1762
 	 */
1763
-	public function update_key( $user_id ) {
1764
-		if ( current_user_can( 'edit_user', $user_id ) && isset( $_POST['give_set_api_key'] ) ) {
1763
+	public function update_key($user_id) {
1764
+		if (current_user_can('edit_user', $user_id) && isset($_POST['give_set_api_key'])) {
1765 1765
 
1766
-			$user = get_userdata( $user_id );
1766
+			$user = get_userdata($user_id);
1767 1767
 
1768
-			$public_key = $this->get_user_public_key( $user_id );
1769
-			$secret_key = $this->get_user_secret_key( $user_id );
1768
+			$public_key = $this->get_user_public_key($user_id);
1769
+			$secret_key = $this->get_user_secret_key($user_id);
1770 1770
 
1771
-			if ( empty( $public_key ) ) {
1772
-				$new_public_key = $this->generate_public_key( $user->user_email );
1773
-				$new_secret_key = $this->generate_private_key( $user->ID );
1771
+			if (empty($public_key)) {
1772
+				$new_public_key = $this->generate_public_key($user->user_email);
1773
+				$new_secret_key = $this->generate_private_key($user->ID);
1774 1774
 
1775
-				update_user_meta( $user_id, $new_public_key, 'give_user_public_key' );
1776
-				update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' );
1775
+				update_user_meta($user_id, $new_public_key, 'give_user_public_key');
1776
+				update_user_meta($user_id, $new_secret_key, 'give_user_secret_key');
1777 1777
 			} else {
1778
-				$this->revoke_api_key( $user_id );
1778
+				$this->revoke_api_key($user_id);
1779 1779
 			}
1780 1780
 		}
1781 1781
 	}
@@ -1790,9 +1790,9 @@  discard block
 block discarded – undo
1790 1790
 	 *
1791 1791
 	 * @return string
1792 1792
 	 */
1793
-	private function generate_public_key( $user_email = '' ) {
1794
-		$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
1795
-		$public   = hash( 'md5', $user_email . $auth_key . date( 'U' ) );
1793
+	private function generate_public_key($user_email = '') {
1794
+		$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
1795
+		$public   = hash('md5', $user_email.$auth_key.date('U'));
1796 1796
 
1797 1797
 		return $public;
1798 1798
 	}
@@ -1807,9 +1807,9 @@  discard block
 block discarded – undo
1807 1807
 	 *
1808 1808
 	 * @return string
1809 1809
 	 */
1810
-	private function generate_private_key( $user_id = 0 ) {
1811
-		$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
1812
-		$secret   = hash( 'md5', $user_id . $auth_key . date( 'U' ) );
1810
+	private function generate_private_key($user_id = 0) {
1811
+		$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
1812
+		$secret   = hash('md5', $user_id.$auth_key.date('U'));
1813 1813
 
1814 1814
 		return $secret;
1815 1815
 	}
@@ -1824,8 +1824,8 @@  discard block
 block discarded – undo
1824 1824
 	 *
1825 1825
 	 * @return string
1826 1826
 	 */
1827
-	public function get_token( $user_id = 0 ) {
1828
-		return hash( 'md5', $this->get_user_secret_key( $user_id ) . $this->get_user_public_key( $user_id ) );
1827
+	public function get_token($user_id = 0) {
1828
+		return hash('md5', $this->get_user_secret_key($user_id).$this->get_user_public_key($user_id));
1829 1829
 	}
1830 1830
 
1831 1831
 	/**
@@ -1839,9 +1839,9 @@  discard block
 block discarded – undo
1839 1839
 
1840 1840
 		// Default sales return
1841 1841
 		$sales                               = array();
1842
-		$sales['donations']['today']         = $this->stats->get_sales( 0, 'today' );
1843
-		$sales['donations']['current_month'] = $this->stats->get_sales( 0, 'this_month' );
1844
-		$sales['donations']['last_month']    = $this->stats->get_sales( 0, 'last_month' );
1842
+		$sales['donations']['today']         = $this->stats->get_sales(0, 'today');
1843
+		$sales['donations']['current_month'] = $this->stats->get_sales(0, 'this_month');
1844
+		$sales['donations']['last_month']    = $this->stats->get_sales(0, 'last_month');
1845 1845
 		$sales['donations']['totals']        = give_get_total_sales();
1846 1846
 
1847 1847
 		return $sales;
@@ -1858,9 +1858,9 @@  discard block
 block discarded – undo
1858 1858
 
1859 1859
 		// Default earnings return
1860 1860
 		$earnings                              = array();
1861
-		$earnings['earnings']['today']         = $this->stats->get_earnings( 0, 'today' );
1862
-		$earnings['earnings']['current_month'] = $this->stats->get_earnings( 0, 'this_month' );
1863
-		$earnings['earnings']['last_month']    = $this->stats->get_earnings( 0, 'last_month' );
1861
+		$earnings['earnings']['today']         = $this->stats->get_earnings(0, 'today');
1862
+		$earnings['earnings']['current_month'] = $this->stats->get_earnings(0, 'this_month');
1863
+		$earnings['earnings']['last_month']    = $this->stats->get_earnings(0, 'last_month');
1864 1864
 		$earnings['earnings']['totals']        = give_get_total_earnings();
1865 1865
 
1866 1866
 		return $earnings;
Please login to merge, or discard this patch.
includes/class-give-db-customers.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -268,7 +268,7 @@
 block discarded – undo
268 268
 	 * @since  1.0
269 269
 	 *
270 270
 	 * @param  string $field id or email
271
-	 * @param  mixed  $value  The Customer ID or email to search
271
+	 * @param  integer  $value  The Customer ID or email to search
272 272
 	 *
273 273
 	 * @return mixed          Upon success, an object of the customer. Upon failure, NULL
274 274
 	 */
Please login to merge, or discard this patch.
Spacing   +113 added lines, -113 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
 
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 
34 34
 		global $wpdb;
35 35
 
36
-		$this->table_name  = $wpdb->prefix . 'give_customers';
36
+		$this->table_name  = $wpdb->prefix.'give_customers';
37 37
 		$this->primary_key = 'id';
38 38
 		$this->version     = '1.0';
39 39
 
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 			'purchase_value' => 0.00,
75 75
 			'purchase_count' => 0,
76 76
 			'notes'          => '',
77
-			'date_created'   => date( 'Y-m-d H:i:s' ),
77
+			'date_created'   => date('Y-m-d H:i:s'),
78 78
 		);
79 79
 	}
80 80
 
@@ -84,40 +84,40 @@  discard block
 block discarded – undo
84 84
 	 * @access  public
85 85
 	 * @since   1.0
86 86
 	 */
87
-	public function add( $data = array() ) {
87
+	public function add($data = array()) {
88 88
 
89 89
 		$defaults = array(
90 90
 			'payment_ids' => ''
91 91
 		);
92 92
 
93
-		$args = wp_parse_args( $data, $defaults );
93
+		$args = wp_parse_args($data, $defaults);
94 94
 
95
-		if ( empty( $args['email'] ) ) {
95
+		if (empty($args['email'])) {
96 96
 			return false;
97 97
 		}
98 98
 
99
-		if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) {
100
-			$args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) );
99
+		if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) {
100
+			$args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids'])));
101 101
 		}
102 102
 
103
-		$customer = $this->get_customer_by( 'email', $args['email'] );
103
+		$customer = $this->get_customer_by('email', $args['email']);
104 104
 
105
-		if ( $customer ) {
105
+		if ($customer) {
106 106
 			// update an existing customer
107 107
 
108 108
 			// Update the payment IDs attached to the customer
109
-			if ( ! empty( $args['payment_ids'] ) ) {
109
+			if ( ! empty($args['payment_ids'])) {
110 110
 
111
-				if ( empty( $customer->payment_ids ) ) {
111
+				if (empty($customer->payment_ids)) {
112 112
 
113 113
 					$customer->payment_ids = $args['payment_ids'];
114 114
 
115 115
 				} else {
116 116
 
117
-					$existing_ids          = array_map( 'absint', explode( ',', $customer->payment_ids ) );
118
-					$payment_ids           = array_map( 'absint', explode( ',', $args['payment_ids'] ) );
119
-					$payment_ids           = array_merge( $payment_ids, $existing_ids );
120
-					$customer->payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) );
117
+					$existing_ids          = array_map('absint', explode(',', $customer->payment_ids));
118
+					$payment_ids           = array_map('absint', explode(',', $args['payment_ids']));
119
+					$payment_ids           = array_merge($payment_ids, $existing_ids);
120
+					$customer->payment_ids = implode(',', array_unique(array_values($payment_ids)));
121 121
 
122 122
 				}
123 123
 
@@ -125,13 +125,13 @@  discard block
 block discarded – undo
125 125
 
126 126
 			}
127 127
 
128
-			$this->update( $customer->id, $args );
128
+			$this->update($customer->id, $args);
129 129
 
130 130
 			return $customer->id;
131 131
 
132 132
 		} else {
133 133
 
134
-			return $this->insert( $args, 'customer' );
134
+			return $this->insert($args, 'customer');
135 135
 
136 136
 		}
137 137
 
@@ -146,20 +146,20 @@  discard block
 block discarded – undo
146 146
 	 * @access  public
147 147
 	 * @since   1.0
148 148
 	 */
149
-	public function delete( $_id_or_email = false ) {
149
+	public function delete($_id_or_email = false) {
150 150
 
151
-		if ( empty( $_id_or_email ) ) {
151
+		if (empty($_id_or_email)) {
152 152
 			return false;
153 153
 		}
154 154
 
155
-		$column   = is_email( $_id_or_email ) ? 'email' : 'id';
156
-		$customer = $this->get_customer_by( $column, $_id_or_email );
155
+		$column   = is_email($_id_or_email) ? 'email' : 'id';
156
+		$customer = $this->get_customer_by($column, $_id_or_email);
157 157
 
158
-		if ( $customer->id > 0 ) {
158
+		if ($customer->id > 0) {
159 159
 
160 160
 			global $wpdb;
161 161
 
162
-			return $wpdb->delete( $this->table_name, array( 'id' => $customer->id ), array( '%d' ) );
162
+			return $wpdb->delete($this->table_name, array('id' => $customer->id), array('%d'));
163 163
 
164 164
 		} else {
165 165
 			return false;
@@ -173,9 +173,9 @@  discard block
 block discarded – undo
173 173
 	 * @access  public
174 174
 	 * @since   1.0
175 175
 	 */
176
-	public function exists( $email = '' ) {
176
+	public function exists($email = '') {
177 177
 
178
-		return (bool) $this->get_column_by( 'id', 'email', $email );
178
+		return (bool) $this->get_column_by('id', 'email', $email);
179 179
 
180 180
 	}
181 181
 
@@ -185,16 +185,16 @@  discard block
 block discarded – undo
185 185
 	 * @access  public
186 186
 	 * @since   1.0
187 187
 	 */
188
-	public function attach_payment( $customer_id = 0, $payment_id = 0 ) {
188
+	public function attach_payment($customer_id = 0, $payment_id = 0) {
189 189
 
190
-		$customer = new Give_Customer( $customer_id );
190
+		$customer = new Give_Customer($customer_id);
191 191
 
192
-		if ( empty( $customer->id ) ) {
192
+		if (empty($customer->id)) {
193 193
 			return false;
194 194
 		}
195 195
 
196 196
 		// Attach the payment, but don't increment stats, as this function previously did not
197
-		return $customer->attach_payment( $payment_id, false );
197
+		return $customer->attach_payment($payment_id, false);
198 198
 
199 199
 	}
200 200
 
@@ -204,16 +204,16 @@  discard block
 block discarded – undo
204 204
 	 * @access  public
205 205
 	 * @since   1.0
206 206
 	 */
207
-	public function remove_payment( $customer_id = 0, $payment_id = 0 ) {
207
+	public function remove_payment($customer_id = 0, $payment_id = 0) {
208 208
 
209
-		$customer = new Give_Customer( $customer_id );
209
+		$customer = new Give_Customer($customer_id);
210 210
 
211
-		if ( ! $customer ) {
211
+		if ( ! $customer) {
212 212
 			return false;
213 213
 		}
214 214
 
215 215
 		// Remove the payment, but don't decrease stats, as this function previously did not
216
-		return $customer->remove_payment( $payment_id, false );
216
+		return $customer->remove_payment($payment_id, false);
217 217
 
218 218
 	}
219 219
 
@@ -225,18 +225,18 @@  discard block
 block discarded – undo
225 225
 	 *
226 226
 	 * @return bool
227 227
 	 */
228
-	public function increment_stats( $customer_id = 0, $amount = 0.00 ) {
228
+	public function increment_stats($customer_id = 0, $amount = 0.00) {
229 229
 
230
-		$customer = new Give_Customer( $customer_id );
230
+		$customer = new Give_Customer($customer_id);
231 231
 
232
-		if ( empty( $customer->id ) ) {
232
+		if (empty($customer->id)) {
233 233
 			return false;
234 234
 		}
235 235
 
236 236
 		$increased_count = $customer->increase_purchase_count();
237
-		$increased_value = $customer->increase_value( $amount );
237
+		$increased_value = $customer->increase_value($amount);
238 238
 
239
-		return ( $increased_count && $increased_value ) ? true : false;
239
+		return ($increased_count && $increased_value) ? true : false;
240 240
 
241 241
 	}
242 242
 
@@ -246,18 +246,18 @@  discard block
 block discarded – undo
246 246
 	 * @access  public
247 247
 	 * @since   1.0
248 248
 	 */
249
-	public function decrement_stats( $customer_id = 0, $amount = 0.00 ) {
249
+	public function decrement_stats($customer_id = 0, $amount = 0.00) {
250 250
 
251
-		$customer = new Give_Customer( $customer_id );
251
+		$customer = new Give_Customer($customer_id);
252 252
 
253
-		if ( ! $customer ) {
253
+		if ( ! $customer) {
254 254
 			return false;
255 255
 		}
256 256
 
257 257
 		$decreased_count = $customer->decrease_purchase_count();
258
-		$decreased_value = $customer->decrease_value( $amount );
258
+		$decreased_value = $customer->decrease_value($amount);
259 259
 
260
-		return ( $decreased_count && $decreased_value ) ? true : false;
260
+		return ($decreased_count && $decreased_value) ? true : false;
261 261
 
262 262
 	}
263 263
 
@@ -272,45 +272,45 @@  discard block
 block discarded – undo
272 272
 	 *
273 273
 	 * @return mixed          Upon success, an object of the customer. Upon failure, NULL
274 274
 	 */
275
-	public function get_customer_by( $field = 'id', $value = 0 ) {
275
+	public function get_customer_by($field = 'id', $value = 0) {
276 276
 		global $wpdb;
277 277
 
278
-		if ( empty( $field ) || empty( $value ) ) {
278
+		if (empty($field) || empty($value)) {
279 279
 			return null;
280 280
 		}
281 281
 
282
-		if ( 'id' == $field || 'user_id' == $field ) {
282
+		if ('id' == $field || 'user_id' == $field) {
283 283
 			// Make sure the value is numeric to avoid casting objects, for example,
284 284
 			// to int 1.
285
-			if ( ! is_numeric( $value ) ) {
285
+			if ( ! is_numeric($value)) {
286 286
 				return false;
287 287
 			}
288 288
 
289
-			$value = intval( $value );
289
+			$value = intval($value);
290 290
 
291
-			if ( $value < 1 ) {
291
+			if ($value < 1) {
292 292
 				return false;
293 293
 			}
294 294
 
295
-		} elseif ( 'email' === $field ) {
295
+		} elseif ('email' === $field) {
296 296
 
297
-			if ( ! is_email( $value ) ) {
297
+			if ( ! is_email($value)) {
298 298
 				return false;
299 299
 			}
300 300
 
301
-			$value = trim( $value );
301
+			$value = trim($value);
302 302
 		}
303 303
 
304
-		if ( ! $value ) {
304
+		if ( ! $value) {
305 305
 			return false;
306 306
 		}
307 307
 
308
-		switch ( $field ) {
308
+		switch ($field) {
309 309
 			case 'id':
310 310
 				$db_field = 'id';
311 311
 				break;
312 312
 			case 'email':
313
-				$value    = sanitize_text_field( $value );
313
+				$value    = sanitize_text_field($value);
314 314
 				$db_field = 'email';
315 315
 				break;
316 316
 			case 'user_id':
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 				return false;
321 321
 		}
322 322
 
323
-		if ( ! $customer = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $db_field = %s LIMIT 1", $value ) ) ) {
323
+		if ( ! $customer = $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $db_field = %s LIMIT 1", $value))) {
324 324
 			return false;
325 325
 		}
326 326
 
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 	 * @access  public
334 334
 	 * @since   1.0
335 335
 	 */
336
-	public function get_customers( $args = array() ) {
336
+	public function get_customers($args = array()) {
337 337
 
338 338
 		global $wpdb;
339 339
 
@@ -345,21 +345,21 @@  discard block
 block discarded – undo
345 345
 			'order'   => 'DESC'
346 346
 		);
347 347
 
348
-		$args = wp_parse_args( $args, $defaults );
348
+		$args = wp_parse_args($args, $defaults);
349 349
 
350
-		if ( $args['number'] < 1 ) {
350
+		if ($args['number'] < 1) {
351 351
 			$args['number'] = 999999999999;
352 352
 		}
353 353
 
354 354
 		$where = ' WHERE 1=1 ';
355 355
 
356 356
 		// specific customers
357
-		if ( ! empty( $args['id'] ) ) {
357
+		if ( ! empty($args['id'])) {
358 358
 
359
-			if ( is_array( $args['id'] ) ) {
360
-				$ids = implode( ',', array_map( 'intval', $args['id'] ) );
359
+			if (is_array($args['id'])) {
360
+				$ids = implode(',', array_map('intval', $args['id']));
361 361
 			} else {
362
-				$ids = intval( $args['id'] );
362
+				$ids = intval($args['id']);
363 363
 			}
364 364
 
365 365
 			$where .= " AND `id` IN( {$ids} ) ";
@@ -367,12 +367,12 @@  discard block
 block discarded – undo
367 367
 		}
368 368
 
369 369
 		// customers for specific user accounts
370
-		if ( ! empty( $args['user_id'] ) ) {
370
+		if ( ! empty($args['user_id'])) {
371 371
 
372
-			if ( is_array( $args['user_id'] ) ) {
373
-				$user_ids = implode( ',', array_map( 'intval', $args['user_id'] ) );
372
+			if (is_array($args['user_id'])) {
373
+				$user_ids = implode(',', array_map('intval', $args['user_id']));
374 374
 			} else {
375
-				$user_ids = intval( $args['user_id'] );
375
+				$user_ids = intval($args['user_id']);
376 376
 			}
377 377
 
378 378
 			$where .= " AND `user_id` IN( {$user_ids} ) ";
@@ -380,15 +380,15 @@  discard block
 block discarded – undo
380 380
 		}
381 381
 
382 382
 		//specific customers by email
383
-		if ( ! empty( $args['email'] ) ) {
383
+		if ( ! empty($args['email'])) {
384 384
 
385
-			if ( is_array( $args['email'] ) ) {
386
-				$emails = "'" . implode( "', '", $args['email'] ) . "'";
385
+			if (is_array($args['email'])) {
386
+				$emails = "'".implode("', '", $args['email'])."'";
387 387
 			} else {
388
-				$emails = "'" . $args['email'] . "'";
388
+				$emails = "'".$args['email']."'";
389 389
 			}
390 390
 
391
-			if ( ! empty( $where ) ) {
391
+			if ( ! empty($where)) {
392 392
 				$where .= " AND `email` IN( {$emails} ) ";
393 393
 			} else {
394 394
 				$where .= "WHERE `email` IN( {$emails} ) ";
@@ -397,31 +397,31 @@  discard block
 block discarded – undo
397 397
 		}
398 398
 
399 399
 		// specific customers by name
400
-		if ( ! empty( $args['name'] ) ) {
400
+		if ( ! empty($args['name'])) {
401 401
 
402
-			if ( ! empty( $where ) ) {
403
-				$where .= " AND `name` LIKE '%%" . $args['name'] . "%%' ";
402
+			if ( ! empty($where)) {
403
+				$where .= " AND `name` LIKE '%%".$args['name']."%%' ";
404 404
 			} else {
405
-				$where .= "WHERE `name` LIKE '%%" . $args['name'] . "%%' ";
405
+				$where .= "WHERE `name` LIKE '%%".$args['name']."%%' ";
406 406
 			}
407 407
 		}
408 408
 
409 409
 		// Customers created for a specific date or in a date range
410
-		if ( ! empty( $args['date'] ) ) {
410
+		if ( ! empty($args['date'])) {
411 411
 
412
-			if ( is_array( $args['date'] ) ) {
412
+			if (is_array($args['date'])) {
413 413
 
414
-				if ( ! empty( $args['date']['start'] ) ) {
414
+				if ( ! empty($args['date']['start'])) {
415 415
 
416
-					$start = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) );
416
+					$start = date('Y-m-d H:i:s', strtotime($args['date']['start']));
417 417
 
418 418
 					$where .= " AND `date_created` >= '{$start}'";
419 419
 
420 420
 				}
421 421
 
422
-				if ( ! empty( $args['date']['end'] ) ) {
422
+				if ( ! empty($args['date']['end'])) {
423 423
 
424
-					$end = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) );
424
+					$end = date('Y-m-d H:i:s', strtotime($args['date']['end']));
425 425
 
426 426
 					$where .= " AND `date_created` <= '{$end}'";
427 427
 
@@ -429,31 +429,31 @@  discard block
 block discarded – undo
429 429
 
430 430
 			} else {
431 431
 
432
-				$year  = date( 'Y', strtotime( $args['date'] ) );
433
-				$month = date( 'm', strtotime( $args['date'] ) );
434
-				$day   = date( 'd', strtotime( $args['date'] ) );
432
+				$year  = date('Y', strtotime($args['date']));
433
+				$month = date('m', strtotime($args['date']));
434
+				$day   = date('d', strtotime($args['date']));
435 435
 
436 436
 				$where .= " AND $year = YEAR ( date_created ) AND $month = MONTH ( date_created ) AND $day = DAY ( date_created )";
437 437
 			}
438 438
 
439 439
 		}
440 440
 
441
-		$args['orderby'] = ! array_key_exists( $args['orderby'], $this->get_columns() ) ? 'id' : $args['orderby'];
441
+		$args['orderby'] = ! array_key_exists($args['orderby'], $this->get_columns()) ? 'id' : $args['orderby'];
442 442
 
443
-		if ( 'purchase_value' == $args['orderby'] ) {
443
+		if ('purchase_value' == $args['orderby']) {
444 444
 			$args['orderby'] = 'purchase_value+0';
445 445
 		}
446 446
 
447
-		$cache_key = md5( 'give_customers_' . serialize( $args ) );
447
+		$cache_key = md5('give_customers_'.serialize($args));
448 448
 
449
-		$customers = wp_cache_get( $cache_key, 'customers' );
449
+		$customers = wp_cache_get($cache_key, 'customers');
450 450
 
451
-		$args['orderby'] = esc_sql( $args['orderby'] );
452
-		$args['order']   = esc_sql( $args['order'] );
451
+		$args['orderby'] = esc_sql($args['orderby']);
452
+		$args['order']   = esc_sql($args['order']);
453 453
 
454
-		if ( $customers === false ) {
455
-			$customers = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM  $this->table_name $where ORDER BY {$args['orderby']} {$args['order']} LIMIT %d,%d;", absint( $args['offset'] ), absint( $args['number'] ) ) );
456
-			wp_cache_set( $cache_key, $customers, 'customers', 3600 );
454
+		if ($customers === false) {
455
+			$customers = $wpdb->get_results($wpdb->prepare("SELECT * FROM  $this->table_name $where ORDER BY {$args['orderby']} {$args['order']} LIMIT %d,%d;", absint($args['offset']), absint($args['number'])));
456
+			wp_cache_set($cache_key, $customers, 'customers', 3600);
457 457
 		}
458 458
 
459 459
 		return $customers;
@@ -467,26 +467,26 @@  discard block
 block discarded – undo
467 467
 	 * @access  public
468 468
 	 * @since   1.0
469 469
 	 */
470
-	public function count( $args = array() ) {
470
+	public function count($args = array()) {
471 471
 
472 472
 		global $wpdb;
473 473
 
474 474
 		$where = ' WHERE 1=1 ';
475 475
 
476
-		if ( ! empty( $args['date'] ) ) {
476
+		if ( ! empty($args['date'])) {
477 477
 
478
-			if ( is_array( $args['date'] ) ) {
478
+			if (is_array($args['date'])) {
479 479
 
480
-				$start = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) );
481
-				$end   = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) );
480
+				$start = date('Y-m-d H:i:s', strtotime($args['date']['start']));
481
+				$end   = date('Y-m-d H:i:s', strtotime($args['date']['end']));
482 482
 
483 483
 				$where .= " AND `date_created` >= '{$start}' AND `date_created` <= '{$end}'";
484 484
 
485 485
 			} else {
486 486
 
487
-				$year  = date( 'Y', strtotime( $args['date'] ) );
488
-				$month = date( 'm', strtotime( $args['date'] ) );
489
-				$day   = date( 'd', strtotime( $args['date'] ) );
487
+				$year  = date('Y', strtotime($args['date']));
488
+				$month = date('m', strtotime($args['date']));
489
+				$day   = date('d', strtotime($args['date']));
490 490
 
491 491
 				$where .= " AND $year = YEAR ( date_created ) AND $month = MONTH ( date_created ) AND $day = DAY ( date_created )";
492 492
 			}
@@ -494,16 +494,16 @@  discard block
 block discarded – undo
494 494
 		}
495 495
 
496 496
 
497
-		$cache_key = md5( 'give_customers_count' . serialize( $args ) );
497
+		$cache_key = md5('give_customers_count'.serialize($args));
498 498
 
499
-		$count = wp_cache_get( $cache_key, 'customers' );
499
+		$count = wp_cache_get($cache_key, 'customers');
500 500
 
501
-		if ( $count === false ) {
502
-			$count = $wpdb->get_var( "SELECT COUNT($this->primary_key) FROM " . $this->table_name . "{$where};" );
503
-			wp_cache_set( $cache_key, $count, 'customers', 3600 );
501
+		if ($count === false) {
502
+			$count = $wpdb->get_var("SELECT COUNT($this->primary_key) FROM ".$this->table_name."{$where};");
503
+			wp_cache_set($cache_key, $count, 'customers', 3600);
504 504
 		}
505 505
 
506
-		return absint( $count );
506
+		return absint($count);
507 507
 
508 508
 	}
509 509
 
@@ -517,9 +517,9 @@  discard block
 block discarded – undo
517 517
 
518 518
 		global $wpdb;
519 519
 
520
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
520
+		require_once(ABSPATH.'wp-admin/includes/upgrade.php');
521 521
 
522
-		$sql = "CREATE TABLE " . $this->table_name . " (
522
+		$sql = "CREATE TABLE ".$this->table_name." (
523 523
 		id bigint(20) NOT NULL AUTO_INCREMENT,
524 524
 		user_id bigint(20) NOT NULL,
525 525
 		email varchar(50) NOT NULL,
@@ -534,8 +534,8 @@  discard block
 block discarded – undo
534 534
 		KEY user (user_id)
535 535
 		) CHARACTER SET utf8 COLLATE utf8_general_ci;";
536 536
 
537
-		dbDelta( $sql );
537
+		dbDelta($sql);
538 538
 
539
-		update_option( $this->table_name . '_db_version', $this->version );
539
+		update_option($this->table_name.'_db_version', $this->version);
540 540
 	}
541 541
 }
Please login to merge, or discard this patch.
includes/class-give-logging.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 	 * @since 1.0
197 197
 	 * @param array $log_data Log entry data
198 198
 	 * @param array $log_meta Log entry meta
199
-	 * @return bool True if successful, false otherwise
199
+	 * @return boolean|null True if successful, false otherwise
200 200
 	 */
201 201
 	public function update_log( $log_data = array(), $log_meta = array() ) {
202 202
 
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
  * @param string $title
368 368
  * @param string $message
369 369
  * @param int    $parent
370
- * @param null   $type
370
+ * @param string   $type
371 371
  *
372 372
  * @global $give_logs GIVE Logs Object
373 373
  *
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 * @access public
69 69
 	 * @since 1.0
70 70
 	 * @return void
71
-	*/
71
+	 */
72 72
 	public function register_taxonomy() {
73 73
 		register_taxonomy( 'give_log_type', 'give_log', array( 'public' => false ) );
74 74
 	}
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 * @param string $type Log type (default: null)
142 142
 	 * @param int $paged Page number (default: null)
143 143
 	 * @return array Array of the connected logs
144
-	*/
144
+	 */
145 145
 	public function get_logs( $object_id = 0, $type = null, $paged = null ) {
146 146
 		return $this->get_connected_logs( array( 'post_parent' => $object_id, 'paged' => $paged, 'log_type' => $type ) );
147 147
 	}
Please login to merge, or discard this 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' ) ) exit;
13
+if ( ! defined('ABSPATH')) exit;
14 14
 
15 15
 /**
16 16
  * Give_Logging Class
@@ -28,10 +28,10 @@  discard block
 block discarded – undo
28 28
 	 */
29 29
 	public function __construct() {
30 30
 		// Create the log post type
31
-		add_action( 'init', array( $this, 'register_post_type' ), 1 );
31
+		add_action('init', array($this, 'register_post_type'), 1);
32 32
 
33 33
 		// Create types taxonomy and default types
34
-		add_action( 'init', array( $this, 'register_taxonomy' ), 1 );
34
+		add_action('init', array($this, 'register_taxonomy'), 1);
35 35
 
36 36
 	}
37 37
 
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	public function register_post_type() {
46 46
 		/* Logs post type */
47 47
 		$log_args = array(
48
-			'labels'			  => array( 'name' => __( 'Logs', 'give' ) ),
48
+			'labels'			  => array('name' => __('Logs', 'give')),
49 49
 			'public'			  => false,
50 50
 			'exclude_from_search' => true,
51 51
 			'publicly_queryable'  => false,
@@ -53,11 +53,11 @@  discard block
 block discarded – undo
53 53
 			'query_var'			  => false,
54 54
 			'rewrite'			  => false,
55 55
 			'capability_type'	  => 'post',
56
-			'supports'			  => array( 'title', 'editor' ),
56
+			'supports'			  => array('title', 'editor'),
57 57
 			'can_export'		  => true
58 58
 		);
59 59
 
60
-		register_post_type( 'give_log', $log_args );
60
+		register_post_type('give_log', $log_args);
61 61
 	}
62 62
 
63 63
 	/**
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 	 * @return void
71 71
 	*/
72 72
 	public function register_taxonomy() {
73
-		register_taxonomy( 'give_log_type', 'give_log', array( 'public' => false ) );
73
+		register_taxonomy('give_log_type', 'give_log', array('public' => false));
74 74
 	}
75 75
 
76 76
 	/**
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 			'sale', 'gateway_error', 'api_request'
88 88
 		);
89 89
 
90
-		return apply_filters( 'give_log_types', $terms );
90
+		return apply_filters('give_log_types', $terms);
91 91
 	}
92 92
 
93 93
 	/**
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
 	 * @param string $type Log type
102 102
 	 * @return bool Whether log type is valid
103 103
 	 */
104
-	function valid_type( $type ) {
105
-		return in_array( $type, $this->log_types() );
104
+	function valid_type($type) {
105
+		return in_array($type, $this->log_types());
106 106
 	}
107 107
 
108 108
 	/**
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	 * @param string $type Log type (default: null)
121 121
 	 * @return int Log ID
122 122
 	 */
123
-	public function add( $title = '', $message = '', $parent = 0, $type = null ) {
123
+	public function add($title = '', $message = '', $parent = 0, $type = null) {
124 124
 		$log_data = array(
125 125
 			'post_title' 	=> $title,
126 126
 			'post_content'	=> $message,
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 			'log_type'		=> $type
129 129
 		);
130 130
 
131
-		return $this->insert_log( $log_data );
131
+		return $this->insert_log($log_data);
132 132
 	}
133 133
 
134 134
 	/**
@@ -142,8 +142,8 @@  discard block
 block discarded – undo
142 142
 	 * @param int $paged Page number (default: null)
143 143
 	 * @return array Array of the connected logs
144 144
 	*/
145
-	public function get_logs( $object_id = 0, $type = null, $paged = null ) {
146
-		return $this->get_connected_logs( array( 'post_parent' => $object_id, 'paged' => $paged, 'log_type' => $type ) );
145
+	public function get_logs($object_id = 0, $type = null, $paged = null) {
146
+		return $this->get_connected_logs(array('post_parent' => $object_id, 'paged' => $paged, 'log_type' => $type));
147 147
 	}
148 148
 
149 149
 	/**
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 	 * @param array $log_meta Log entry meta
157 157
 	 * @return int The ID of the newly created log item
158 158
 	 */
159
-	function insert_log( $log_data = array(), $log_meta = array() ) {
159
+	function insert_log($log_data = array(), $log_meta = array()) {
160 160
 		$defaults = array(
161 161
 			'post_type' 	=> 'give_log',
162 162
 			'post_status'	=> 'publish',
@@ -165,26 +165,26 @@  discard block
 block discarded – undo
165 165
 			'log_type'		=> false
166 166
 		);
167 167
 
168
-		$args = wp_parse_args( $log_data, $defaults );
168
+		$args = wp_parse_args($log_data, $defaults);
169 169
 
170
-		do_action( 'give_pre_insert_log', $log_data, $log_meta );
170
+		do_action('give_pre_insert_log', $log_data, $log_meta);
171 171
 
172 172
 		// Store the log entry
173
-		$log_id = wp_insert_post( $args );
173
+		$log_id = wp_insert_post($args);
174 174
 
175 175
 		// Set the log type, if any
176
-		if ( $log_data['log_type'] && $this->valid_type( $log_data['log_type'] ) ) {
177
-			wp_set_object_terms( $log_id, $log_data['log_type'], 'give_log_type', false );
176
+		if ($log_data['log_type'] && $this->valid_type($log_data['log_type'])) {
177
+			wp_set_object_terms($log_id, $log_data['log_type'], 'give_log_type', false);
178 178
 		}
179 179
 
180 180
 		// Set log meta, if any
181
-		if ( $log_id && ! empty( $log_meta ) ) {
182
-			foreach ( (array) $log_meta as $key => $meta ) {
183
-				update_post_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta );
181
+		if ($log_id && ! empty($log_meta)) {
182
+			foreach ((array) $log_meta as $key => $meta) {
183
+				update_post_meta($log_id, '_give_log_'.sanitize_key($key), $meta);
184 184
 			}
185 185
 		}
186 186
 
187
-		do_action( 'give_post_insert_log', $log_id, $log_data, $log_meta );
187
+		do_action('give_post_insert_log', $log_id, $log_data, $log_meta);
188 188
 
189 189
 		return $log_id;
190 190
 	}
@@ -198,9 +198,9 @@  discard block
 block discarded – undo
198 198
 	 * @param array $log_meta Log entry meta
199 199
 	 * @return bool True if successful, false otherwise
200 200
 	 */
201
-	public function update_log( $log_data = array(), $log_meta = array() ) {
201
+	public function update_log($log_data = array(), $log_meta = array()) {
202 202
 
203
-		do_action( 'give_pre_update_log', $log_data, $log_meta );
203
+		do_action('give_pre_update_log', $log_data, $log_meta);
204 204
 
205 205
 		$defaults = array(
206 206
 			'post_type' 	=> 'give_log',
@@ -208,19 +208,19 @@  discard block
 block discarded – undo
208 208
 			'post_parent'	=> 0
209 209
 		);
210 210
 
211
-		$args = wp_parse_args( $log_data, $defaults );
211
+		$args = wp_parse_args($log_data, $defaults);
212 212
 
213 213
 		// Store the log entry
214
-		$log_id = wp_update_post( $args );
214
+		$log_id = wp_update_post($args);
215 215
 
216
-		if ( $log_id && ! empty( $log_meta ) ) {
217
-			foreach ( (array) $log_meta as $key => $meta ) {
218
-				if ( ! empty( $meta ) )
219
-					update_post_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta );
216
+		if ($log_id && ! empty($log_meta)) {
217
+			foreach ((array) $log_meta as $key => $meta) {
218
+				if ( ! empty($meta))
219
+					update_post_meta($log_id, '_give_log_'.sanitize_key($key), $meta);
220 220
 			}
221 221
 		}
222 222
 
223
-		do_action( 'give_post_update_log', $log_id, $log_data, $log_meta );
223
+		do_action('give_post_update_log', $log_id, $log_data, $log_meta);
224 224
 	}
225 225
 
226 226
 	/**
@@ -233,18 +233,18 @@  discard block
 block discarded – undo
233 233
 	 * @param array $args Query arguments
234 234
 	 * @return mixed array if logs were found, false otherwise
235 235
 	 */
236
-	public function get_connected_logs( $args = array() ) {
236
+	public function get_connected_logs($args = array()) {
237 237
 		$defaults = array(
238 238
 			'post_type'      => 'give_log',
239 239
 			'posts_per_page' => 20,
240 240
 			'post_status'    => 'publish',
241
-			'paged'          => get_query_var( 'paged' ),
241
+			'paged'          => get_query_var('paged'),
242 242
 			'log_type'       => false
243 243
 		);
244 244
 
245
-		$query_args = wp_parse_args( $args, $defaults );
245
+		$query_args = wp_parse_args($args, $defaults);
246 246
 
247
-		if ( $query_args['log_type'] && $this->valid_type( $query_args['log_type'] ) ) {
247
+		if ($query_args['log_type'] && $this->valid_type($query_args['log_type'])) {
248 248
 			$query_args['tax_query'] = array(
249 249
 				array(
250 250
 					'taxonomy' 	=> 'give_log_type',
@@ -254,9 +254,9 @@  discard block
 block discarded – undo
254 254
 			);
255 255
 		}
256 256
 
257
-		$logs = get_posts( $query_args );
257
+		$logs = get_posts($query_args);
258 258
 
259
-		if ( $logs )
259
+		if ($logs)
260 260
 			return $logs;
261 261
 
262 262
 		// No logs found
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 	 * @param array $date_query Log data query (default: null) (since 1.9)
275 275
 	 * @return int Log count
276 276
 	 */
277
-	public function get_log_count( $object_id = 0, $type = null, $meta_query = null, $date_query = null ) {
277
+	public function get_log_count($object_id = 0, $type = null, $meta_query = null, $date_query = null) {
278 278
 		
279 279
 		global $pagenow, $typenow;
280 280
 
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 			'fields'           => 'ids',
287 287
 		);
288 288
 
289
-		if ( ! empty( $type ) && $this->valid_type( $type ) ) {
289
+		if ( ! empty($type) && $this->valid_type($type)) {
290 290
 			$query_args['tax_query'] = array(
291 291
 				array(
292 292
 					'taxonomy' 	=> 'give_log_type',
@@ -296,15 +296,15 @@  discard block
 block discarded – undo
296 296
 			);
297 297
 		}
298 298
 
299
-		if ( ! empty( $meta_query ) ) {
299
+		if ( ! empty($meta_query)) {
300 300
 			$query_args['meta_query'] = $meta_query;
301 301
 		}
302 302
 
303
-		if ( ! empty( $date_query ) ) {
303
+		if ( ! empty($date_query)) {
304 304
 			$query_args['date_query'] = $date_query;
305 305
 		}
306 306
 
307
-		$logs = new WP_Query( $query_args );
307
+		$logs = new WP_Query($query_args);
308 308
 
309 309
 		return (int) $logs->post_count;
310 310
 	}
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 	 * @param array $meta_query Log meta query (default: null)
321 321
 	 * @return void
322 322
 	 */
323
-	public function delete_logs( $object_id = 0, $type = null, $meta_query = null  ) {
323
+	public function delete_logs($object_id = 0, $type = null, $meta_query = null) {
324 324
 		$query_args = array(
325 325
 			'post_parent' 	=> $object_id,
326 326
 			'post_type'		=> 'give_log',
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 			'fields'        => 'ids'
330 330
 		);
331 331
 
332
-		if ( ! empty( $type ) && $this->valid_type( $type ) ) {
332
+		if ( ! empty($type) && $this->valid_type($type)) {
333 333
 			$query_args['tax_query'] = array(
334 334
 				array(
335 335
 					'taxonomy' 	=> 'give_log_type',
@@ -339,15 +339,15 @@  discard block
 block discarded – undo
339 339
 			);
340 340
 		}
341 341
 
342
-		if ( ! empty( $meta_query ) ) {
342
+		if ( ! empty($meta_query)) {
343 343
 			$query_args['meta_query'] = $meta_query;
344 344
 		}
345 345
 
346
-		$logs = get_posts( $query_args );
346
+		$logs = get_posts($query_args);
347 347
 
348
-		if ( $logs ) {
349
-			foreach ( $logs as $log ) {
350
-				wp_delete_post( $log, true );
348
+		if ($logs) {
349
+			foreach ($logs as $log) {
350
+				wp_delete_post($log, true);
351 351
 			}
352 352
 		}
353 353
 	}
@@ -375,8 +375,8 @@  discard block
 block discarded – undo
375 375
  *
376 376
  * @return mixed ID of the new log entry
377 377
  */
378
-function give_record_log( $title = '', $message = '', $parent = 0, $type = null ) {
378
+function give_record_log($title = '', $message = '', $parent = 0, $type = null) {
379 379
 	global $give_logs;
380
-	$log = $give_logs->add( $title, $message, $parent, $type );
380
+	$log = $give_logs->add($title, $message, $parent, $type);
381 381
 	return $log;
382 382
 }
383 383
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +9 added lines, -5 removed lines patch added patch discarded remove patch
@@ -10,7 +10,9 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) exit;
13
+if ( ! defined( 'ABSPATH' ) ) {
14
+	exit;
15
+}
14 16
 
15 17
 /**
16 18
  * Give_Logging Class
@@ -215,8 +217,9 @@  discard block
 block discarded – undo
215 217
 
216 218
 		if ( $log_id && ! empty( $log_meta ) ) {
217 219
 			foreach ( (array) $log_meta as $key => $meta ) {
218
-				if ( ! empty( $meta ) )
219
-					update_post_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta );
220
+				if ( ! empty( $meta ) ) {
221
+									update_post_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta );
222
+				}
220 223
 			}
221 224
 		}
222 225
 
@@ -256,8 +259,9 @@  discard block
 block discarded – undo
256 259
 
257 260
 		$logs = get_posts( $query_args );
258 261
 
259
-		if ( $logs )
260
-			return $logs;
262
+		if ( $logs ) {
263
+					return $logs;
264
+		}
261 265
 
262 266
 		// No logs found
263 267
 		return false;
Please login to merge, or discard this patch.
includes/class-give-session.php 3 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -167,10 +167,10 @@  discard block
 block discarded – undo
167 167
 	 *
168 168
 	 * @since 1.0
169 169
 	 *
170
-	 * @param $key   $_SESSION key
171
-	 * @param $value $_SESSION variable
172 170
 	 *
173
-	 * @return mixed Session variable
171
+	 * @param string $key
172
+	 * @param integer $value
173
+	 * @return string Session variable
174 174
 	 */
175 175
 	public function set( $key, $value ) {
176 176
 
@@ -222,13 +222,13 @@  discard block
 block discarded – undo
222 222
 	/**
223 223
 	 * Starts a new session if one hasn't started yet.
224 224
 	 *
225
-	 * @return null
225
+	 * @return boolean
226 226
 	 * Checks to see if the server supports PHP sessions
227 227
 	 * or if the GIVE_USE_PHP_SESSIONS constant is defined
228 228
 	 *
229 229
 	 * @access public
230 230
 	 * @since  1.0
231
-	 * @return bool $ret True if we are using PHP sessions, false otherwise
231
+	 * @return boolean $ret True if we are using PHP sessions, false otherwise
232 232
 	 */
233 233
 	public function use_php_sessions() {
234 234
 
Please login to merge, or discard this patch.
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Give Session
4
- *
5
- * This is a wrapper class for WP_Session / PHP $_SESSION and handles the storage of Give sessions
6
- *
7
- * @package     Give
8
- * @subpackage  Classes/Session
9
- * @copyright   Copyright (c) 2015, WordImpress
10
- * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
11
- * @since       1.0
12
- */
3
+	 * Give Session
4
+	 *
5
+	 * This is a wrapper class for WP_Session / PHP $_SESSION and handles the storage of Give sessions
6
+	 *
7
+	 * @package     Give
8
+	 * @subpackage  Classes/Session
9
+	 * @copyright   Copyright (c) 2015, WordImpress
10
+	 * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
11
+	 * @since       1.0
12
+	 */
13 13
 
14 14
 // Exit if accessed directly
15 15
 if ( ! defined( 'ABSPATH' ) ) {
Please login to merge, or discard this patch.
Spacing   +48 added lines, -48 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
 
@@ -71,44 +71,44 @@  discard block
 block discarded – undo
71 71
 	public function __construct() {
72 72
 
73 73
 		$this->use_php_sessions = $this->use_php_sessions();
74
-		$this->exp_option       = give_get_option( 'session_lifetime' );
74
+		$this->exp_option       = give_get_option('session_lifetime');
75 75
 
76
-		if ( $this->use_php_sessions ) {
76
+		if ($this->use_php_sessions) {
77 77
 
78
-			if ( is_multisite() ) {
78
+			if (is_multisite()) {
79 79
 
80
-				$this->prefix = '_' . get_current_blog_id();
80
+				$this->prefix = '_'.get_current_blog_id();
81 81
 
82 82
 			}
83 83
 
84 84
 			// Use PHP SESSION (must be enabled via the GIVE_USE_PHP_SESSIONS constant)
85
-			add_action( 'init', array( $this, 'maybe_start_session' ), - 2 );
85
+			add_action('init', array($this, 'maybe_start_session'), - 2);
86 86
 
87 87
 		} else {
88 88
 
89 89
 			// Use WP_Session (default)
90
-			if ( ! defined( 'WP_SESSION_COOKIE' ) ) {
91
-				define( 'WP_SESSION_COOKIE', 'give_wp_session' );
90
+			if ( ! defined('WP_SESSION_COOKIE')) {
91
+				define('WP_SESSION_COOKIE', 'give_wp_session');
92 92
 			}
93 93
 
94
-			if ( ! class_exists( 'Recursive_ArrayAccess' ) ) {
95
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/class-recursive-arrayaccess.php';
94
+			if ( ! class_exists('Recursive_ArrayAccess')) {
95
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/class-recursive-arrayaccess.php';
96 96
 			}
97 97
 
98
-			if ( ! class_exists( 'WP_Session' ) ) {
99
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/class-wp-session.php';
100
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/wp-session.php';
98
+			if ( ! class_exists('WP_Session')) {
99
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/class-wp-session.php';
100
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/wp-session.php';
101 101
 			}
102 102
 
103
-			add_filter( 'wp_session_expiration_variant', array( $this, 'set_expiration_variant_time' ), 99999 );
104
-			add_filter( 'wp_session_expiration', array( $this, 'set_expiration_time' ), 99999 );
103
+			add_filter('wp_session_expiration_variant', array($this, 'set_expiration_variant_time'), 99999);
104
+			add_filter('wp_session_expiration', array($this, 'set_expiration_time'), 99999);
105 105
 
106 106
 		}
107 107
 
108
-		if ( empty( $this->session ) && ! $this->use_php_sessions ) {
109
-			add_action( 'plugins_loaded', array( $this, 'init' ), - 1 );
108
+		if (empty($this->session) && ! $this->use_php_sessions) {
109
+			add_action('plugins_loaded', array($this, 'init'), - 1);
110 110
 		} else {
111
-			add_action( 'init', array( $this, 'init' ), - 1 );
111
+			add_action('init', array($this, 'init'), - 1);
112 112
 		}
113 113
 
114 114
 	}
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
 	 */
123 123
 	public function init() {
124 124
 
125
-		if ( $this->use_php_sessions ) {
126
-			$this->session = isset( $_SESSION[ 'give' . $this->prefix ] ) && is_array( $_SESSION[ 'give' . $this->prefix ] ) ? $_SESSION[ 'give' . $this->prefix ] : array();
125
+		if ($this->use_php_sessions) {
126
+			$this->session = isset($_SESSION['give'.$this->prefix]) && is_array($_SESSION['give'.$this->prefix]) ? $_SESSION['give'.$this->prefix] : array();
127 127
 		} else {
128 128
 			$this->session = WP_Session::get_instance();
129 129
 		}
@@ -155,10 +155,10 @@  discard block
 block discarded – undo
155 155
 	 *
156 156
 	 * @return string Session variable
157 157
 	 */
158
-	public function get( $key ) {
159
-		$key = sanitize_key( $key );
158
+	public function get($key) {
159
+		$key = sanitize_key($key);
160 160
 
161
-		return isset( $this->session[ $key ] ) ? maybe_unserialize( $this->session[ $key ] ) : false;
161
+		return isset($this->session[$key]) ? maybe_unserialize($this->session[$key]) : false;
162 162
 
163 163
 	}
164 164
 
@@ -172,21 +172,21 @@  discard block
 block discarded – undo
172 172
 	 *
173 173
 	 * @return mixed Session variable
174 174
 	 */
175
-	public function set( $key, $value ) {
175
+	public function set($key, $value) {
176 176
 
177
-		$key = sanitize_key( $key );
177
+		$key = sanitize_key($key);
178 178
 
179
-		if ( is_array( $value ) ) {
180
-			$this->session[ $key ] = serialize( $value );
179
+		if (is_array($value)) {
180
+			$this->session[$key] = serialize($value);
181 181
 		} else {
182
-			$this->session[ $key ] = $value;
182
+			$this->session[$key] = $value;
183 183
 		}
184 184
 
185
-		if ( $this->use_php_sessions ) {
186
-			$_SESSION[ 'give' . $this->prefix ] = $this->session;
185
+		if ($this->use_php_sessions) {
186
+			$_SESSION['give'.$this->prefix] = $this->session;
187 187
 		}
188 188
 
189
-		return $this->session[ $key ];
189
+		return $this->session[$key];
190 190
 	}
191 191
 
192 192
 	/**
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 	 */
202 202
 	public function set_expiration_variant_time() {
203 203
 
204
-		return ( ! empty( $this->exp_option ) ? ( intval( $this->exp_option ) - 3600 ) : 30 * 60 * 23 );
204
+		return ( ! empty($this->exp_option) ? (intval($this->exp_option) - 3600) : 30 * 60 * 23);
205 205
 	}
206 206
 
207 207
 	/**
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 	 */
217 217
 	public function set_expiration_time() {
218 218
 
219
-		return ( ! empty( $this->exp_option ) ? intval( $this->exp_option ) : 30 * 60 * 24 );
219
+		return ( ! empty($this->exp_option) ? intval($this->exp_option) : 30 * 60 * 24);
220 220
 	}
221 221
 
222 222
 	/**
@@ -235,21 +235,21 @@  discard block
 block discarded – undo
235 235
 		$ret = false;
236 236
 
237 237
 		// If the database variable is already set, no need to run autodetection
238
-		$give_use_php_sessions = (bool) get_option( 'give_use_php_sessions' );
238
+		$give_use_php_sessions = (bool) get_option('give_use_php_sessions');
239 239
 
240
-		if ( ! $give_use_php_sessions ) {
240
+		if ( ! $give_use_php_sessions) {
241 241
 
242 242
 			// Attempt to detect if the server supports PHP sessions
243
-			if ( function_exists( 'session_start' ) && ! ini_get( 'safe_mode' ) ) {
243
+			if (function_exists('session_start') && ! ini_get('safe_mode')) {
244 244
 
245
-				$this->set( 'give_use_php_sessions', 1 );
245
+				$this->set('give_use_php_sessions', 1);
246 246
 
247
-				if ( $this->get( 'give_use_php_sessions' ) ) {
247
+				if ($this->get('give_use_php_sessions')) {
248 248
 
249 249
 					$ret = true;
250 250
 
251 251
 					// Set the database option
252
-					update_option( 'give_use_php_sessions', true );
252
+					update_option('give_use_php_sessions', true);
253 253
 
254 254
 				}
255 255
 
@@ -260,13 +260,13 @@  discard block
 block discarded – undo
260 260
 		}
261 261
 
262 262
 		// Enable or disable PHP Sessions based on the GIVE_USE_PHP_SESSIONS constant
263
-		if ( defined( 'GIVE_USE_PHP_SESSIONS' ) && GIVE_USE_PHP_SESSIONS ) {
263
+		if (defined('GIVE_USE_PHP_SESSIONS') && GIVE_USE_PHP_SESSIONS) {
264 264
 			$ret = true;
265
-		} else if ( defined( 'GIVE_USE_PHP_SESSIONS' ) && ! GIVE_USE_PHP_SESSIONS ) {
265
+		} else if (defined('GIVE_USE_PHP_SESSIONS') && ! GIVE_USE_PHP_SESSIONS) {
266 266
 			$ret = false;
267 267
 		}
268 268
 
269
-		return (bool) apply_filters( 'give_use_php_sessions', $ret );
269
+		return (bool) apply_filters('give_use_php_sessions', $ret);
270 270
 	}
271 271
 
272 272
 	/**
@@ -279,11 +279,11 @@  discard block
 block discarded – undo
279 279
 
280 280
 //		session_destroy(); //Uncomment for testing ONLY
281 281
 
282
-		if ( ! session_id() && ! headers_sent() ) {
283
-			$lifetime = current_time( 'timestamp' ) + $this->set_expiration_time();
282
+		if ( ! session_id() && ! headers_sent()) {
283
+			$lifetime = current_time('timestamp') + $this->set_expiration_time();
284 284
 			session_start();
285
-			setcookie( session_name(), session_id(), $lifetime ); //
286
-			setcookie( session_name() . '_expiration', $lifetime, $lifetime );
285
+			setcookie(session_name(), session_id(), $lifetime); //
286
+			setcookie(session_name().'_expiration', $lifetime, $lifetime);
287 287
 		}
288 288
 	}
289 289
 
@@ -298,9 +298,9 @@  discard block
 block discarded – undo
298 298
 
299 299
 		$expiration = false;
300 300
 
301
-		if ( session_id() && isset( $_COOKIE[ session_name() . '_expiration' ] ) ) {
301
+		if (session_id() && isset($_COOKIE[session_name().'_expiration'])) {
302 302
 
303
-			$expiration = date( 'D, d M Y h:i:s', intval( $_COOKIE[ session_name() . '_expiration' ] ) );
303
+			$expiration = date('D, d M Y h:i:s', intval($_COOKIE[session_name().'_expiration']));
304 304
 
305 305
 		}
306 306
 
Please login to merge, or discard this patch.
includes/class-give-stats.php 2 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -121,6 +121,7 @@
 block discarded – undo
121 121
 	 *
122 122
 	 * @access public
123 123
 	 * @since  1.0
124
+	 * @param string|boolean $date
124 125
 	 * @return array|WP_Error If the date is invalid, a WP_Error object will be returned
125 126
 	 */
126 127
 	public function convert_date( $date, $end_date = false ) {
Please login to merge, or discard this patch.
Spacing   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -76,19 +76,19 @@  discard block
 block discarded – undo
76 76
 	 */
77 77
 	public function get_predefined_dates() {
78 78
 		$predefined = array(
79
-			'today'        => __( 'Today', 'give' ),
80
-			'yesterday'    => __( 'Yesterday', 'give' ),
81
-			'this_week'    => __( 'This Week', 'give' ),
82
-			'last_week'    => __( 'Last Week', 'give' ),
83
-			'this_month'   => __( 'This Month', 'give' ),
84
-			'last_month'   => __( 'Last Month', 'give' ),
85
-			'this_quarter' => __( 'This Quarter', 'give' ),
86
-			'last_quarter' => __( 'Last Quarter', 'give' ),
87
-			'this_year'    => __( 'This Year', 'give' ),
88
-			'last_year'    => __( 'Last Year', 'give' )
79
+			'today'        => __('Today', 'give'),
80
+			'yesterday'    => __('Yesterday', 'give'),
81
+			'this_week'    => __('This Week', 'give'),
82
+			'last_week'    => __('Last Week', 'give'),
83
+			'this_month'   => __('This Month', 'give'),
84
+			'last_month'   => __('Last Month', 'give'),
85
+			'this_quarter' => __('This Quarter', 'give'),
86
+			'last_quarter' => __('Last Quarter', 'give'),
87
+			'this_year'    => __('This Year', 'give'),
88
+			'last_year'    => __('Last Year', 'give')
89 89
 		);
90 90
 
91
-		return apply_filters( 'give_stats_predefined_dates', $predefined );
91
+		return apply_filters('give_stats_predefined_dates', $predefined);
92 92
 	}
93 93
 
94 94
 	/**
@@ -100,20 +100,20 @@  discard block
 block discarded – undo
100 100
 	 * @since  1.0
101 101
 	 * @return void
102 102
 	 */
103
-	public function setup_dates( $_start_date = 'this_month', $_end_date = false ) {
103
+	public function setup_dates($_start_date = 'this_month', $_end_date = false) {
104 104
 
105
-		if ( empty( $_start_date ) ) {
105
+		if (empty($_start_date)) {
106 106
 			$this->start_date = 'this_month';
107 107
 		}
108 108
 
109 109
 		$this->start_date = $_start_date;
110 110
 
111
-		if( empty( $_end_date ) ) {
111
+		if (empty($_end_date)) {
112 112
 			$_end_date = $_start_date;
113 113
 		}
114 114
 
115
-		$this->start_date = $this->convert_date( $_start_date );
116
-		$this->end_date   = $this->convert_date( $_end_date, true );
115
+		$this->start_date = $this->convert_date($_start_date);
116
+		$this->end_date   = $this->convert_date($_end_date, true);
117 117
 	}
118 118
 
119 119
 	/**
@@ -123,26 +123,26 @@  discard block
 block discarded – undo
123 123
 	 * @since  1.0
124 124
 	 * @return array|WP_Error If the date is invalid, a WP_Error object will be returned
125 125
 	 */
126
-	public function convert_date( $date, $end_date = false ) {
126
+	public function convert_date($date, $end_date = false) {
127 127
 
128 128
 		$timestamp = false;
129 129
 		$second    = 0;
130 130
 		$minute    = 0;
131 131
 		$hour      = 0;
132 132
 		$day       = 1;
133
-		$month     = date( 'n', current_time( 'timestamp' ) );
134
-		$year      = date( 'Y', current_time( 'timestamp' ) );
133
+		$month     = date('n', current_time('timestamp'));
134
+		$year      = date('Y', current_time('timestamp'));
135 135
 
136
-		if ( array_key_exists( $date, $this->get_predefined_dates() ) ) {
136
+		if (array_key_exists($date, $this->get_predefined_dates())) {
137 137
 
138 138
 			// This is a predefined date rate, such as last_week
139
-			switch ( $date ) {
139
+			switch ($date) {
140 140
 
141 141
 				case 'this_month' :
142 142
 
143
-					if ( $end_date ) {
143
+					if ($end_date) {
144 144
 
145
-						$day = cal_days_in_month( CAL_GREGORIAN, $month, $year );
145
+						$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
146 146
 
147 147
 					}
148 148
 
@@ -150,28 +150,28 @@  discard block
 block discarded – undo
150 150
 
151 151
 				case 'last_month' :
152 152
 
153
-					if ( $month == 1 ) {
153
+					if ($month == 1) {
154 154
 
155 155
 						$month = 12;
156
-						$year --;
156
+						$year--;
157 157
 
158 158
 					} else {
159 159
 
160
-						$month --;
160
+						$month--;
161 161
 
162 162
 					}
163 163
 
164
-					if ( $end_date ) {
165
-						$day = cal_days_in_month( CAL_GREGORIAN, $month, $year );
164
+					if ($end_date) {
165
+						$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
166 166
 					}
167 167
 
168 168
 					break;
169 169
 
170 170
 				case 'today' :
171 171
 
172
-					$day = date( 'd', current_time( 'timestamp' ) );
172
+					$day = date('d', current_time('timestamp'));
173 173
 
174
-					if ( $end_date ) {
174
+					if ($end_date) {
175 175
 						$hour   = 11;
176 176
 						$minute = 59;
177 177
 						$second = 59;
@@ -181,23 +181,23 @@  discard block
 block discarded – undo
181 181
 
182 182
 				case 'yesterday' :
183 183
 
184
-					$day = date( 'd', current_time( 'timestamp' ) ) - 1;
184
+					$day = date('d', current_time('timestamp')) - 1;
185 185
 
186 186
 					// Check if Today is the first day of the month (meaning subtracting one will get us 0)
187
-					if ( $day < 1 ) {
187
+					if ($day < 1) {
188 188
 
189 189
 						// If current month is 1
190
-						if ( 1 == $month ) {
190
+						if (1 == $month) {
191 191
 
192 192
 							$year -= 1; // Today is January 1, so skip back to last day of December
193 193
 							$month = 12;
194
-							$day   = cal_days_in_month( CAL_GREGORIAN, $month, $year );
194
+							$day   = cal_days_in_month(CAL_GREGORIAN, $month, $year);
195 195
 
196 196
 						} else {
197 197
 
198 198
 							// Go back one month and get the last day of the month
199 199
 							$month -= 1;
200
-							$day = cal_days_in_month( CAL_GREGORIAN, $month, $year );
200
+							$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
201 201
 
202 202
 						}
203 203
 					}
@@ -206,12 +206,12 @@  discard block
 block discarded – undo
206 206
 
207 207
 				case 'this_week' :
208 208
 
209
-					$days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24;
210
-					$today              = date( 'd', current_time( 'timestamp' ) ) * 60 * 60 * 24;
209
+					$days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24;
210
+					$today              = date('d', current_time('timestamp')) * 60 * 60 * 24;
211 211
 
212
-					if ( $today < $days_to_week_start ) {
212
+					if ($today < $days_to_week_start) {
213 213
 
214
-						if ( $month > 1 ) {
214
+						if ($month > 1) {
215 215
 							$month -= 1;
216 216
 						} else {
217 217
 							$month = 12;
@@ -219,19 +219,19 @@  discard block
 block discarded – undo
219 219
 
220 220
 					}
221 221
 
222
-					if ( ! $end_date ) {
222
+					if ( ! $end_date) {
223 223
 
224 224
 						// Getting the start day
225 225
 
226
-						$day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1;
227
-						$day += get_option( 'start_of_week' );
226
+						$day = date('d', current_time('timestamp') - $days_to_week_start) - 1;
227
+						$day += get_option('start_of_week');
228 228
 
229 229
 					} else {
230 230
 
231 231
 						// Getting the end day
232 232
 
233
-						$day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1;
234
-						$day += get_option( 'start_of_week' ) + 6;
233
+						$day = date('d', current_time('timestamp') - $days_to_week_start) - 1;
234
+						$day += get_option('start_of_week') + 6;
235 235
 
236 236
 					}
237 237
 
@@ -239,12 +239,12 @@  discard block
 block discarded – undo
239 239
 
240 240
 				case 'last_week' :
241 241
 
242
-					$days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24;
243
-					$today              = date( 'd', current_time( 'timestamp' ) ) * 60 * 60 * 24;
242
+					$days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24;
243
+					$today              = date('d', current_time('timestamp')) * 60 * 60 * 24;
244 244
 
245
-					if ( $today < $days_to_week_start ) {
245
+					if ($today < $days_to_week_start) {
246 246
 
247
-						if ( $month > 1 ) {
247
+						if ($month > 1) {
248 248
 							$month -= 1;
249 249
 						} else {
250 250
 							$month = 12;
@@ -252,19 +252,19 @@  discard block
 block discarded – undo
252 252
 
253 253
 					}
254 254
 
255
-					if ( ! $end_date ) {
255
+					if ( ! $end_date) {
256 256
 
257 257
 						// Getting the start day
258 258
 
259
-						$day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8;
260
-						$day += get_option( 'start_of_week' );
259
+						$day = date('d', current_time('timestamp') - $days_to_week_start) - 8;
260
+						$day += get_option('start_of_week');
261 261
 
262 262
 					} else {
263 263
 
264 264
 						// Getting the end day
265 265
 
266
-						$day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8;
267
-						$day += get_option( 'start_of_week' ) + 6;
266
+						$day = date('d', current_time('timestamp') - $days_to_week_start) - 8;
267
+						$day += get_option('start_of_week') + 6;
268 268
 
269 269
 					}
270 270
 
@@ -272,39 +272,39 @@  discard block
 block discarded – undo
272 272
 
273 273
 				case 'this_quarter' :
274 274
 
275
-					$month_now = date( 'n', current_time( 'timestamp' ) );
275
+					$month_now = date('n', current_time('timestamp'));
276 276
 
277
-					if ( $month_now <= 3 ) {
277
+					if ($month_now <= 3) {
278 278
 
279
-						if ( ! $end_date ) {
279
+						if ( ! $end_date) {
280 280
 							$month = 1;
281 281
 						} else {
282 282
 							$month  = 3;
283
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
283
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
284 284
 							$hour   = 11;
285 285
 							$minute = 59;
286 286
 							$second = 59;
287 287
 						}
288 288
 
289
-					} else if ( $month_now <= 6 ) {
289
+					} else if ($month_now <= 6) {
290 290
 
291
-						if ( ! $end_date ) {
291
+						if ( ! $end_date) {
292 292
 							$month = 4;
293 293
 						} else {
294 294
 							$month  = 6;
295
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
295
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
296 296
 							$hour   = 11;
297 297
 							$minute = 59;
298 298
 							$second = 59;
299 299
 						}
300 300
 
301
-					} else if ( $month_now <= 9 ) {
301
+					} else if ($month_now <= 9) {
302 302
 
303
-						if ( ! $end_date ) {
303
+						if ( ! $end_date) {
304 304
 							$month = 7;
305 305
 						} else {
306 306
 							$month  = 9;
307
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
307
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
308 308
 							$hour   = 11;
309 309
 							$minute = 59;
310 310
 							$second = 59;
@@ -312,11 +312,11 @@  discard block
 block discarded – undo
312 312
 
313 313
 					} else {
314 314
 
315
-						if ( ! $end_date ) {
315
+						if ( ! $end_date) {
316 316
 							$month = 10;
317 317
 						} else {
318 318
 							$month  = 12;
319
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
319
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
320 320
 							$hour   = 11;
321 321
 							$minute = 59;
322 322
 							$second = 59;
@@ -328,40 +328,40 @@  discard block
 block discarded – undo
328 328
 
329 329
 				case 'last_quarter' :
330 330
 
331
-					$month_now = date( 'n', current_time( 'timestamp' ) );
331
+					$month_now = date('n', current_time('timestamp'));
332 332
 
333
-					if ( $month_now <= 3 ) {
333
+					if ($month_now <= 3) {
334 334
 
335
-						if ( ! $end_date ) {
335
+						if ( ! $end_date) {
336 336
 							$month = 10;
337 337
 						} else {
338 338
 							$year -= 1;
339 339
 							$month  = 12;
340
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
340
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
341 341
 							$hour   = 11;
342 342
 							$minute = 59;
343 343
 							$second = 59;
344 344
 						}
345 345
 
346
-					} else if ( $month_now <= 6 ) {
346
+					} else if ($month_now <= 6) {
347 347
 
348
-						if ( ! $end_date ) {
348
+						if ( ! $end_date) {
349 349
 							$month = 1;
350 350
 						} else {
351 351
 							$month  = 3;
352
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
352
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
353 353
 							$hour   = 11;
354 354
 							$minute = 59;
355 355
 							$second = 59;
356 356
 						}
357 357
 
358
-					} else if ( $month_now <= 9 ) {
358
+					} else if ($month_now <= 9) {
359 359
 
360
-						if ( ! $end_date ) {
360
+						if ( ! $end_date) {
361 361
 							$month = 4;
362 362
 						} else {
363 363
 							$month  = 6;
364
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
364
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
365 365
 							$hour   = 11;
366 366
 							$minute = 59;
367 367
 							$second = 59;
@@ -369,11 +369,11 @@  discard block
 block discarded – undo
369 369
 
370 370
 					} else {
371 371
 
372
-						if ( ! $end_date ) {
372
+						if ( ! $end_date) {
373 373
 							$month = 7;
374 374
 						} else {
375 375
 							$month  = 9;
376
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
376
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
377 377
 							$hour   = 11;
378 378
 							$minute = 59;
379 379
 							$second = 59;
@@ -385,11 +385,11 @@  discard block
 block discarded – undo
385 385
 
386 386
 				case 'this_year' :
387 387
 
388
-					if ( ! $end_date ) {
388
+					if ( ! $end_date) {
389 389
 						$month = 1;
390 390
 					} else {
391 391
 						$month  = 12;
392
-						$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
392
+						$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
393 393
 						$hour   = 11;
394 394
 						$minute = 59;
395 395
 						$second = 59;
@@ -400,11 +400,11 @@  discard block
 block discarded – undo
400 400
 				case 'last_year' :
401 401
 
402 402
 					$year -= 1;
403
-					if ( ! $end_date ) {
403
+					if ( ! $end_date) {
404 404
 						$month = 1;
405 405
 					} else {
406 406
 						$month  = 12;
407
-						$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
407
+						$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
408 408
 						$hour   = 11;
409 409
 						$minute = 59;
410 410
 						$second = 59;
@@ -415,30 +415,30 @@  discard block
 block discarded – undo
415 415
 			}
416 416
 
417 417
 
418
-		} else if ( is_numeric( $date ) ) {
418
+		} else if (is_numeric($date)) {
419 419
 
420 420
 			// return $date unchanged since it is a timestamp
421 421
 			$this->timestamp = true;
422 422
 
423
-		} else if ( false !== strtotime( $date ) ) {
423
+		} else if (false !== strtotime($date)) {
424 424
 
425 425
 			$this->timestamp = true;
426
-			$date            = strtotime( $date, current_time( 'timestamp' ) );
426
+			$date            = strtotime($date, current_time('timestamp'));
427 427
 
428 428
 		} else {
429 429
 
430
-			return new WP_Error( 'invalid_date', __( 'Improper date provided.', 'give' ) );
430
+			return new WP_Error('invalid_date', __('Improper date provided.', 'give'));
431 431
 
432 432
 		}
433 433
 
434
-		if ( ! is_wp_error( $date ) && ! $this->timestamp ) {
434
+		if ( ! is_wp_error($date) && ! $this->timestamp) {
435 435
 
436 436
 			// Create an exact timestamp
437
-			$date = mktime( $hour, $minute, $second, $month, $day, $year );
437
+			$date = mktime($hour, $minute, $second, $month, $day, $year);
438 438
 
439 439
 		}
440 440
 
441
-		return apply_filters( 'give_stats_date', $date, $end_date, $this );
441
+		return apply_filters('give_stats_date', $date, $end_date, $this);
442 442
 
443 443
 	}
444 444
 
@@ -449,33 +449,33 @@  discard block
 block discarded – undo
449 449
 	 * @since  1.0
450 450
 	 * @return string
451 451
 	 */
452
-	public function count_where( $where = '' ) {
452
+	public function count_where($where = '') {
453 453
 		// Only get payments in our date range
454 454
 
455 455
 		$start_where = '';
456 456
 		$end_where   = '';
457 457
 
458
-		if ( $this->start_date ) {
458
+		if ($this->start_date) {
459 459
 
460
-			if ( $this->timestamp ) {
460
+			if ($this->timestamp) {
461 461
 				$format = 'Y-m-d H:i:s';
462 462
 			} else {
463 463
 				$format = 'Y-m-d 00:00:00';
464 464
 			}
465 465
 
466
-			$start_date  = date( $format, $this->start_date );
466
+			$start_date  = date($format, $this->start_date);
467 467
 			$start_where = " AND p.post_date >= '{$start_date}'";
468 468
 		}
469 469
 
470
-		if ( $this->end_date ) {
470
+		if ($this->end_date) {
471 471
 
472
-			if ( $this->timestamp ) {
472
+			if ($this->timestamp) {
473 473
 				$format = 'Y-m-d H:i:s';
474 474
 			} else {
475 475
 				$format = 'Y-m-d 23:59:59';
476 476
 			}
477 477
 
478
-			$end_date = date( $format, $this->end_date );
478
+			$end_date = date($format, $this->end_date);
479 479
 
480 480
 			$end_where = " AND p.post_date <= '{$end_date}'";
481 481
 		}
@@ -492,34 +492,34 @@  discard block
 block discarded – undo
492 492
 	 * @since  1.0
493 493
 	 * @return string
494 494
 	 */
495
-	public function payments_where( $where = '' ) {
495
+	public function payments_where($where = '') {
496 496
 
497 497
 		global $wpdb;
498 498
 
499 499
 		$start_where = '';
500 500
 		$end_where   = '';
501 501
 
502
-		if ( $this->start_date ) {
502
+		if ($this->start_date) {
503 503
 
504
-			if ( $this->timestamp ) {
504
+			if ($this->timestamp) {
505 505
 				$format = 'Y-m-d H:i:s';
506 506
 			} else {
507 507
 				$format = 'Y-m-d 00:00:00';
508 508
 			}
509 509
 
510
-			$start_date  = date( $format, $this->start_date );
510
+			$start_date  = date($format, $this->start_date);
511 511
 			$start_where = " AND $wpdb->posts.post_date >= '{$start_date}'";
512 512
 		}
513 513
 
514
-		if ( $this->end_date ) {
514
+		if ($this->end_date) {
515 515
 
516
-			if ( $this->timestamp ) {
516
+			if ($this->timestamp) {
517 517
 				$format = 'Y-m-d H:i:s';
518 518
 			} else {
519 519
 				$format = 'Y-m-d 23:59:59';
520 520
 			}
521 521
 
522
-			$end_date = date( $format, $this->end_date );
522
+			$end_date = date($format, $this->end_date);
523 523
 
524 524
 			$end_where = " AND $wpdb->posts.post_date <= '{$end_date}'";
525 525
 		}
Please login to merge, or discard this patch.
includes/emails/class-give-email-tags.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -477,7 +477,7 @@
 block discarded – undo
477 477
  *
478 478
  * @param int $payment_id
479 479
  *
480
- * @return int payment_id
480
+ * @return string payment_id
481 481
  */
482 482
 function give_email_tag_payment_id( $payment_id ) {
483 483
 	return give_get_payment_number( $payment_id );
Please login to merge, or discard this patch.
Spacing   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  */
24 24
 
25 25
 // Exit if accessed directly
26
-if ( ! defined( 'ABSPATH' ) ) {
26
+if ( ! defined('ABSPATH')) {
27 27
 	exit;
28 28
 }
29 29
 
@@ -51,9 +51,9 @@  discard block
 block discarded – undo
51 51
 	 * @param string   $tag  Email tag to be replace in email
52 52
 	 * @param callable $func Hook to run when email tag is found
53 53
 	 */
54
-	public function add( $tag, $description, $func ) {
55
-		if ( is_callable( $func ) ) {
56
-			$this->tags[ $tag ] = array(
54
+	public function add($tag, $description, $func) {
55
+		if (is_callable($func)) {
56
+			$this->tags[$tag] = array(
57 57
 				'tag'         => $tag,
58 58
 				'description' => $description,
59 59
 				'func'        => $func
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
 	 *
69 69
 	 * @param string $tag Email tag to remove hook from
70 70
 	 */
71
-	public function remove( $tag ) {
72
-		unset( $this->tags[ $tag ] );
71
+	public function remove($tag) {
72
+		unset($this->tags[$tag]);
73 73
 	}
74 74
 
75 75
 	/**
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
 	 *
82 82
 	 * @return bool
83 83
 	 */
84
-	public function email_tag_exists( $tag ) {
85
-		return array_key_exists( $tag, $this->tags );
84
+	public function email_tag_exists($tag) {
85
+		return array_key_exists($tag, $this->tags);
86 86
 	}
87 87
 
88 88
 	/**
@@ -106,16 +106,16 @@  discard block
 block discarded – undo
106 106
 	 *
107 107
 	 * @return string Content with email tags filtered out.
108 108
 	 */
109
-	public function do_tags( $content, $payment_id ) {
109
+	public function do_tags($content, $payment_id) {
110 110
 
111 111
 		// Check if there is atleast one tag added
112
-		if ( empty( $this->tags ) || ! is_array( $this->tags ) ) {
112
+		if (empty($this->tags) || ! is_array($this->tags)) {
113 113
 			return $content;
114 114
 		}
115 115
 
116 116
 		$this->payment_id = $payment_id;
117 117
 
118
-		$new_content = preg_replace_callback( "/{([A-z0-9\-\_]+)}/s", array( $this, 'do_tag' ), $content );
118
+		$new_content = preg_replace_callback("/{([A-z0-9\-\_]+)}/s", array($this, 'do_tag'), $content);
119 119
 
120 120
 		$this->payment_id = null;
121 121
 
@@ -131,17 +131,17 @@  discard block
 block discarded – undo
131 131
 	 *
132 132
 	 * @return mixed
133 133
 	 */
134
-	public function do_tag( $m ) {
134
+	public function do_tag($m) {
135 135
 
136 136
 		// Get tag
137 137
 		$tag = $m[1];
138 138
 
139 139
 		// Return tag if tag not set
140
-		if ( ! $this->email_tag_exists( $tag ) ) {
140
+		if ( ! $this->email_tag_exists($tag)) {
141 141
 			return $m[0];
142 142
 		}
143 143
 
144
-		return call_user_func( $this->tags[ $tag ]['func'], $this->payment_id, $tag );
144
+		return call_user_func($this->tags[$tag]['func'], $this->payment_id, $tag);
145 145
 	}
146 146
 
147 147
 }
@@ -155,8 +155,8 @@  discard block
 block discarded – undo
155 155
  * @param string $description Description of the email tag added
156 156
  * @param callable $func Hook to run when email tag is found
157 157
  */
158
-function give_add_email_tag( $tag, $description, $func ) {
159
-	Give()->email_tags->add( $tag, $description, $func );
158
+function give_add_email_tag($tag, $description, $func) {
159
+	Give()->email_tags->add($tag, $description, $func);
160 160
 }
161 161
 
162 162
 /**
@@ -166,8 +166,8 @@  discard block
 block discarded – undo
166 166
  *
167 167
  * @param string $tag Email tag to remove hook from
168 168
  */
169
-function give_remove_email_tag( $tag ) {
170
-	Give()->email_tags->remove( $tag );
169
+function give_remove_email_tag($tag) {
170
+	Give()->email_tags->remove($tag);
171 171
 }
172 172
 
173 173
 /**
@@ -179,8 +179,8 @@  discard block
 block discarded – undo
179 179
  *
180 180
  * @return bool
181 181
  */
182
-function give_email_tag_exists( $tag ) {
183
-	return Give()->email_tags->email_tag_exists( $tag );
182
+function give_email_tag_exists($tag) {
183
+	return Give()->email_tags->email_tag_exists($tag);
184 184
 }
185 185
 
186 186
 /**
@@ -209,13 +209,13 @@  discard block
 block discarded – undo
209 209
 	$email_tags = give_get_email_tags();
210 210
 
211 211
 	// Check
212
-	if ( count( $email_tags ) > 0 ) {
212
+	if (count($email_tags) > 0) {
213 213
 
214 214
 		// Loop
215
-		foreach ( $email_tags as $email_tag ) {
215
+		foreach ($email_tags as $email_tag) {
216 216
 
217 217
 			// Add email tag to list
218
-			$list .= '<code>{' . $email_tag['tag'] . '}</code> - ' . $email_tag['description'] . '<br/>';
218
+			$list .= '<code>{'.$email_tag['tag'].'}</code> - '.$email_tag['description'].'<br/>';
219 219
 
220 220
 		}
221 221
 
@@ -235,13 +235,13 @@  discard block
 block discarded – undo
235 235
  *
236 236
  * @return string Content with email tags filtered out.
237 237
  */
238
-function give_do_email_tags( $content, $payment_id ) {
238
+function give_do_email_tags($content, $payment_id) {
239 239
 
240 240
 	// Replace all tags
241
-	$content = Give()->email_tags->do_tags( $content, $payment_id );
241
+	$content = Give()->email_tags->do_tags($content, $payment_id);
242 242
 
243 243
 	// Maintaining backwards compatibility
244
-	$content = apply_filters( 'give_email_template_tags', $content, give_get_payment_meta( $payment_id ), $payment_id );
244
+	$content = apply_filters('give_email_template_tags', $content, give_get_payment_meta($payment_id), $payment_id);
245 245
 
246 246
 	// Return content
247 247
 	return $content;
@@ -253,10 +253,10 @@  discard block
 block discarded – undo
253 253
  * @since 1.0
254 254
  */
255 255
 function give_load_email_tags() {
256
-	do_action( 'give_add_email_tags' );
256
+	do_action('give_add_email_tags');
257 257
 }
258 258
 
259
-add_action( 'init', 'give_load_email_tags', - 999 );
259
+add_action('init', 'give_load_email_tags', - 999);
260 260
 
261 261
 /**
262 262
  * Add default Give email template tags
@@ -269,82 +269,82 @@  discard block
 block discarded – undo
269 269
 	$email_tags = array(
270 270
 		array(
271 271
 			'tag'         => 'donation',
272
-			'description' => __( "The name of completed donation form.", 'give' ),
272
+			'description' => __("The name of completed donation form.", 'give'),
273 273
 			'function'    => 'give_email_tag_donation'
274 274
 		),
275 275
 		array(
276 276
 			'tag'         => 'name',
277
-			'description' => __( "The donor's first name", 'give' ),
277
+			'description' => __("The donor's first name", 'give'),
278 278
 			'function'    => 'give_email_tag_first_name'
279 279
 		),
280 280
 		array(
281 281
 			'tag'         => 'fullname',
282
-			'description' => __( "The donor's full name, first and last", 'give' ),
282
+			'description' => __("The donor's full name, first and last", 'give'),
283 283
 			'function'    => 'give_email_tag_fullname'
284 284
 		),
285 285
 		array(
286 286
 			'tag'         => 'username',
287
-			'description' => __( "The donor's user name on the site, if they registered an account", 'give' ),
287
+			'description' => __("The donor's user name on the site, if they registered an account", 'give'),
288 288
 			'function'    => 'give_email_tag_username'
289 289
 		),
290 290
 		array(
291 291
 			'tag'         => 'user_email',
292
-			'description' => __( "The donor's email address", 'give' ),
292
+			'description' => __("The donor's email address", 'give'),
293 293
 			'function'    => 'give_email_tag_user_email'
294 294
 		),
295 295
 		array(
296 296
 			'tag'         => 'billing_address',
297
-			'description' => __( 'The donor\'s billing address', 'give' ),
297
+			'description' => __('The donor\'s billing address', 'give'),
298 298
 			'function'    => 'give_email_tag_billing_address'
299 299
 		),
300 300
 		array(
301 301
 			'tag'         => 'date',
302
-			'description' => __( 'The date of the donation', 'give' ),
302
+			'description' => __('The date of the donation', 'give'),
303 303
 			'function'    => 'give_email_tag_date'
304 304
 		),
305 305
 		array(
306 306
 			'tag'         => 'price',
307
-			'description' => __( 'The total price of the donation', 'give' ),
307
+			'description' => __('The total price of the donation', 'give'),
308 308
 			'function'    => 'give_email_tag_price'
309 309
 		),
310 310
 		array(
311 311
 			'tag'         => 'payment_id',
312
-			'description' => __( 'The unique ID number for this donation', 'give' ),
312
+			'description' => __('The unique ID number for this donation', 'give'),
313 313
 			'function'    => 'give_email_tag_payment_id'
314 314
 		),
315 315
 		array(
316 316
 			'tag'         => 'receipt_id',
317
-			'description' => __( 'The unique ID number for this donation receipt', 'give' ),
317
+			'description' => __('The unique ID number for this donation receipt', 'give'),
318 318
 			'function'    => 'give_email_tag_receipt_id'
319 319
 		),
320 320
 		array(
321 321
 			'tag'         => 'payment_method',
322
-			'description' => __( 'The method of payment used for this donation', 'give' ),
322
+			'description' => __('The method of payment used for this donation', 'give'),
323 323
 			'function'    => 'give_email_tag_payment_method'
324 324
 		),
325 325
 		array(
326 326
 			'tag'         => 'sitename',
327
-			'description' => __( 'Your site name', 'give' ),
327
+			'description' => __('Your site name', 'give'),
328 328
 			'function'    => 'give_email_tag_sitename'
329 329
 		),
330 330
 		array(
331 331
 			'tag'         => 'receipt_link',
332
-			'description' => __( 'Adds a link so users can view their receipt directly on your website if they are unable to view it in the browser correctly.', 'give' ),
332
+			'description' => __('Adds a link so users can view their receipt directly on your website if they are unable to view it in the browser correctly.', 'give'),
333 333
 			'function'    => 'give_email_tag_receipt_link'
334 334
 		),
335 335
 	);
336 336
 
337 337
 	// Apply give_email_tags filter
338
-	$email_tags = apply_filters( 'give_email_tags', $email_tags );
338
+	$email_tags = apply_filters('give_email_tags', $email_tags);
339 339
 
340 340
 	// Add email tags
341
-	foreach ( $email_tags as $email_tag ) {
342
-		give_add_email_tag( $email_tag['tag'], $email_tag['description'], $email_tag['function'] );
341
+	foreach ($email_tags as $email_tag) {
342
+		give_add_email_tag($email_tag['tag'], $email_tag['description'], $email_tag['function']);
343 343
 	}
344 344
 
345 345
 }
346 346
 
347
-add_action( 'give_add_email_tags', 'give_setup_email_tags' );
347
+add_action('give_add_email_tags', 'give_setup_email_tags');
348 348
 
349 349
 
350 350
 /**
@@ -355,12 +355,12 @@  discard block
 block discarded – undo
355 355
  *
356 356
  * @return string name
357 357
  */
358
-function give_email_tag_first_name( $payment_id ) {
359
-	$payment_data = give_get_payment_meta( $payment_id );
360
-	if ( empty( $payment_data['user_info'] ) ) {
358
+function give_email_tag_first_name($payment_id) {
359
+	$payment_data = give_get_payment_meta($payment_id);
360
+	if (empty($payment_data['user_info'])) {
361 361
 		return '';
362 362
 	}
363
-	$email_name = give_get_email_names( $payment_data['user_info'] );
363
+	$email_name = give_get_email_names($payment_data['user_info']);
364 364
 
365 365
 	return $email_name['name'];
366 366
 }
@@ -373,12 +373,12 @@  discard block
 block discarded – undo
373 373
  *
374 374
  * @return string fullname
375 375
  */
376
-function give_email_tag_fullname( $payment_id ) {
377
-	$payment_data = give_get_payment_meta( $payment_id );
378
-	if ( empty( $payment_data['user_info'] ) ) {
376
+function give_email_tag_fullname($payment_id) {
377
+	$payment_data = give_get_payment_meta($payment_id);
378
+	if (empty($payment_data['user_info'])) {
379 379
 		return '';
380 380
 	}
381
-	$email_name = give_get_email_names( $payment_data['user_info'] );
381
+	$email_name = give_get_email_names($payment_data['user_info']);
382 382
 
383 383
 	return $email_name['fullname'];
384 384
 }
@@ -391,12 +391,12 @@  discard block
 block discarded – undo
391 391
  *
392 392
  * @return string username
393 393
  */
394
-function give_email_tag_username( $payment_id ) {
395
-	$payment_data = give_get_payment_meta( $payment_id );
396
-	if ( empty( $payment_data['user_info'] ) ) {
394
+function give_email_tag_username($payment_id) {
395
+	$payment_data = give_get_payment_meta($payment_id);
396
+	if (empty($payment_data['user_info'])) {
397 397
 		return '';
398 398
 	}
399
-	$email_name = give_get_email_names( $payment_data['user_info'] );
399
+	$email_name = give_get_email_names($payment_data['user_info']);
400 400
 
401 401
 	return $email_name['username'];
402 402
 }
@@ -409,8 +409,8 @@  discard block
 block discarded – undo
409 409
  *
410 410
  * @return string user_email
411 411
  */
412
-function give_email_tag_user_email( $payment_id ) {
413
-	return give_get_payment_user_email( $payment_id );
412
+function give_email_tag_user_email($payment_id) {
413
+	return give_get_payment_user_email($payment_id);
414 414
 }
415 415
 
416 416
 /**
@@ -421,10 +421,10 @@  discard block
 block discarded – undo
421 421
  *
422 422
  * @return string billing_address
423 423
  */
424
-function give_email_tag_billing_address( $payment_id ) {
424
+function give_email_tag_billing_address($payment_id) {
425 425
 
426
-	$user_info    = give_get_payment_meta_user_info( $payment_id );
427
-	$user_address = ! empty( $user_info['address'] ) ? $user_info['address'] : array(
426
+	$user_info    = give_get_payment_meta_user_info($payment_id);
427
+	$user_address = ! empty($user_info['address']) ? $user_info['address'] : array(
428 428
 		'line1'   => '',
429 429
 		'line2'   => '',
430 430
 		'city'    => '',
@@ -433,11 +433,11 @@  discard block
 block discarded – undo
433 433
 		'zip'     => ''
434 434
 	);
435 435
 
436
-	$return = $user_address['line1'] . "\n";
437
-	if ( ! empty( $user_address['line2'] ) ) {
438
-		$return .= $user_address['line2'] . "\n";
436
+	$return = $user_address['line1']."\n";
437
+	if ( ! empty($user_address['line2'])) {
438
+		$return .= $user_address['line2']."\n";
439 439
 	}
440
-	$return .= $user_address['city'] . ' ' . $user_address['zip'] . ' ' . $user_address['state'] . "\n";
440
+	$return .= $user_address['city'].' '.$user_address['zip'].' '.$user_address['state']."\n";
441 441
 	$return .= $user_address['country'];
442 442
 
443 443
 	return $return;
@@ -451,10 +451,10 @@  discard block
 block discarded – undo
451 451
  *
452 452
  * @return string date
453 453
  */
454
-function give_email_tag_date( $payment_id ) {
455
-	$payment_data = give_get_payment_meta( $payment_id );
454
+function give_email_tag_date($payment_id) {
455
+	$payment_data = give_get_payment_meta($payment_id);
456 456
 
457
-	return date_i18n( get_option( 'date_format' ), strtotime( $payment_data['date'] ) );
457
+	return date_i18n(get_option('date_format'), strtotime($payment_data['date']));
458 458
 }
459 459
 
460 460
 /**
@@ -465,10 +465,10 @@  discard block
 block discarded – undo
465 465
  *
466 466
  * @return string price
467 467
  */
468
-function give_email_tag_price( $payment_id ) {
469
-	$price = give_currency_filter( give_format_amount( give_get_payment_amount( $payment_id ) ), give_get_payment_currency_code( $payment_id ) );
468
+function give_email_tag_price($payment_id) {
469
+	$price = give_currency_filter(give_format_amount(give_get_payment_amount($payment_id)), give_get_payment_currency_code($payment_id));
470 470
 
471
-	return html_entity_decode( $price, ENT_COMPAT, 'UTF-8' );
471
+	return html_entity_decode($price, ENT_COMPAT, 'UTF-8');
472 472
 }
473 473
 
474 474
 /**
@@ -479,8 +479,8 @@  discard block
 block discarded – undo
479 479
  *
480 480
  * @return int payment_id
481 481
  */
482
-function give_email_tag_payment_id( $payment_id ) {
483
-	return give_get_payment_number( $payment_id );
482
+function give_email_tag_payment_id($payment_id) {
483
+	return give_get_payment_number($payment_id);
484 484
 }
485 485
 
486 486
 /**
@@ -491,8 +491,8 @@  discard block
 block discarded – undo
491 491
  *
492 492
  * @return string receipt_id
493 493
  */
494
-function give_email_tag_receipt_id( $payment_id ) {
495
-	return give_get_payment_key( $payment_id );
494
+function give_email_tag_receipt_id($payment_id) {
495
+	return give_get_payment_key($payment_id);
496 496
 }
497 497
 
498 498
 /**
@@ -503,9 +503,9 @@  discard block
 block discarded – undo
503 503
  *
504 504
  * @return string $form_title
505 505
  */
506
-function give_email_tag_donation( $payment_id ) {
507
-	$payment_data = give_get_payment_meta( $payment_id );
508
-	$form_title   = ( ! empty( $payment_data['form_title'] ) ? $payment_data['form_title'] : __( 'There was an error retrieving this donation title', 'give' ) );
506
+function give_email_tag_donation($payment_id) {
507
+	$payment_data = give_get_payment_meta($payment_id);
508
+	$form_title   = ( ! empty($payment_data['form_title']) ? $payment_data['form_title'] : __('There was an error retrieving this donation title', 'give'));
509 509
 
510 510
 	return $form_title;
511 511
 }
@@ -518,8 +518,8 @@  discard block
 block discarded – undo
518 518
  *
519 519
  * @return string gateway
520 520
  */
521
-function give_email_tag_payment_method( $payment_id ) {
522
-	return give_get_gateway_checkout_label( give_get_payment_gateway( $payment_id ) );
521
+function give_email_tag_payment_method($payment_id) {
522
+	return give_get_gateway_checkout_label(give_get_payment_gateway($payment_id));
523 523
 }
524 524
 
525 525
 /**
@@ -530,8 +530,8 @@  discard block
 block discarded – undo
530 530
  *
531 531
  * @return string sitename
532 532
  */
533
-function give_email_tag_sitename( $payment_id ) {
534
-	return wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES );
533
+function give_email_tag_sitename($payment_id) {
534
+	return wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
535 535
 }
536 536
 
537 537
 /**
@@ -542,9 +542,9 @@  discard block
 block discarded – undo
542 542
  *
543 543
  * @return string receipt_link
544 544
  */
545
-function give_email_tag_receipt_link( $payment_id ) {
546
-	return sprintf( __( '%1$sView it in your browser.%2$s', 'give' ), '<a href="' . esc_url( add_query_arg( array(
547
-			'payment_key' => give_get_payment_key( $payment_id ),
545
+function give_email_tag_receipt_link($payment_id) {
546
+	return sprintf(__('%1$sView it in your browser.%2$s', 'give'), '<a href="'.esc_url(add_query_arg(array(
547
+			'payment_key' => give_get_payment_key($payment_id),
548 548
 			'give_action' => 'view_receipt'
549
-		), home_url() ) ) . '">', '</a>' );
549
+		), home_url())).'">', '</a>');
550 550
 }
551 551
\ No newline at end of file
Please login to merge, or discard this patch.
includes/forms/functions.php 2 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
  * Used to redirect a user back to the purchase
155 155
  * page if there are errors present.
156 156
  *
157
- * @param array $args
157
+ * @param string $args
158 158
  *
159 159
  * @access public
160 160
  * @since  1.0
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
  *
660 660
  * @param int $form_id ID of the form
661 661
  *
662
- * @return float Amount of the lowest price
662
+ * @return string Amount of the lowest price
663 663
  */
664 664
 function give_get_lowest_price_option( $form_id = 0 ) {
665 665
 	if ( empty( $form_id ) ) {
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
  *
708 708
  * @param int $form_id ID of the form
709 709
  *
710
- * @return float Amount of the highest price
710
+ * @return string Amount of the highest price
711 711
  */
712 712
 function give_get_highest_price_option( $form_id = 0 ) {
713 713
 
@@ -753,7 +753,7 @@  discard block
 block discarded – undo
753 753
  *
754 754
  * @param int $form_id ID number of the form to retrieve a price for
755 755
  *
756
- * @return mixed string|int Price of the form
756
+ * @return string string|int Price of the form
757 757
  */
758 758
 function give_get_form_price( $form_id = 0 ) {
759 759
 
@@ -858,7 +858,7 @@  discard block
 block discarded – undo
858 858
  *
859 859
  * @param int $form_id ID number of the form to retrieve a goal for
860 860
  *
861
- * @return mixed string|int Goal of the form
861
+ * @return string string|int Goal of the form
862 862
  */
863 863
 function give_get_form_goal( $form_id = 0 ) {
864 864
 
Please login to merge, or discard this patch.
Spacing   +174 added lines, -174 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
 
@@ -23,14 +23,14 @@  discard block
 block discarded – undo
23 23
 
24 24
 	global $typenow;
25 25
 
26
-	if ( $typenow != 'give_forms' && $typenow != 'give_campaigns' ) {
26
+	if ($typenow != 'give_forms' && $typenow != 'give_campaigns') {
27 27
 		return true;
28 28
 	}
29 29
 
30 30
 	return false;
31 31
 }
32 32
 
33
-add_filter( 'give_shortcode_button_condition', 'give_shortcode_button_condition' );
33
+add_filter('give_shortcode_button_condition', 'give_shortcode_button_condition');
34 34
 
35 35
 
36 36
 /**
@@ -40,11 +40,11 @@  discard block
 block discarded – undo
40 40
  *
41 41
  * @return int|false
42 42
  */
43
-function get_form_id_from_args( $args ) {
43
+function get_form_id_from_args($args) {
44 44
 
45
-	if ( isset( $args['form_id'] ) && $args['form_id'] != 0 ) {
45
+	if (isset($args['form_id']) && $args['form_id'] != 0) {
46 46
 
47
-		return intval( $args['form_id'] );
47
+		return intval($args['form_id']);
48 48
 	}
49 49
 
50 50
 	return false;
@@ -59,23 +59,23 @@  discard block
 block discarded – undo
59 59
  *
60 60
  * @return bool
61 61
  */
62
-function give_is_float_labels_enabled( $args ) {
62
+function give_is_float_labels_enabled($args) {
63 63
 
64 64
 	$float_labels = '';
65 65
 
66
-	if ( ! empty( $args['float_labels'] ) ) {
66
+	if ( ! empty($args['float_labels'])) {
67 67
 		$float_labels = $args['float_labels'];
68 68
 	}
69 69
 
70
-	if ( empty( $float_labels ) ) {
71
-		$float_labels = get_post_meta( $args['form_id'], '_give_form_floating_labels', true );
70
+	if (empty($float_labels)) {
71
+		$float_labels = get_post_meta($args['form_id'], '_give_form_floating_labels', true);
72 72
 	}
73 73
 
74
-	if ( empty( $float_labels ) ) {
75
-		$float_labels = give_get_option( 'enable_floatlabels' ) ? 'enabled' : 'disabled';
74
+	if (empty($float_labels)) {
75
+		$float_labels = give_get_option('enable_floatlabels') ? 'enabled' : 'disabled';
76 76
 	}
77 77
 
78
-	return ( $float_labels == 'enabled' ) ? true : false;
78
+	return ($float_labels == 'enabled') ? true : false;
79 79
 }
80 80
 
81 81
 /**
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 
91 91
 	$can_checkout = true; // Always true for now
92 92
 
93
-	return (bool) apply_filters( 'give_can_checkout', $can_checkout );
93
+	return (bool) apply_filters('give_can_checkout', $can_checkout);
94 94
 }
95 95
 
96 96
 /**
@@ -103,9 +103,9 @@  discard block
 block discarded – undo
103 103
 function give_get_success_page_uri() {
104 104
 	global $give_options;
105 105
 
106
-	$success_page = isset( $give_options['success_page'] ) ? get_permalink( absint( $give_options['success_page'] ) ) : get_bloginfo( 'url' );
106
+	$success_page = isset($give_options['success_page']) ? get_permalink(absint($give_options['success_page'])) : get_bloginfo('url');
107 107
 
108
-	return apply_filters( 'give_get_success_page_uri', $success_page );
108
+	return apply_filters('give_get_success_page_uri', $success_page);
109 109
 }
110 110
 
111 111
 /**
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
  */
117 117
 function give_is_success_page() {
118 118
 	global $give_options;
119
-	$is_success_page = isset( $give_options['success_page'] ) ? is_page( $give_options['success_page'] ) : false;
119
+	$is_success_page = isset($give_options['success_page']) ? is_page($give_options['success_page']) : false;
120 120
 
121
-	return apply_filters( 'give_is_success_page', $is_success_page );
121
+	return apply_filters('give_is_success_page', $is_success_page);
122 122
 }
123 123
 
124 124
 /**
@@ -132,18 +132,18 @@  discard block
 block discarded – undo
132 132
  * @since       1.0
133 133
  * @return      void
134 134
  */
135
-function give_send_to_success_page( $query_string = null ) {
135
+function give_send_to_success_page($query_string = null) {
136 136
 	global $give_options;
137 137
 
138 138
 	$redirect = give_get_success_page_uri();
139 139
 
140
-	if ( $query_string ) {
140
+	if ($query_string) {
141 141
 		$redirect .= $query_string;
142 142
 	}
143 143
 
144
-	$gateway = isset( $_REQUEST['give-gateway'] ) ? $_REQUEST['give-gateway'] : '';
144
+	$gateway = isset($_REQUEST['give-gateway']) ? $_REQUEST['give-gateway'] : '';
145 145
 
146
-	wp_redirect( apply_filters( 'give_success_page_redirect', $redirect, $gateway, $query_string ) );
146
+	wp_redirect(apply_filters('give_success_page_redirect', $redirect, $gateway, $query_string));
147 147
 	give_die();
148 148
 }
149 149
 
@@ -160,25 +160,25 @@  discard block
 block discarded – undo
160 160
  * @since  1.0
161 161
  * @return Void
162 162
  */
163
-function give_send_back_to_checkout( $args = array() ) {
163
+function give_send_back_to_checkout($args = array()) {
164 164
 
165
-	$redirect = ( isset( $_POST['give-current-url'] ) ) ? $_POST['give-current-url'] : '';
166
-	$form_id  = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : 0;
165
+	$redirect = (isset($_POST['give-current-url'])) ? $_POST['give-current-url'] : '';
166
+	$form_id  = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : 0;
167 167
 
168 168
 	$defaults = array(
169 169
 		'form-id' => (int) $form_id
170 170
 	);
171 171
 
172 172
 	// Check for backward compatibility
173
-	if ( is_string( $args ) ) {
174
-		$args = str_replace( '?', '', $args );
173
+	if (is_string($args)) {
174
+		$args = str_replace('?', '', $args);
175 175
 	}
176 176
 
177
-	$args = wp_parse_args( $args, $defaults );
177
+	$args = wp_parse_args($args, $defaults);
178 178
 
179
-	$redirect = add_query_arg( $args, $redirect ) . '#give-form-' . $form_id . '-wrap';
179
+	$redirect = add_query_arg($args, $redirect).'#give-form-'.$form_id.'-wrap';
180 180
 
181
-	wp_redirect( apply_filters( 'give_send_back_to_checkout', $redirect, $args ) );
181
+	wp_redirect(apply_filters('give_send_back_to_checkout', $redirect, $args));
182 182
 	give_die();
183 183
 }
184 184
 
@@ -193,15 +193,15 @@  discard block
 block discarded – undo
193 193
  * @since       1.0
194 194
  * @return      string
195 195
  */
196
-function give_get_success_page_url( $query_string = null ) {
196
+function give_get_success_page_url($query_string = null) {
197 197
 	global $give_options;
198 198
 
199
-	$success_page = get_permalink( $give_options['success_page'] );
200
-	if ( $query_string ) {
199
+	$success_page = get_permalink($give_options['success_page']);
200
+	if ($query_string) {
201 201
 		$success_page .= $query_string;
202 202
 	}
203 203
 
204
-	return apply_filters( 'give_success_page_url', $success_page );
204
+	return apply_filters('give_success_page_url', $success_page);
205 205
 }
206 206
 
207 207
 /**
@@ -214,15 +214,15 @@  discard block
 block discarded – undo
214 214
  *
215 215
  * @return mixed|void Full URL to the Transaction Failed page, if present, home page if it doesn't exist
216 216
  */
217
-function give_get_failed_transaction_uri( $extras = false ) {
217
+function give_get_failed_transaction_uri($extras = false) {
218 218
 	global $give_options;
219 219
 
220
-	$uri = ! empty( $give_options['failure_page'] ) ? trailingslashit( get_permalink( $give_options['failure_page'] ) ) : home_url();
221
-	if ( $extras ) {
220
+	$uri = ! empty($give_options['failure_page']) ? trailingslashit(get_permalink($give_options['failure_page'])) : home_url();
221
+	if ($extras) {
222 222
 		$uri .= $extras;
223 223
 	}
224 224
 
225
-	return apply_filters( 'give_get_failed_transaction_uri', $uri );
225
+	return apply_filters('give_get_failed_transaction_uri', $uri);
226 226
 }
227 227
 
228 228
 /**
@@ -233,9 +233,9 @@  discard block
 block discarded – undo
233 233
  */
234 234
 function give_is_failed_transaction_page() {
235 235
 	global $give_options;
236
-	$ret = isset( $give_options['failure_page'] ) ? is_page( $give_options['failure_page'] ) : false;
236
+	$ret = isset($give_options['failure_page']) ? is_page($give_options['failure_page']) : false;
237 237
 
238
-	return apply_filters( 'give_is_failure_page', $ret );
238
+	return apply_filters('give_is_failure_page', $ret);
239 239
 }
240 240
 
241 241
 /**
@@ -247,18 +247,18 @@  discard block
 block discarded – undo
247 247
  */
248 248
 function give_listen_for_failed_payments() {
249 249
 
250
-	$failed_page = give_get_option( 'failure_page', 0 );
250
+	$failed_page = give_get_option('failure_page', 0);
251 251
 
252
-	if ( ! empty( $failed_page ) && is_page( $failed_page ) && ! empty( $_GET['payment-id'] ) ) {
252
+	if ( ! empty($failed_page) && is_page($failed_page) && ! empty($_GET['payment-id'])) {
253 253
 
254
-		$payment_id = absint( $_GET['payment-id'] );
255
-		give_update_payment_status( $payment_id, 'failed' );
254
+		$payment_id = absint($_GET['payment-id']);
255
+		give_update_payment_status($payment_id, 'failed');
256 256
 
257 257
 	}
258 258
 
259 259
 }
260 260
 
261
-add_action( 'template_redirect', 'give_listen_for_failed_payments' );
261
+add_action('template_redirect', 'give_listen_for_failed_payments');
262 262
 
263 263
 
264 264
 /**
@@ -271,11 +271,11 @@  discard block
 block discarded – undo
271 271
  * @since       1.0
272 272
  * @return      bool
273 273
  */
274
-function give_field_is_required( $field = '', $form_id ) {
274
+function give_field_is_required($field = '', $form_id) {
275 275
 
276
-	$required_fields = give_purchase_form_required_fields( $form_id );
276
+	$required_fields = give_purchase_form_required_fields($form_id);
277 277
 
278
-	return array_key_exists( $field, $required_fields );
278
+	return array_key_exists($field, $required_fields);
279 279
 }
280 280
 
281 281
 /**
@@ -285,9 +285,9 @@  discard block
 block discarded – undo
285 285
  * @return      array
286 286
  */
287 287
 function give_get_banned_emails() {
288
-	$emails = array_map( 'trim', give_get_option( 'banned_emails', array() ) );
288
+	$emails = array_map('trim', give_get_option('banned_emails', array()));
289 289
 
290
-	return apply_filters( 'give_get_banned_emails', $emails );
290
+	return apply_filters('give_get_banned_emails', $emails);
291 291
 }
292 292
 
293 293
 /**
@@ -296,15 +296,15 @@  discard block
 block discarded – undo
296 296
  * @since       2.0
297 297
  * @return      bool
298 298
  */
299
-function give_is_email_banned( $email = '' ) {
299
+function give_is_email_banned($email = '') {
300 300
 
301
-	if ( empty( $email ) ) {
301
+	if (empty($email)) {
302 302
 		return false;
303 303
 	}
304 304
 
305
-	$ret = in_array( trim( $email ), give_get_banned_emails() );
305
+	$ret = in_array(trim($email), give_get_banned_emails());
306 306
 
307
-	return apply_filters( 'give_is_email_banned', $ret, $email );
307
+	return apply_filters('give_is_email_banned', $ret, $email);
308 308
 }
309 309
 
310 310
 /**
@@ -314,9 +314,9 @@  discard block
 block discarded – undo
314 314
  * @return      bool True if enforce SSL is enabled, false otherwise
315 315
  */
316 316
 function give_is_ssl_enforced() {
317
-	$ssl_enforced = give_get_option( 'enforce_ssl', false );
317
+	$ssl_enforced = give_get_option('enforce_ssl', false);
318 318
 
319
-	return (bool) apply_filters( 'give_is_ssl_enforced', $ssl_enforced );
319
+	return (bool) apply_filters('give_is_ssl_enforced', $ssl_enforced);
320 320
 }
321 321
 
322 322
 /**
@@ -327,17 +327,17 @@  discard block
 block discarded – undo
327 327
  * @return void
328 328
  */
329 329
 function give_enforced_ssl_redirect_handler() {
330
-	if ( ! give_is_ssl_enforced() || is_admin() || is_ssl() ) {
330
+	if ( ! give_is_ssl_enforced() || is_admin() || is_ssl()) {
331 331
 		return;
332 332
 	}
333 333
 
334
-	if ( isset( $_SERVER["HTTPS"] ) && $_SERVER["HTTPS"] == "on" ) {
334
+	if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") {
335 335
 		return;
336 336
 	}
337 337
 
338
-	$uri = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
338
+	$uri = 'https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
339 339
 
340
-	wp_safe_redirect( $uri );
340
+	wp_safe_redirect($uri);
341 341
 	exit;
342 342
 }
343 343
 
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
  * @return void
351 351
  */
352 352
 function give_enforced_ssl_asset_handler() {
353
-	if ( ! give_is_ssl_enforced() || is_admin() ) {
353
+	if ( ! give_is_ssl_enforced() || is_admin()) {
354 354
 		return;
355 355
 	}
356 356
 
@@ -368,10 +368,10 @@  discard block
 block discarded – undo
368 368
 		'site_url'
369 369
 	);
370 370
 
371
-	$filters = apply_filters( 'give_enforced_ssl_asset_filters', $filters );
371
+	$filters = apply_filters('give_enforced_ssl_asset_filters', $filters);
372 372
 
373
-	foreach ( $filters as $filter ) {
374
-		add_filter( $filter, 'give_enforced_ssl_asset_filter', 1 );
373
+	foreach ($filters as $filter) {
374
+		add_filter($filter, 'give_enforced_ssl_asset_filter', 1);
375 375
 	}
376 376
 }
377 377
 
@@ -386,11 +386,11 @@  discard block
 block discarded – undo
386 386
  *
387 387
  * @return mixed
388 388
  */
389
-function give_enforced_ssl_asset_filter( $content ) {
389
+function give_enforced_ssl_asset_filter($content) {
390 390
 
391
-	if ( is_array( $content ) ) {
391
+	if (is_array($content)) {
392 392
 
393
-		$content = array_map( 'give_enforced_ssl_asset_filter', $content );
393
+		$content = array_map('give_enforced_ssl_asset_filter', $content);
394 394
 
395 395
 	} else {
396 396
 
@@ -437,14 +437,14 @@  discard block
 block discarded – undo
437 437
  *
438 438
  * @return void
439 439
  */
440
-function give_record_sale_in_log( $give_form_id = 0, $payment_id, $price_id = false, $sale_date = null ) {
440
+function give_record_sale_in_log($give_form_id = 0, $payment_id, $price_id = false, $sale_date = null) {
441 441
 	global $give_logs;
442 442
 
443 443
 	$log_data = array(
444 444
 		'post_parent'   => $give_form_id,
445 445
 		'log_type'      => 'sale',
446
-		'post_date'     => isset( $sale_date ) ? $sale_date : null,
447
-		'post_date_gmt' => isset( $sale_date ) ? $sale_date : null
446
+		'post_date'     => isset($sale_date) ? $sale_date : null,
447
+		'post_date_gmt' => isset($sale_date) ? $sale_date : null
448 448
 	);
449 449
 
450 450
 	$log_meta = array(
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
 		'price_id'   => (int) $price_id
453 453
 	);
454 454
 
455
-	$give_logs->insert_log( $log_data, $log_meta );
455
+	$give_logs->insert_log($log_data, $log_meta);
456 456
 }
457 457
 
458 458
 
@@ -465,8 +465,8 @@  discard block
 block discarded – undo
465 465
  *
466 466
  * @return bool|int
467 467
  */
468
-function give_increase_purchase_count( $give_form_id = 0 ) {
469
-	$form = new Give_Donate_Form( $give_form_id );
468
+function give_increase_purchase_count($give_form_id = 0) {
469
+	$form = new Give_Donate_Form($give_form_id);
470 470
 
471 471
 	return $form->increase_sales();
472 472
 }
@@ -480,8 +480,8 @@  discard block
 block discarded – undo
480 480
  *
481 481
  * @return bool|int
482 482
  */
483
-function give_decrease_purchase_count( $give_form_id = 0 ) {
484
-	$form = new Give_Donate_Form( $give_form_id );
483
+function give_decrease_purchase_count($give_form_id = 0) {
484
+	$form = new Give_Donate_Form($give_form_id);
485 485
 
486 486
 	return $form->decrease_sales();
487 487
 }
@@ -496,10 +496,10 @@  discard block
 block discarded – undo
496 496
  *
497 497
  * @return bool|int
498 498
  */
499
-function give_increase_earnings( $give_form_id = 0, $amount ) {
500
-	$form = new Give_Donate_Form( $give_form_id );
499
+function give_increase_earnings($give_form_id = 0, $amount) {
500
+	$form = new Give_Donate_Form($give_form_id);
501 501
 
502
-	return $form->increase_earnings( $amount );
502
+	return $form->increase_earnings($amount);
503 503
 }
504 504
 
505 505
 /**
@@ -512,10 +512,10 @@  discard block
 block discarded – undo
512 512
  *
513 513
  * @return bool|int
514 514
  */
515
-function give_decrease_earnings( $give_form_id = 0, $amount ) {
516
-	$form = new Give_Donate_Form( $give_form_id );
515
+function give_decrease_earnings($give_form_id = 0, $amount) {
516
+	$form = new Give_Donate_Form($give_form_id);
517 517
 
518
-	return $form->decrease_earnings( $amount );
518
+	return $form->decrease_earnings($amount);
519 519
 }
520 520
 
521 521
 
@@ -528,8 +528,8 @@  discard block
 block discarded – undo
528 528
  *
529 529
  * @return int $earnings Earnings for a certain form
530 530
  */
531
-function give_get_form_earnings_stats( $give_form_id = 0 ) {
532
-	$give_form = new Give_Donate_Form( $give_form_id );
531
+function give_get_form_earnings_stats($give_form_id = 0) {
532
+	$give_form = new Give_Donate_Form($give_form_id);
533 533
 
534 534
 	return $give_form->earnings;
535 535
 }
@@ -544,8 +544,8 @@  discard block
 block discarded – undo
544 544
  *
545 545
  * @return int $sales Amount of sales for a certain form
546 546
  */
547
-function give_get_form_sales_stats( $give_form_id = 0 ) {
548
-	$give_form = new Give_Donate_Form( $give_form_id );
547
+function give_get_form_sales_stats($give_form_id = 0) {
548
+	$give_form = new Give_Donate_Form($give_form_id);
549 549
 
550 550
 	return $give_form->sales;
551 551
 }
@@ -560,16 +560,16 @@  discard block
 block discarded – undo
560 560
  *
561 561
  * @return float $sales Average monthly sales
562 562
  */
563
-function give_get_average_monthly_form_sales( $form_id = 0 ) {
564
-	$sales        = give_get_form_sales_stats( $form_id );
565
-	$release_date = get_post_field( 'post_date', $form_id );
563
+function give_get_average_monthly_form_sales($form_id = 0) {
564
+	$sales        = give_get_form_sales_stats($form_id);
565
+	$release_date = get_post_field('post_date', $form_id);
566 566
 
567
-	$diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) );
567
+	$diff = abs(current_time('timestamp') - strtotime($release_date));
568 568
 
569
-	$months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication
569
+	$months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication
570 570
 
571
-	if ( $months > 0 ) {
572
-		$sales = ( $sales / $months );
571
+	if ($months > 0) {
572
+		$sales = ($sales / $months);
573 573
 	}
574 574
 
575 575
 	return $sales;
@@ -585,16 +585,16 @@  discard block
 block discarded – undo
585 585
  *
586 586
  * @return float $earnings Average monthly earnings
587 587
  */
588
-function give_get_average_monthly_form_earnings( $form_id = 0 ) {
589
-	$earnings     = give_get_form_earnings_stats( $form_id );
590
-	$release_date = get_post_field( 'post_date', $form_id );
588
+function give_get_average_monthly_form_earnings($form_id = 0) {
589
+	$earnings     = give_get_form_earnings_stats($form_id);
590
+	$release_date = get_post_field('post_date', $form_id);
591 591
 
592
-	$diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) );
592
+	$diff = abs(current_time('timestamp') - strtotime($release_date));
593 593
 
594
-	$months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication
594
+	$months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication
595 595
 
596
-	if ( $months > 0 ) {
597
-		$earnings = ( $earnings / $months );
596
+	if ($months > 0) {
597
+		$earnings = ($earnings / $months);
598 598
 	}
599 599
 
600 600
 	return $earnings < 0 ? 0 : $earnings;
@@ -614,21 +614,21 @@  discard block
 block discarded – undo
614 614
  *
615 615
  * @return string $price_name Name of the price option
616 616
  */
617
-function give_get_price_option_name( $form_id = 0, $price_id = 0, $payment_id = 0 ) {
617
+function give_get_price_option_name($form_id = 0, $price_id = 0, $payment_id = 0) {
618 618
 
619
-	$prices     = give_get_variable_prices( $form_id );
619
+	$prices     = give_get_variable_prices($form_id);
620 620
 	$price_name = '';
621 621
 
622
-	foreach ( $prices as $price ) {
622
+	foreach ($prices as $price) {
623 623
 
624
-		if ( $price['_give_id']['level_id'] === $price_id ) {
625
-			$price_name = isset( $price['_give_text'] ) ? $price['_give_text'] : '';
624
+		if ($price['_give_id']['level_id'] === $price_id) {
625
+			$price_name = isset($price['_give_text']) ? $price['_give_text'] : '';
626 626
 		}
627 627
 
628 628
 	}
629 629
 
630 630
 
631
-	return apply_filters( 'give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id );
631
+	return apply_filters('give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id);
632 632
 }
633 633
 
634 634
 
@@ -641,14 +641,14 @@  discard block
 block discarded – undo
641 641
  *
642 642
  * @return string $range A fully formatted price range
643 643
  */
644
-function give_price_range( $form_id = 0 ) {
645
-	$low   = give_get_lowest_price_option( $form_id );
646
-	$high  = give_get_highest_price_option( $form_id );
647
-	$range = '<span class="give_price_range_low">' . give_currency_filter( give_format_amount( $low ) ) . '</span>';
644
+function give_price_range($form_id = 0) {
645
+	$low   = give_get_lowest_price_option($form_id);
646
+	$high  = give_get_highest_price_option($form_id);
647
+	$range = '<span class="give_price_range_low">'.give_currency_filter(give_format_amount($low)).'</span>';
648 648
 	$range .= '<span class="give_price_range_sep">&nbsp;&ndash;&nbsp;</span>';
649
-	$range .= '<span class="give_price_range_high">' . give_currency_filter( give_format_amount( $high ) ) . '</span>';
649
+	$range .= '<span class="give_price_range_high">'.give_currency_filter(give_format_amount($high)).'</span>';
650 650
 
651
-	return apply_filters( 'give_price_range', $range, $form_id, $low, $high );
651
+	return apply_filters('give_price_range', $range, $form_id, $low, $high);
652 652
 }
653 653
 
654 654
 
@@ -661,43 +661,43 @@  discard block
 block discarded – undo
661 661
  *
662 662
  * @return float Amount of the lowest price
663 663
  */
664
-function give_get_lowest_price_option( $form_id = 0 ) {
665
-	if ( empty( $form_id ) ) {
664
+function give_get_lowest_price_option($form_id = 0) {
665
+	if (empty($form_id)) {
666 666
 		$form_id = get_the_ID();
667 667
 	}
668 668
 
669
-	if ( ! give_has_variable_prices( $form_id ) ) {
670
-		return give_get_form_price( $form_id );
669
+	if ( ! give_has_variable_prices($form_id)) {
670
+		return give_get_form_price($form_id);
671 671
 	}
672 672
 
673
-	$prices = give_get_variable_prices( $form_id );
673
+	$prices = give_get_variable_prices($form_id);
674 674
 
675 675
 	$low = 0.00;
676 676
 
677
-	if ( ! empty( $prices ) ) {
677
+	if ( ! empty($prices)) {
678 678
 
679
-		foreach ( $prices as $key => $price ) {
679
+		foreach ($prices as $key => $price) {
680 680
 
681
-			if ( empty( $price['_give_amount'] ) ) {
681
+			if (empty($price['_give_amount'])) {
682 682
 				continue;
683 683
 			}
684 684
 
685
-			if ( ! isset( $min ) ) {
685
+			if ( ! isset($min)) {
686 686
 				$min = $price['_give_amount'];
687 687
 			} else {
688
-				$min = min( $min, give_sanitize_amount( $price['_give_amount'] ) );
688
+				$min = min($min, give_sanitize_amount($price['_give_amount']));
689 689
 			}
690 690
 
691
-			if ( $price['_give_amount'] == $min ) {
691
+			if ($price['_give_amount'] == $min) {
692 692
 				$min_id = $key;
693 693
 			}
694 694
 		}
695 695
 
696
-		$low = $prices[ $min_id ]['_give_amount'];
696
+		$low = $prices[$min_id]['_give_amount'];
697 697
 
698 698
 	}
699 699
 
700
-	return give_sanitize_amount( $low );
700
+	return give_sanitize_amount($low);
701 701
 }
702 702
 
703 703
 /**
@@ -709,41 +709,41 @@  discard block
 block discarded – undo
709 709
  *
710 710
  * @return float Amount of the highest price
711 711
  */
712
-function give_get_highest_price_option( $form_id = 0 ) {
712
+function give_get_highest_price_option($form_id = 0) {
713 713
 
714
-	if ( empty( $form_id ) ) {
714
+	if (empty($form_id)) {
715 715
 		$form_id = get_the_ID();
716 716
 	}
717 717
 
718
-	if ( ! give_has_variable_prices( $form_id ) ) {
719
-		return give_get_form_price( $form_id );
718
+	if ( ! give_has_variable_prices($form_id)) {
719
+		return give_get_form_price($form_id);
720 720
 	}
721 721
 
722
-	$prices = give_get_variable_prices( $form_id );
722
+	$prices = give_get_variable_prices($form_id);
723 723
 
724 724
 	$high = 0.00;
725 725
 
726
-	if ( ! empty( $prices ) ) {
726
+	if ( ! empty($prices)) {
727 727
 
728 728
 		$max = 0;
729 729
 
730
-		foreach ( $prices as $key => $price ) {
731
-			if ( empty( $price['_give_amount'] ) ) {
730
+		foreach ($prices as $key => $price) {
731
+			if (empty($price['_give_amount'])) {
732 732
 				continue;
733 733
 			}
734
-			$give_amount = give_sanitize_amount( $price['_give_amount'] );
734
+			$give_amount = give_sanitize_amount($price['_give_amount']);
735 735
 
736
-			$max = max( $max, $give_amount );
736
+			$max = max($max, $give_amount);
737 737
 
738
-			if ( $give_amount == $max ) {
738
+			if ($give_amount == $max) {
739 739
 				$max_id = $key;
740 740
 			}
741 741
 		}
742 742
 
743
-		$high = $prices[ $max_id ]['_give_amount'];
743
+		$high = $prices[$max_id]['_give_amount'];
744 744
 	}
745 745
 
746
-	return give_sanitize_amount( $high );
746
+	return give_sanitize_amount($high);
747 747
 }
748 748
 
749 749
 /**
@@ -755,13 +755,13 @@  discard block
 block discarded – undo
755 755
  *
756 756
  * @return mixed string|int Price of the form
757 757
  */
758
-function give_get_form_price( $form_id = 0 ) {
758
+function give_get_form_price($form_id = 0) {
759 759
 
760
-	if ( empty( $form_id ) ) {
760
+	if (empty($form_id)) {
761 761
 		return false;
762 762
 	}
763 763
 
764
-	$form = new Give_Donate_Form( $form_id );
764
+	$form = new Give_Donate_Form($form_id);
765 765
 
766 766
 	return $form->price;
767 767
 }
@@ -778,52 +778,52 @@  discard block
 block discarded – undo
778 778
  *
779 779
  * @return int $formatted_price
780 780
  */
781
-function give_price( $form_id = 0, $echo = true, $price_id = false ) {
781
+function give_price($form_id = 0, $echo = true, $price_id = false) {
782 782
 
783
-	if ( empty( $form_id ) ) {
783
+	if (empty($form_id)) {
784 784
 		$form_id = get_the_ID();
785 785
 	}
786 786
 
787
-	if ( give_has_variable_prices( $form_id ) ) {
787
+	if (give_has_variable_prices($form_id)) {
788 788
 
789
-		$prices = give_get_variable_prices( $form_id );
789
+		$prices = give_get_variable_prices($form_id);
790 790
 
791
-		if ( false !== $price_id ) {
791
+		if (false !== $price_id) {
792 792
 
793 793
 			//loop through multi-prices to see which is default
794
-			foreach ( $prices as $price ) {
794
+			foreach ($prices as $price) {
795 795
 				//this is the default price
796
-				if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) {
796
+				if (isset($price['_give_default']) && $price['_give_default'] === 'default') {
797 797
 					$price = (float) $price['_give_amount'];
798 798
 				};
799 799
 			}
800 800
 
801 801
 		} else {
802 802
 
803
-			$price = give_get_lowest_price_option( $form_id );
803
+			$price = give_get_lowest_price_option($form_id);
804 804
 		}
805 805
 
806
-		$price = give_sanitize_amount( $price );
806
+		$price = give_sanitize_amount($price);
807 807
 
808 808
 	} else {
809 809
 
810
-		$price = give_get_form_price( $form_id );
810
+		$price = give_get_form_price($form_id);
811 811
 
812 812
 	}
813 813
 
814
-	$price           = apply_filters( 'give_form_price', give_sanitize_amount( $price ), $form_id );
815
-	$formatted_price = '<span class="give_price" id="give_price_' . $form_id . '">' . $price . '</span>';
816
-	$formatted_price = apply_filters( 'give_form_price_after_html', $formatted_price, $form_id, $price );
814
+	$price           = apply_filters('give_form_price', give_sanitize_amount($price), $form_id);
815
+	$formatted_price = '<span class="give_price" id="give_price_'.$form_id.'">'.$price.'</span>';
816
+	$formatted_price = apply_filters('give_form_price_after_html', $formatted_price, $form_id, $price);
817 817
 
818
-	if ( $echo ) {
818
+	if ($echo) {
819 819
 		echo $formatted_price;
820 820
 	} else {
821 821
 		return $formatted_price;
822 822
 	}
823 823
 }
824 824
 
825
-add_filter( 'give_form_price', 'give_format_amount', 10 );
826
-add_filter( 'give_form_price', 'give_currency_filter', 20 );
825
+add_filter('give_form_price', 'give_format_amount', 10);
826
+add_filter('give_form_price', 'give_currency_filter', 20);
827 827
 
828 828
 
829 829
 /**
@@ -837,18 +837,18 @@  discard block
 block discarded – undo
837 837
  *
838 838
  * @return float $amount Amount of the price option
839 839
  */
840
-function give_get_price_option_amount( $form_id = 0, $price_id = 0 ) {
841
-	$prices = give_get_variable_prices( $form_id );
840
+function give_get_price_option_amount($form_id = 0, $price_id = 0) {
841
+	$prices = give_get_variable_prices($form_id);
842 842
 
843 843
 	$amount = 0.00;
844 844
 
845
-	foreach ( $prices as $price ) {
846
-		if ( isset( $price['_give_id']['level_id'] ) && $price['_give_id']['level_id'] === $price_id ) {
847
-			$amount = isset( $price['_give_amount'] ) ? $price['_give_amount'] : 0.00;
845
+	foreach ($prices as $price) {
846
+		if (isset($price['_give_id']['level_id']) && $price['_give_id']['level_id'] === $price_id) {
847
+			$amount = isset($price['_give_amount']) ? $price['_give_amount'] : 0.00;
848 848
 		};
849 849
 	}
850 850
 
851
-	return apply_filters( 'give_get_price_option_amount', give_sanitize_amount( $amount ), $form_id, $price_id );
851
+	return apply_filters('give_get_price_option_amount', give_sanitize_amount($amount), $form_id, $price_id);
852 852
 }
853 853
 
854 854
 /**
@@ -860,13 +860,13 @@  discard block
 block discarded – undo
860 860
  *
861 861
  * @return mixed string|int Goal of the form
862 862
  */
863
-function give_get_form_goal( $form_id = 0 ) {
863
+function give_get_form_goal($form_id = 0) {
864 864
 
865
-	if ( empty( $form_id ) ) {
865
+	if (empty($form_id)) {
866 866
 		return false;
867 867
 	}
868 868
 
869
-	$form = new Give_Donate_Form( $form_id );
869
+	$form = new Give_Donate_Form($form_id);
870 870
 
871 871
 	return $form->goal;
872 872
 
@@ -882,24 +882,24 @@  discard block
 block discarded – undo
882 882
  *
883 883
  * @return string $formatted_goal
884 884
  */
885
-function give_goal( $form_id = 0, $echo = true ) {
885
+function give_goal($form_id = 0, $echo = true) {
886 886
 
887
-	if ( empty( $form_id ) ) {
887
+	if (empty($form_id)) {
888 888
 		$form_id = get_the_ID();
889 889
 	}
890 890
 
891
-	$goal = give_get_form_goal( $form_id );
891
+	$goal = give_get_form_goal($form_id);
892 892
 
893
-	$goal           = apply_filters( 'give_form_goal', give_sanitize_amount( $goal ), $form_id );
894
-	$formatted_goal = '<span class="give_price" id="give_price_' . $form_id . '">' . $goal . '</span>';
895
-	$formatted_goal = apply_filters( 'give_form_price_after_html', $formatted_goal, $form_id, $goal );
893
+	$goal           = apply_filters('give_form_goal', give_sanitize_amount($goal), $form_id);
894
+	$formatted_goal = '<span class="give_price" id="give_price_'.$form_id.'">'.$goal.'</span>';
895
+	$formatted_goal = apply_filters('give_form_price_after_html', $formatted_goal, $form_id, $goal);
896 896
 
897
-	if ( $echo ) {
897
+	if ($echo) {
898 898
 		echo $formatted_goal;
899 899
 	} else {
900 900
 		return $formatted_goal;
901 901
 	}
902 902
 }
903 903
 
904
-add_filter( 'give_form_goal', 'give_format_amount', 10 );
905
-add_filter( 'give_form_goal', 'give_currency_filter', 20 );
904
+add_filter('give_form_goal', 'give_format_amount', 10);
905
+add_filter('give_form_goal', 'give_currency_filter', 20);
Please login to merge, or discard this patch.