Test Failed
Pull Request — master (#3324)
by Devin
07:59
created
includes/class-give-stats.php 1 patch
Spacing   +106 added lines, -106 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
 
@@ -93,19 +93,19 @@  discard block
 block discarded – undo
93 93
 	 */
94 94
 	public function get_predefined_dates() {
95 95
 		$predefined = array(
96
-			'today'        => esc_html__( 'Today', 'give' ),
97
-			'yesterday'    => esc_html__( 'Yesterday', 'give' ),
98
-			'this_week'    => esc_html__( 'This Week', 'give' ),
99
-			'last_week'    => esc_html__( 'Last Week', 'give' ),
100
-			'this_month'   => esc_html__( 'This Month', 'give' ),
101
-			'last_month'   => esc_html__( 'Last Month', 'give' ),
102
-			'this_quarter' => esc_html__( 'This Quarter', 'give' ),
103
-			'last_quarter' => esc_html__( 'Last Quarter', 'give' ),
104
-			'this_year'    => esc_html__( 'This Year', 'give' ),
105
-			'last_year'    => esc_html__( 'Last Year', 'give' ),
96
+			'today'        => esc_html__('Today', 'give'),
97
+			'yesterday'    => esc_html__('Yesterday', 'give'),
98
+			'this_week'    => esc_html__('This Week', 'give'),
99
+			'last_week'    => esc_html__('Last Week', 'give'),
100
+			'this_month'   => esc_html__('This Month', 'give'),
101
+			'last_month'   => esc_html__('Last Month', 'give'),
102
+			'this_quarter' => esc_html__('This Quarter', 'give'),
103
+			'last_quarter' => esc_html__('Last Quarter', 'give'),
104
+			'this_year'    => esc_html__('This Year', 'give'),
105
+			'last_year'    => esc_html__('Last Year', 'give'),
106 106
 		);
107 107
 
108
-		return apply_filters( 'give_stats_predefined_dates', $predefined );
108
+		return apply_filters('give_stats_predefined_dates', $predefined);
109 109
 	}
110 110
 
111 111
 	/**
@@ -121,18 +121,18 @@  discard block
 block discarded – undo
121 121
 	 *
122 122
 	 * @return void
123 123
 	 */
124
-	public function setup_dates( $_start_date = 'this_month', $_end_date = false ) {
124
+	public function setup_dates($_start_date = 'this_month', $_end_date = false) {
125 125
 
126
-		if ( empty( $_start_date ) ) {
126
+		if (empty($_start_date)) {
127 127
 			$_start_date = 'this_month';
128 128
 		}
129 129
 
130
-		if ( empty( $_end_date ) ) {
130
+		if (empty($_end_date)) {
131 131
 			$_end_date = $_start_date;
132 132
 		}
133 133
 
134
-		$this->start_date = $this->convert_date( $_start_date );
135
-		$this->end_date   = $this->convert_date( $_end_date, true );
134
+		$this->start_date = $this->convert_date($_start_date);
135
+		$this->end_date   = $this->convert_date($_end_date, true);
136 136
 	}
137 137
 
138 138
 	/**
@@ -148,26 +148,26 @@  discard block
 block discarded – undo
148 148
 	 *
149 149
 	 * @return array|WP_Error   If the date is invalid, a WP_Error object will be returned.
150 150
 	 */
151
-	public function convert_date( $date, $end_date = false ) {
151
+	public function convert_date($date, $end_date = false) {
152 152
 
153 153
 		$this->timestamp = false;
154 154
 		$second          = $end_date ? 59 : 0;
155 155
 		$minute          = $end_date ? 59 : 0;
156 156
 		$hour            = $end_date ? 23 : 0;
157 157
 		$day             = 1;
158
-		$month           = date( 'n', current_time( 'timestamp' ) );
159
-		$year            = date( 'Y', current_time( 'timestamp' ) );
158
+		$month           = date('n', current_time('timestamp'));
159
+		$year            = date('Y', current_time('timestamp'));
160 160
 
161
-		if ( array_key_exists( (string) $date, $this->get_predefined_dates() ) ) {
161
+		if (array_key_exists((string) $date, $this->get_predefined_dates())) {
162 162
 
163 163
 			// This is a predefined date rate, such as last_week
164
-			switch ( $date ) {
164
+			switch ($date) {
165 165
 
166 166
 				case 'this_month' :
167 167
 
168
-					if ( $end_date ) {
168
+					if ($end_date) {
169 169
 
170
-						$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
170
+						$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
171 171
 						$hour   = 23;
172 172
 						$minute = 59;
173 173
 						$second = 59;
@@ -177,28 +177,28 @@  discard block
 block discarded – undo
177 177
 
178 178
 				case 'last_month' :
179 179
 
180
-					if ( $month == 1 ) {
180
+					if ($month == 1) {
181 181
 
182 182
 						$month = 12;
183
-						$year --;
183
+						$year--;
184 184
 
185 185
 					} else {
186 186
 
187
-						$month --;
187
+						$month--;
188 188
 
189 189
 					}
190 190
 
191
-					if ( $end_date ) {
192
-						$day = cal_days_in_month( CAL_GREGORIAN, $month, $year );
191
+					if ($end_date) {
192
+						$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
193 193
 					}
194 194
 
195 195
 					break;
196 196
 
197 197
 				case 'today' :
198 198
 
199
-					$day = date( 'd', current_time( 'timestamp' ) );
199
+					$day = date('d', current_time('timestamp'));
200 200
 
201
-					if ( $end_date ) {
201
+					if ($end_date) {
202 202
 						$hour   = 23;
203 203
 						$minute = 59;
204 204
 						$second = 59;
@@ -208,23 +208,23 @@  discard block
 block discarded – undo
208 208
 
209 209
 				case 'yesterday' :
210 210
 
211
-					$day = date( 'd', current_time( 'timestamp' ) ) - 1;
211
+					$day = date('d', current_time('timestamp')) - 1;
212 212
 
213 213
 					// Check if Today is the first day of the month (meaning subtracting one will get us 0)
214
-					if ( $day < 1 ) {
214
+					if ($day < 1) {
215 215
 
216 216
 						// If current month is 1
217
-						if ( 1 == $month ) {
217
+						if (1 == $month) {
218 218
 
219 219
 							$year -= 1; // Today is January 1, so skip back to last day of December
220 220
 							$month = 12;
221
-							$day   = cal_days_in_month( CAL_GREGORIAN, $month, $year );
221
+							$day   = cal_days_in_month(CAL_GREGORIAN, $month, $year);
222 222
 
223 223
 						} else {
224 224
 
225 225
 							// Go back one month and get the last day of the month
226 226
 							$month -= 1;
227
-							$day = cal_days_in_month( CAL_GREGORIAN, $month, $year );
227
+							$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
228 228
 
229 229
 						}
230 230
 					}
@@ -233,12 +233,12 @@  discard block
 block discarded – undo
233 233
 
234 234
 				case 'this_week' :
235 235
 
236
-					$days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24;
237
-					$today              = date( 'j', current_time( 'timestamp' ) ) * 60 * 60 * 24;
236
+					$days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24;
237
+					$today              = date('j', current_time('timestamp')) * 60 * 60 * 24;
238 238
 
239
-					if ( $today <= $days_to_week_start ) {
239
+					if ($today <= $days_to_week_start) {
240 240
 
241
-						if ( $month > 1 ) {
241
+						if ($month > 1) {
242 242
 							$month -= 1;
243 243
 						} else {
244 244
 							$month = 12;
@@ -246,19 +246,19 @@  discard block
 block discarded – undo
246 246
 
247 247
 					}
248 248
 
249
-					if ( ! $end_date ) {
249
+					if ( ! $end_date) {
250 250
 
251 251
 						// Getting the start day
252 252
 
253
-						$day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1;
254
-						$day += get_option( 'start_of_week' );
253
+						$day = date('d', current_time('timestamp') - $days_to_week_start) - 1;
254
+						$day += get_option('start_of_week');
255 255
 
256 256
 					} else {
257 257
 
258 258
 						// Getting the end day
259 259
 
260
-						$day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1;
261
-						$day += get_option( 'start_of_week' ) + 6;
260
+						$day = date('d', current_time('timestamp') - $days_to_week_start) - 1;
261
+						$day += get_option('start_of_week') + 6;
262 262
 
263 263
 					}
264 264
 
@@ -266,12 +266,12 @@  discard block
 block discarded – undo
266 266
 
267 267
 				case 'last_week' :
268 268
 
269
-					$days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24;
270
-					$today              = date( 'j', current_time( 'timestamp' ) ) * 60 * 60 * 24;
269
+					$days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24;
270
+					$today              = date('j', current_time('timestamp')) * 60 * 60 * 24;
271 271
 
272
-					if ( $today <= $days_to_week_start ) {
272
+					if ($today <= $days_to_week_start) {
273 273
 
274
-						if ( $month > 1 ) {
274
+						if ($month > 1) {
275 275
 							$month -= 1;
276 276
 						} else {
277 277
 							$month = 12;
@@ -279,19 +279,19 @@  discard block
 block discarded – undo
279 279
 
280 280
 					}
281 281
 
282
-					if ( ! $end_date ) {
282
+					if ( ! $end_date) {
283 283
 
284 284
 						// Getting the start day
285 285
 
286
-						$day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8;
287
-						$day += get_option( 'start_of_week' );
286
+						$day = date('d', current_time('timestamp') - $days_to_week_start) - 8;
287
+						$day += get_option('start_of_week');
288 288
 
289 289
 					} else {
290 290
 
291 291
 						// Getting the end day
292 292
 
293
-						$day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8;
294
-						$day += get_option( 'start_of_week' ) + 6;
293
+						$day = date('d', current_time('timestamp') - $days_to_week_start) - 8;
294
+						$day += get_option('start_of_week') + 6;
295 295
 
296 296
 					}
297 297
 
@@ -299,39 +299,39 @@  discard block
 block discarded – undo
299 299
 
300 300
 				case 'this_quarter' :
301 301
 
302
-					$month_now = date( 'n', current_time( 'timestamp' ) );
302
+					$month_now = date('n', current_time('timestamp'));
303 303
 
304
-					if ( $month_now <= 3 ) {
304
+					if ($month_now <= 3) {
305 305
 
306
-						if ( ! $end_date ) {
306
+						if ( ! $end_date) {
307 307
 							$month = 1;
308 308
 						} else {
309 309
 							$month  = 3;
310
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
310
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
311 311
 							$hour   = 23;
312 312
 							$minute = 59;
313 313
 							$second = 59;
314 314
 						}
315 315
 
316
-					} else if ( $month_now <= 6 ) {
316
+					} else if ($month_now <= 6) {
317 317
 
318
-						if ( ! $end_date ) {
318
+						if ( ! $end_date) {
319 319
 							$month = 4;
320 320
 						} else {
321 321
 							$month  = 6;
322
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
322
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
323 323
 							$hour   = 23;
324 324
 							$minute = 59;
325 325
 							$second = 59;
326 326
 						}
327 327
 
328
-					} else if ( $month_now <= 9 ) {
328
+					} else if ($month_now <= 9) {
329 329
 
330
-						if ( ! $end_date ) {
330
+						if ( ! $end_date) {
331 331
 							$month = 7;
332 332
 						} else {
333 333
 							$month  = 9;
334
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
334
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
335 335
 							$hour   = 23;
336 336
 							$minute = 59;
337 337
 							$second = 59;
@@ -339,11 +339,11 @@  discard block
 block discarded – undo
339 339
 
340 340
 					} else {
341 341
 
342
-						if ( ! $end_date ) {
342
+						if ( ! $end_date) {
343 343
 							$month = 10;
344 344
 						} else {
345 345
 							$month  = 12;
346
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
346
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
347 347
 							$hour   = 23;
348 348
 							$minute = 59;
349 349
 							$second = 59;
@@ -355,40 +355,40 @@  discard block
 block discarded – undo
355 355
 
356 356
 				case 'last_quarter' :
357 357
 
358
-					$month_now = date( 'n', current_time( 'timestamp' ) );
358
+					$month_now = date('n', current_time('timestamp'));
359 359
 
360
-					if ( $month_now <= 3 ) {
360
+					if ($month_now <= 3) {
361 361
 
362
-						if ( ! $end_date ) {
362
+						if ( ! $end_date) {
363 363
 							$month = 10;
364 364
 						} else {
365 365
 							$year -= 1;
366 366
 							$month  = 12;
367
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
367
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
368 368
 							$hour   = 23;
369 369
 							$minute = 59;
370 370
 							$second = 59;
371 371
 						}
372 372
 
373
-					} else if ( $month_now <= 6 ) {
373
+					} else if ($month_now <= 6) {
374 374
 
375
-						if ( ! $end_date ) {
375
+						if ( ! $end_date) {
376 376
 							$month = 1;
377 377
 						} else {
378 378
 							$month  = 3;
379
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
379
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
380 380
 							$hour   = 23;
381 381
 							$minute = 59;
382 382
 							$second = 59;
383 383
 						}
384 384
 
385
-					} else if ( $month_now <= 9 ) {
385
+					} else if ($month_now <= 9) {
386 386
 
387
-						if ( ! $end_date ) {
387
+						if ( ! $end_date) {
388 388
 							$month = 4;
389 389
 						} else {
390 390
 							$month  = 6;
391
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
391
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
392 392
 							$hour   = 23;
393 393
 							$minute = 59;
394 394
 							$second = 59;
@@ -396,11 +396,11 @@  discard block
 block discarded – undo
396 396
 
397 397
 					} else {
398 398
 
399
-						if ( ! $end_date ) {
399
+						if ( ! $end_date) {
400 400
 							$month = 7;
401 401
 						} else {
402 402
 							$month  = 9;
403
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
403
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
404 404
 							$hour   = 23;
405 405
 							$minute = 59;
406 406
 							$second = 59;
@@ -412,11 +412,11 @@  discard block
 block discarded – undo
412 412
 
413 413
 				case 'this_year' :
414 414
 
415
-					if ( ! $end_date ) {
415
+					if ( ! $end_date) {
416 416
 						$month = 1;
417 417
 					} else {
418 418
 						$month  = 12;
419
-						$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
419
+						$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
420 420
 						$hour   = 23;
421 421
 						$minute = 59;
422 422
 						$second = 59;
@@ -427,11 +427,11 @@  discard block
 block discarded – undo
427 427
 				case 'last_year' :
428 428
 
429 429
 					$year -= 1;
430
-					if ( ! $end_date ) {
430
+					if ( ! $end_date) {
431 431
 						$month = 1;
432 432
 					} else {
433 433
 						$month  = 12;
434
-						$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
434
+						$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
435 435
 						$hour   = 23;
436 436
 						$minute = 59;
437 437
 						$second = 59;
@@ -442,30 +442,30 @@  discard block
 block discarded – undo
442 442
 			}
443 443
 
444 444
 
445
-		} else if ( is_numeric( $date ) ) {
445
+		} else if (is_numeric($date)) {
446 446
 
447 447
 			// return $date unchanged since it is a timestamp
448 448
 			$this->timestamp = true;
449 449
 
450
-		} else if ( false !== strtotime( $date ) ) {
450
+		} else if (false !== strtotime($date)) {
451 451
 
452
-			$date  = strtotime( $date, current_time( 'timestamp' ) );
453
-			$year  = date( 'Y', $date );
454
-			$month = date( 'm', $date );
455
-			$day   = date( 'd', $date );
452
+			$date  = strtotime($date, current_time('timestamp'));
453
+			$year  = date('Y', $date);
454
+			$month = date('m', $date);
455
+			$day   = date('d', $date);
456 456
 
457 457
 		} else {
458 458
 
459
-			return new WP_Error( 'invalid_date', esc_html__( 'Improper date provided.', 'give' ) );
459
+			return new WP_Error('invalid_date', esc_html__('Improper date provided.', 'give'));
460 460
 
461 461
 		}
462 462
 
463
-		if ( false === $this->timestamp ) {
463
+		if (false === $this->timestamp) {
464 464
 			// Create an exact timestamp
465
-			$date = mktime( $hour, $minute, $second, $month, $day, $year );
465
+			$date = mktime($hour, $minute, $second, $month, $day, $year);
466 466
 		}
467 467
 
468
-		return apply_filters( 'give_stats_date', $date, $end_date, $this );
468
+		return apply_filters('give_stats_date', $date, $end_date, $this);
469 469
 
470 470
 	}
471 471
 
@@ -481,33 +481,33 @@  discard block
 block discarded – undo
481 481
 	 * 
482 482
 	 * @return string
483 483
 	 */
484
-	public function count_where( $where = '' ) {
484
+	public function count_where($where = '') {
485 485
 		// Only get payments in our date range
486 486
 
487 487
 		$start_where = '';
488 488
 		$end_where   = '';
489 489
 
490
-		if ( $this->start_date ) {
490
+		if ($this->start_date) {
491 491
 
492
-			if ( $this->timestamp ) {
492
+			if ($this->timestamp) {
493 493
 				$format = 'Y-m-d H:i:s';
494 494
 			} else {
495 495
 				$format = 'Y-m-d 00:00:00';
496 496
 			}
497 497
 
498
-			$start_date  = date( $format, $this->start_date );
498
+			$start_date  = date($format, $this->start_date);
499 499
 			$start_where = " AND p.post_date >= '{$start_date}'";
500 500
 		}
501 501
 
502
-		if ( $this->end_date ) {
502
+		if ($this->end_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 23:59:59';
508 508
 			}
509 509
 
510
-			$end_date = date( $format, $this->end_date );
510
+			$end_date = date($format, $this->end_date);
511 511
 
512 512
 			$end_where = " AND p.post_date <= '{$end_date}'";
513 513
 		}
@@ -529,34 +529,34 @@  discard block
 block discarded – undo
529 529
 	 *
530 530
 	 * @return string
531 531
 	 */
532
-	public function payments_where( $where = '' ) {
532
+	public function payments_where($where = '') {
533 533
 
534 534
 		global $wpdb;
535 535
 
536 536
 		$start_where = '';
537 537
 		$end_where   = '';
538 538
 
539
-		if ( ! is_wp_error( $this->start_date ) ) {
539
+		if ( ! is_wp_error($this->start_date)) {
540 540
 
541
-			if ( $this->timestamp ) {
541
+			if ($this->timestamp) {
542 542
 				$format = 'Y-m-d H:i:s';
543 543
 			} else {
544 544
 				$format = 'Y-m-d 00:00:00';
545 545
 			}
546 546
 
547
-			$start_date  = date( $format, $this->start_date );
547
+			$start_date  = date($format, $this->start_date);
548 548
 			$start_where = " AND $wpdb->posts.post_date >= '{$start_date}'";
549 549
 		}
550 550
 
551
-		if ( ! is_wp_error( $this->end_date ) ) {
551
+		if ( ! is_wp_error($this->end_date)) {
552 552
 
553
-			if ( $this->timestamp ) {
553
+			if ($this->timestamp) {
554 554
 				$format = 'Y-m-d H:i:s';
555 555
 			} else {
556 556
 				$format = 'Y-m-d 23:59:59';
557 557
 			}
558 558
 
559
-			$end_date = date( $format, $this->end_date );
559
+			$end_date = date($format, $this->end_date);
560 560
 
561 561
 			$end_where = " AND $wpdb->posts.post_date <= '{$end_date}'";
562 562
 		}
Please login to merge, or discard this patch.
includes/class-give-donate-form.php 1 patch
Spacing   +137 added lines, -137 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
 
@@ -348,11 +348,11 @@  discard block
 block discarded – undo
348 348
 	 * @param  int|bool $_id   Post id. Default is false.
349 349
 	 * @param  array    $_args Arguments passed.
350 350
 	 */
351
-	public function __construct( $_id = false, $_args = array() ) {
351
+	public function __construct($_id = false, $_args = array()) {
352 352
 
353
-		$donation_form = WP_Post::get_instance( $_id );
353
+		$donation_form = WP_Post::get_instance($_id);
354 354
 
355
-		return $this->setup_donation_form( $donation_form );
355
+		return $this->setup_donation_form($donation_form);
356 356
 	}
357 357
 
358 358
 	/**
@@ -365,23 +365,23 @@  discard block
 block discarded – undo
365 365
 	 *
366 366
 	 * @return bool                   If the setup was successful or not.
367 367
 	 */
368
-	private function setup_donation_form( $donation_form ) {
368
+	private function setup_donation_form($donation_form) {
369 369
 
370
-		if ( ! is_object( $donation_form ) ) {
370
+		if ( ! is_object($donation_form)) {
371 371
 			return false;
372 372
 		}
373 373
 
374
-		if ( ! is_a( $donation_form, 'WP_Post' ) ) {
374
+		if ( ! is_a($donation_form, 'WP_Post')) {
375 375
 			return false;
376 376
 		}
377 377
 
378
-		if ( 'give_forms' !== $donation_form->post_type ) {
378
+		if ('give_forms' !== $donation_form->post_type) {
379 379
 			return false;
380 380
 		}
381 381
 
382
-		foreach ( $donation_form as $key => $value ) {
382
+		foreach ($donation_form as $key => $value) {
383 383
 
384
-			switch ( $key ) {
384
+			switch ($key) {
385 385
 
386 386
 				default:
387 387
 					$this->$key = $value;
@@ -405,16 +405,16 @@  discard block
 block discarded – undo
405 405
 	 *
406 406
 	 * @return mixed
407 407
 	 */
408
-	public function __get( $key ) {
408
+	public function __get($key) {
409 409
 
410
-		if ( method_exists( $this, 'get_' . $key ) ) {
410
+		if (method_exists($this, 'get_'.$key)) {
411 411
 
412
-			return call_user_func( array( $this, 'get_' . $key ) );
412
+			return call_user_func(array($this, 'get_'.$key));
413 413
 
414 414
 		} else {
415 415
 
416 416
 			/* translators: %s: property key */
417
-			return new WP_Error( 'give-form-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) );
417
+			return new WP_Error('give-form-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key));
418 418
 
419 419
 		}
420 420
 
@@ -430,30 +430,30 @@  discard block
 block discarded – undo
430 430
 	 *
431 431
 	 * @return bool|int    False if data isn't passed and class not instantiated for creation, or New Form ID.
432 432
 	 */
433
-	public function create( $data = array() ) {
433
+	public function create($data = array()) {
434 434
 
435
-		if ( $this->id != 0 ) {
435
+		if ($this->id != 0) {
436 436
 			return false;
437 437
 		}
438 438
 
439 439
 		$defaults = array(
440 440
 			'post_type'   => 'give_forms',
441 441
 			'post_status' => 'draft',
442
-			'post_title'  => __( 'New Donation Form', 'give' ),
442
+			'post_title'  => __('New Donation Form', 'give'),
443 443
 		);
444 444
 
445
-		$args = wp_parse_args( $data, $defaults );
445
+		$args = wp_parse_args($data, $defaults);
446 446
 
447 447
 		/**
448 448
 		 * Fired before a donation form is created
449 449
 		 *
450 450
 		 * @param array $args The post object arguments used for creation.
451 451
 		 */
452
-		do_action( 'give_form_pre_create', $args );
452
+		do_action('give_form_pre_create', $args);
453 453
 
454
-		$id = wp_insert_post( $args, true );
454
+		$id = wp_insert_post($args, true);
455 455
 
456
-		$donation_form = WP_Post::get_instance( $id );
456
+		$donation_form = WP_Post::get_instance($id);
457 457
 
458 458
 		/**
459 459
 		 * Fired after a donation form is created
@@ -461,9 +461,9 @@  discard block
 block discarded – undo
461 461
 		 * @param int   $id   The post ID of the created item.
462 462
 		 * @param array $args The post object arguments used for creation.
463 463
 		 */
464
-		do_action( 'give_form_post_create', $id, $args );
464
+		do_action('give_form_post_create', $id, $args);
465 465
 
466
-		return $this->setup_donation_form( $donation_form );
466
+		return $this->setup_donation_form($donation_form);
467 467
 
468 468
 	}
469 469
 
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
 	 * @return string Donation form name.
489 489
 	 */
490 490
 	public function get_name() {
491
-		return get_the_title( $this->ID );
491
+		return get_the_title($this->ID);
492 492
 	}
493 493
 
494 494
 	/**
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
 	 */
502 502
 	public function get_price() {
503 503
 
504
-		if ( ! isset( $this->price ) ) {
504
+		if ( ! isset($this->price)) {
505 505
 
506 506
 			$this->price = give_maybe_sanitize_amount(
507 507
 				give_get_meta(
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
 				)
512 512
 			);
513 513
 
514
-			if ( ! $this->price ) {
514
+			if ( ! $this->price) {
515 515
 				$this->price = 0;
516 516
 			}
517 517
 
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
 		 * @param string     $price The donation form price.
526 526
 		 * @param string|int $id    The form ID.
527 527
 		 */
528
-		return apply_filters( 'give_get_set_price', $this->price, $this->ID );
528
+		return apply_filters('give_get_set_price', $this->price, $this->ID);
529 529
 	}
530 530
 
531 531
 	/**
@@ -538,22 +538,22 @@  discard block
 block discarded – undo
538 538
 	 */
539 539
 	public function get_minimum_price() {
540 540
 
541
-		if ( ! isset( $this->minimum_price ) ) {
541
+		if ( ! isset($this->minimum_price)) {
542 542
 
543
-			$this->minimum_price = give_get_meta( $this->ID, '_give_custom_amount_range_minimum', true );
543
+			$this->minimum_price = give_get_meta($this->ID, '_give_custom_amount_range_minimum', true);
544 544
 
545 545
 			// Give backward < 2.1
546
-			if ( empty( $this->minimum_price ) ) {
547
-				$this->minimum_price = give_get_meta( $this->ID, '_give_custom_amount_minimum', true );
546
+			if (empty($this->minimum_price)) {
547
+				$this->minimum_price = give_get_meta($this->ID, '_give_custom_amount_minimum', true);
548 548
 			}
549 549
 
550
-			if ( ! $this->is_custom_price_mode() ) {
551
-				$this->minimum_price = give_get_lowest_price_option( $this->ID );
550
+			if ( ! $this->is_custom_price_mode()) {
551
+				$this->minimum_price = give_get_lowest_price_option($this->ID);
552 552
 			}
553 553
 
554 554
 		}
555 555
 
556
-		return apply_filters( 'give_get_set_minimum_price', $this->minimum_price, $this->ID );
556
+		return apply_filters('give_get_set_minimum_price', $this->minimum_price, $this->ID);
557 557
 	}
558 558
 
559 559
 	/**
@@ -566,15 +566,15 @@  discard block
 block discarded – undo
566 566
 	 */
567 567
 	public function get_maximum_price() {
568 568
 
569
-		if ( ! isset( $this->maximum_price ) ) {
570
-			$this->maximum_price = give_get_meta( $this->ID, '_give_custom_amount_range_maximum', true, 999999.99 );
569
+		if ( ! isset($this->maximum_price)) {
570
+			$this->maximum_price = give_get_meta($this->ID, '_give_custom_amount_range_maximum', true, 999999.99);
571 571
 
572
-			if ( ! $this->is_custom_price_mode() ) {
573
-				$this->maximum_price = give_get_highest_price_option( $this->ID );
572
+			if ( ! $this->is_custom_price_mode()) {
573
+				$this->maximum_price = give_get_highest_price_option($this->ID);
574 574
 			}
575 575
 		}
576 576
 
577
-		return apply_filters( 'give_get_set_maximum_price', $this->maximum_price, $this->ID );
577
+		return apply_filters('give_get_set_maximum_price', $this->maximum_price, $this->ID);
578 578
 	}
579 579
 
580 580
 	/**
@@ -587,9 +587,9 @@  discard block
 block discarded – undo
587 587
 	 */
588 588
 	public function get_prices() {
589 589
 
590
-		if ( ! isset( $this->prices ) ) {
590
+		if ( ! isset($this->prices)) {
591 591
 
592
-			$this->prices = give_get_meta( $this->ID, '_give_donation_levels', true );
592
+			$this->prices = give_get_meta($this->ID, '_give_donation_levels', true);
593 593
 
594 594
 		}
595 595
 
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 		 * @param array      $prices The array of mulit-level prices.
602 602
 		 * @param int|string $ID     The ID of the form.
603 603
 		 */
604
-		return apply_filters( 'give_get_donation_levels', $this->prices, $this->ID );
604
+		return apply_filters('give_get_donation_levels', $this->prices, $this->ID);
605 605
 
606 606
 	}
607 607
 
@@ -615,18 +615,18 @@  discard block
 block discarded – undo
615 615
 	 *
616 616
 	 * @return array|null
617 617
 	 */
618
-	public function get_level_info( $price_id ) {
618
+	public function get_level_info($price_id) {
619 619
 		$level_info = array();
620 620
 
621 621
 		// Bailout.
622
-		if ( 'multi' !== $this->get_type() ) {
622
+		if ('multi' !== $this->get_type()) {
623 623
 			return null;
624
-		} elseif ( ! ( $levels = $this->get_prices() ) ) {
624
+		} elseif ( ! ($levels = $this->get_prices())) {
625 625
 			return $level_info;
626 626
 		}
627 627
 
628
-		foreach ( $levels as $level ) {
629
-			if ( $price_id === $level['_give_id']['level_id'] ) {
628
+		foreach ($levels as $level) {
629
+			if ($price_id === $level['_give_id']['level_id']) {
630 630
 				$level_info = $level;
631 631
 				break;
632 632
 			}
@@ -646,25 +646,25 @@  discard block
 block discarded – undo
646 646
 	 */
647 647
 	public function get_goal() {
648 648
 
649
-		if ( ! isset( $this->goal ) ) {
649
+		if ( ! isset($this->goal)) {
650 650
 
651
-			$goal_format = give_get_form_goal_format( $this->ID );
651
+			$goal_format = give_get_form_goal_format($this->ID);
652 652
 
653
-			if ( 'donation' === $goal_format ) {
654
-				$this->goal = give_get_meta( $this->ID, '_give_number_of_donation_goal', true );
655
-			} elseif ( 'donors' === $goal_format ) {
656
-				$this->goal = give_get_meta( $this->ID, '_give_number_of_donor_goal', true );
653
+			if ('donation' === $goal_format) {
654
+				$this->goal = give_get_meta($this->ID, '_give_number_of_donation_goal', true);
655
+			} elseif ('donors' === $goal_format) {
656
+				$this->goal = give_get_meta($this->ID, '_give_number_of_donor_goal', true);
657 657
 			} else {
658
-				$this->goal = give_get_meta( $this->ID, '_give_set_goal', true );
658
+				$this->goal = give_get_meta($this->ID, '_give_set_goal', true);
659 659
 			}
660 660
 
661
-			if ( ! $this->goal ) {
661
+			if ( ! $this->goal) {
662 662
 				$this->goal = 0;
663 663
 			}
664 664
 
665 665
 		}
666 666
 
667
-		return apply_filters( 'give_get_set_goal', $this->goal, $this->ID );
667
+		return apply_filters('give_get_set_goal', $this->goal, $this->ID);
668 668
 
669 669
 	}
670 670
 
@@ -678,10 +678,10 @@  discard block
 block discarded – undo
678 678
 	 */
679 679
 	public function is_single_price_mode() {
680 680
 
681
-		$option = give_get_meta( $this->ID, '_give_price_option', true );
681
+		$option = give_get_meta($this->ID, '_give_price_option', true);
682 682
 		$ret    = 0;
683 683
 
684
-		if ( empty( $option ) || $option === 'set' ) {
684
+		if (empty($option) || $option === 'set') {
685 685
 			$ret = 1;
686 686
 		}
687 687
 
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
 		 * @param bool       $ret Is donation form in single price mode?
694 694
 		 * @param int|string $ID  The ID of the donation form.
695 695
 		 */
696
-		return (bool) apply_filters( 'give_single_price_option_mode', $ret, $this->ID );
696
+		return (bool) apply_filters('give_single_price_option_mode', $ret, $this->ID);
697 697
 
698 698
 	}
699 699
 
@@ -707,10 +707,10 @@  discard block
 block discarded – undo
707 707
 	 */
708 708
 	public function is_custom_price_mode() {
709 709
 
710
-		$option = give_get_meta( $this->ID, '_give_custom_amount', true );
710
+		$option = give_get_meta($this->ID, '_give_custom_amount', true);
711 711
 		$ret    = 0;
712 712
 
713
-		if ( give_is_setting_enabled( $option ) ) {
713
+		if (give_is_setting_enabled($option)) {
714 714
 			$ret = 1;
715 715
 		}
716 716
 
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
 		 * @param bool       $ret Is donation form in custom price mode?
723 723
 		 * @param int|string $ID  The ID of the donation form.
724 724
 		 */
725
-		return (bool) apply_filters( 'give_custom_price_option_mode', $ret, $this->ID );
725
+		return (bool) apply_filters('give_custom_price_option_mode', $ret, $this->ID);
726 726
 
727 727
 	}
728 728
 
@@ -736,20 +736,20 @@  discard block
 block discarded – undo
736 736
 	 *
737 737
 	 * @return bool
738 738
 	 */
739
-	public function is_custom_price( $amount ) {
739
+	public function is_custom_price($amount) {
740 740
 		$result = false;
741
-		$amount = give_maybe_sanitize_amount( $amount );
741
+		$amount = give_maybe_sanitize_amount($amount);
742 742
 
743
-		if ( $this->is_custom_price_mode() ) {
743
+		if ($this->is_custom_price_mode()) {
744 744
 
745
-			if ( 'set' === $this->get_type() ) {
746
-				if ( $amount !== $this->get_price() ) {
745
+			if ('set' === $this->get_type()) {
746
+				if ($amount !== $this->get_price()) {
747 747
 					$result = true;
748 748
 				}
749 749
 
750
-			} elseif ( 'multi' === $this->get_type() ) {
751
-				$level_amounts = array_map( 'give_maybe_sanitize_amount', wp_list_pluck( $this->get_prices(), '_give_amount' ) );
752
-				$result        = ! in_array( $amount, $level_amounts );
750
+			} elseif ('multi' === $this->get_type()) {
751
+				$level_amounts = array_map('give_maybe_sanitize_amount', wp_list_pluck($this->get_prices(), '_give_amount'));
752
+				$result        = ! in_array($amount, $level_amounts);
753 753
 			}
754 754
 		}
755 755
 
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
 		 *
763 763
 		 * @since 1.8.18
764 764
 		 */
765
-		return (bool) apply_filters( 'give_is_custom_price', $result, $amount, $this->ID );
765
+		return (bool) apply_filters('give_is_custom_price', $result, $amount, $this->ID);
766 766
 	}
767 767
 
768 768
 	/**
@@ -777,10 +777,10 @@  discard block
 block discarded – undo
777 777
 	 */
778 778
 	public function has_variable_prices() {
779 779
 
780
-		$option = give_get_meta( $this->ID, '_give_price_option', true );
780
+		$option = give_get_meta($this->ID, '_give_price_option', true);
781 781
 		$ret    = 0;
782 782
 
783
-		if ( $option === 'multi' ) {
783
+		if ($option === 'multi') {
784 784
 			$ret = 1;
785 785
 		}
786 786
 
@@ -790,7 +790,7 @@  discard block
 block discarded – undo
790 790
 		 * @param bool       $ret Does donation form have variable prices?
791 791
 		 * @param int|string $ID  The ID of the donation form.
792 792
 		 */
793
-		return (bool) apply_filters( 'give_has_variable_prices', $ret, $this->ID );
793
+		return (bool) apply_filters('give_has_variable_prices', $ret, $this->ID);
794 794
 
795 795
 	}
796 796
 
@@ -804,17 +804,17 @@  discard block
 block discarded – undo
804 804
 	 */
805 805
 	public function get_type() {
806 806
 
807
-		if ( ! isset( $this->type ) ) {
807
+		if ( ! isset($this->type)) {
808 808
 
809
-			$this->type = give_get_meta( $this->ID, '_give_price_option', true );
809
+			$this->type = give_get_meta($this->ID, '_give_price_option', true);
810 810
 
811
-			if ( empty( $this->type ) ) {
811
+			if (empty($this->type)) {
812 812
 				$this->type = 'set';
813 813
 			}
814 814
 
815 815
 		}
816 816
 
817
-		return apply_filters( 'give_get_form_type', $this->type, $this->ID );
817
+		return apply_filters('give_get_form_type', $this->type, $this->ID);
818 818
 
819 819
 	}
820 820
 
@@ -830,23 +830,23 @@  discard block
 block discarded – undo
830 830
 	 *
831 831
 	 * @return string
832 832
 	 */
833
-	public function get_form_classes( $args ) {
833
+	public function get_form_classes($args) {
834 834
 
835
-		$float_labels_option = give_is_float_labels_enabled( $args )
835
+		$float_labels_option = give_is_float_labels_enabled($args)
836 836
 			? 'float-labels-enabled'
837 837
 			: '';
838 838
 
839
-		$form_classes_array = apply_filters( 'give_form_classes', array(
839
+		$form_classes_array = apply_filters('give_form_classes', array(
840 840
 			'give-form',
841
-			'give-form-' . $this->ID,
842
-			'give-form-type-' . $this->get_type(),
841
+			'give-form-'.$this->ID,
842
+			'give-form-type-'.$this->get_type(),
843 843
 			$float_labels_option,
844
-		), $this->ID, $args );
844
+		), $this->ID, $args);
845 845
 
846 846
 		// Remove empty class names.
847
-		$form_classes_array = array_filter( $form_classes_array );
847
+		$form_classes_array = array_filter($form_classes_array);
848 848
 
849
-		return implode( ' ', $form_classes_array );
849
+		return implode(' ', $form_classes_array);
850 850
 
851 851
 	}
852 852
 
@@ -861,22 +861,22 @@  discard block
 block discarded – undo
861 861
 	 *
862 862
 	 * @return string
863 863
 	 */
864
-	public function get_form_wrap_classes( $args ) {
864
+	public function get_form_wrap_classes($args) {
865 865
 		$custom_class = array(
866 866
 			'give-form-wrap',
867 867
 		);
868 868
 
869
-		if ( $this->is_close_donation_form() ) {
869
+		if ($this->is_close_donation_form()) {
870 870
 			$custom_class[] = 'give-form-closed';
871 871
 		} else {
872
-			$display_option = ( isset( $args['display_style'] ) && ! empty( $args['display_style'] ) )
872
+			$display_option = (isset($args['display_style']) && ! empty($args['display_style']))
873 873
 				? $args['display_style']
874
-				: give_get_meta( $this->ID, '_give_payment_display', true );
874
+				: give_get_meta($this->ID, '_give_payment_display', true);
875 875
 
876 876
 			$custom_class[] = "give-display-{$display_option}";
877 877
 
878 878
 			// If admin want to show only button for form then user inbuilt modal functionality.
879
-			if ( 'button' === $display_option ) {
879
+			if ('button' === $display_option) {
880 880
 				$custom_class[] = 'give-display-button-only';
881 881
 			}
882 882
 		}
@@ -887,10 +887,10 @@  discard block
 block discarded – undo
887 887
 		 *
888 888
 		 * @since 1.0
889 889
 		 */
890
-		$form_wrap_classes_array = (array) apply_filters( 'give_form_wrap_classes', $custom_class, $this->ID, $args );
890
+		$form_wrap_classes_array = (array) apply_filters('give_form_wrap_classes', $custom_class, $this->ID, $args);
891 891
 
892 892
 
893
-		return implode( ' ', $form_wrap_classes_array );
893
+		return implode(' ', $form_wrap_classes_array);
894 894
 
895 895
 	}
896 896
 
@@ -905,7 +905,7 @@  discard block
 block discarded – undo
905 905
 	public function is_set_type_donation_form() {
906 906
 		$form_type = $this->get_type();
907 907
 
908
-		return ( 'set' === $form_type ? true : false );
908
+		return ('set' === $form_type ? true : false);
909 909
 	}
910 910
 
911 911
 	/**
@@ -919,7 +919,7 @@  discard block
 block discarded – undo
919 919
 	public function is_multi_type_donation_form() {
920 920
 		$form_type = $this->get_type();
921 921
 
922
-		return ( 'multi' === $form_type ? true : false );
922
+		return ('multi' === $form_type ? true : false);
923 923
 
924 924
 	}
925 925
 
@@ -933,15 +933,15 @@  discard block
 block discarded – undo
933 933
 	 */
934 934
 	public function get_sales() {
935 935
 
936
-		if ( ! isset( $this->sales ) ) {
936
+		if ( ! isset($this->sales)) {
937 937
 
938
-			if ( '' == give_get_meta( $this->ID, '_give_form_sales', true ) ) {
939
-				add_post_meta( $this->ID, '_give_form_sales', 0 );
938
+			if ('' == give_get_meta($this->ID, '_give_form_sales', true)) {
939
+				add_post_meta($this->ID, '_give_form_sales', 0);
940 940
 			} // End if
941 941
 
942
-			$this->sales = give_get_meta( $this->ID, '_give_form_sales', true );
942
+			$this->sales = give_get_meta($this->ID, '_give_form_sales', true);
943 943
 
944
-			if ( $this->sales < 0 ) {
944
+			if ($this->sales < 0) {
945 945
 				// Never let sales be less than zero.
946 946
 				$this->sales = 0;
947 947
 			}
@@ -962,13 +962,13 @@  discard block
 block discarded – undo
962 962
 	 *
963 963
 	 * @return int|false     New number of total sales.
964 964
 	 */
965
-	public function increase_sales( $quantity = 1 ) {
965
+	public function increase_sales($quantity = 1) {
966 966
 
967
-		$sales       = give_get_form_sales_stats( $this->ID );
968
-		$quantity    = absint( $quantity );
967
+		$sales       = give_get_form_sales_stats($this->ID);
968
+		$quantity    = absint($quantity);
969 969
 		$total_sales = $sales + $quantity;
970 970
 
971
-		if ( $this->update_meta( '_give_form_sales', $total_sales ) ) {
971
+		if ($this->update_meta('_give_form_sales', $total_sales)) {
972 972
 
973 973
 			$this->sales = $total_sales;
974 974
 
@@ -989,17 +989,17 @@  discard block
 block discarded – undo
989 989
 	 *
990 990
 	 * @return int|false     New number of total sales.
991 991
 	 */
992
-	public function decrease_sales( $quantity = 1 ) {
992
+	public function decrease_sales($quantity = 1) {
993 993
 
994
-		$sales = give_get_form_sales_stats( $this->ID );
994
+		$sales = give_get_form_sales_stats($this->ID);
995 995
 
996 996
 		// Only decrease if not already zero
997
-		if ( $sales > 0 ) {
997
+		if ($sales > 0) {
998 998
 
999
-			$quantity    = absint( $quantity );
999
+			$quantity    = absint($quantity);
1000 1000
 			$total_sales = $sales - $quantity;
1001 1001
 
1002
-			if ( $this->update_meta( '_give_form_sales', $total_sales ) ) {
1002
+			if ($this->update_meta('_give_form_sales', $total_sales)) {
1003 1003
 
1004 1004
 				$this->sales = $sales;
1005 1005
 
@@ -1023,15 +1023,15 @@  discard block
 block discarded – undo
1023 1023
 	 */
1024 1024
 	public function get_earnings() {
1025 1025
 
1026
-		if ( ! isset( $this->earnings ) ) {
1026
+		if ( ! isset($this->earnings)) {
1027 1027
 
1028
-			if ( '' == give_get_meta( $this->ID, '_give_form_earnings', true ) ) {
1029
-				add_post_meta( $this->ID, '_give_form_earnings', 0 );
1028
+			if ('' == give_get_meta($this->ID, '_give_form_earnings', true)) {
1029
+				add_post_meta($this->ID, '_give_form_earnings', 0);
1030 1030
 			}
1031 1031
 
1032
-			$this->earnings = give_get_meta( $this->ID, '_give_form_earnings', true );
1032
+			$this->earnings = give_get_meta($this->ID, '_give_form_earnings', true);
1033 1033
 
1034
-			if ( $this->earnings < 0 ) {
1034
+			if ($this->earnings < 0) {
1035 1035
 				// Never let earnings be less than zero
1036 1036
 				$this->earnings = 0;
1037 1037
 			}
@@ -1055,9 +1055,9 @@  discard block
 block discarded – undo
1055 1055
 	 *
1056 1056
 	 * @return float|false
1057 1057
 	 */
1058
-	public function increase_earnings( $amount = 0, $payment_id = 0 ) {
1058
+	public function increase_earnings($amount = 0, $payment_id = 0) {
1059 1059
 
1060
-		$earnings   = give_get_form_earnings_stats( $this->ID );
1060
+		$earnings = give_get_form_earnings_stats($this->ID);
1061 1061
 
1062 1062
 		/**
1063 1063
 		 * Modify the earning amount when increasing.
@@ -1068,11 +1068,11 @@  discard block
 block discarded – undo
1068 1068
 		 * @param int   $form_id    Donation form ID.
1069 1069
 		 * @param int   $payment_id Donation ID.
1070 1070
 		 */
1071
-		$amount = apply_filters( 'give_increase_form_earnings_amount', $amount, $this->ID, $payment_id );
1071
+		$amount = apply_filters('give_increase_form_earnings_amount', $amount, $this->ID, $payment_id);
1072 1072
 
1073 1073
 		$new_amount = $earnings + (float) $amount;
1074 1074
 
1075
-		if ( $this->update_meta( '_give_form_earnings', $new_amount ) ) {
1075
+		if ($this->update_meta('_give_form_earnings', $new_amount)) {
1076 1076
 
1077 1077
 			$this->earnings = $new_amount;
1078 1078
 
@@ -1095,11 +1095,11 @@  discard block
 block discarded – undo
1095 1095
 	 *
1096 1096
 	 * @return float|false
1097 1097
 	 */
1098
-	public function decrease_earnings( $amount, $payment_id = 0 ) {
1098
+	public function decrease_earnings($amount, $payment_id = 0) {
1099 1099
 
1100
-		$earnings = give_get_form_earnings_stats( $this->ID );
1100
+		$earnings = give_get_form_earnings_stats($this->ID);
1101 1101
 
1102
-		if ( $earnings > 0 ) {
1102
+		if ($earnings > 0) {
1103 1103
 
1104 1104
 			/**
1105 1105
 			 * Modify the earning value when decreasing it.
@@ -1110,12 +1110,12 @@  discard block
 block discarded – undo
1110 1110
 			 * @param int   $form_id    Donation Form ID.
1111 1111
 			 * @param int   $payment_id Donation ID.
1112 1112
 			 */
1113
-			$amount = apply_filters( 'give_decrease_form_earnings_amount', $amount, $this->ID, $payment_id );
1113
+			$amount = apply_filters('give_decrease_form_earnings_amount', $amount, $this->ID, $payment_id);
1114 1114
 
1115 1115
 			// Only decrease if greater than zero
1116 1116
 			$new_amount = $earnings - (float) $amount;
1117 1117
 
1118
-			if ( $this->update_meta( '_give_form_earnings', $new_amount ) ) {
1118
+			if ($this->update_meta('_give_form_earnings', $new_amount)) {
1119 1119
 				$this->earnings = $new_amount;
1120 1120
 
1121 1121
 				return $this->earnings;
@@ -1141,10 +1141,10 @@  discard block
 block discarded – undo
1141 1141
 	 * @return bool
1142 1142
 	 */
1143 1143
 	public function is_close_donation_form() {
1144
-		$is_closed = ( 'closed' === give_get_meta( $this->ID, '_give_form_status', true, 'open' ) );
1144
+		$is_closed = ('closed' === give_get_meta($this->ID, '_give_form_status', true, 'open'));
1145 1145
 
1146 1146
 		// If manual upgrade not completed, proceed with backward compatible code.
1147
-		if ( ! give_has_upgrade_completed( 'v210_verify_form_status_upgrades' ) ) {
1147
+		if ( ! give_has_upgrade_completed('v210_verify_form_status_upgrades')) {
1148 1148
 
1149 1149
 			// Check for backward compatibility.
1150 1150
 			$is_closed = $this->bc_210_is_close_donation_form();
@@ -1174,17 +1174,17 @@  discard block
 block discarded – undo
1174 1174
 	 *
1175 1175
 	 * @return bool                            The result of the update query.
1176 1176
 	 */
1177
-	private function update_meta( $meta_key = '', $meta_value = '' ) {
1177
+	private function update_meta($meta_key = '', $meta_value = '') {
1178 1178
 
1179 1179
 		/* @var WPDB $wpdb */
1180 1180
 		global $wpdb;
1181 1181
 
1182 1182
 		// Bailout.
1183
-		if ( empty( $meta_key ) ) {
1183
+		if (empty($meta_key)) {
1184 1184
 			return false;
1185 1185
 		}
1186 1186
 
1187
-		if ( give_update_meta( $this->ID, $meta_key, $meta_value ) ) {
1187
+		if (give_update_meta($this->ID, $meta_key, $meta_value)) {
1188 1188
 			return true;
1189 1189
 		}
1190 1190
 
@@ -1201,33 +1201,33 @@  discard block
 block discarded – undo
1201 1201
 	private function bc_210_is_close_donation_form() {
1202 1202
 
1203 1203
 		$close_form      = false;
1204
-		$is_goal_enabled = give_is_setting_enabled( give_get_meta( $this->ID, '_give_goal_option', true, 'disabled' ) );
1204
+		$is_goal_enabled = give_is_setting_enabled(give_get_meta($this->ID, '_give_goal_option', true, 'disabled'));
1205 1205
 
1206 1206
 		// Proceed, if the form goal is enabled.
1207
-		if ( $is_goal_enabled ) {
1207
+		if ($is_goal_enabled) {
1208 1208
 
1209
-			$close_form_when_goal_achieved = give_is_setting_enabled( give_get_meta( $this->ID, '_give_close_form_when_goal_achieved', true, 'disabled' ) );
1209
+			$close_form_when_goal_achieved = give_is_setting_enabled(give_get_meta($this->ID, '_give_close_form_when_goal_achieved', true, 'disabled'));
1210 1210
 
1211 1211
 			// Proceed, if close form when goal achieved option is enabled.
1212
-			if ( $close_form_when_goal_achieved ) {
1212
+			if ($close_form_when_goal_achieved) {
1213 1213
 
1214
-				$form        = new Give_Donate_Form( $this->ID );
1215
-				$goal_format = give_get_form_goal_format( $this->ID );
1214
+				$form        = new Give_Donate_Form($this->ID);
1215
+				$goal_format = give_get_form_goal_format($this->ID);
1216 1216
 
1217 1217
 				// Verify whether the form is closed or not after processing data based on goal format.
1218
-				switch ( $goal_format ) {
1218
+				switch ($goal_format) {
1219 1219
 					case 'donation':
1220 1220
 						$closed = $form->get_goal() <= $form->get_sales();
1221 1221
 						break;
1222 1222
 					case 'donors':
1223
-						$closed = $form->get_goal() <= give_get_form_donor_count( $this->ID );
1223
+						$closed = $form->get_goal() <= give_get_form_donor_count($this->ID);
1224 1224
 						break;
1225 1225
 					default :
1226 1226
 						$closed = $form->get_goal() <= $form->get_earnings();
1227 1227
 						break;
1228 1228
 				}
1229 1229
 
1230
-				if ( $closed ) {
1230
+				if ($closed) {
1231 1231
 					$close_form = true;
1232 1232
 				}
1233 1233
 
Please login to merge, or discard this patch.
includes/forms/functions.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
  *
156 156
  * Used to redirect a user back to the donation form if there are errors present.
157 157
  *
158
- * @param array|string $args
158
+ * @param string $args
159 159
  *
160 160
  * @access public
161 161
  * @since  1.0
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
  * @since  1.0
302 302
  * @since  1.8.16 Add security check
303 303
  *
304
- * @return bool
304
+ * @return false|null
305 305
  */
306 306
 function give_listen_for_failed_payments() {
307 307
 
Please login to merge, or discard this patch.
Spacing   +249 added lines, -251 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' ) {
26
+	if ($typenow != 'give_forms') {
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 = give_get_meta( $args['form_id'], '_give_form_floating_labels', true );
70
+	if (empty($float_labels)) {
71
+		$float_labels = give_get_meta($args['form_id'], '_give_form_floating_labels', true);
72 72
 	}
73 73
 
74
-	if ( empty( $float_labels ) || ( 'global' === $float_labels ) ) {
75
-		$float_labels = give_get_option( 'floatlabels', 'disabled' );
74
+	if (empty($float_labels) || ('global' === $float_labels)) {
75
+		$float_labels = give_get_option('floatlabels', 'disabled');
76 76
 	}
77 77
 
78
-	return give_is_setting_enabled( $float_labels );
78
+	return give_is_setting_enabled($float_labels);
79 79
 }
80 80
 
81 81
 /**
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 
92 92
 	$can_checkout = true;
93 93
 
94
-	return (bool) apply_filters( 'give_can_checkout', $can_checkout );
94
+	return (bool) apply_filters('give_can_checkout', $can_checkout);
95 95
 }
96 96
 
97 97
 /**
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
 function give_get_success_page_uri() {
106 106
 	$give_options = give_get_settings();
107 107
 
108
-	$success_page = isset( $give_options['success_page'] ) ? get_permalink( absint( $give_options['success_page'] ) ) : get_bloginfo( 'url' );
108
+	$success_page = isset($give_options['success_page']) ? get_permalink(absint($give_options['success_page'])) : get_bloginfo('url');
109 109
 
110
-	return apply_filters( 'give_get_success_page_uri', $success_page );
110
+	return apply_filters('give_get_success_page_uri', $success_page);
111 111
 }
112 112
 
113 113
 /**
@@ -119,9 +119,9 @@  discard block
 block discarded – undo
119 119
  */
120 120
 function give_is_success_page() {
121 121
 	$give_options    = give_get_settings();
122
-	$is_success_page = isset( $give_options['success_page'] ) ? is_page( $give_options['success_page'] ) : false;
122
+	$is_success_page = isset($give_options['success_page']) ? is_page($give_options['success_page']) : false;
123 123
 
124
-	return apply_filters( 'give_is_success_page', $is_success_page );
124
+	return apply_filters('give_is_success_page', $is_success_page);
125 125
 }
126 126
 
127 127
 /**
@@ -135,17 +135,17 @@  discard block
 block discarded – undo
135 135
  * @since       1.0
136 136
  * @return      void
137 137
  */
138
-function give_send_to_success_page( $query_string = null ) {
138
+function give_send_to_success_page($query_string = null) {
139 139
 
140 140
 	$redirect = give_get_success_page_uri();
141 141
 
142
-	if ( $query_string ) {
142
+	if ($query_string) {
143 143
 		$redirect .= $query_string;
144 144
 	}
145 145
 
146
-	$gateway = isset( $_REQUEST['give-gateway'] ) ? $_REQUEST['give-gateway'] : '';
146
+	$gateway = isset($_REQUEST['give-gateway']) ? $_REQUEST['give-gateway'] : '';
147 147
 
148
-	wp_redirect( apply_filters( 'give_success_page_redirect', $redirect, $gateway, $query_string ) );
148
+	wp_redirect(apply_filters('give_success_page_redirect', $redirect, $gateway, $query_string));
149 149
 	give_die();
150 150
 }
151 151
 
@@ -161,19 +161,19 @@  discard block
 block discarded – undo
161 161
  * @since  1.0
162 162
  * @return Void
163 163
  */
164
-function give_send_back_to_checkout( $args = array() ) {
164
+function give_send_back_to_checkout($args = array()) {
165 165
 
166
-	$url     = isset( $_POST['give-current-url'] ) ? sanitize_text_field( $_POST['give-current-url'] ) : '';
166
+	$url     = isset($_POST['give-current-url']) ? sanitize_text_field($_POST['give-current-url']) : '';
167 167
 	$form_id = 0;
168 168
 
169 169
 	// Set the form_id.
170
-	if ( isset( $_POST['give-form-id'] ) ) {
171
-		$form_id = sanitize_text_field( $_POST['give-form-id'] );
170
+	if (isset($_POST['give-form-id'])) {
171
+		$form_id = sanitize_text_field($_POST['give-form-id']);
172 172
 	}
173 173
 
174 174
 	// Need a URL to continue. If none, redirect back to single form.
175
-	if ( empty( $url ) ) {
176
-		wp_safe_redirect( get_permalink( $form_id ) );
175
+	if (empty($url)) {
176
+		wp_safe_redirect(get_permalink($form_id));
177 177
 		give_die();
178 178
 	}
179 179
 
@@ -182,41 +182,41 @@  discard block
 block discarded – undo
182 182
 	);
183 183
 
184 184
 	// Set the $level_id.
185
-	if ( isset( $_POST['give-price-id'] ) ) {
186
-		$defaults['level-id'] = sanitize_text_field( $_POST['give-price-id'] );
185
+	if (isset($_POST['give-price-id'])) {
186
+		$defaults['level-id'] = sanitize_text_field($_POST['give-price-id']);
187 187
 	}
188 188
 
189 189
 	// Check for backward compatibility.
190
-	if ( is_string( $args ) ) {
191
-		$args = str_replace( '?', '', $args );
190
+	if (is_string($args)) {
191
+		$args = str_replace('?', '', $args);
192 192
 	}
193 193
 
194
-	$args = wp_parse_args( $args, $defaults );
194
+	$args = wp_parse_args($args, $defaults);
195 195
 
196 196
 	// Merge URL query with $args to maintain third-party URL parameters after redirect.
197
-	$url_data = wp_parse_url( $url );
197
+	$url_data = wp_parse_url($url);
198 198
 
199 199
 	// Check if an array to prevent notices before parsing.
200
-	if ( isset( $url_data['query'] ) && ! empty( $url_data['query'] ) ) {
201
-		parse_str( $url_data['query'], $query );
200
+	if (isset($url_data['query']) && ! empty($url_data['query'])) {
201
+		parse_str($url_data['query'], $query);
202 202
 
203 203
 		// Precaution: don't allow any CC info.
204
-		unset( $query['card_number'] );
205
-		unset( $query['card_cvc'] );
204
+		unset($query['card_number']);
205
+		unset($query['card_cvc']);
206 206
 
207 207
 	} else {
208 208
 		// No $url_data so pass empty array.
209 209
 		$query = array();
210 210
 	}
211 211
 
212
-	$new_query        = array_merge( $args, $query );
213
-	$new_query_string = http_build_query( $new_query );
212
+	$new_query        = array_merge($args, $query);
213
+	$new_query_string = http_build_query($new_query);
214 214
 
215 215
 	// Assemble URL parts.
216
-	$redirect = home_url( '/' . $url_data['path'] . '?' . $new_query_string . '#give-form-' . $form_id . '-wrap' );
216
+	$redirect = home_url('/'.$url_data['path'].'?'.$new_query_string.'#give-form-'.$form_id.'-wrap');
217 217
 
218 218
 	// Redirect them.
219
-	wp_safe_redirect( apply_filters( 'give_send_back_to_checkout', $redirect, $args ) );
219
+	wp_safe_redirect(apply_filters('give_send_back_to_checkout', $redirect, $args));
220 220
 	give_die();
221 221
 
222 222
 }
@@ -232,16 +232,16 @@  discard block
 block discarded – undo
232 232
  * @since       1.0
233 233
  * @return      string
234 234
  */
235
-function give_get_success_page_url( $query_string = null ) {
235
+function give_get_success_page_url($query_string = null) {
236 236
 
237
-	$success_page = give_get_option( 'success_page', 0 );
238
-	$success_page = get_permalink( $success_page );
237
+	$success_page = give_get_option('success_page', 0);
238
+	$success_page = get_permalink($success_page);
239 239
 
240
-	if ( $query_string ) {
240
+	if ($query_string) {
241 241
 		$success_page .= $query_string;
242 242
 	}
243 243
 
244
-	return apply_filters( 'give_success_page_url', $success_page );
244
+	return apply_filters('give_success_page_url', $success_page);
245 245
 
246 246
 }
247 247
 
@@ -254,32 +254,31 @@  discard block
 block discarded – undo
254 254
  *
255 255
  * @return mixed Full URL to the Failed Donation Page, if present, home page if it doesn't exist.
256 256
  */
257
-function give_get_failed_transaction_uri( $extras = false ) {
257
+function give_get_failed_transaction_uri($extras = false) {
258 258
 	$give_options = give_get_settings();
259 259
 
260 260
 	// Remove question mark.
261
-	if ( 0 === strpos( $extras, '?' ) ) {
262
-		$extras = substr( $extras, 1 );
261
+	if (0 === strpos($extras, '?')) {
262
+		$extras = substr($extras, 1);
263 263
 	}
264 264
 
265
-	$extras_args = wp_parse_args( $extras );
265
+	$extras_args = wp_parse_args($extras);
266 266
 
267 267
 	// Set nonce if payment id exist in extra params.
268
-	if ( array_key_exists( 'payment-id', $extras_args ) ) {
269
-		$extras_args['_wpnonce'] = wp_create_nonce( "give-failed-donation-{$extras_args['payment-id']}" );
270
-		$extras                  = http_build_query( $extras_args );
268
+	if (array_key_exists('payment-id', $extras_args)) {
269
+		$extras_args['_wpnonce'] = wp_create_nonce("give-failed-donation-{$extras_args['payment-id']}");
270
+		$extras                  = http_build_query($extras_args);
271 271
 	}
272 272
 
273
-	$uri = ! empty( $give_options['failure_page'] ) ?
274
-		trailingslashit( get_permalink( $give_options['failure_page'] ) ) :
275
-		home_url();
273
+	$uri = ! empty($give_options['failure_page']) ?
274
+		trailingslashit(get_permalink($give_options['failure_page'])) : home_url();
276 275
 
277 276
 
278
-	if ( $extras ) {
277
+	if ($extras) {
279 278
 		$uri .= "?{$extras}";
280 279
 	}
281 280
 
282
-	return apply_filters( 'give_get_failed_transaction_uri', $uri );
281
+	return apply_filters('give_get_failed_transaction_uri', $uri);
283 282
 }
284 283
 
285 284
 /**
@@ -290,9 +289,9 @@  discard block
 block discarded – undo
290 289
  */
291 290
 function give_is_failed_transaction_page() {
292 291
 	$give_options = give_get_settings();
293
-	$ret          = isset( $give_options['failure_page'] ) ? is_page( $give_options['failure_page'] ) : false;
292
+	$ret          = isset($give_options['failure_page']) ? is_page($give_options['failure_page']) : false;
294 293
 
295
-	return apply_filters( 'give_is_failure_page', $ret );
294
+	return apply_filters('give_is_failure_page', $ret);
296 295
 }
297 296
 
298 297
 /**
@@ -305,25 +304,25 @@  discard block
 block discarded – undo
305 304
  */
306 305
 function give_listen_for_failed_payments() {
307 306
 
308
-	$failed_page = give_get_option( 'failure_page', 0 );
309
-	$payment_id  = ! empty( $_GET['payment-id'] ) ? absint( $_GET['payment-id'] ) : 0;
310
-	$nonce       = ! empty( $_GET['_wpnonce'] ) ? give_clean( $_GET['_wpnonce'] ) : false;
307
+	$failed_page = give_get_option('failure_page', 0);
308
+	$payment_id  = ! empty($_GET['payment-id']) ? absint($_GET['payment-id']) : 0;
309
+	$nonce       = ! empty($_GET['_wpnonce']) ? give_clean($_GET['_wpnonce']) : false;
311 310
 
312 311
 	// Bailout.
313
-	if ( ! $failed_page || ! is_page( $failed_page ) || ! $payment_id || ! $nonce ) {
312
+	if ( ! $failed_page || ! is_page($failed_page) || ! $payment_id || ! $nonce) {
314 313
 		return false;
315 314
 	}
316 315
 
317 316
 	// Security check.
318
-	if ( ! wp_verify_nonce( $nonce, "give-failed-donation-{$payment_id}" ) ) {
319
-		wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ) );
317
+	if ( ! wp_verify_nonce($nonce, "give-failed-donation-{$payment_id}")) {
318
+		wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'));
320 319
 	}
321 320
 
322 321
 	// Set payment status to failure
323
-	give_update_payment_status( $payment_id, 'failed' );
322
+	give_update_payment_status($payment_id, 'failed');
324 323
 }
325 324
 
326
-add_action( 'template_redirect', 'give_listen_for_failed_payments' );
325
+add_action('template_redirect', 'give_listen_for_failed_payments');
327 326
 
328 327
 /**
329 328
  * Retrieve the Donation History page URI
@@ -336,9 +335,9 @@  discard block
 block discarded – undo
336 335
 function give_get_history_page_uri() {
337 336
 	$give_options = give_get_settings();
338 337
 
339
-	$history_page = isset( $give_options['history_page'] ) ? get_permalink( absint( $give_options['history_page'] ) ) : get_bloginfo( 'url' );
338
+	$history_page = isset($give_options['history_page']) ? get_permalink(absint($give_options['history_page'])) : get_bloginfo('url');
340 339
 
341
-	return apply_filters( 'give_get_history_page_uri', $history_page );
340
+	return apply_filters('give_get_history_page_uri', $history_page);
342 341
 }
343 342
 
344 343
 /**
@@ -351,11 +350,11 @@  discard block
 block discarded – undo
351 350
  * @since       1.0
352 351
  * @return      bool
353 352
  */
354
-function give_field_is_required( $field = '', $form_id ) {
353
+function give_field_is_required($field = '', $form_id) {
355 354
 
356
-	$required_fields = give_get_required_fields( $form_id );
355
+	$required_fields = give_get_required_fields($form_id);
357 356
 
358
-	return array_key_exists( $field, $required_fields );
357
+	return array_key_exists($field, $required_fields);
359 358
 }
360 359
 
361 360
 /**
@@ -372,12 +371,12 @@  discard block
 block discarded – undo
372 371
  *
373 372
  * @return void
374 373
  */
375
-function give_record_donation_in_log( $give_form_id = 0, $payment_id, $price_id = false, $donation_date = null ) {
374
+function give_record_donation_in_log($give_form_id = 0, $payment_id, $price_id = false, $donation_date = null) {
376 375
 	$log_data = array(
377 376
 		'log_parent'   => $payment_id,
378 377
 		'log_type'     => 'sale',
379
-		'log_date'     => isset( $donation_date ) ? $donation_date : null,
380
-		'log_date_gmt' => isset( $donation_date ) ? $donation_date : null,
378
+		'log_date'     => isset($donation_date) ? $donation_date : null,
379
+		'log_date_gmt' => isset($donation_date) ? $donation_date : null,
381 380
 	);
382 381
 
383 382
 	$log_meta = array(
@@ -385,7 +384,7 @@  discard block
 block discarded – undo
385 384
 		'price_id' => (int) $price_id,
386 385
 	);
387 386
 
388
-	Give()->logs->insert_log( $log_data, $log_meta );
387
+	Give()->logs->insert_log($log_data, $log_meta);
389 388
 }
390 389
 
391 390
 
@@ -399,13 +398,13 @@  discard block
 block discarded – undo
399 398
  *
400 399
  * @return bool|int
401 400
  */
402
-function give_increase_donation_count( $form_id = 0, $quantity = 1 ) {
401
+function give_increase_donation_count($form_id = 0, $quantity = 1) {
403 402
 	$quantity = (int) $quantity;
404 403
 
405 404
 	/** @var \Give_Donate_Form $form */
406
-	$form = new Give_Donate_Form( $form_id );
405
+	$form = new Give_Donate_Form($form_id);
407 406
 
408
-	return $form->increase_sales( $quantity );
407
+	return $form->increase_sales($quantity);
409 408
 }
410 409
 
411 410
 /**
@@ -418,13 +417,13 @@  discard block
 block discarded – undo
418 417
  *
419 418
  * @return bool|int
420 419
  */
421
-function give_decrease_donation_count( $form_id = 0, $quantity = 1 ) {
420
+function give_decrease_donation_count($form_id = 0, $quantity = 1) {
422 421
 	$quantity = (int) $quantity;
423 422
 
424 423
 	/** @var \Give_Donate_Form $form */
425
-	$form = new Give_Donate_Form( $form_id );
424
+	$form = new Give_Donate_Form($form_id);
426 425
 
427
-	return $form->decrease_sales( $quantity );
426
+	return $form->decrease_sales($quantity);
428 427
 }
429 428
 
430 429
 /**
@@ -440,11 +439,11 @@  discard block
 block discarded – undo
440 439
  *
441 440
  * @return bool|int
442 441
  */
443
-function give_increase_earnings( $give_form_id = 0, $amount, $payment_id = 0 ) {
442
+function give_increase_earnings($give_form_id = 0, $amount, $payment_id = 0) {
444 443
 	/** @var \Give_Donate_Form $form */
445
-	$form = new Give_Donate_Form( $give_form_id );
444
+	$form = new Give_Donate_Form($give_form_id);
446 445
 
447
-	return $form->increase_earnings( $amount, $payment_id );
446
+	return $form->increase_earnings($amount, $payment_id);
448 447
 }
449 448
 
450 449
 /**
@@ -462,11 +461,11 @@  discard block
 block discarded – undo
462 461
  *
463 462
  * @return bool|int
464 463
  */
465
-function give_decrease_form_earnings( $form_id = 0, $amount, $payment_id = 0 ) {
464
+function give_decrease_form_earnings($form_id = 0, $amount, $payment_id = 0) {
466 465
 	/** @var \Give_Donate_Form $form */
467
-	$form = new Give_Donate_Form( $form_id );
466
+	$form = new Give_Donate_Form($form_id);
468 467
 
469
-	return $form->decrease_earnings( $amount, $payment_id );
468
+	return $form->decrease_earnings($amount, $payment_id);
470 469
 }
471 470
 
472 471
 
@@ -479,15 +478,15 @@  discard block
 block discarded – undo
479 478
  *
480 479
  * @return int $earnings Earnings for a certain form
481 480
  */
482
-function give_get_form_earnings_stats( $form_id = 0 ) {
483
-	$give_form = new Give_Donate_Form( $form_id );
481
+function give_get_form_earnings_stats($form_id = 0) {
482
+	$give_form = new Give_Donate_Form($form_id);
484 483
 
485 484
 	/**
486 485
 	 * Filter the form earnings
487 486
 	 *
488 487
 	 * @since 1.8.17
489 488
 	 */
490
-	return apply_filters( 'give_get_form_earnings_stats', $give_form->earnings, $form_id, $give_form );
489
+	return apply_filters('give_get_form_earnings_stats', $give_form->earnings, $form_id, $give_form);
491 490
 }
492 491
 
493 492
 
@@ -500,8 +499,8 @@  discard block
 block discarded – undo
500 499
  *
501 500
  * @return int $sales Amount of sales for a certain form
502 501
  */
503
-function give_get_form_sales_stats( $give_form_id = 0 ) {
504
-	$give_form = new Give_Donate_Form( $give_form_id );
502
+function give_get_form_sales_stats($give_form_id = 0) {
503
+	$give_form = new Give_Donate_Form($give_form_id);
505 504
 
506 505
 	return $give_form->sales;
507 506
 }
@@ -516,16 +515,16 @@  discard block
 block discarded – undo
516 515
  *
517 516
  * @return float $sales Average monthly sales
518 517
  */
519
-function give_get_average_monthly_form_sales( $form_id = 0 ) {
520
-	$sales        = give_get_form_sales_stats( $form_id );
521
-	$release_date = get_post_field( 'post_date', $form_id );
518
+function give_get_average_monthly_form_sales($form_id = 0) {
519
+	$sales        = give_get_form_sales_stats($form_id);
520
+	$release_date = get_post_field('post_date', $form_id);
522 521
 
523
-	$diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) );
522
+	$diff = abs(current_time('timestamp') - strtotime($release_date));
524 523
 
525
-	$months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication
524
+	$months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication
526 525
 
527
-	if ( $months > 0 ) {
528
-		$sales = ( $sales / $months );
526
+	if ($months > 0) {
527
+		$sales = ($sales / $months);
529 528
 	}
530 529
 
531 530
 	return $sales;
@@ -541,16 +540,16 @@  discard block
 block discarded – undo
541 540
  *
542 541
  * @return float $earnings Average monthly earnings
543 542
  */
544
-function give_get_average_monthly_form_earnings( $form_id = 0 ) {
545
-	$earnings     = give_get_form_earnings_stats( $form_id );
546
-	$release_date = get_post_field( 'post_date', $form_id );
543
+function give_get_average_monthly_form_earnings($form_id = 0) {
544
+	$earnings     = give_get_form_earnings_stats($form_id);
545
+	$release_date = get_post_field('post_date', $form_id);
547 546
 
548
-	$diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) );
547
+	$diff = abs(current_time('timestamp') - strtotime($release_date));
549 548
 
550
-	$months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication
549
+	$months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication
551 550
 
552
-	if ( $months > 0 ) {
553
-		$earnings = ( $earnings / $months );
551
+	if ($months > 0) {
552
+		$earnings = ($earnings / $months);
554 553
 	}
555 554
 
556 555
 	return $earnings < 0 ? 0 : $earnings;
@@ -571,34 +570,34 @@  discard block
 block discarded – undo
571 570
  *
572 571
  * @return string $price_name Name of the price option
573 572
  */
574
-function give_get_price_option_name( $form_id = 0, $price_id = 0, $payment_id = 0, $use_fallback = true ) {
573
+function give_get_price_option_name($form_id = 0, $price_id = 0, $payment_id = 0, $use_fallback = true) {
575 574
 
576
-	$prices     = give_get_variable_prices( $form_id );
575
+	$prices     = give_get_variable_prices($form_id);
577 576
 	$price_name = '';
578 577
 
579
-	if ( false === $prices ) {
578
+	if (false === $prices) {
580 579
 		return $price_name;
581 580
 	}
582 581
 
583
-	foreach ( $prices as $price ) {
582
+	foreach ($prices as $price) {
584 583
 
585
-		if ( intval( $price['_give_id']['level_id'] ) === intval( $price_id ) ) {
584
+		if (intval($price['_give_id']['level_id']) === intval($price_id)) {
586 585
 
587
-			$price_text     = isset( $price['_give_text'] ) ? $price['_give_text'] : '';
586
+			$price_text     = isset($price['_give_text']) ? $price['_give_text'] : '';
588 587
 			$price_fallback = $use_fallback ?
589 588
 				give_currency_filter(
590 589
 					give_format_amount(
591 590
 						$price['_give_amount'],
592
-						array( 'sanitize' => false )
591
+						array('sanitize' => false)
593 592
 					),
594
-					array( 'decode_currency' => true )
593
+					array('decode_currency' => true)
595 594
 				) : '';
596
-			$price_name     = ! empty( $price_text ) ? $price_text : $price_fallback;
595
+			$price_name = ! empty($price_text) ? $price_text : $price_fallback;
597 596
 
598 597
 		}
599 598
 	}
600 599
 
601
-	return apply_filters( 'give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id );
600
+	return apply_filters('give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id);
602 601
 }
603 602
 
604 603
 
@@ -612,25 +611,25 @@  discard block
 block discarded – undo
612 611
  *
613 612
  * @return string $range A fully formatted price range
614 613
  */
615
-function give_price_range( $form_id = 0, $formatted = true ) {
616
-	$low        = give_get_lowest_price_option( $form_id );
617
-	$high       = give_get_highest_price_option( $form_id );
618
-	$order_type = ! empty( $_REQUEST['order'] ) ? $_REQUEST['order'] : 'asc';
614
+function give_price_range($form_id = 0, $formatted = true) {
615
+	$low        = give_get_lowest_price_option($form_id);
616
+	$high       = give_get_highest_price_option($form_id);
617
+	$order_type = ! empty($_REQUEST['order']) ? $_REQUEST['order'] : 'asc';
619 618
 
620 619
 	$range = sprintf(
621 620
 		'<span class="give_price_range_%1$s">%2$s</span><span class="give_price_range_sep">&nbsp;&ndash;&nbsp;</span><span class="give_price_range_%3$s">%4$s</span>',
622 621
 		'asc' === $order_type ? 'low' : 'high',
623
-		'asc' === $order_type ? give_currency_filter( give_format_amount( $low, array( 'sanitize' => false ) ) ) : give_currency_filter( give_format_amount( $high, array( 'sanitize' => false ) ) ),
622
+		'asc' === $order_type ? give_currency_filter(give_format_amount($low, array('sanitize' => false))) : give_currency_filter(give_format_amount($high, array('sanitize' => false))),
624 623
 		'asc' === $order_type ? 'high' : 'low',
625
-		'asc' === $order_type ? give_currency_filter( give_format_amount( $high, array( 'sanitize' => false ) ) ) : give_currency_filter( give_format_amount( $low, array( 'sanitize' => false ) ) )
624
+		'asc' === $order_type ? give_currency_filter(give_format_amount($high, array('sanitize' => false))) : give_currency_filter(give_format_amount($low, array('sanitize' => false)))
626 625
 
627 626
 	);
628 627
 
629
-	if ( ! $formatted ) {
630
-		$range = wp_strip_all_tags( $range );
628
+	if ( ! $formatted) {
629
+		$range = wp_strip_all_tags($range);
631 630
 	}
632 631
 
633
-	return apply_filters( 'give_price_range', $range, $form_id, $low, $high );
632
+	return apply_filters('give_price_range', $range, $form_id, $low, $high);
634 633
 }
635 634
 
636 635
 
@@ -645,35 +644,35 @@  discard block
 block discarded – undo
645 644
  *
646 645
  * @return int ID of the lowest price
647 646
  */
648
-function give_get_lowest_price_id( $form_id = 0 ) {
647
+function give_get_lowest_price_id($form_id = 0) {
649 648
 
650
-	if ( empty( $form_id ) ) {
649
+	if (empty($form_id)) {
651 650
 		$form_id = get_the_ID();
652 651
 	}
653 652
 
654
-	if ( ! give_has_variable_prices( $form_id ) ) {
655
-		return give_get_form_price( $form_id );
653
+	if ( ! give_has_variable_prices($form_id)) {
654
+		return give_get_form_price($form_id);
656 655
 	}
657 656
 
658
-	$prices = give_get_variable_prices( $form_id );
657
+	$prices = give_get_variable_prices($form_id);
659 658
 
660 659
 	$min = $min_id = 0;
661 660
 
662
-	if ( ! empty( $prices ) ) {
661
+	if ( ! empty($prices)) {
663 662
 
664
-		foreach ( $prices as $key => $price ) {
663
+		foreach ($prices as $key => $price) {
665 664
 
666
-			if ( empty( $price['_give_amount'] ) ) {
665
+			if (empty($price['_give_amount'])) {
667 666
 				continue;
668 667
 			}
669 668
 
670
-			if ( ! isset( $min ) ) {
669
+			if ( ! isset($min)) {
671 670
 				$min = $price['_give_amount'];
672 671
 			} else {
673
-				$min = min( $min, $price['_give_amount'] );
672
+				$min = min($min, $price['_give_amount']);
674 673
 			}
675 674
 
676
-			if ( $price['_give_amount'] == $min ) {
675
+			if ($price['_give_amount'] == $min) {
677 676
 				$min_id = $price['_give_id']['level_id'];
678 677
 			}
679 678
 		}
@@ -691,22 +690,22 @@  discard block
 block discarded – undo
691 690
  *
692 691
  * @return float Amount of the lowest price
693 692
  */
694
-function give_get_lowest_price_option( $form_id = 0 ) {
695
-	if ( empty( $form_id ) ) {
693
+function give_get_lowest_price_option($form_id = 0) {
694
+	if (empty($form_id)) {
696 695
 		$form_id = get_the_ID();
697 696
 	}
698 697
 
699
-	if ( ! give_has_variable_prices( $form_id ) ) {
700
-		return give_get_form_price( $form_id );
698
+	if ( ! give_has_variable_prices($form_id)) {
699
+		return give_get_form_price($form_id);
701 700
 	}
702 701
 
703
-	if ( ! ( $low = get_post_meta( $form_id, '_give_levels_minimum_amount', true ) ) ) {
702
+	if ( ! ($low = get_post_meta($form_id, '_give_levels_minimum_amount', true))) {
704 703
 		// Backward compatibility.
705
-		$prices = wp_list_pluck( give_get_variable_prices( $form_id ), '_give_amount' );
706
-		$low    = ! empty( $prices ) ? min( $prices ) : 0;
704
+		$prices = wp_list_pluck(give_get_variable_prices($form_id), '_give_amount');
705
+		$low    = ! empty($prices) ? min($prices) : 0;
707 706
 	}
708 707
 
709
-	return give_maybe_sanitize_amount( $low );
708
+	return give_maybe_sanitize_amount($low);
710 709
 }
711 710
 
712 711
 /**
@@ -718,23 +717,23 @@  discard block
 block discarded – undo
718 717
  *
719 718
  * @return float Amount of the highest price
720 719
  */
721
-function give_get_highest_price_option( $form_id = 0 ) {
720
+function give_get_highest_price_option($form_id = 0) {
722 721
 
723
-	if ( empty( $form_id ) ) {
722
+	if (empty($form_id)) {
724 723
 		$form_id = get_the_ID();
725 724
 	}
726 725
 
727
-	if ( ! give_has_variable_prices( $form_id ) ) {
728
-		return give_get_form_price( $form_id );
726
+	if ( ! give_has_variable_prices($form_id)) {
727
+		return give_get_form_price($form_id);
729 728
 	}
730 729
 
731
-	if ( ! ( $high = get_post_meta( $form_id, '_give_levels_maximum_amount', true ) ) ) {
730
+	if ( ! ($high = get_post_meta($form_id, '_give_levels_maximum_amount', true))) {
732 731
 		// Backward compatibility.
733
-		$prices = wp_list_pluck( give_get_variable_prices( $form_id ), '_give_amount' );
734
-		$high   = ! empty( $prices ) ? max( $prices ) : 0;
732
+		$prices = wp_list_pluck(give_get_variable_prices($form_id), '_give_amount');
733
+		$high   = ! empty($prices) ? max($prices) : 0;
735 734
 	}
736 735
 
737
-	return give_maybe_sanitize_amount( $high );
736
+	return give_maybe_sanitize_amount($high);
738 737
 }
739 738
 
740 739
 /**
@@ -746,15 +745,15 @@  discard block
 block discarded – undo
746 745
  *
747 746
  * @return mixed string|int Price of the form
748 747
  */
749
-function give_get_form_price( $form_id = 0 ) {
748
+function give_get_form_price($form_id = 0) {
750 749
 
751
-	if ( empty( $form_id ) ) {
750
+	if (empty($form_id)) {
752 751
 		return false;
753 752
 	}
754 753
 
755
-	$form = new Give_Donate_Form( $form_id );
754
+	$form = new Give_Donate_Form($form_id);
756 755
 
757
-	return $form->__get( 'price' );
756
+	return $form->__get('price');
758 757
 }
759 758
 
760 759
 /**
@@ -766,13 +765,13 @@  discard block
 block discarded – undo
766 765
  *
767 766
  * @return mixed string|int Minimum price of the form
768 767
  */
769
-function give_get_form_minimum_price( $form_id = 0 ) {
768
+function give_get_form_minimum_price($form_id = 0) {
770 769
 
771
-	if ( empty( $form_id ) ) {
770
+	if (empty($form_id)) {
772 771
 		return false;
773 772
 	}
774 773
 
775
-	$form = new Give_Donate_Form( $form_id );
774
+	$form = new Give_Donate_Form($form_id);
776 775
 
777 776
 	return $form->get_minimum_price();
778 777
 
@@ -787,13 +786,13 @@  discard block
 block discarded – undo
787 786
  *
788 787
  * @return bool|float
789 788
  */
790
-function give_get_form_maximum_price( $form_id = 0 ) {
789
+function give_get_form_maximum_price($form_id = 0) {
791 790
 
792
-	if ( empty( $form_id ) ) {
791
+	if (empty($form_id)) {
793 792
 		return false;
794 793
 	}
795 794
 
796
-	$form = new Give_Donate_Form( $form_id );
795
+	$form = new Give_Donate_Form($form_id);
797 796
 
798 797
 	return $form->get_maximum_price();
799 798
 }
@@ -809,48 +808,48 @@  discard block
 block discarded – undo
809 808
  *
810 809
  * @return int $formatted_price
811 810
  */
812
-function give_price( $form_id = 0, $echo = true, $price_id = false ) {
811
+function give_price($form_id = 0, $echo = true, $price_id = false) {
813 812
 	$price = 0;
814 813
 
815
-	if ( empty( $form_id ) ) {
814
+	if (empty($form_id)) {
816 815
 		$form_id = get_the_ID();
817 816
 	}
818 817
 
819
-	if ( give_has_variable_prices( $form_id ) ) {
818
+	if (give_has_variable_prices($form_id)) {
820 819
 
821
-		$prices = give_get_variable_prices( $form_id );
820
+		$prices = give_get_variable_prices($form_id);
822 821
 
823
-		if ( false !== $price_id ) {
822
+		if (false !== $price_id) {
824 823
 
825 824
 			// loop through multi-prices to see which is default
826
-			foreach ( $prices as $price ) {
825
+			foreach ($prices as $price) {
827 826
 				// this is the default price
828
-				if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) {
827
+				if (isset($price['_give_default']) && $price['_give_default'] === 'default') {
829 828
 					$price = (float) $price['_give_amount'];
830 829
 				};
831 830
 			}
832 831
 		} else {
833 832
 
834
-			$price = give_get_lowest_price_option( $form_id );
833
+			$price = give_get_lowest_price_option($form_id);
835 834
 		}
836 835
 	} else {
837 836
 
838
-		$price = give_get_form_price( $form_id );
837
+		$price = give_get_form_price($form_id);
839 838
 	}
840 839
 
841
-	$price           = apply_filters( 'give_form_price', give_maybe_sanitize_amount( $price ), $form_id );
842
-	$formatted_price = '<span class="give_price" id="give_price_' . $form_id . '">' . $price . '</span>';
843
-	$formatted_price = apply_filters( 'give_form_price_after_html', $formatted_price, $form_id, $price );
840
+	$price           = apply_filters('give_form_price', give_maybe_sanitize_amount($price), $form_id);
841
+	$formatted_price = '<span class="give_price" id="give_price_'.$form_id.'">'.$price.'</span>';
842
+	$formatted_price = apply_filters('give_form_price_after_html', $formatted_price, $form_id, $price);
844 843
 
845
-	if ( $echo ) {
844
+	if ($echo) {
846 845
 		echo $formatted_price;
847 846
 	} else {
848 847
 		return $formatted_price;
849 848
 	}
850 849
 }
851 850
 
852
-add_filter( 'give_form_price', 'give_format_amount', 10 );
853
-add_filter( 'give_form_price', 'give_currency_filter', 20 );
851
+add_filter('give_form_price', 'give_format_amount', 10);
852
+add_filter('give_form_price', 'give_currency_filter', 20);
854 853
 
855 854
 
856 855
 /**
@@ -863,19 +862,19 @@  discard block
 block discarded – undo
863 862
  *
864 863
  * @return float $amount Amount of the price option
865 864
  */
866
-function give_get_price_option_amount( $form_id = 0, $price_id = 0 ) {
867
-	$prices = give_get_variable_prices( $form_id );
865
+function give_get_price_option_amount($form_id = 0, $price_id = 0) {
866
+	$prices = give_get_variable_prices($form_id);
868 867
 
869 868
 	$amount = 0.00;
870 869
 
871
-	foreach ( $prices as $price ) {
872
-		if ( isset( $price['_give_id']['level_id'] ) && $price['_give_id']['level_id'] == $price_id ) {
873
-			$amount = isset( $price['_give_amount'] ) ? $price['_give_amount'] : 0.00;
870
+	foreach ($prices as $price) {
871
+		if (isset($price['_give_id']['level_id']) && $price['_give_id']['level_id'] == $price_id) {
872
+			$amount = isset($price['_give_amount']) ? $price['_give_amount'] : 0.00;
874 873
 			break;
875 874
 		};
876 875
 	}
877 876
 
878
-	return apply_filters( 'give_get_price_option_amount', give_maybe_sanitize_amount( $amount ), $form_id, $price_id );
877
+	return apply_filters('give_get_price_option_amount', give_maybe_sanitize_amount($amount), $form_id, $price_id);
879 878
 }
880 879
 
881 880
 /**
@@ -887,13 +886,13 @@  discard block
 block discarded – undo
887 886
  *
888 887
  * @return mixed string|int Goal of the form
889 888
  */
890
-function give_get_form_goal( $form_id = 0 ) {
889
+function give_get_form_goal($form_id = 0) {
891 890
 
892
-	if ( empty( $form_id ) ) {
891
+	if (empty($form_id)) {
893 892
 		return false;
894 893
 	}
895 894
 
896
-	$form = new Give_Donate_Form( $form_id );
895
+	$form = new Give_Donate_Form($form_id);
897 896
 
898 897
 	return $form->goal;
899 898
 
@@ -908,13 +907,13 @@  discard block
 block discarded – undo
908 907
  *
909 908
  * @return mixed string|int Goal of the form
910 909
  */
911
-function give_get_form_goal_format( $form_id = 0 ) {
910
+function give_get_form_goal_format($form_id = 0) {
912 911
 
913
-	if ( empty( $form_id ) ) {
912
+	if (empty($form_id)) {
914 913
 		return false;
915 914
 	}
916 915
 
917
-	return give_get_meta( $form_id, '_give_goal_format', true );
916
+	return give_get_meta($form_id, '_give_goal_format', true);
918 917
 
919 918
 }
920 919
 
@@ -928,19 +927,19 @@  discard block
 block discarded – undo
928 927
  *
929 928
  * @return string $formatted_goal
930 929
  */
931
-function give_goal( $form_id = 0, $echo = true ) {
930
+function give_goal($form_id = 0, $echo = true) {
932 931
 
933
-	if ( empty( $form_id ) ) {
932
+	if (empty($form_id)) {
934 933
 		$form_id = get_the_ID();
935 934
 	}
936 935
 
937
-	$goal        = give_get_form_goal( $form_id );
938
-	$goal_format = give_get_form_goal_format( $form_id );
936
+	$goal        = give_get_form_goal($form_id);
937
+	$goal_format = give_get_form_goal_format($form_id);
939 938
 
940
-	if ( 'donation' === $goal_format ) {
939
+	if ('donation' === $goal_format) {
941 940
 		$goal = "{$goal} donations";
942 941
 	} else {
943
-		$goal = apply_filters( 'give_form_goal', give_maybe_sanitize_amount( $goal ), $form_id );
942
+		$goal = apply_filters('give_form_goal', give_maybe_sanitize_amount($goal), $form_id);
944 943
 	}
945 944
 
946 945
 	$formatted_goal = sprintf(
@@ -948,17 +947,17 @@  discard block
 block discarded – undo
948 947
 		$form_id,
949 948
 		$goal
950 949
 	);
951
-	$formatted_goal = apply_filters( 'give_form_price_after_html', $formatted_goal, $form_id, $goal );
950
+	$formatted_goal = apply_filters('give_form_price_after_html', $formatted_goal, $form_id, $goal);
952 951
 
953
-	if ( $echo ) {
952
+	if ($echo) {
954 953
 		echo $formatted_goal;
955 954
 	} else {
956 955
 		return $formatted_goal;
957 956
 	}
958 957
 }
959 958
 
960
-add_filter( 'give_form_goal', 'give_format_amount', 10 );
961
-add_filter( 'give_form_goal', 'give_currency_filter', 20 );
959
+add_filter('give_form_goal', 'give_format_amount', 10);
960
+add_filter('give_form_goal', 'give_currency_filter', 20);
962 961
 
963 962
 
964 963
 /**
@@ -970,15 +969,15 @@  discard block
 block discarded – undo
970 969
  *
971 970
  * @return bool  $ret Whether or not the logged_in_only setting is set
972 971
  */
973
-function give_logged_in_only( $form_id ) {
972
+function give_logged_in_only($form_id) {
974 973
 	// If _give_logged_in_only is set to enable then guest can donate from that specific form.
975 974
 	// Otherwise it is member only donation form.
976
-	$val = give_get_meta( $form_id, '_give_logged_in_only', true );
977
-	$val = ! empty( $val ) ? $val : 'enabled';
975
+	$val = give_get_meta($form_id, '_give_logged_in_only', true);
976
+	$val = ! empty($val) ? $val : 'enabled';
978 977
 
979
-	$ret = ! give_is_setting_enabled( $val );
978
+	$ret = ! give_is_setting_enabled($val);
980 979
 
981
-	return (bool) apply_filters( 'give_logged_in_only', $ret, $form_id );
980
+	return (bool) apply_filters('give_logged_in_only', $ret, $form_id);
982 981
 }
983 982
 
984 983
 
@@ -991,11 +990,11 @@  discard block
 block discarded – undo
991 990
  *
992 991
  * @return string
993 992
  */
994
-function give_show_login_register_option( $form_id ) {
993
+function give_show_login_register_option($form_id) {
995 994
 
996
-	$show_register_form = give_get_meta( $form_id, '_give_show_register_form', true );
995
+	$show_register_form = give_get_meta($form_id, '_give_show_register_form', true);
997 996
 
998
-	return apply_filters( 'give_show_register_form', $show_register_form, $form_id );
997
+	return apply_filters('give_show_register_form', $show_register_form, $form_id);
999 998
 
1000 999
 }
1001 1000
 
@@ -1011,12 +1010,12 @@  discard block
 block discarded – undo
1011 1010
  *
1012 1011
  * @return array
1013 1012
  */
1014
-function _give_get_prefill_form_field_values( $form_id ) {
1013
+function _give_get_prefill_form_field_values($form_id) {
1015 1014
 	$logged_in_donor_info = array();
1016 1015
 
1017
-	if ( is_user_logged_in() ) :
1018
-		$donor_data    = get_userdata( get_current_user_id() );
1019
-		$donor         = new Give_Donor( get_current_user_id(), true );
1016
+	if (is_user_logged_in()) :
1017
+		$donor_data    = get_userdata(get_current_user_id());
1018
+		$donor         = new Give_Donor(get_current_user_id(), true);
1020 1019
 		$donor_address = $donor->get_donor_address();
1021 1020
 		$company_name  = $donor->get_company_name();
1022 1021
 
@@ -1055,23 +1054,23 @@  discard block
 block discarded – undo
1055 1054
 
1056 1055
 	// Bailout: Auto fill form field values only form form which donor is donating.
1057 1056
 	if (
1058
-		empty( $_GET['form-id'] )
1057
+		empty($_GET['form-id'])
1059 1058
 		|| ! $form_id
1060
-		|| ( $form_id !== absint( $_GET['form-id'] ) )
1059
+		|| ($form_id !== absint($_GET['form-id']))
1061 1060
 	) {
1062 1061
 		return $logged_in_donor_info;
1063 1062
 	}
1064 1063
 
1065 1064
 	// Get purchase data.
1066
-	$give_purchase_data = Give()->session->get( 'give_purchase' );
1065
+	$give_purchase_data = Give()->session->get('give_purchase');
1067 1066
 
1068 1067
 	// Get donor info from form data.
1069
-	$give_donor_info_in_session = empty( $give_purchase_data['post_data'] )
1068
+	$give_donor_info_in_session = empty($give_purchase_data['post_data'])
1070 1069
 		? array()
1071 1070
 		: $give_purchase_data['post_data'];
1072 1071
 
1073 1072
 	// Output.
1074
-	return wp_parse_args( $give_donor_info_in_session, $logged_in_donor_info );
1073
+	return wp_parse_args($give_donor_info_in_session, $logged_in_donor_info);
1075 1074
 }
1076 1075
 
1077 1076
 /**
@@ -1084,13 +1083,13 @@  discard block
 block discarded – undo
1084 1083
  *
1085 1084
  * @return int
1086 1085
  */
1087
-function give_get_form_donor_count( $form_id, $args = array() ) {
1086
+function give_get_form_donor_count($form_id, $args = array()) {
1088 1087
 	global $wpdb;
1089 1088
 
1090
-	$cache_key   = Give_Cache::get_key( "form_donor_count_{$form_id}", $args, false );
1091
-	$donor_count = absint( Give_Cache::get_db_query( $cache_key ) );
1089
+	$cache_key   = Give_Cache::get_key("form_donor_count_{$form_id}", $args, false);
1090
+	$donor_count = absint(Give_Cache::get_db_query($cache_key));
1092 1091
 
1093
-	if ( $form_id && ! $donor_count ) {
1092
+	if ($form_id && ! $donor_count) {
1094 1093
 		// Set arguments.
1095 1094
 		$args = wp_parse_args(
1096 1095
 			$args,
@@ -1124,7 +1123,7 @@  discard block
 block discarded – undo
1124 1123
 			'publish'
1125 1124
 		);
1126 1125
 
1127
-		$donor_count = absint( $wpdb->get_var( $query ) );
1126
+		$donor_count = absint($wpdb->get_var($query));
1128 1127
 	}
1129 1128
 
1130 1129
 
@@ -1133,9 +1132,9 @@  discard block
 block discarded – undo
1133 1132
 	 *
1134 1133
 	 * @since 2.1.0
1135 1134
 	 */
1136
-	$donor_count = apply_filters( 'give_get_form_donor_count', $donor_count, $form_id, $args );
1135
+	$donor_count = apply_filters('give_get_form_donor_count', $donor_count, $form_id, $args);
1137 1136
 
1138
-	Give_Cache::set_db_query( $cache_key, $donor_count );
1137
+	Give_Cache::set_db_query($cache_key, $donor_count);
1139 1138
 
1140 1139
 	return $donor_count;
1141 1140
 }
@@ -1149,33 +1148,33 @@  discard block
 block discarded – undo
1149 1148
  *
1150 1149
  * @return void
1151 1150
  */
1152
-function give_set_form_closed_status( $form_id ) {
1151
+function give_set_form_closed_status($form_id) {
1153 1152
 
1154 1153
 	// Bailout.
1155
-	if ( empty( $form_id ) ) {
1154
+	if (empty($form_id)) {
1156 1155
 		return;
1157 1156
 	}
1158 1157
 
1159 1158
 	$open_form       = false;
1160
-	$is_goal_enabled = give_is_setting_enabled( give_get_meta( $form_id, '_give_goal_option', true, 'disabled' ) );
1159
+	$is_goal_enabled = give_is_setting_enabled(give_get_meta($form_id, '_give_goal_option', true, 'disabled'));
1161 1160
 
1162 1161
 	// Proceed, if the form goal is enabled.
1163
-	if ( $is_goal_enabled ) {
1162
+	if ($is_goal_enabled) {
1164 1163
 
1165
-		$close_form_when_goal_achieved = give_is_setting_enabled( give_get_meta( $form_id, '_give_close_form_when_goal_achieved', true, 'disabled' ) );
1164
+		$close_form_when_goal_achieved = give_is_setting_enabled(give_get_meta($form_id, '_give_close_form_when_goal_achieved', true, 'disabled'));
1166 1165
 
1167 1166
 		// Proceed, if close form when goal achieved option is enabled.
1168
-		if ( $close_form_when_goal_achieved ) {
1167
+		if ($close_form_when_goal_achieved) {
1169 1168
 
1170
-			$form                = new Give_Donate_Form( $form_id );
1171
-			$goal_progress_stats = give_goal_progress_stats( $form );
1169
+			$form                = new Give_Donate_Form($form_id);
1170
+			$goal_progress_stats = give_goal_progress_stats($form);
1172 1171
 
1173 1172
 			// Verify whether the form is closed or not after processing data.
1174 1173
 			$closed = $goal_progress_stats['raw_goal'] <= $goal_progress_stats['raw_actual'];
1175 1174
 
1176 1175
 			// Update form meta if verified that the form is closed.
1177
-			if ( $closed ) {
1178
-				give_update_meta( $form_id, '_give_form_status', 'closed' );
1176
+			if ($closed) {
1177
+				give_update_meta($form_id, '_give_form_status', 'closed');
1179 1178
 			} else {
1180 1179
 				$open_form = true;
1181 1180
 			}
@@ -1187,8 +1186,8 @@  discard block
 block discarded – undo
1187 1186
 	}
1188 1187
 
1189 1188
 	// If $open_form is true, then update form status to open.
1190
-	if ( $open_form ) {
1191
-		give_update_meta( $form_id, '_give_form_status', 'open' );
1189
+	if ($open_form) {
1190
+		give_update_meta($form_id, '_give_form_status', 'open');
1192 1191
 	}
1193 1192
 }
1194 1193
 
@@ -1201,32 +1200,31 @@  discard block
 block discarded – undo
1201 1200
  *
1202 1201
  * @return string
1203 1202
  */
1204
-function give_admin_form_goal_stats( $form_id ) {
1203
+function give_admin_form_goal_stats($form_id) {
1205 1204
 
1206 1205
 	$html             = '';
1207
-	$goal_stats       = give_goal_progress_stats( $form_id );
1208
-	$percent_complete = round( ( $goal_stats['raw_actual'] / $goal_stats['raw_goal'] ), 3 ) * 100;
1206
+	$goal_stats       = give_goal_progress_stats($form_id);
1207
+	$percent_complete = round(($goal_stats['raw_actual'] / $goal_stats['raw_goal']), 3) * 100;
1209 1208
 
1210 1209
 	$html .= sprintf(
1211 1210
 		'<div class="give-admin-progress-bar" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="%1$s">
1212 1211
 <span style="width:%1$s%%;"></span>
1213 1212
 </div>',
1214
-		esc_attr( $goal_stats['progress'] )
1213
+		esc_attr($goal_stats['progress'])
1215 1214
 	);
1216 1215
 
1217 1216
 	$html .= sprintf(
1218
-		( 'percentage' !== $goal_stats['format'] ) ?
1219
-			'<div class="give-goal-text"><span>%1$s</span> %2$s <a href="%3$s">%4$s</a> %5$s ' :
1220
-			'<div class="give-goal-text"><a href="%3$s">%1$s </a>',
1221
-		( 'percentage' !== $goal_stats['format'] ) ? $goal_stats['actual'] : $percent_complete . '%',
1222
-		( 'percentage' !== $goal_stats['format'] ) ? __( 'of', 'give' ) : '',
1223
-		esc_url( admin_url( "post.php?post={$form_id}&action=edit&give_tab=donation_goal_options" ) ),
1217
+		('percentage' !== $goal_stats['format']) ?
1218
+			'<div class="give-goal-text"><span>%1$s</span> %2$s <a href="%3$s">%4$s</a> %5$s ' : '<div class="give-goal-text"><a href="%3$s">%1$s </a>',
1219
+		('percentage' !== $goal_stats['format']) ? $goal_stats['actual'] : $percent_complete.'%',
1220
+		('percentage' !== $goal_stats['format']) ? __('of', 'give') : '',
1221
+		esc_url(admin_url("post.php?post={$form_id}&action=edit&give_tab=donation_goal_options")),
1224 1222
 		$goal_stats['goal'],
1225
-		( 'donors' === $goal_stats['format'] ? __( 'Donors', 'give' ) : ( 'donation' === $goal_stats['format'] ? __( 'Donations', 'give' ) : '' ) )
1223
+		('donors' === $goal_stats['format'] ? __('Donors', 'give') : ('donation' === $goal_stats['format'] ? __('Donations', 'give') : ''))
1226 1224
 	);
1227 1225
 
1228
-	if ( $goal_stats['raw_actual'] >= $goal_stats['raw_goal'] ) {
1229
-		$html .= sprintf( '<span class="give-admin-goal-achieved"><span class="dashicons dashicons-star-filled"></span> %s</span>', __( 'Goal achieved', 'give' ) );
1226
+	if ($goal_stats['raw_actual'] >= $goal_stats['raw_goal']) {
1227
+		$html .= sprintf('<span class="give-admin-goal-achieved"><span class="dashicons dashicons-star-filled"></span> %s</span>', __('Goal achieved', 'give'));
1230 1228
 	}
1231 1229
 
1232 1230
 	$html .= '</div>';
Please login to merge, or discard this patch.
includes/user-functions.php 1 patch
Spacing   +131 added lines, -131 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly.
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -30,54 +30,54 @@  discard block
 block discarded – undo
30 30
  *
31 31
  * @return bool|array List of all user donations.
32 32
  */
33
-function give_get_users_donations( $user = 0, $number = 20, $pagination = false, $status = 'complete' ) {
33
+function give_get_users_donations($user = 0, $number = 20, $pagination = false, $status = 'complete') {
34 34
 
35
-	if ( empty( $user ) ) {
35
+	if (empty($user)) {
36 36
 		$user = get_current_user_id();
37 37
 	}
38 38
 
39
-	if ( 0 === $user && ! Give()->email_access->token_exists ) {
39
+	if (0 === $user && ! Give()->email_access->token_exists) {
40 40
 		return false;
41 41
 	}
42 42
 
43
-	$status = ( 'complete' === $status ) ? 'publish' : $status;
43
+	$status = ('complete' === $status) ? 'publish' : $status;
44 44
 	$paged = 1;
45 45
 
46
-	if ( $pagination ) {
47
-		if ( get_query_var( 'paged' ) ) {
48
-			$paged = get_query_var( 'paged' );
49
-		} elseif ( get_query_var( 'page' ) ) {
50
-			$paged = get_query_var( 'page' );
46
+	if ($pagination) {
47
+		if (get_query_var('paged')) {
48
+			$paged = get_query_var('paged');
49
+		} elseif (get_query_var('page')) {
50
+			$paged = get_query_var('page');
51 51
 		}
52 52
 	}
53 53
 
54
-	$args = apply_filters( 'give_get_users_donations_args', array(
54
+	$args = apply_filters('give_get_users_donations_args', array(
55 55
 		'user'    => $user,
56 56
 		'number'  => $number,
57 57
 		'status'  => $status,
58 58
 		'orderby' => 'date',
59
-	) );
59
+	));
60 60
 
61
-	if ( $pagination ) {
61
+	if ($pagination) {
62 62
 		$args['page'] = $paged;
63 63
 	} else {
64 64
 		$args['nopaging'] = true;
65 65
 	}
66 66
 
67
-	$by_user_id = is_numeric( $user ) ? true : false;
68
-	$donor   = new Give_Donor( $user, $by_user_id );
67
+	$by_user_id = is_numeric($user) ? true : false;
68
+	$donor = new Give_Donor($user, $by_user_id);
69 69
 
70
-	if ( ! empty( $donor->payment_ids ) ) {
70
+	if ( ! empty($donor->payment_ids)) {
71 71
 
72
-		unset( $args['user'] );
73
-		$args['post__in'] = array_map( 'absint', explode( ',', $donor->payment_ids ) );
72
+		unset($args['user']);
73
+		$args['post__in'] = array_map('absint', explode(',', $donor->payment_ids));
74 74
 
75 75
 	}
76 76
 
77
-	$donations = give_get_payments( apply_filters( 'give_get_users_donations_args', $args ) );
77
+	$donations = give_get_payments(apply_filters('give_get_users_donations_args', $args));
78 78
 
79 79
 	// No donations.
80
-	if ( ! $donations ) {
80
+	if ( ! $donations) {
81 81
 		return false;
82 82
 	}
83 83
 
@@ -96,65 +96,65 @@  discard block
 block discarded – undo
96 96
  *
97 97
  * @return bool|object List of unique forms donated by user
98 98
  */
99
-function give_get_users_completed_donations( $user = 0, $status = 'complete' ) {
100
-	if ( empty( $user ) ) {
99
+function give_get_users_completed_donations($user = 0, $status = 'complete') {
100
+	if (empty($user)) {
101 101
 		$user = get_current_user_id();
102 102
 	}
103 103
 
104
-	if ( empty( $user ) ) {
104
+	if (empty($user)) {
105 105
 		return false;
106 106
 	}
107 107
 
108
-	$by_user_id = is_numeric( $user ) ? true : false;
108
+	$by_user_id = is_numeric($user) ? true : false;
109 109
 
110
-	$donor = new Give_Donor( $user, $by_user_id );
110
+	$donor = new Give_Donor($user, $by_user_id);
111 111
 
112
-	if ( empty( $donor->payment_ids ) ) {
112
+	if (empty($donor->payment_ids)) {
113 113
 		return false;
114 114
 	}
115 115
 
116 116
 	// Get all the items donated.
117
-	$payment_ids    = array_reverse( explode( ',', $donor->payment_ids ) );
118
-	$limit_payments = apply_filters( 'give_users_completed_donations_payments', 50 );
119
-	if ( ! empty( $limit_payments ) ) {
120
-		$payment_ids = array_slice( $payment_ids, 0, $limit_payments );
117
+	$payment_ids    = array_reverse(explode(',', $donor->payment_ids));
118
+	$limit_payments = apply_filters('give_users_completed_donations_payments', 50);
119
+	if ( ! empty($limit_payments)) {
120
+		$payment_ids = array_slice($payment_ids, 0, $limit_payments);
121 121
 	}
122 122
 	$donation_data = array();
123
-	foreach ( $payment_ids as $payment_id ) {
124
-		$donation_data[] = give_get_payment_meta( $payment_id );
123
+	foreach ($payment_ids as $payment_id) {
124
+		$donation_data[] = give_get_payment_meta($payment_id);
125 125
 	}
126 126
 
127
-	if ( empty( $donation_data ) ) {
127
+	if (empty($donation_data)) {
128 128
 		return false;
129 129
 	}
130 130
 
131 131
 	// Grab only the post ids "form_id" of the forms donated on this order.
132 132
 	$completed_donations_ids = array();
133
-	foreach ( $donation_data as $donation_meta ) {
134
-		$completed_donations_ids[] = isset( $donation_meta['form_id'] ) ? $donation_meta['form_id'] : '';
133
+	foreach ($donation_data as $donation_meta) {
134
+		$completed_donations_ids[] = isset($donation_meta['form_id']) ? $donation_meta['form_id'] : '';
135 135
 	}
136 136
 
137
-	if ( empty( $completed_donations_ids ) ) {
137
+	if (empty($completed_donations_ids)) {
138 138
 		return false;
139 139
 	}
140 140
 
141 141
 	// Only include each donation once.
142
-	$form_ids = array_unique( $completed_donations_ids );
142
+	$form_ids = array_unique($completed_donations_ids);
143 143
 
144 144
 	// Make sure we still have some products and a first item.
145
-	if ( empty( $form_ids ) || ! isset( $form_ids[0] ) ) {
145
+	if (empty($form_ids) || ! isset($form_ids[0])) {
146 146
 		return false;
147 147
 	}
148 148
 
149
-	$post_type = get_post_type( $form_ids[0] );
149
+	$post_type = get_post_type($form_ids[0]);
150 150
 
151
-	$args = apply_filters( 'give_get_users_completed_donations_args', array(
151
+	$args = apply_filters('give_get_users_completed_donations_args', array(
152 152
 		'include'        => $form_ids,
153 153
 		'post_type'      => $post_type,
154
-		'posts_per_page' => - 1,
155
-	) );
154
+		'posts_per_page' => -1,
155
+	));
156 156
 
157
-	return apply_filters( 'give_users_completed_donations_list', get_posts( $args ) );
157
+	return apply_filters('give_users_completed_donations_list', get_posts($args));
158 158
 }
159 159
 
160 160
 
@@ -170,12 +170,12 @@  discard block
 block discarded – undo
170 170
  *
171 171
  * @return bool True if has donated, false other wise.
172 172
  */
173
-function give_has_donations( $user_id = null ) {
174
-	if ( empty( $user_id ) ) {
173
+function give_has_donations($user_id = null) {
174
+	if (empty($user_id)) {
175 175
 		$user_id = get_current_user_id();
176 176
 	}
177 177
 
178
-	if ( give_get_users_donations( $user_id, 1 ) ) {
178
+	if (give_get_users_donations($user_id, 1)) {
179 179
 		return true; // User has at least one donation.
180 180
 	}
181 181
 
@@ -196,23 +196,23 @@  discard block
 block discarded – undo
196 196
  *
197 197
  * @return array
198 198
  */
199
-function give_get_donation_stats_by_user( $user = '' ) {
199
+function give_get_donation_stats_by_user($user = '') {
200 200
 
201 201
 	$field = '';
202 202
 
203
-	if ( is_email( $user ) ) {
203
+	if (is_email($user)) {
204 204
 		$field = 'email';
205
-	} elseif ( is_numeric( $user ) ) {
205
+	} elseif (is_numeric($user)) {
206 206
 		$field = 'user_id';
207 207
 	}
208 208
 
209
-	$stats    = array();
210
-	$donor = Give()->donors->get_donor_by( $field, $user );
209
+	$stats = array();
210
+	$donor = Give()->donors->get_donor_by($field, $user);
211 211
 
212
-	if ( $donor ) {
213
-		$donor = new Give_Donor( $donor->id );
214
-		$stats['purchases']   = absint( $donor->purchase_count );
215
-		$stats['total_spent'] = give_maybe_sanitize_amount( $donor->get_total_donation_amount() );
212
+	if ($donor) {
213
+		$donor = new Give_Donor($donor->id);
214
+		$stats['purchases']   = absint($donor->purchase_count);
215
+		$stats['total_spent'] = give_maybe_sanitize_amount($donor->get_total_donation_amount());
216 216
 	}
217 217
 
218 218
 	/**
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 	 *
221 221
 	 * @since 1.7
222 222
 	 */
223
-	$stats = (array) apply_filters( 'give_donation_stats_by_user', $stats, $user );
223
+	$stats = (array) apply_filters('give_donation_stats_by_user', $stats, $user);
224 224
 
225 225
 	return $stats;
226 226
 }
@@ -238,21 +238,21 @@  discard block
 block discarded – undo
238 238
  *
239 239
  * @return int The total number of donations.
240 240
  */
241
-function give_count_donations_of_donor( $user = null ) {
241
+function give_count_donations_of_donor($user = null) {
242 242
 
243 243
 	// Logged in?
244
-	if ( empty( $user ) ) {
244
+	if (empty($user)) {
245 245
 		$user = get_current_user_id();
246 246
 	}
247 247
 
248 248
 	// Email access?
249
-	if ( empty( $user ) && Give()->email_access->token_email ) {
249
+	if (empty($user) && Give()->email_access->token_email) {
250 250
 		$user = Give()->email_access->token_email;
251 251
 	}
252 252
 
253
-	$stats = ! empty( $user ) ? give_get_donation_stats_by_user( $user ) : false;
253
+	$stats = ! empty($user) ? give_get_donation_stats_by_user($user) : false;
254 254
 
255
-	return isset( $stats['purchases'] ) ? $stats['purchases'] : 0;
255
+	return isset($stats['purchases']) ? $stats['purchases'] : 0;
256 256
 }
257 257
 
258 258
 /**
@@ -265,9 +265,9 @@  discard block
 block discarded – undo
265 265
  *
266 266
  * @return float The total amount the user has spent
267 267
  */
268
-function give_donation_total_of_user( $user = null ) {
268
+function give_donation_total_of_user($user = null) {
269 269
 
270
-	$stats = give_get_donation_stats_by_user( $user );
270
+	$stats = give_get_donation_stats_by_user($user);
271 271
 
272 272
 	return $stats['total_spent'];
273 273
 }
@@ -283,40 +283,40 @@  discard block
 block discarded – undo
283 283
  *
284 284
  * @return bool
285 285
  */
286
-function give_validate_username( $username, $form_id = 0 ) {
286
+function give_validate_username($username, $form_id = 0) {
287 287
 	$valid = true;
288 288
 
289 289
 	// Validate username.
290
-	if ( ! empty( $username ) ) {
290
+	if ( ! empty($username)) {
291 291
 
292 292
 		// Sanitize username.
293
-		$sanitized_user_name = sanitize_user( $username, false );
293
+		$sanitized_user_name = sanitize_user($username, false);
294 294
 
295 295
 		// We have an user name, check if it already exists.
296
-		if ( username_exists( $username ) ) {
296
+		if (username_exists($username)) {
297 297
 			// Username already registered.
298
-			give_set_error( 'username_unavailable', __( 'Username already taken.', 'give' ) );
298
+			give_set_error('username_unavailable', __('Username already taken.', 'give'));
299 299
 			$valid = false;
300 300
 
301 301
 			// Check if it's valid.
302
-		} elseif ( $sanitized_user_name !== $username ) {
302
+		} elseif ($sanitized_user_name !== $username) {
303 303
 			// Invalid username.
304
-			if ( is_multisite() ) {
305
-				give_set_error( 'username_invalid', __( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ) );
304
+			if (is_multisite()) {
305
+				give_set_error('username_invalid', __('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give'));
306 306
 				$valid = false;
307 307
 			} else {
308
-				give_set_error( 'username_invalid', __( 'Invalid username.', 'give' ) );
308
+				give_set_error('username_invalid', __('Invalid username.', 'give'));
309 309
 				$valid = false;
310 310
 			}
311 311
 		}
312 312
 	} else {
313 313
 		// Username is empty.
314
-		give_set_error( 'username_empty', __( 'Enter a username.', 'give' ) );
314
+		give_set_error('username_empty', __('Enter a username.', 'give'));
315 315
 		$valid = false;
316 316
 
317 317
 		// Check if guest checkout is disable for form.
318
-		if ( $form_id && give_logged_in_only( $form_id ) ) {
319
-			give_set_error( 'registration_required', __( 'You must register or login to complete your donation.', 'give' ) );
318
+		if ($form_id && give_logged_in_only($form_id)) {
319
+			give_set_error('registration_required', __('You must register or login to complete your donation.', 'give'));
320 320
 			$valid = false;
321 321
 		}
322 322
 	}
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 	 *
331 331
 	 * @since 1.8
332 332
 	 */
333
-	$valid = (bool) apply_filters( 'give_validate_username', $valid, $username, $form_id );
333
+	$valid = (bool) apply_filters('give_validate_username', $valid, $username, $form_id);
334 334
 
335 335
 	return $valid;
336 336
 }
@@ -346,30 +346,30 @@  discard block
 block discarded – undo
346 346
  *
347 347
  * @return bool
348 348
  */
349
-function give_validate_user_email( $email, $registering_new_user = false ) {
349
+function give_validate_user_email($email, $registering_new_user = false) {
350 350
 	$valid = true;
351 351
 
352
-	if ( empty( $email ) ) {
352
+	if (empty($email)) {
353 353
 		// No email.
354
-		give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) );
354
+		give_set_error('email_empty', __('Enter an email.', 'give'));
355 355
 		$valid = false;
356 356
 
357
-	} elseif ( email_exists( $email ) ) {
357
+	} elseif (email_exists($email)) {
358 358
 		// Email already exists.
359
-		give_set_error( 'email_exists', __( 'Email already exists.', 'give' ) );
359
+		give_set_error('email_exists', __('Email already exists.', 'give'));
360 360
 		$valid = false;
361 361
 
362
-	} elseif ( ! is_email( $email ) ) {
362
+	} elseif ( ! is_email($email)) {
363 363
 		// Validate email.
364
-		give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) );
364
+		give_set_error('email_invalid', __('Invalid email.', 'give'));
365 365
 		$valid = false;
366 366
 
367
-	} elseif ( $registering_new_user ) {
367
+	} elseif ($registering_new_user) {
368 368
 
369 369
 		// If donor email is not primary.
370
-		if ( ! email_exists( $email ) && give_donor_email_exists( $email ) && give_is_additional_email( $email ) ) {
370
+		if ( ! email_exists($email) && give_donor_email_exists($email) && give_is_additional_email($email)) {
371 371
 			// Check if email exists.
372
-			give_set_error( 'email_used', __( 'The email address provided is already active for another user.', 'give' ) );
372
+			give_set_error('email_used', __('The email address provided is already active for another user.', 'give'));
373 373
 			$valid = false;
374 374
 		}
375 375
 	}
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 	 *
384 384
 	 * @since 1.8
385 385
 	 */
386
-	$valid = (bool) apply_filters( 'give_validate_user_email', $valid, $email, $registering_new_user );
386
+	$valid = (bool) apply_filters('give_validate_user_email', $valid, $email, $registering_new_user);
387 387
 
388 388
 	return $valid;
389 389
 }
@@ -399,34 +399,34 @@  discard block
 block discarded – undo
399 399
  *
400 400
  * @return bool
401 401
  */
402
-function give_validate_user_password( $password = '', $confirm_password = '', $registering_new_user = false ) {
402
+function give_validate_user_password($password = '', $confirm_password = '', $registering_new_user = false) {
403 403
 	$valid = true;
404 404
 
405 405
 	// Passwords Validation For New Donors Only.
406
-	if ( $registering_new_user ) {
406
+	if ($registering_new_user) {
407 407
 		// Password or confirmation missing.
408
-		if ( ! $password ) {
408
+		if ( ! $password) {
409 409
 			// The password is invalid.
410
-			give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) );
410
+			give_set_error('password_empty', __('Enter a password.', 'give'));
411 411
 			$valid = false;
412
-		} elseif ( ! $confirm_password ) {
412
+		} elseif ( ! $confirm_password) {
413 413
 			// Confirmation password is invalid.
414
-			give_set_error( 'confirmation_empty', __( 'Enter the password confirmation.', 'give' ) );
414
+			give_set_error('confirmation_empty', __('Enter the password confirmation.', 'give'));
415 415
 			$valid = false;
416 416
 		}
417 417
 	}
418 418
 	// Passwords Validation For New Donors as well as Existing Donors.
419
-	if ( $password || $confirm_password ) {
420
-		if ( strlen( $password ) < 6 || strlen( $confirm_password ) < 6 ) {
419
+	if ($password || $confirm_password) {
420
+		if (strlen($password) < 6 || strlen($confirm_password) < 6) {
421 421
 			// Seems Weak Password.
422
-			give_set_error( 'password_weak', __( 'Passwords should have at least 6 characters.', 'give' ) );
422
+			give_set_error('password_weak', __('Passwords should have at least 6 characters.', 'give'));
423 423
 			$valid = false;
424 424
 		}
425
-		if ( $password && $confirm_password ) {
425
+		if ($password && $confirm_password) {
426 426
 			// Verify confirmation matches.
427
-			if ( $password !== $confirm_password ) {
427
+			if ($password !== $confirm_password) {
428 428
 				// Passwords do not match.
429
-				give_set_error( 'password_mismatch', __( 'Passwords you entered do not match. Please try again.', 'give' ) );
429
+				give_set_error('password_mismatch', __('Passwords you entered do not match. Please try again.', 'give'));
430 430
 				$valid = false;
431 431
 			}
432 432
 		}
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
 	 *
443 443
 	 * @since 1.8
444 444
 	 */
445
-	$valid = (bool) apply_filters( 'give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user );
445
+	$valid = (bool) apply_filters('give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user);
446 446
 
447 447
 	return $valid;
448 448
 }
@@ -470,8 +470,8 @@  discard block
 block discarded – undo
470 470
  *
471 471
  * @return array The donor's address, if any
472 472
  */
473
-function give_get_donor_address( $donor_id = null, $args = array() ) {
474
-	if ( empty( $donor_id ) ) {
473
+function give_get_donor_address($donor_id = null, $args = array()) {
474
+	if (empty($donor_id)) {
475 475
 		$donor_id = get_current_user_id();
476 476
 	}
477 477
 
@@ -493,33 +493,33 @@  discard block
 block discarded – undo
493 493
 
494 494
 
495 495
 	// Backward compatibility for user id param.
496
-	$by_user_id = get_user_by( 'id', $donor_id ) ? true : false;
496
+	$by_user_id = get_user_by('id', $donor_id) ? true : false;
497 497
 
498 498
 	// Backward compatibility.
499
-	if ( ! give_has_upgrade_completed( 'v20_upgrades_user_address' ) && $by_user_id ) {
499
+	if ( ! give_has_upgrade_completed('v20_upgrades_user_address') && $by_user_id) {
500 500
 		return wp_parse_args(
501
-			(array) get_user_meta( $donor_id, '_give_user_address', true ),
501
+			(array) get_user_meta($donor_id, '_give_user_address', true),
502 502
 			$default_address
503 503
 		);
504 504
 	}
505 505
 
506
-	$donor = new Give_Donor( $donor_id, $by_user_id );
506
+	$donor = new Give_Donor($donor_id, $by_user_id);
507 507
 
508 508
 	if (
509 509
 		! $donor->id ||
510
-		empty( $donor->address ) ||
511
-		! array_key_exists( $args['address_type'], $donor->address )
510
+		empty($donor->address) ||
511
+		! array_key_exists($args['address_type'], $donor->address)
512 512
 	) {
513 513
 		return $default_address;
514 514
 	}
515 515
 
516
-	switch ( true ) {
517
-		case is_string( end( $donor->address[ $args['address_type'] ] ) ):
518
-			$address = wp_parse_args( $donor->address[ $args['address_type'] ], $default_address );
516
+	switch (true) {
517
+		case is_string(end($donor->address[$args['address_type']])):
518
+			$address = wp_parse_args($donor->address[$args['address_type']], $default_address);
519 519
 			break;
520 520
 
521
-		case is_array( end( $donor->address[ $args['address_type'] ] ) ):
522
-			$address = wp_parse_args( array_shift( $donor->address[ $args['address_type'] ] ), $default_address );
521
+		case is_array(end($donor->address[$args['address_type']])):
522
+			$address = wp_parse_args(array_shift($donor->address[$args['address_type']]), $default_address);
523 523
 			break;
524 524
 	}
525 525
 
@@ -539,17 +539,17 @@  discard block
 block discarded – undo
539 539
  *
540 540
  * @return void
541 541
  */
542
-function give_new_user_notification( $user_id = 0, $user_data = array() ) {
542
+function give_new_user_notification($user_id = 0, $user_data = array()) {
543 543
 	// Bailout.
544
-	if ( empty( $user_id ) || empty( $user_data ) ) {
544
+	if (empty($user_id) || empty($user_data)) {
545 545
 		return;
546 546
 	}
547 547
 
548
-	do_action( 'give_new-donor-register_email_notification', $user_id, $user_data );
549
-	do_action( 'give_donor-register_email_notification', $user_id, $user_data );
548
+	do_action('give_new-donor-register_email_notification', $user_id, $user_data);
549
+	do_action('give_donor-register_email_notification', $user_id, $user_data);
550 550
 }
551 551
 
552
-add_action( 'give_insert_user', 'give_new_user_notification', 10, 2 );
552
+add_action('give_insert_user', 'give_new_user_notification', 10, 2);
553 553
 
554 554
 
555 555
 /**
@@ -565,33 +565,33 @@  discard block
 block discarded – undo
565 565
  *
566 566
  * @return string
567 567
  */
568
-function give_get_donor_name_by( $id = 0, $from = 'donation' ) {
568
+function give_get_donor_name_by($id = 0, $from = 'donation') {
569 569
 
570 570
 	// ID shouldn't be empty.
571
-	if ( empty( $id ) ) {
571
+	if (empty($id)) {
572 572
 		return '';
573 573
 	}
574 574
 
575 575
 	$name = '';
576 576
 
577
-	switch ( $from ) {
577
+	switch ($from) {
578 578
 
579 579
 		case 'donation':
580
-			$first_name    = give_get_meta( $id, '_give_donor_billing_first_name', true );
581
-			$last_name     = give_get_meta( $id, '_give_donor_billing_last_name', true );
580
+			$first_name    = give_get_meta($id, '_give_donor_billing_first_name', true);
581
+			$last_name     = give_get_meta($id, '_give_donor_billing_last_name', true);
582 582
 
583
-			$name = trim( "{$first_name} {$last_name}" );
583
+			$name = trim("{$first_name} {$last_name}");
584 584
 
585 585
 			break;
586 586
 
587 587
 		case 'donor':
588
-			$name = Give()->donors->get_column( 'name', $id );
588
+			$name = Give()->donors->get_column('name', $id);
589 589
 
590 590
 			break;
591 591
 
592 592
 	}
593 593
 
594
-	return trim( $name );
594
+	return trim($name);
595 595
 
596 596
 }
597 597
 
@@ -604,8 +604,8 @@  discard block
 block discarded – undo
604 604
  *
605 605
  * @return boolean  The user's ID on success, and false on failure.
606 606
  */
607
-function give_donor_email_exists( $email ) {
608
-	if ( Give()->donors->get_donor_by( 'email', $email ) ) {
607
+function give_donor_email_exists($email) {
608
+	if (Give()->donors->get_donor_by('email', $email)) {
609 609
 		return true;
610 610
 	}
611 611
 	return false;
@@ -620,14 +620,14 @@  discard block
 block discarded – undo
620 620
  *
621 621
  * @return bool
622 622
  */
623
-function give_is_additional_email( $email ) {
623
+function give_is_additional_email($email) {
624 624
 	global $wpdb;
625 625
 
626 626
 	$meta_table = Give()->donor_meta->table_name;
627 627
 	$meta_type  = Give()->donor_meta->meta_type;
628
-	$donor_id   = $wpdb->get_var( $wpdb->prepare( "SELECT {$meta_type}_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $email ) );
628
+	$donor_id   = $wpdb->get_var($wpdb->prepare("SELECT {$meta_type}_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $email));
629 629
 
630
-	if ( empty( $donor_id ) ) {
630
+	if (empty($donor_id)) {
631 631
 		return false;
632 632
 	}
633 633
 
Please login to merge, or discard this patch.
includes/gateways/actions.php 1 patch
Spacing   +20 added lines, -20 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
 
@@ -21,14 +21,14 @@  discard block
 block discarded – undo
21 21
  *
22 22
  * @param $data
23 23
  */
24
-function give_process_gateway_select( $data ) {
25
-	if ( isset( $_POST['gateway_submit'] ) ) {
26
-		wp_redirect( esc_url( add_query_arg( 'payment-mode', $_POST['payment-mode'] ) ) );
24
+function give_process_gateway_select($data) {
25
+	if (isset($_POST['gateway_submit'])) {
26
+		wp_redirect(esc_url(add_query_arg('payment-mode', $_POST['payment-mode'])));
27 27
 		exit;
28 28
 	}
29 29
 }
30 30
 
31
-add_action( 'give_gateway_select', 'give_process_gateway_select' );
31
+add_action('give_gateway_select', 'give_process_gateway_select');
32 32
 
33 33
 /**
34 34
  * Loads a payment gateway via AJAX.
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
39 39
  */
40 40
 function give_load_ajax_gateway() {
41 41
 
42
-	$post_data = give_clean( $_POST ); // WPCS: input var ok, CSRF ok.
42
+	$post_data = give_clean($_POST); // WPCS: input var ok, CSRF ok.
43 43
 
44
-	if ( isset( $post_data['give_payment_mode'] ) ) {
44
+	if (isset($post_data['give_payment_mode'])) {
45 45
 
46
-		$form_id_prefix = ! empty( $post_data['give_form_id_prefix'] ) ? $post_data['give_form_id_prefix'] : '';
46
+		$form_id_prefix = ! empty($post_data['give_form_id_prefix']) ? $post_data['give_form_id_prefix'] : '';
47 47
 
48 48
 		$args = array(
49 49
 			'id_prefix' => $form_id_prefix,
@@ -54,14 +54,14 @@  discard block
 block discarded – undo
54 54
 		 *
55 55
 		 * @since 1.7
56 56
 		 */
57
-		do_action( 'give_donation_form', $post_data['give_form_id'], $args );
57
+		do_action('give_donation_form', $post_data['give_form_id'], $args);
58 58
 
59 59
 		exit();
60 60
 	}
61 61
 }
62 62
 
63
-add_action( 'wp_ajax_give_load_gateway', 'give_load_ajax_gateway' );
64
-add_action( 'wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway' );
63
+add_action('wp_ajax_give_load_gateway', 'give_load_ajax_gateway');
64
+add_action('wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway');
65 65
 
66 66
 /**
67 67
  * Create wp nonce using Ajax call.
@@ -73,18 +73,18 @@  discard block
 block discarded – undo
73 73
  * @return void
74 74
  */
75 75
 function give_donation_form_nonce() {
76
-	if ( isset( $_POST['give_form_id'] ) ) {
76
+	if (isset($_POST['give_form_id'])) {
77 77
 
78 78
 		// Get donation form id.
79
-		$form_id = is_numeric( $_POST['give_form_id'] ) ? absint( $_POST['give_form_id'] ) : 0;
79
+		$form_id = is_numeric($_POST['give_form_id']) ? absint($_POST['give_form_id']) : 0;
80 80
 
81 81
 		// Send nonce json data.
82
-		wp_send_json_success( wp_create_nonce( "give_donation_form_nonce_{$form_id}" ) );
82
+		wp_send_json_success(wp_create_nonce("give_donation_form_nonce_{$form_id}"));
83 83
 	}
84 84
 }
85 85
 
86
-add_action( 'wp_ajax_give_donation_form_nonce', 'give_donation_form_nonce' );
87
-add_action( 'wp_ajax_nopriv_give_donation_form_nonce', 'give_donation_form_nonce' );
86
+add_action('wp_ajax_give_donation_form_nonce', 'give_donation_form_nonce');
87
+add_action('wp_ajax_nopriv_give_donation_form_nonce', 'give_donation_form_nonce');
88 88
 
89 89
 /**
90 90
  * Sets an error within the donation form if no gateways are enabled.
@@ -97,11 +97,11 @@  discard block
 block discarded – undo
97 97
 function give_no_gateway_error() {
98 98
 	$gateways = give_get_enabled_payment_gateways();
99 99
 
100
-	if ( empty( $gateways ) ) {
101
-		give_set_error( 'no_gateways', esc_html__( 'You must enable a payment gateway to use Give.', 'give' ) );
100
+	if (empty($gateways)) {
101
+		give_set_error('no_gateways', esc_html__('You must enable a payment gateway to use Give.', 'give'));
102 102
 	} else {
103
-		give_unset_error( 'no_gateways' );
103
+		give_unset_error('no_gateways');
104 104
 	}
105 105
 }
106 106
 
107
-add_action( 'init', 'give_no_gateway_error' );
107
+add_action('init', 'give_no_gateway_error');
Please login to merge, or discard this patch.
includes/class-give-db-donor-meta.php 1 patch
Spacing   +5 added lines, -5 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
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 		/* @var WPDB $wpdb */
54 54
 		global $wpdb;
55 55
 
56
-		$wpdb->donormeta   = $this->table_name = $wpdb->prefix . 'give_donormeta';
56
+		$wpdb->donormeta   = $this->table_name = $wpdb->prefix.'give_donormeta';
57 57
 		$this->primary_key = 'meta_id';
58 58
 		$this->version     = '1.0';
59 59
 
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
 		global $wpdb;
93 93
 
94 94
 		if (
95
-			! give_has_upgrade_completed( 'v20_rename_donor_tables' ) &&
96
-			$wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s","{$wpdb->prefix}give_customermeta" ) )
95
+			! give_has_upgrade_completed('v20_rename_donor_tables') &&
96
+			$wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_customermeta"))
97 97
 		) {
98 98
 			$wpdb->donormeta = $this->table_name = "{$wpdb->prefix}give_customermeta";
99 99
 			$this->meta_type = 'customer';
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 	 *
113 113
 	 * @return bool
114 114
 	 */
115
-	protected function is_valid_post_type( $ID ) {
115
+	protected function is_valid_post_type($ID) {
116 116
 		return $ID && true;
117 117
 	}
118 118
 
Please login to merge, or discard this patch.
includes/class-give-html-elements.php 1 patch
Spacing   +157 added lines, -157 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
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 *
36 36
 	 * @return string       Donations dropdown.
37 37
 	 */
38
-	public function donations_dropdown( $args = array() ) {
38
+	public function donations_dropdown($args = array()) {
39 39
 
40 40
 		$defaults = array(
41 41
 			'name'        => 'donations',
@@ -45,32 +45,32 @@  discard block
 block discarded – undo
45 45
 			'selected'    => 0,
46 46
 			'chosen'      => false,
47 47
 			'number'      => 30,
48
-			'placeholder' => __( 'Select a donation', 'give' ),
48
+			'placeholder' => __('Select a donation', 'give'),
49 49
 		);
50 50
 
51
-		$args = wp_parse_args( $args, $defaults );
51
+		$args = wp_parse_args($args, $defaults);
52 52
 
53
-		$payments = new Give_Payments_Query( array(
53
+		$payments = new Give_Payments_Query(array(
54 54
 			'number' => $args['number'],
55
-		) );
55
+		));
56 56
 
57 57
 		$payments = $payments->get_payments();
58 58
 
59 59
 		$options = array();
60 60
 
61 61
 		// Provide nice human readable options.
62
-		if ( $payments ) {
62
+		if ($payments) {
63 63
 			$options[0] = $args['placeholder'];
64
-			foreach ( $payments as $payment ) {
64
+			foreach ($payments as $payment) {
65 65
 
66
-				$options[ absint( $payment->ID ) ] = esc_html( '#' . $payment->ID . ' - ' . $payment->email . ' - ' . $payment->form_title );
66
+				$options[absint($payment->ID)] = esc_html('#'.$payment->ID.' - '.$payment->email.' - '.$payment->form_title);
67 67
 
68 68
 			}
69 69
 		} else {
70
-			$options[0] = __( 'No donations found.', 'give' );
70
+			$options[0] = __('No donations found.', 'give');
71 71
 		}
72 72
 
73
-		$output = $this->select( array(
73
+		$output = $this->select(array(
74 74
 			'name'             => $args['name'],
75 75
 			'selected'         => $args['selected'],
76 76
 			'id'               => $args['id'],
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 			'select_atts'      => $args['select_atts'],
83 83
 			'show_option_all'  => false,
84 84
 			'show_option_none' => false,
85
-		) );
85
+		));
86 86
 
87 87
 		return $output;
88 88
 	}
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 	 *
100 100
 	 * @return string      Give forms dropdown.
101 101
 	 */
102
-	public function forms_dropdown( $args = array() ) {
102
+	public function forms_dropdown($args = array()) {
103 103
 
104 104
 		$defaults = array(
105 105
 			'name'        => 'forms',
@@ -109,14 +109,14 @@  discard block
 block discarded – undo
109 109
 			'selected'    => 0,
110 110
 			'chosen'      => false,
111 111
 			'number'      => 30,
112
-			'placeholder' => esc_attr__( 'All Forms', 'give' ),
112
+			'placeholder' => esc_attr__('All Forms', 'give'),
113 113
 			'data'        => array(
114 114
 				'search-type' => 'form',
115 115
 			),
116 116
 			'query_args' => array()
117 117
 		);
118 118
 
119
-		$args = wp_parse_args( $args, $defaults );
119
+		$args = wp_parse_args($args, $defaults);
120 120
 
121 121
 		$form_args = wp_parse_args(
122 122
 			$args['query_args'],
@@ -128,37 +128,37 @@  discard block
 block discarded – undo
128 128
 			)
129 129
 		);
130 130
 
131
-		$cache_key   = Give_Cache::get_key( 'give_forms', $form_args, false );
131
+		$cache_key = Give_Cache::get_key('give_forms', $form_args, false);
132 132
 
133 133
 		// Get forms from cache.
134
-		$forms = Give_Cache::get_db_query( $cache_key );
134
+		$forms = Give_Cache::get_db_query($cache_key);
135 135
 
136
-		if ( is_null( $forms ) ) {
137
-			$forms = new WP_Query( $form_args );
136
+		if (is_null($forms)) {
137
+			$forms = new WP_Query($form_args);
138 138
 			$forms = $forms->posts;
139
-			Give_Cache::set_db_query( $cache_key, $forms );
139
+			Give_Cache::set_db_query($cache_key, $forms);
140 140
 		}
141 141
 
142 142
 		$options = array();
143 143
 
144 144
 		// Ensure the selected.
145
-		if ( false !== $args['selected'] && $args['selected'] !== 0 ) {
146
-			$options[ $args['selected'] ] = get_the_title( $args['selected'] );
145
+		if (false !== $args['selected'] && $args['selected'] !== 0) {
146
+			$options[$args['selected']] = get_the_title($args['selected']);
147 147
 		}
148 148
 
149
-		$options[0] = esc_html__( 'No forms found.', 'give' );
150
-		if ( ! empty( $forms ) ) {
149
+		$options[0] = esc_html__('No forms found.', 'give');
150
+		if ( ! empty($forms)) {
151 151
 			$options[0] = $args['placeholder'];
152
-			foreach ( $forms as $form ) {
153
-				$form_title = empty( $form->post_title )
154
-					? sprintf( __( 'Untitled (#%s)', 'give' ), $form->ID )
152
+			foreach ($forms as $form) {
153
+				$form_title = empty($form->post_title)
154
+					? sprintf(__('Untitled (#%s)', 'give'), $form->ID)
155 155
 					: $form->post_title;
156 156
 
157
-				$options[ absint( $form->ID ) ] = esc_html( $form_title );
157
+				$options[absint($form->ID)] = esc_html($form_title);
158 158
 			}
159 159
 		}
160 160
 
161
-		$output = $this->select( array(
161
+		$output = $this->select(array(
162 162
 			'name'             => $args['name'],
163 163
 			'selected'         => $args['selected'],
164 164
 			'id'               => $args['id'],
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 			'show_option_all'  => false,
171 171
 			'show_option_none' => false,
172 172
 			'data'             => $args['data'],
173
-		) );
173
+		));
174 174
 
175 175
 		return $output;
176 176
 	}
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 	 *
188 188
 	 * @return string      Donors dropdown.
189 189
 	 */
190
-	public function donor_dropdown( $args = array() ) {
190
+	public function donor_dropdown($args = array()) {
191 191
 
192 192
 		$defaults = array(
193 193
 			'name'        => 'donors',
@@ -196,57 +196,57 @@  discard block
 block discarded – undo
196 196
 			'multiple'    => false,
197 197
 			'selected'    => 0,
198 198
 			'chosen'      => true,
199
-			'placeholder' => esc_attr__( 'Select a Donor', 'give' ),
199
+			'placeholder' => esc_attr__('Select a Donor', 'give'),
200 200
 			'number'      => 30,
201 201
 			'data'        => array(
202 202
 				'search-type' => 'donor',
203 203
 			),
204 204
 		);
205 205
 
206
-		$args = wp_parse_args( $args, $defaults );
206
+		$args = wp_parse_args($args, $defaults);
207 207
 
208
-		$donors = Give()->donors->get_donors( array(
208
+		$donors = Give()->donors->get_donors(array(
209 209
 			'number' => $args['number']
210
-		) );
210
+		));
211 211
 
212 212
 		$options = array();
213 213
 
214
-		if ( $donors ) {
215
-			$options[0] = esc_html__( 'No donor attached', 'give' );
216
-			foreach ( $donors as $donor ) {
217
-				$options[ absint( $donor->id ) ] = esc_html( $donor->name . ' (' . $donor->email . ')' );
214
+		if ($donors) {
215
+			$options[0] = esc_html__('No donor attached', 'give');
216
+			foreach ($donors as $donor) {
217
+				$options[absint($donor->id)] = esc_html($donor->name.' ('.$donor->email.')');
218 218
 			}
219 219
 		} else {
220
-			$options[0] = esc_html__( 'No donors found.', 'give' );
220
+			$options[0] = esc_html__('No donors found.', 'give');
221 221
 		}
222 222
 
223
-		if ( ! empty( $args['selected'] ) ) {
223
+		if ( ! empty($args['selected'])) {
224 224
 
225 225
 			// If a selected customer has been specified, we need to ensure it's in the initial list of customers displayed.
226
-			if ( ! array_key_exists( $args['selected'], $options ) ) {
226
+			if ( ! array_key_exists($args['selected'], $options)) {
227 227
 
228
-				$donor = new Give_Donor( $args['selected'] );
228
+				$donor = new Give_Donor($args['selected']);
229 229
 
230
-				if ( $donor ) {
230
+				if ($donor) {
231 231
 
232
-					$options[ absint( $args['selected'] ) ] = esc_html( $donor->name . ' (' . $donor->email . ')' );
232
+					$options[absint($args['selected'])] = esc_html($donor->name.' ('.$donor->email.')');
233 233
 
234 234
 				}
235 235
 			}
236 236
 		}
237 237
 
238
-		$output = $this->select( array(
238
+		$output = $this->select(array(
239 239
 			'name'             => $args['name'],
240 240
 			'selected'         => $args['selected'],
241 241
 			'id'               => $args['id'],
242
-			'class'            => $args['class'] . ' give-customer-select',
242
+			'class'            => $args['class'].' give-customer-select',
243 243
 			'options'          => $options,
244 244
 			'multiple'         => $args['multiple'],
245 245
 			'chosen'           => $args['chosen'],
246 246
 			'show_option_all'  => false,
247 247
 			'show_option_none' => false,
248 248
 			'data'             => $args['data'],
249
-		) );
249
+		));
250 250
 
251 251
 		return $output;
252 252
 	}
@@ -265,22 +265,22 @@  discard block
 block discarded – undo
265 265
 	 *
266 266
 	 * @return string           Categories dropdown.
267 267
 	 */
268
-	public function category_dropdown( $name = 'give_forms_categories', $selected = 0, $args = array() ) {
269
-		$categories = get_terms( 'give_forms_category', apply_filters( 'give_forms_category_dropdown', array() ) );
268
+	public function category_dropdown($name = 'give_forms_categories', $selected = 0, $args = array()) {
269
+		$categories = get_terms('give_forms_category', apply_filters('give_forms_category_dropdown', array()));
270 270
 
271 271
 		$options = array();
272 272
 
273
-		foreach ( $categories as $category ) {
274
-			$options[ absint( $category->term_id ) ] = esc_html( $category->name );
273
+		foreach ($categories as $category) {
274
+			$options[absint($category->term_id)] = esc_html($category->name);
275 275
 		}
276 276
 
277
-		$output = $this->select( wp_parse_args( $args, array(
277
+		$output = $this->select(wp_parse_args($args, array(
278 278
 			'name'             => $name,
279 279
 			'selected'         => $selected,
280 280
 			'options'          => $options,
281
-			'show_option_all'  => esc_html__( 'All Categories', 'give' ),
281
+			'show_option_all'  => esc_html__('All Categories', 'give'),
282 282
 			'show_option_none' => false,
283
-		) ) );
283
+		)));
284 284
 
285 285
 		return $output;
286 286
 	}
@@ -299,22 +299,22 @@  discard block
 block discarded – undo
299 299
 	 *
300 300
 	 * @return string           Tags dropdown.
301 301
 	 */
302
-	public function tags_dropdown( $name = 'give_forms_tags', $selected = 0, $args = array() ) {
303
-		$tags    = get_terms( 'give_forms_tag', apply_filters( 'give_forms_tag_dropdown', array() ) );
302
+	public function tags_dropdown($name = 'give_forms_tags', $selected = 0, $args = array()) {
303
+		$tags    = get_terms('give_forms_tag', apply_filters('give_forms_tag_dropdown', array()));
304 304
 
305 305
 		$options = array();
306 306
 
307
-		foreach ( $tags as $tag ) {
308
-			$options[ absint( $tag->term_id ) ] = esc_html( $tag->name );
307
+		foreach ($tags as $tag) {
308
+			$options[absint($tag->term_id)] = esc_html($tag->name);
309 309
 		}
310 310
 
311
-		$output = $this->select( wp_parse_args( $args, array(
311
+		$output = $this->select(wp_parse_args($args, array(
312 312
 			'name'             => $name,
313 313
 			'selected'         => $selected,
314 314
 			'options'          => $options,
315
-			'show_option_all'  => esc_html__( 'All Tags', 'give' ),
315
+			'show_option_all'  => esc_html__('All Tags', 'give'),
316 316
 			'show_option_none' => false,
317
-		) ) );
317
+		)));
318 318
 
319 319
 		return $output;
320 320
 	}
@@ -334,25 +334,25 @@  discard block
 block discarded – undo
334 334
 	 *
335 335
 	 * @return string               Years dropdown.
336 336
 	 */
337
-	public function year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) {
338
-		$current    = date( 'Y' );
339
-		$start_year = $current - absint( $years_before );
340
-		$end_year   = $current + absint( $years_after );
341
-		$selected   = empty( $selected ) ? date( 'Y' ) : $selected;
337
+	public function year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) {
338
+		$current    = date('Y');
339
+		$start_year = $current - absint($years_before);
340
+		$end_year   = $current + absint($years_after);
341
+		$selected   = empty($selected) ? date('Y') : $selected;
342 342
 		$options    = array();
343 343
 
344
-		while ( $start_year <= $end_year ) {
345
-			$options[ absint( $start_year ) ] = $start_year;
346
-			$start_year ++;
344
+		while ($start_year <= $end_year) {
345
+			$options[absint($start_year)] = $start_year;
346
+			$start_year++;
347 347
 		}
348 348
 
349
-		$output = $this->select( array(
349
+		$output = $this->select(array(
350 350
 			'name'             => $name,
351 351
 			'selected'         => $selected,
352 352
 			'options'          => $options,
353 353
 			'show_option_all'  => false,
354 354
 			'show_option_none' => false,
355
-		) );
355
+		));
356 356
 
357 357
 		return $output;
358 358
 	}
@@ -370,23 +370,23 @@  discard block
 block discarded – undo
370 370
 	 *
371 371
 	 * @return string           Months dropdown.
372 372
 	 */
373
-	public function month_dropdown( $name = 'month', $selected = 0 ) {
373
+	public function month_dropdown($name = 'month', $selected = 0) {
374 374
 		$month    = 1;
375 375
 		$options  = array();
376
-		$selected = empty( $selected ) ? date( 'n' ) : $selected;
376
+		$selected = empty($selected) ? date('n') : $selected;
377 377
 
378
-		while ( $month <= 12 ) {
379
-			$options[ absint( $month ) ] = give_month_num_to_name( $month );
380
-			$month ++;
378
+		while ($month <= 12) {
379
+			$options[absint($month)] = give_month_num_to_name($month);
380
+			$month++;
381 381
 		}
382 382
 
383
-		$output = $this->select( array(
383
+		$output = $this->select(array(
384 384
 			'name'             => $name,
385 385
 			'selected'         => $selected,
386 386
 			'options'          => $options,
387 387
 			'show_option_all'  => false,
388 388
 			'show_option_none' => false,
389
-		) );
389
+		));
390 390
 
391 391
 		return $output;
392 392
 	}
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 	 *
404 404
 	 * @return string      The dropdown.
405 405
 	 */
406
-	public function select( $args = array() ) {
406
+	public function select($args = array()) {
407 407
 		$defaults = array(
408 408
 			'options'          => array(),
409 409
 			'name'             => null,
@@ -414,74 +414,74 @@  discard block
 block discarded – undo
414 414
 			'placeholder'      => null,
415 415
 			'multiple'         => false,
416 416
 			'select_atts'      => false,
417
-			'show_option_all'  => __( 'All', 'give' ),
418
-			'show_option_none' => __( 'None', 'give' ),
417
+			'show_option_all'  => __('All', 'give'),
418
+			'show_option_none' => __('None', 'give'),
419 419
 			'data'             => array(),
420 420
 			'readonly'         => false,
421 421
 			'disabled'         => false,
422 422
 		);
423 423
 
424
-		$args = wp_parse_args( $args, $defaults );
424
+		$args = wp_parse_args($args, $defaults);
425 425
 
426 426
 		$data_elements = '';
427
-		foreach ( $args['data'] as $key => $value ) {
428
-			$data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
427
+		foreach ($args['data'] as $key => $value) {
428
+			$data_elements .= ' data-'.esc_attr($key).'="'.esc_attr($value).'"';
429 429
 		}
430 430
 
431 431
 		$multiple = '';
432
-		if ( $args['multiple'] ) {
432
+		if ($args['multiple']) {
433 433
 			$multiple = 'MULTIPLE';
434 434
 		}
435 435
 
436
-		if ( $args['chosen'] ) {
436
+		if ($args['chosen']) {
437 437
 			$args['class'] .= ' give-select-chosen';
438 438
 		}
439 439
 
440 440
 		$placeholder = '';
441
-		if ( $args['placeholder'] ) {
441
+		if ($args['placeholder']) {
442 442
 			$placeholder = $args['placeholder'];
443 443
 		}
444 444
 
445 445
 		$output = sprintf(
446 446
 			'<select name="%1$s" id="%2$s" autocomplete="address-level4" class="give-select %3$s" %4$s %5$s placeholder="%6$s" data-placeholder="%6$s" %7$s>',
447
-			esc_attr( $args['name'] ),
448
-			esc_attr( sanitize_key( str_replace( '-', '_', $args['id'] ) ) ),
449
-			esc_attr( $args['class'] ),
447
+			esc_attr($args['name']),
448
+			esc_attr(sanitize_key(str_replace('-', '_', $args['id']))),
449
+			esc_attr($args['class']),
450 450
 			$multiple,
451 451
 			$args['select_atts'],
452 452
 			$placeholder,
453 453
 			$data_elements
454 454
 		);
455 455
 
456
-		if ( $args['show_option_all'] ) {
457
-			if ( $args['multiple'] ) {
458
-				$selected = selected( true, in_array( 0, $args['selected'] ), false );
456
+		if ($args['show_option_all']) {
457
+			if ($args['multiple']) {
458
+				$selected = selected(true, in_array(0, $args['selected']), false);
459 459
 			} else {
460
-				$selected = selected( $args['selected'], 0, false );
460
+				$selected = selected($args['selected'], 0, false);
461 461
 			}
462
-			$output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>';
462
+			$output .= '<option value="all"'.$selected.'>'.esc_html($args['show_option_all']).'</option>';
463 463
 		}
464 464
 
465
-		if ( ! empty( $args['options'] ) ) {
465
+		if ( ! empty($args['options'])) {
466 466
 
467
-			if ( $args['show_option_none'] ) {
468
-				if ( $args['multiple'] ) {
469
-					$selected = selected( true, in_array( - 1, $args['selected'] ), false );
467
+			if ($args['show_option_none']) {
468
+				if ($args['multiple']) {
469
+					$selected = selected(true, in_array( -1, $args['selected'] ), false);
470 470
 				} else {
471
-					$selected = selected( $args['selected'], - 1, false );
471
+					$selected = selected($args['selected'], - 1, false);
472 472
 				}
473
-				$output .= '<option value="-1"' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>';
473
+				$output .= '<option value="-1"'.$selected.'>'.esc_html($args['show_option_none']).'</option>';
474 474
 			}
475 475
 
476
-			foreach ( $args['options'] as $key => $option ) {
476
+			foreach ($args['options'] as $key => $option) {
477 477
 
478
-				if ( $args['multiple'] && is_array( $args['selected'] ) ) {
479
-					$selected = selected( true, in_array( $key, $args['selected'] ), false );
478
+				if ($args['multiple'] && is_array($args['selected'])) {
479
+					$selected = selected(true, in_array($key, $args['selected']), false);
480 480
 				} else {
481
-					$selected = selected( $args['selected'], $key, false );
481
+					$selected = selected($args['selected'], $key, false);
482 482
 				}
483 483
 
484
-				$output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>';
484
+				$output .= '<option value="'.esc_attr($key).'"'.$selected.'>'.esc_html($option).'</option>';
485 485
 			}
486 486
 		}
487 487
 
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
 	 *
503 503
 	 * @return string      The checkbox.
504 504
 	 */
505
-	public function checkbox( $args = array() ) {
505
+	public function checkbox($args = array()) {
506 506
 		$defaults = array(
507 507
 			'name'    => null,
508 508
 			'current' => null,
@@ -513,16 +513,16 @@  discard block
 block discarded – undo
513 513
 			),
514 514
 		);
515 515
 
516
-		$args = wp_parse_args( $args, $defaults );
516
+		$args = wp_parse_args($args, $defaults);
517 517
 
518 518
 		$options = '';
519
-		if ( ! empty( $args['options']['disabled'] ) ) {
519
+		if ( ! empty($args['options']['disabled'])) {
520 520
 			$options .= ' disabled="disabled"';
521
-		} elseif ( ! empty( $args['options']['readonly'] ) ) {
521
+		} elseif ( ! empty($args['options']['readonly'])) {
522 522
 			$options .= ' readonly';
523 523
 		}
524 524
 
525
-		$output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />';
525
+		$output = '<input type="checkbox"'.$options.' name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" class="'.$args['class'].' '.esc_attr($args['name']).'" '.checked(1, $args['current'], false).' />';
526 526
 
527 527
 		return $output;
528 528
 	}
@@ -539,22 +539,22 @@  discard block
 block discarded – undo
539 539
 	 *
540 540
 	 * @return string      The text field.
541 541
 	 */
542
-	public function text( $args = array() ) {
542
+	public function text($args = array()) {
543 543
 		// Backwards compatibility.
544
-		if ( func_num_args() > 1 ) {
544
+		if (func_num_args() > 1) {
545 545
 			$args = func_get_args();
546 546
 
547 547
 			$name  = $args[0];
548
-			$value = isset( $args[1] ) ? $args[1] : '';
549
-			$label = isset( $args[2] ) ? $args[2] : '';
550
-			$desc  = isset( $args[3] ) ? $args[3] : '';
548
+			$value = isset($args[1]) ? $args[1] : '';
549
+			$label = isset($args[2]) ? $args[2] : '';
550
+			$desc  = isset($args[3]) ? $args[3] : '';
551 551
 		}
552 552
 
553 553
 		$defaults = array(
554
-			'name'         => isset( $name ) ? $name : 'text',
555
-			'value'        => isset( $value ) ? $value : null,
556
-			'label'        => isset( $label ) ? $label : null,
557
-			'desc'         => isset( $desc ) ? $desc : null,
554
+			'name'         => isset($name) ? $name : 'text',
555
+			'value'        => isset($value) ? $value : null,
556
+			'label'        => isset($label) ? $label : null,
557
+			'desc'         => isset($desc) ? $desc : null,
558 558
 			'placeholder'  => '',
559 559
 			'class'        => 'regular-text',
560 560
 			'disabled'     => false,
@@ -562,29 +562,29 @@  discard block
 block discarded – undo
562 562
 			'data'         => false,
563 563
 		);
564 564
 
565
-		$args = wp_parse_args( $args, $defaults );
565
+		$args = wp_parse_args($args, $defaults);
566 566
 
567 567
 		$disabled = '';
568
-		if ( $args['disabled'] ) {
568
+		if ($args['disabled']) {
569 569
 			$disabled = ' disabled="disabled"';
570 570
 		}
571 571
 
572 572
 		$data = '';
573
-		if ( ! empty( $args['data'] ) ) {
574
-			foreach ( $args['data'] as $key => $value ) {
575
-				$data .= 'data-' . $key . '="' . $value . '" ';
573
+		if ( ! empty($args['data'])) {
574
+			foreach ($args['data'] as $key => $value) {
575
+				$data .= 'data-'.$key.'="'.$value.'" ';
576 576
 			}
577 577
 		}
578 578
 
579
-		$output = '<span id="give-' . sanitize_key( $args['name'] ) . '-wrap">';
579
+		$output = '<span id="give-'.sanitize_key($args['name']).'-wrap">';
580 580
 
581
-		$output .= '<label class="give-label" for="give-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>';
581
+		$output .= '<label class="give-label" for="give-'.sanitize_key($args['name']).'">'.esc_html($args['label']).'</label>';
582 582
 
583
-		if ( ! empty( $args['desc'] ) ) {
584
-			$output .= '<span class="give-description">' . esc_html( $args['desc'] ) . '</span>';
583
+		if ( ! empty($args['desc'])) {
584
+			$output .= '<span class="give-description">'.esc_html($args['desc']).'</span>';
585 585
 		}
586 586
 
587
-		$output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $args['class'] . '" ' . $data . '' . $disabled . '/>';
587
+		$output .= '<input type="text" name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" autocomplete="'.esc_attr($args['autocomplete']).'" value="'.esc_attr($args['value']).'" placeholder="'.esc_attr($args['placeholder']).'" class="'.$args['class'].'" '.$data.''.$disabled.'/>';
588 588
 
589 589
 		$output .= '</span>';
590 590
 
@@ -603,15 +603,15 @@  discard block
 block discarded – undo
603 603
 	 *
604 604
 	 * @return string      The date picker.
605 605
 	 */
606
-	public function date_field( $args = array() ) {
606
+	public function date_field($args = array()) {
607 607
 
608
-		if ( empty( $args['class'] ) ) {
608
+		if (empty($args['class'])) {
609 609
 			$args['class'] = 'give_datepicker';
610
-		} elseif ( ! strpos( $args['class'], 'give_datepicker' ) ) {
610
+		} elseif ( ! strpos($args['class'], 'give_datepicker')) {
611 611
 			$args['class'] .= ' give_datepicker';
612 612
 		}
613 613
 
614
-		return $this->text( $args );
614
+		return $this->text($args);
615 615
 	}
616 616
 
617 617
 	/**
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
 	 *
627 627
 	 * @return string      The textarea.
628 628
 	 */
629
-	public function textarea( $args = array() ) {
629
+	public function textarea($args = array()) {
630 630
 		$defaults = array(
631 631
 			'name'     => 'textarea',
632 632
 			'value'    => null,
@@ -636,21 +636,21 @@  discard block
 block discarded – undo
636 636
 			'disabled' => false,
637 637
 		);
638 638
 
639
-		$args = wp_parse_args( $args, $defaults );
639
+		$args = wp_parse_args($args, $defaults);
640 640
 
641 641
 		$disabled = '';
642
-		if ( $args['disabled'] ) {
642
+		if ($args['disabled']) {
643 643
 			$disabled = ' disabled="disabled"';
644 644
 		}
645 645
 
646
-		$output = '<span id="give-' . sanitize_key( $args['name'] ) . '-wrap">';
646
+		$output = '<span id="give-'.sanitize_key($args['name']).'-wrap">';
647 647
 
648
-		$output .= '<label class="give-label" for="give-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>';
648
+		$output .= '<label class="give-label" for="give-'.sanitize_key($args['name']).'">'.esc_html($args['label']).'</label>';
649 649
 
650
-		$output .= '<textarea name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>';
650
+		$output .= '<textarea name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" class="'.$args['class'].'"'.$disabled.'>'.esc_attr($args['value']).'</textarea>';
651 651
 
652
-		if ( ! empty( $args['desc'] ) ) {
653
-			$output .= '<span class="give-description">' . esc_html( $args['desc'] ) . '</span>';
652
+		if ( ! empty($args['desc'])) {
653
+			$output .= '<span class="give-description">'.esc_html($args['desc']).'</span>';
654 654
 		}
655 655
 
656 656
 		$output .= '</span>';
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
 	 *
671 671
 	 * @return string      The text field with ajax search.
672 672
 	 */
673
-	public function ajax_user_search( $args = array() ) {
673
+	public function ajax_user_search($args = array()) {
674 674
 
675 675
 		$defaults = array(
676 676
 			'name'        => 'users',
@@ -681,13 +681,13 @@  discard block
 block discarded – undo
681 681
 			'chosen'      => true,
682 682
 			'number'      => 30,
683 683
 			'select_atts' => '',
684
-			'placeholder' => __( 'Select a user', 'give' ),
684
+			'placeholder' => __('Select a user', 'give'),
685 685
 			'data'        => array(
686 686
 				'search-type' => 'user',
687 687
 			),
688 688
 		);
689 689
 
690
-		$args = wp_parse_args( $args, $defaults );
690
+		$args = wp_parse_args($args, $defaults);
691 691
 
692 692
 		// Set initial args.
693 693
 		$get_users_args = array(
@@ -696,31 +696,31 @@  discard block
 block discarded – undo
696 696
 
697 697
 		// Ensure selected user is not included in initial query.
698 698
 		// This is because sites with many users, it's not a guarantee the selected user will be returned.
699
-		if ( ! empty( $args['selected'] ) ) {
699
+		if ( ! empty($args['selected'])) {
700 700
 			$get_users_args['exclude'] = $args['selected'];
701 701
 		}
702 702
 
703 703
 		// Initial users array.
704
-		$users = apply_filters( 'give_ajax_user_search_initial_results', get_users( $get_users_args ), $args );
704
+		$users = apply_filters('give_ajax_user_search_initial_results', get_users($get_users_args), $args);
705 705
 
706 706
 		// Now add the selected user to the $users array if the arg is present.
707
-		if ( ! empty( $args['selected'] ) ) {
708
-			$selected_user =  apply_filters( 'give_ajax_user_search_selected_results', get_users( "include={$args['selected']}" ), $args );;
709
-			$users         = array_merge( $users, $selected_user );
707
+		if ( ! empty($args['selected'])) {
708
+			$selected_user = apply_filters('give_ajax_user_search_selected_results', get_users("include={$args['selected']}"), $args); ;
709
+			$users         = array_merge($users, $selected_user);
710 710
 		}
711 711
 
712 712
 		$options = array();
713 713
 
714
-		if ( $users ) {
714
+		if ($users) {
715 715
 			$options[0] = $args['placeholder'];
716
-			foreach ( $users as $user ) {
717
-				$options[ absint( $user->ID ) ] = esc_html( $user->user_login . ' (' . $user->user_email . ')' );
716
+			foreach ($users as $user) {
717
+				$options[absint($user->ID)] = esc_html($user->user_login.' ('.$user->user_email.')');
718 718
 			}
719 719
 		} else {
720
-			$options[0] = __( 'No users found.', 'give' );
720
+			$options[0] = __('No users found.', 'give');
721 721
 		}
722 722
 
723
-		$output = $this->select( array(
723
+		$output = $this->select(array(
724 724
 			'name'             => $args['name'],
725 725
 			'selected'         => $args['selected'],
726 726
 			'id'               => $args['id'],
@@ -733,7 +733,7 @@  discard block
 block discarded – undo
733 733
 			'show_option_all'  => false,
734 734
 			'show_option_none' => false,
735 735
 			'data'             => $args['data'],
736
-		) );
736
+		));
737 737
 
738 738
 		return $output;
739 739
 
Please login to merge, or discard this patch.
includes/class-give-cli-commands.php 1 patch
Spacing   +258 added lines, -258 removed lines patch added patch discarded remove patch
@@ -7,12 +7,12 @@  discard block
 block discarded – undo
7 7
  */
8 8
 
9 9
 // Exit if accessed directly.
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if ( ! defined('ABSPATH')) {
11 11
 	exit;
12 12
 }
13 13
 
14 14
 // Add give command.
15
-WP_CLI::add_command( 'give', 'GIVE_CLI_COMMAND' );
15
+WP_CLI::add_command('give', 'GIVE_CLI_COMMAND');
16 16
 
17 17
 
18 18
 /**
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
 	 *
77 77
 	 * @subcommand    logo
78 78
 	 */
79
-	public function ascii( $args, $assoc_args ) {
80
-		WP_CLI::log( file_get_contents( GIVE_PLUGIN_DIR . 'assets/dist/images/give-ascii-logo.txt' ) );
79
+	public function ascii($args, $assoc_args) {
80
+		WP_CLI::log(file_get_contents(GIVE_PLUGIN_DIR.'assets/dist/images/give-ascii-logo.txt'));
81 81
 	}
82 82
 
83 83
 
@@ -102,54 +102,54 @@  discard block
 block discarded – undo
102 102
 	 *
103 103
 	 * @subcommand    details
104 104
 	 */
105
-	public function details( $args, $assoc_args ) {
105
+	public function details($args, $assoc_args) {
106 106
 
107 107
 		/**
108 108
 		 * Plugin Information
109 109
 		 */
110
-		WP_CLI::log( $this->color_message( __( 'Give Version: ', 'give' ) ) . GIVE_VERSION );
110
+		WP_CLI::log($this->color_message(__('Give Version: ', 'give')).GIVE_VERSION);
111 111
 
112 112
 		/**
113 113
 		 * General Information.
114 114
 		 */
115
-		WP_CLI::log( "\n####   " . $this->color_message( __( 'General information', 'give' ) ) . '   ####' );
115
+		WP_CLI::log("\n####   ".$this->color_message(__('General information', 'give')).'   ####');
116 116
 
117
-		$success_page = give_get_option( 'success_page' );
118
-		$failure_page = give_get_option( 'failure_page' );
119
-		$history_page = give_get_option( 'history_page' );
117
+		$success_page = give_get_option('success_page');
118
+		$failure_page = give_get_option('failure_page');
119
+		$history_page = give_get_option('history_page');
120 120
 
121
-		WP_CLI::log( $this->color_message( sprintf( __( 'Success Page: ', 'give' ) ) ) . ( $success_page ? "[{$success_page}] " . get_permalink( $success_page ) : __( 'Not Set', 'give' ) ) );
122
-		WP_CLI::log( $this->color_message( __( 'Failed Donation Page: ', 'give' ) ) . ( $failure_page ? "[{$failure_page}] " . get_permalink( $failure_page ) : __( 'Not Set', 'give' ) ) );
123
-		WP_CLI::log( $this->color_message( __( 'Donation History Page: ', 'give' ) ) . ( $history_page ? "[{$history_page}] " . get_permalink( $history_page ) : __( 'Not Set', 'give' ) ) );
124
-		WP_CLI::log( $this->color_message( __( 'Country: ', 'give' ) ) . give_get_country() );
121
+		WP_CLI::log($this->color_message(sprintf(__('Success Page: ', 'give'))).($success_page ? "[{$success_page}] ".get_permalink($success_page) : __('Not Set', 'give')));
122
+		WP_CLI::log($this->color_message(__('Failed Donation Page: ', 'give')).($failure_page ? "[{$failure_page}] ".get_permalink($failure_page) : __('Not Set', 'give')));
123
+		WP_CLI::log($this->color_message(__('Donation History Page: ', 'give')).($history_page ? "[{$history_page}] ".get_permalink($history_page) : __('Not Set', 'give')));
124
+		WP_CLI::log($this->color_message(__('Country: ', 'give')).give_get_country());
125 125
 
126 126
 		/**
127 127
 		 * Currency Information.
128 128
 		 */
129
-		$default_gateway = give_get_option( 'default_gateway' );
129
+		$default_gateway = give_get_option('default_gateway');
130 130
 
131
-		WP_CLI::log( "\n####   " . $this->color_message( __( 'Currency Information', 'give' ) ) . '   ####' );
131
+		WP_CLI::log("\n####   ".$this->color_message(__('Currency Information', 'give')).'   ####');
132 132
 
133
-		WP_CLI::log( $this->color_message( __( 'Currency: ', 'give' ), give_get_currency() ) );
134
-		WP_CLI::log( $this->color_message( __( 'Currency Position: ', 'give' ), give_get_currency_position() ) );
135
-		WP_CLI::log( $this->color_message( __( 'Thousand Separator: ', 'give' ), give_get_price_thousand_separator() ) );
136
-		WP_CLI::log( $this->color_message( __( 'Decimal Separator: ', 'give' ), give_get_price_decimal_separator() ) );
137
-		WP_CLI::log( $this->color_message( __( 'Number of Decimals: ', 'give' ), give_get_price_decimals() ) );
138
-		WP_CLI::log( $this->color_message( __( 'Test Mode: ', 'give' ), ( give_get_option( 'test_mode' ) ? __( 'Yes', 'give' ) : __( 'No', 'give' ) ) ) );
139
-		WP_CLI::log( $this->color_message( __( 'Default Gateway: ', 'give' ), ( $default_gateway ? $default_gateway : __( 'Not Set', 'give' ) ) ) );
133
+		WP_CLI::log($this->color_message(__('Currency: ', 'give'), give_get_currency()));
134
+		WP_CLI::log($this->color_message(__('Currency Position: ', 'give'), give_get_currency_position()));
135
+		WP_CLI::log($this->color_message(__('Thousand Separator: ', 'give'), give_get_price_thousand_separator()));
136
+		WP_CLI::log($this->color_message(__('Decimal Separator: ', 'give'), give_get_price_decimal_separator()));
137
+		WP_CLI::log($this->color_message(__('Number of Decimals: ', 'give'), give_get_price_decimals()));
138
+		WP_CLI::log($this->color_message(__('Test Mode: ', 'give'), (give_get_option('test_mode') ? __('Yes', 'give') : __('No', 'give'))));
139
+		WP_CLI::log($this->color_message(__('Default Gateway: ', 'give'), ($default_gateway ? $default_gateway : __('Not Set', 'give'))));
140 140
 
141 141
 		// Payment gateways Information.
142
-		$gateways = give_get_ordered_payment_gateways( give_get_payment_gateways() );
143
-		WP_CLI::log( $this->color_message( __( 'Enabled Gateways: ', 'give' ) ) );
142
+		$gateways = give_get_ordered_payment_gateways(give_get_payment_gateways());
143
+		WP_CLI::log($this->color_message(__('Enabled Gateways: ', 'give')));
144 144
 
145
-		if ( ! empty( $gateways ) ) {
145
+		if ( ! empty($gateways)) {
146 146
 			self::$counter = 1;
147
-			foreach ( $gateways as $gateway ) {
148
-				WP_CLI::log( '  ' . $this->color_message( self::$counter, $gateway['admin_label'] ) );
149
-				self::$counter ++;
147
+			foreach ($gateways as $gateway) {
148
+				WP_CLI::log('  '.$this->color_message(self::$counter, $gateway['admin_label']));
149
+				self::$counter++;
150 150
 			}
151 151
 		} else {
152
-			WP_CLI::log( __( 'Not any payment gateways found', 'give' ) );
152
+			WP_CLI::log(__('Not any payment gateways found', 'give'));
153 153
 		}
154 154
 	}
155 155
 
@@ -181,15 +181,15 @@  discard block
 block discarded – undo
181 181
 	 *
182 182
 	 * @subcommand    forms
183 183
 	 */
184
-	public function forms( $args, $assoc_args ) {
184
+	public function forms($args, $assoc_args) {
185 185
 		global $wp_query;
186
-		$form_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? absint( $assoc_args['id'] ) : false;
187
-		$number  = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? absint( $assoc_args['number'] ) : 10;
186
+		$form_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? absint($assoc_args['id']) : false;
187
+		$number  = isset($assoc_args) && array_key_exists('number', $assoc_args) ? absint($assoc_args['number']) : 10;
188 188
 		$start   = time();
189 189
 
190 190
 		// Cache previous number query var.
191 191
 		$is_set_number = $cache_per_page = false;
192
-		if ( isset( $wp_query->query_vars['number'] ) ) {
192
+		if (isset($wp_query->query_vars['number'])) {
193 193
 			$cache_per_page = $wp_query->query_vars['number'];
194 194
 			$is_set_number  = true;
195 195
 		}
@@ -198,22 +198,22 @@  discard block
 block discarded – undo
198 198
 		$wp_query->query_vars['number'] = $number;
199 199
 
200 200
 		// Get forms.
201
-		$forms = $form_id ? $this->api->get_forms( $form_id ) : $this->api->get_forms();
201
+		$forms = $form_id ? $this->api->get_forms($form_id) : $this->api->get_forms();
202 202
 
203 203
 		// Reset number query var.
204
-		if ( $is_set_number ) {
204
+		if ($is_set_number) {
205 205
 			$wp_query->query_vars['number'] = $cache_per_page;
206 206
 		}
207 207
 
208 208
 		// Bailout.
209
-		if ( array_key_exists( 'error', $forms ) ) {
209
+		if (array_key_exists('error', $forms)) {
210 210
 
211
-			WP_CLI::warning( $forms['error'] );
211
+			WP_CLI::warning($forms['error']);
212 212
 
213 213
 			return;
214
-		} elseif ( empty( $forms['forms'] ) ) {
214
+		} elseif (empty($forms['forms'])) {
215 215
 
216
-			WP_CLI::error( __( 'No forms found.', 'give' ) );
216
+			WP_CLI::error(__('No forms found.', 'give'));
217 217
 
218 218
 			return;
219 219
 		}
@@ -221,25 +221,25 @@  discard block
 block discarded – undo
221 221
 		// Param to check if form typeis already showed or not.
222 222
 		$is_show_form_type = false;
223 223
 
224
-		if ( 1 === count( $forms ) && $form_id ) {
224
+		if (1 === count($forms) && $form_id) {
225 225
 			// Show single form.
226
-			foreach ( $forms['forms'][0] as $key => $info ) {
227
-				switch ( $key ) {
226
+			foreach ($forms['forms'][0] as $key => $info) {
227
+				switch ($key) {
228 228
 					case 'stats':
229
-						$this->color_main_heading( ucfirst( $key ) );
229
+						$this->color_main_heading(ucfirst($key));
230 230
 
231
-						foreach ( $info as $heading => $data ) {
232
-							$this->color_sub_heading( ucfirst( $heading ) );
233
-							switch ( $heading ) {
231
+						foreach ($info as $heading => $data) {
232
+							$this->color_sub_heading(ucfirst($heading));
233
+							switch ($heading) {
234 234
 								default:
235
-									foreach ( $data as $subheading => $subdata ) {
235
+									foreach ($data as $subheading => $subdata) {
236 236
 
237
-										switch ( $subheading ) {
237
+										switch ($subheading) {
238 238
 											case 'earnings':
239
-												WP_CLI::log( $this->color_message( $subheading . ': ', give_currency_filter( $subdata ) ) );
239
+												WP_CLI::log($this->color_message($subheading.': ', give_currency_filter($subdata)));
240 240
 												break;
241 241
 											default:
242
-												WP_CLI::log( $this->color_message( $subheading . ': ', $subdata ) );
242
+												WP_CLI::log($this->color_message($subheading.': ', $subdata));
243 243
 										}
244 244
 									}
245 245
 							}
@@ -249,26 +249,26 @@  discard block
 block discarded – undo
249 249
 					case 'pricing':
250 250
 					case 'info':
251 251
 					default:
252
-						$this->color_main_heading( ucfirst( $key ) );
252
+						$this->color_main_heading(ucfirst($key));
253 253
 
254 254
 						// Show form type.
255
-						if ( ! $is_show_form_type ) {
256
-							$form              = new Give_Donate_Form( $form_id );
255
+						if ( ! $is_show_form_type) {
256
+							$form              = new Give_Donate_Form($form_id);
257 257
 							$is_show_form_type = true;
258 258
 
259
-							WP_CLI::log( $this->color_message( __( 'form type', 'give' ), $form->get_type() ) );
259
+							WP_CLI::log($this->color_message(__('form type', 'give'), $form->get_type()));
260 260
 						}
261 261
 
262
-						foreach ( $info as $heading => $data ) {
262
+						foreach ($info as $heading => $data) {
263 263
 
264
-							switch ( $heading ) {
264
+							switch ($heading) {
265 265
 								case 'id':
266
-									WP_CLI::log( $this->color_message( $heading, $data ) );
266
+									WP_CLI::log($this->color_message($heading, $data));
267 267
 									break;
268 268
 
269 269
 								default:
270
-									$data = empty( $data ) ? __( 'Not set', 'give' ) : $data;
271
-									WP_CLI::log( $this->color_message( $heading, $data ) );
270
+									$data = empty($data) ? __('Not set', 'give') : $data;
271
+									WP_CLI::log($this->color_message($heading, $data));
272 272
 							}
273 273
 						}
274 274
 				}// End switch().
@@ -279,37 +279,37 @@  discard block
 block discarded – undo
279 279
 			$is_table_first_row_set = false;
280 280
 			$table_column_count     = 0;
281 281
 
282
-			WP_CLI::line( $this->color_message( sprintf( __( '%d donation forms found', 'give' ), count( $forms['forms'] ) ), '', false ) );
282
+			WP_CLI::line($this->color_message(sprintf(__('%d donation forms found', 'give'), count($forms['forms'])), '', false));
283 283
 
284
-			foreach ( $forms['forms'] as $index => $form_data ) {
284
+			foreach ($forms['forms'] as $index => $form_data) {
285 285
 
286 286
 				// Default table data.
287 287
 				$table_first_row = array();
288 288
 				$table_row       = array();
289 289
 
290
-				foreach ( $form_data['info'] as $key => $form ) {
290
+				foreach ($form_data['info'] as $key => $form) {
291 291
 
292 292
 					// Do not show thumbnail, content and link in table.
293
-					if ( in_array( $key, array( 'content', 'thumbnail', 'link' ), true ) ) {
293
+					if (in_array($key, array('content', 'thumbnail', 'link'), true)) {
294 294
 						continue;
295 295
 					}
296 296
 
297
-					if ( ! $is_table_first_row_set ) {
297
+					if ( ! $is_table_first_row_set) {
298 298
 						$table_first_row[] = $key;
299 299
 					}
300 300
 
301 301
 					$table_row[] = $form;
302 302
 
303
-					if ( 'status' === $key ) {
303
+					if ('status' === $key) {
304 304
 						// First array item will be an form id in our case.
305
-						$form = new Give_Donate_Form( absint( $table_row[0] ) );
305
+						$form = new Give_Donate_Form(absint($table_row[0]));
306 306
 
307 307
 						$table_row[] = $form->get_type();
308 308
 					}
309 309
 				}
310 310
 
311 311
 				// Set table first row.
312
-				if ( ! $is_table_first_row_set ) {
312
+				if ( ! $is_table_first_row_set) {
313 313
 
314 314
 					// Add extra column to table.
315 315
 					$table_first_row[] = 'type';
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 				$table_data[] = $table_row;
323 323
 			}// End foreach().
324 324
 
325
-			$this->display_table( $table_data );
325
+			$this->display_table($table_data);
326 326
 		}// End if().
327 327
 	}
328 328
 
@@ -375,59 +375,59 @@  discard block
 block discarded – undo
375 375
 	 *
376 376
 	 * @subcommand    donors
377 377
 	 */
378
-	public function donors( $args, $assoc_args ) {
378
+	public function donors($args, $assoc_args) {
379 379
 		global $wp_query;
380
-		$donor_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? absint( $assoc_args['id'] ) : false;
381
-		$email    = isset( $assoc_args ) && array_key_exists( 'email', $assoc_args ) ? $assoc_args['email'] : false;
382
-		$name     = isset( $assoc_args ) && array_key_exists( 'name', $assoc_args ) ? $assoc_args['name'] : '';
383
-		$create   = isset( $assoc_args ) && array_key_exists( 'create', $assoc_args ) ? $assoc_args['create'] : false;
384
-		$number   = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? $assoc_args['number'] : 10;
385
-		$form_id  = isset( $assoc_args ) && array_key_exists( 'form-id', $assoc_args ) ? $assoc_args['form-id'] : 0;
386
-		$format   = isset( $assoc_args ) && array_key_exists( 'format', $assoc_args ) ? $assoc_args['format'] : 'table';
380
+		$donor_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? absint($assoc_args['id']) : false;
381
+		$email    = isset($assoc_args) && array_key_exists('email', $assoc_args) ? $assoc_args['email'] : false;
382
+		$name     = isset($assoc_args) && array_key_exists('name', $assoc_args) ? $assoc_args['name'] : '';
383
+		$create   = isset($assoc_args) && array_key_exists('create', $assoc_args) ? $assoc_args['create'] : false;
384
+		$number   = isset($assoc_args) && array_key_exists('number', $assoc_args) ? $assoc_args['number'] : 10;
385
+		$form_id  = isset($assoc_args) && array_key_exists('form-id', $assoc_args) ? $assoc_args['form-id'] : 0;
386
+		$format   = isset($assoc_args) && array_key_exists('format', $assoc_args) ? $assoc_args['format'] : 'table';
387 387
 		$start    = time();
388 388
 
389
-		if ( $create ) {
390
-			if ( 80 < $create ) {
391
-				WP_CLI::warning( 'Currently we can only generate maximum 80 donors.', 'give' );
389
+		if ($create) {
390
+			if (80 < $create) {
391
+				WP_CLI::warning('Currently we can only generate maximum 80 donors.', 'give');
392 392
 				$create = 80;
393 393
 			}
394 394
 
395 395
 			$number = 1;
396 396
 
397
-			if ( isset( $assoc_args['email'] ) && ! is_email( $email ) ) {
398
-				WP_CLI::warning( 'Wrong email address provided.', 'give' );
397
+			if (isset($assoc_args['email']) && ! is_email($email)) {
398
+				WP_CLI::warning('Wrong email address provided.', 'give');
399 399
 
400 400
 				return;
401 401
 			}
402 402
 
403 403
 			// Create one or more donors.
404
-			if ( ! $email ) {
404
+			if ( ! $email) {
405 405
 				// If no email is specified, look to see if we are generating arbitrary donor accounts.
406
-				$number = is_numeric( $create ) ? absint( $create ) : 1;
406
+				$number = is_numeric($create) ? absint($create) : 1;
407 407
 			}
408 408
 
409
-			for ( $i = 0; $i < $number; $i ++ ) {
409
+			for ($i = 0; $i < $number; $i++) {
410 410
 				$name  = $name ? $name : $this->get_random_name();
411
-				$email = $email ? $email : $this->get_random_email( $name );
411
+				$email = $email ? $email : $this->get_random_email($name);
412 412
 
413 413
 				$args = array(
414 414
 					'email' => $email,
415 415
 					'name'  => $name,
416 416
 				);
417 417
 
418
-				$donor_id = Give()->donors->add( $args );
418
+				$donor_id = Give()->donors->add($args);
419 419
 
420
-				if ( $donor_id ) {
421
-					WP_CLI::line( $this->color_message( sprintf( __( 'Donor #%d created successfully', 'give' ), $donor_id ) ) );
420
+				if ($donor_id) {
421
+					WP_CLI::line($this->color_message(sprintf(__('Donor #%d created successfully', 'give'), $donor_id)));
422 422
 				} else {
423
-					WP_CLI::error( __( 'Failed to create donor', 'give' ) );
423
+					WP_CLI::error(__('Failed to create donor', 'give'));
424 424
 				}
425 425
 
426 426
 				// Reset email and name to false so it is generated on the next loop (if creating donors).
427 427
 				$email = $name = false;
428 428
 			}
429 429
 
430
-			WP_CLI::line( $this->color_message( sprintf( __( '%1$d donors created in %2$d seconds', 'give' ), $number, time() - $start ) ) );
430
+			WP_CLI::line($this->color_message(sprintf(__('%1$d donors created in %2$d seconds', 'give'), $number, time() - $start)));
431 431
 
432 432
 		} else {
433 433
 			// Counter.
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
 			 */
442 442
 			// Cache previous number query var.
443 443
 			$is_set_number = $cache_per_page = false;
444
-			if ( isset( $wp_query->query_vars['number'] ) ) {
444
+			if (isset($wp_query->query_vars['number'])) {
445 445
 				$cache_per_page = $wp_query->query_vars['number'];
446 446
 				$is_set_number  = true;
447 447
 			}
@@ -450,24 +450,24 @@  discard block
 block discarded – undo
450 450
 			$wp_query->query_vars['number'] = $number;
451 451
 
452 452
 			// Get donors.
453
-			if ( $form_id ) {
453
+			if ($form_id) {
454 454
 				// @TODO: Allow user to get a list of donors by donation status.
455
-				$donors = $this->get_donors_by_form_id( $form_id );
455
+				$donors = $this->get_donors_by_form_id($form_id);
456 456
 			} else {
457
-				$donors = $this->api->get_donors( $search );
457
+				$donors = $this->api->get_donors($search);
458 458
 			}
459 459
 
460 460
 			// Reset number query var.
461
-			if ( $is_set_number ) {
461
+			if ($is_set_number) {
462 462
 				$wp_query->query_vars['number'] = $cache_per_page;
463 463
 			}
464 464
 
465
-			if ( isset( $donors['error'] ) ) {
466
-				WP_CLI::error( $donors['error'] );
465
+			if (isset($donors['error'])) {
466
+				WP_CLI::error($donors['error']);
467 467
 			}
468 468
 
469
-			if ( empty( $donors ) ) {
470
-				WP_CLI::error( __( 'No donors found.', 'give' ) );
469
+			if (empty($donors)) {
470
+				WP_CLI::error(__('No donors found.', 'give'));
471 471
 
472 472
 				return;
473 473
 			}
@@ -475,24 +475,24 @@  discard block
 block discarded – undo
475 475
 			$table_data             = array();
476 476
 			$is_table_first_row_set = false;
477 477
 
478
-			foreach ( $donors['donors'] as $donor_data ) {
478
+			foreach ($donors['donors'] as $donor_data) {
479 479
 				// Set default table row data.
480
-				$table_first_row = array( __( 's_no', 'give' ) );
481
-				$table_row       = array( self::$counter );
480
+				$table_first_row = array(__('s_no', 'give'));
481
+				$table_row       = array(self::$counter);
482 482
 
483
-				foreach ( $donor_data as $key => $donor ) {
484
-					switch ( $key ) {
483
+				foreach ($donor_data as $key => $donor) {
484
+					switch ($key) {
485 485
 						case 'stats':
486
-							foreach ( $donor as $heading => $data ) {
486
+							foreach ($donor as $heading => $data) {
487 487
 
488 488
 								// Get first row.
489
-								if ( ! $is_table_first_row_set ) {
489
+								if ( ! $is_table_first_row_set) {
490 490
 									$table_first_row[] = $heading;
491 491
 								}
492 492
 
493
-								switch ( $heading ) {
493
+								switch ($heading) {
494 494
 									case 'total_spent':
495
-										$table_row[] = give_currency_filter( $data );
495
+										$table_row[] = give_currency_filter($data);
496 496
 										break;
497 497
 
498 498
 									default:
@@ -503,10 +503,10 @@  discard block
 block discarded – undo
503 503
 
504 504
 						case 'info':
505 505
 						default:
506
-							foreach ( $donor as $heading => $data ) {
506
+							foreach ($donor as $heading => $data) {
507 507
 
508 508
 								// Get first row.
509
-								if ( ! $is_table_first_row_set ) {
509
+								if ( ! $is_table_first_row_set) {
510 510
 									$table_first_row[] = $heading;
511 511
 								}
512 512
 
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
 				}
517 517
 
518 518
 				// Add first row data to table data.
519
-				if ( ! $is_table_first_row_set ) {
519
+				if ( ! $is_table_first_row_set) {
520 520
 					$table_data[]           = $table_first_row;
521 521
 					$is_table_first_row_set = true;
522 522
 				}
@@ -525,44 +525,44 @@  discard block
 block discarded – undo
525 525
 				$table_data[] = $table_row;
526 526
 
527 527
 				// Increase counter.
528
-				self::$counter ++;
528
+				self::$counter++;
529 529
 			}// End foreach().
530 530
 
531
-			switch ( $format ) {
531
+			switch ($format) {
532 532
 				case 'json':
533 533
 					$table_column_name = $table_data[0];
534
-					unset( $table_data[0] );
534
+					unset($table_data[0]);
535 535
 
536 536
 					$new_table_data = array();
537
-					foreach ( $table_data as $index => $data ) {
538
-						foreach ( $data as $key => $value ) {
539
-							$new_table_data[ $index ][ $table_column_name[ $key ] ] = $value;
537
+					foreach ($table_data as $index => $data) {
538
+						foreach ($data as $key => $value) {
539
+							$new_table_data[$index][$table_column_name[$key]] = $value;
540 540
 						}
541 541
 					}
542 542
 
543
-					WP_CLI::log( json_encode( $new_table_data ) );
543
+					WP_CLI::log(json_encode($new_table_data));
544 544
 					break;
545 545
 
546 546
 				case 'csv':
547
-					$file_path = trailingslashit( WP_CONTENT_DIR ) . 'uploads/give_donors_' . date( 'Y_m_d_s', current_time( 'timestamp' ) ) . '.csv';
548
-					$fp        = fopen( $file_path, 'w' );
547
+					$file_path = trailingslashit(WP_CONTENT_DIR).'uploads/give_donors_'.date('Y_m_d_s', current_time('timestamp')).'.csv';
548
+					$fp        = fopen($file_path, 'w');
549 549
 
550
-					if ( is_writable( $file_path ) ) {
551
-						foreach ( $table_data as $fields ) {
552
-							fputcsv( $fp, $fields );
550
+					if (is_writable($file_path)) {
551
+						foreach ($table_data as $fields) {
552
+							fputcsv($fp, $fields);
553 553
 						}
554 554
 
555
-						fclose( $fp );
555
+						fclose($fp);
556 556
 
557
-						WP_CLI::success( "Donors list csv created successfully: {$file_path}" );
557
+						WP_CLI::success("Donors list csv created successfully: {$file_path}");
558 558
 					} else {
559
-						WP_CLI::warning( "Unable to create donors list csv file: {$file_path} (May folder do not have write permission)" );
559
+						WP_CLI::warning("Unable to create donors list csv file: {$file_path} (May folder do not have write permission)");
560 560
 					}
561 561
 
562 562
 					break;
563 563
 
564 564
 				default:
565
-					$this->display_table( $table_data );
565
+					$this->display_table($table_data);
566 566
 			}// End switch().
567 567
 		}// End if().
568 568
 	}
@@ -592,13 +592,13 @@  discard block
 block discarded – undo
592 592
 	 *
593 593
 	 * @subcommand    donations
594 594
 	 */
595
-	public function donations( $args, $assoc_args ) {
595
+	public function donations($args, $assoc_args) {
596 596
 		global $wp_query;
597
-		$number = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? $assoc_args['number'] : 10;
597
+		$number = isset($assoc_args) && array_key_exists('number', $assoc_args) ? $assoc_args['number'] : 10;
598 598
 
599 599
 		// Cache previous number query var.
600 600
 		$is_set_number = $cache_per_page = false;
601
-		if ( isset( $wp_query->query_vars['number'] ) ) {
601
+		if (isset($wp_query->query_vars['number'])) {
602 602
 			$cache_per_page = $wp_query->query_vars['number'];
603 603
 			$is_set_number  = true;
604 604
 		}
@@ -610,46 +610,46 @@  discard block
 block discarded – undo
610 610
 		$donations = $this->api->get_recent_donations();
611 611
 
612 612
 		// Reset number query var.
613
-		if ( $is_set_number ) {
613
+		if ($is_set_number) {
614 614
 			$wp_query->query_vars['number'] = $cache_per_page;
615 615
 		}
616 616
 
617
-		if ( empty( $donations ) ) {
618
-			WP_CLI::error( __( 'No donations found.', 'give' ) );
617
+		if (empty($donations)) {
618
+			WP_CLI::error(__('No donations found.', 'give'));
619 619
 
620 620
 			return;
621 621
 		}
622 622
 
623 623
 		self::$counter = 1;
624 624
 
625
-		foreach ( $donations['donations'] as $key => $donation ) {
626
-			$this->color_main_heading( sprintf( __( '%1$s. Donation #%2$s', 'give' ), self::$counter, $donation['ID'] ), 'Y' );
627
-			self::$counter ++;
625
+		foreach ($donations['donations'] as $key => $donation) {
626
+			$this->color_main_heading(sprintf(__('%1$s. Donation #%2$s', 'give'), self::$counter, $donation['ID']), 'Y');
627
+			self::$counter++;
628 628
 
629
-			foreach ( $donation as $column => $data ) {
629
+			foreach ($donation as $column => $data) {
630 630
 
631
-				if ( is_array( $data ) ) {
632
-					$this->color_sub_heading( $column );
633
-					foreach ( $data as $subcolumn => $subdata ) {
631
+				if (is_array($data)) {
632
+					$this->color_sub_heading($column);
633
+					foreach ($data as $subcolumn => $subdata) {
634 634
 
635 635
 						// Decode html codes.
636
-						switch ( $subcolumn ) {
636
+						switch ($subcolumn) {
637 637
 							case 'name':
638
-								$subdata = html_entity_decode( $subdata );
638
+								$subdata = html_entity_decode($subdata);
639 639
 								break;
640 640
 						}
641 641
 
642 642
 						// @TODO Check if multi dimension array information is importent to show or not. For example inside donation array we have array for fees data inside payment meta.
643
-						if ( is_array( $subdata ) ) {
643
+						if (is_array($subdata)) {
644 644
 							continue;
645 645
 						}
646 646
 
647
-						WP_CLI::log( $this->color_message( $subcolumn, $subdata ) );
647
+						WP_CLI::log($this->color_message($subcolumn, $subdata));
648 648
 					}
649 649
 					continue;
650 650
 				}
651 651
 
652
-				WP_CLI::log( $this->color_message( $column, $data ) );
652
+				WP_CLI::log($this->color_message($column, $data));
653 653
 			}
654 654
 		}
655 655
 	}
@@ -689,27 +689,27 @@  discard block
 block discarded – undo
689 689
 	 *
690 690
 	 * @return        void
691 691
 	 */
692
-	public function report( $args, $assoc_args ) {
692
+	public function report($args, $assoc_args) {
693 693
 		$stats      = new Give_Payment_Stats();
694
-		$date       = isset( $assoc_args ) && array_key_exists( 'date', $assoc_args ) ? $assoc_args['date'] : false;
695
-		$start_date = isset( $assoc_args ) && array_key_exists( 'start-date', $assoc_args ) ? $assoc_args['start-date'] : false;
696
-		$end_date   = isset( $assoc_args ) && array_key_exists( 'end-date', $assoc_args ) ? $assoc_args['end-date'] : false;
697
-		$form_id    = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? $assoc_args['id'] : 0;
694
+		$date       = isset($assoc_args) && array_key_exists('date', $assoc_args) ? $assoc_args['date'] : false;
695
+		$start_date = isset($assoc_args) && array_key_exists('start-date', $assoc_args) ? $assoc_args['start-date'] : false;
696
+		$end_date   = isset($assoc_args) && array_key_exists('end-date', $assoc_args) ? $assoc_args['end-date'] : false;
697
+		$form_id    = isset($assoc_args) && array_key_exists('id', $assoc_args) ? $assoc_args['id'] : 0;
698 698
 
699
-		if ( ! empty( $date ) ) {
699
+		if ( ! empty($date)) {
700 700
 			$start_date = $date;
701 701
 			$end_date   = false;
702
-		} elseif ( empty( $date ) && empty( $start_date ) ) {
702
+		} elseif (empty($date) && empty($start_date)) {
703 703
 			$start_date = 'this_month';
704 704
 			$end_date   = false;
705 705
 		}
706 706
 
707 707
 		// Get stats.
708
-		$earnings = $stats->get_earnings( $form_id, $start_date, $end_date );
709
-		$sales    = $stats->get_sales( $form_id, $start_date, $end_date );
708
+		$earnings = $stats->get_earnings($form_id, $start_date, $end_date);
709
+		$sales    = $stats->get_sales($form_id, $start_date, $end_date);
710 710
 
711
-		WP_CLI::line( $this->color_message( __( 'Earnings', 'give' ), give_currency_filter( $earnings, array( 'decode_currency' => true ) ) ) );
712
-		WP_CLI::line( $this->color_message( __( 'Sales', 'give' ), $sales ) );
711
+		WP_CLI::line($this->color_message(__('Earnings', 'give'), give_currency_filter($earnings, array('decode_currency' => true))));
712
+		WP_CLI::line($this->color_message(__('Sales', 'give'), $sales));
713 713
 	}
714 714
 
715 715
 
@@ -736,27 +736,27 @@  discard block
 block discarded – undo
736 736
 	 *
737 737
 	 * @subcommand    cache
738 738
 	 */
739
-	public function cache( $args, $assoc_args ) {
740
-		$action = isset( $assoc_args ) && array_key_exists( 'action', $assoc_args ) ? $assoc_args['action'] : false;
739
+	public function cache($args, $assoc_args) {
740
+		$action = isset($assoc_args) && array_key_exists('action', $assoc_args) ? $assoc_args['action'] : false;
741 741
 
742 742
 		// Bailout.
743
-		if ( ! $action || ! in_array( $action, array( 'delete' ), true ) ) {
744
-			WP_CLI::warning( __( 'Type wp give cache --action=delete to delete all stat transients', 'give' ) );
743
+		if ( ! $action || ! in_array($action, array('delete'), true)) {
744
+			WP_CLI::warning(__('Type wp give cache --action=delete to delete all stat transients', 'give'));
745 745
 
746 746
 			return;
747 747
 		}
748 748
 
749
-		switch ( $action ) {
749
+		switch ($action) {
750 750
 			case 'delete':
751 751
 				// Reset counter.
752 752
 				self::$counter = 1;
753 753
 
754
-				if ( $this->delete_stats_transients() ) {
754
+				if ($this->delete_stats_transients()) {
755 755
 					// Report .eading.
756
-					WP_CLI::success( 'Give cache deleted.' );
756
+					WP_CLI::success('Give cache deleted.');
757 757
 				} else {
758 758
 					// Report .eading.
759
-					WP_CLI::warning( 'We did not find any Give plugin cache to delete :)' );
759
+					WP_CLI::warning('We did not find any Give plugin cache to delete :)');
760 760
 				}
761 761
 				break;
762 762
 		}
@@ -785,27 +785,27 @@  discard block
 block discarded – undo
785 785
 			ARRAY_A
786 786
 		);
787 787
 
788
-		if ( ! empty( $stat_option_names ) ) {
788
+		if ( ! empty($stat_option_names)) {
789 789
 
790
-			foreach ( $stat_option_names as $option_name ) {
790
+			foreach ($stat_option_names as $option_name) {
791 791
 				$error       = false;
792 792
 				$option_name = $option_name['option_name'];
793 793
 
794
-				switch ( true ) {
795
-					case ( false !== strpos( $option_name, 'transient' ) ):
796
-						$option_name = str_replace( '_transient_', '', $option_name );
797
-						$error       = delete_transient( $option_name );
794
+				switch (true) {
795
+					case (false !== strpos($option_name, 'transient')):
796
+						$option_name = str_replace('_transient_', '', $option_name);
797
+						$error       = delete_transient($option_name);
798 798
 						break;
799 799
 
800 800
 					default:
801
-						$error = delete_option( $option_name );
801
+						$error = delete_option($option_name);
802 802
 				}
803 803
 
804
-				if ( $error ) {
805
-					WP_CLI::log( $this->color_message( self::$counter, $option_name ) );
806
-					self::$counter ++;
804
+				if ($error) {
805
+					WP_CLI::log($this->color_message(self::$counter, $option_name));
806
+					self::$counter++;
807 807
 				} else {
808
-					WP_CLI::log( $this->color_message( __( 'Error while deleting this transient', 'give' ), $option_name ) );
808
+					WP_CLI::log($this->color_message(__('Error while deleting this transient', 'give'), $option_name));
809 809
 				}
810 810
 			}
811 811
 
@@ -826,13 +826,13 @@  discard block
 block discarded – undo
826 826
 	 *
827 827
 	 * @return   string
828 828
 	 */
829
-	private function color_message( $heading, $message = '', $colon = true, $color = 'g' ) {
829
+	private function color_message($heading, $message = '', $colon = true, $color = 'g') {
830 830
 		// Add colon.
831
-		if ( $colon ) {
832
-			$heading = $heading . ': ';
831
+		if ($colon) {
832
+			$heading = $heading.': ';
833 833
 		}
834 834
 
835
-		return WP_CLI::colorize( "%{$color}" . $heading . '%n' ) . $message;
835
+		return WP_CLI::colorize("%{$color}".$heading.'%n').$message;
836 836
 	}
837 837
 
838 838
 
@@ -847,8 +847,8 @@  discard block
 block discarded – undo
847 847
 	 *
848 848
 	 * @return    void
849 849
 	 */
850
-	private function color_main_heading( $heading, $color = 'g' ) {
851
-		WP_CLI::log( "\n######   " . $this->color_message( $heading, '', false, $color ) . '   ######' );
850
+	private function color_main_heading($heading, $color = 'g') {
851
+		WP_CLI::log("\n######   ".$this->color_message($heading, '', false, $color).'   ######');
852 852
 	}
853 853
 
854 854
 	/**
@@ -861,8 +861,8 @@  discard block
 block discarded – undo
861 861
 	 *
862 862
 	 * @return    void
863 863
 	 */
864
-	private function color_sub_heading( $subheading ) {
865
-		WP_CLI::log( "\n--->" . $subheading . '', '', false );
864
+	private function color_sub_heading($subheading) {
865
+		WP_CLI::log("\n--->".$subheading.'', '', false);
866 866
 	}
867 867
 
868 868
 
@@ -876,17 +876,17 @@  discard block
 block discarded – undo
876 876
 	 *
877 877
 	 * @return    void
878 878
 	 */
879
-	private function display_table( $data ) {
879
+	private function display_table($data) {
880 880
 		$table = new \cli\Table();
881 881
 
882 882
 		// Set table header.
883
-		$table->setHeaders( $data[0] );
883
+		$table->setHeaders($data[0]);
884 884
 
885 885
 		// Remove table header.
886
-		unset( $data[0] );
886
+		unset($data[0]);
887 887
 
888 888
 		// Set table data.
889
-		$table->setRows( $data );
889
+		$table->setRows($data);
890 890
 
891 891
 		// Display table.
892 892
 		$table->display();
@@ -903,14 +903,14 @@  discard block
 block discarded – undo
903 903
 	 * @return array
904 904
 	 */
905 905
 
906
-	private function get_donors_by_form_id( $form_id ) {
906
+	private function get_donors_by_form_id($form_id) {
907 907
 		$donors = array();
908 908
 
909 909
 		$donations = new Give_Payments_Query(
910 910
 			array(
911
-				'give_forms' => array( $form_id ),
912
-				'number'     => - 1,
913
-				'status'     => array( 'publish' ),
911
+				'give_forms' => array($form_id),
912
+				'number'     => -1,
913
+				'status'     => array('publish'),
914 914
 			)
915 915
 		);
916 916
 
@@ -918,16 +918,16 @@  discard block
 block discarded – undo
918 918
 		$skip_donors = array();
919 919
 
920 920
 		/* @var Give_Payment|object $donation Payment object. */
921
-		foreach ( $donations as $donation ) {
921
+		foreach ($donations as $donation) {
922 922
 
923
-			if ( in_array( $donation->customer_id, $skip_donors, true ) ) {
923
+			if (in_array($donation->customer_id, $skip_donors, true)) {
924 924
 				continue;
925 925
 			}
926 926
 
927
-			if ( ! empty( $donors ) ) {
928
-				$donors['donors'][] = current( current( $this->api->get_donors( (int) $donation->customer_id ) ) );
927
+			if ( ! empty($donors)) {
928
+				$donors['donors'][] = current(current($this->api->get_donors((int) $donation->customer_id)));
929 929
 			} else {
930
-				$donors = array_merge( $donors, $this->api->get_donors( (int) $donation->customer_id ) );
930
+				$donors = array_merge($donors, $this->api->get_donors((int) $donation->customer_id));
931 931
 			}
932 932
 
933 933
 			$skip_donors[] = $donation->customer_id;
@@ -972,15 +972,15 @@  discard block
 block discarded – undo
972 972
 		);
973 973
 
974 974
 		// Generate a random forename.
975
-		$random_name = $names[ mt_rand( 0, sizeof( $names ) - 1 ) ];
975
+		$random_name = $names[mt_rand(0, sizeof($names) - 1)];
976 976
 
977 977
 		// Generate a random surname.
978
-		$random_surname = $surnames[ mt_rand( 0, sizeof( $surnames ) - 1 ) ];
978
+		$random_surname = $surnames[mt_rand(0, sizeof($surnames) - 1)];
979 979
 
980 980
 		// Generate name.
981 981
 		$name = "{$random_name} {$random_surname}";
982 982
 
983
-		if ( in_array( $name, $this->new_donor_names ) ) {
983
+		if (in_array($name, $this->new_donor_names)) {
984 984
 			$name = $this->get_random_name();
985 985
 		}
986 986
 
@@ -999,8 +999,8 @@  discard block
 block discarded – undo
999 999
 	 *
1000 1000
 	 * @return string
1001 1001
 	 */
1002
-	private function get_random_email( $name ) {
1003
-		return implode( '.', explode( ' ', strtolower( $name ) ) ) . '@test.com';
1002
+	private function get_random_email($name) {
1003
+		return implode('.', explode(' ', strtolower($name))).'@test.com';
1004 1004
 	}
1005 1005
 
1006 1006
 	/**
@@ -1015,59 +1015,59 @@  discard block
 block discarded – undo
1015 1015
 	 * @when after_wp_load
1016 1016
 	 * @subcommand test-mode
1017 1017
 	 */
1018
-	public function test_mode( $args, $assoc ) {
1018
+	public function test_mode($args, $assoc) {
1019 1019
 
1020 1020
 		// Return if associative arguments are not specified.
1021
-		if ( empty( $assoc ) ) {
1022
-			WP_CLI::error( "--enable or --disable flag is missing." );
1021
+		if (empty($assoc)) {
1022
+			WP_CLI::error("--enable or --disable flag is missing.");
1023 1023
 			return;
1024 1024
 		}
1025 1025
 
1026
-		$enabled_gateways = give_get_option( 'gateways' );
1027
-		$default_gateway  = give_get_option( 'default_gateway' );
1026
+		$enabled_gateways = give_get_option('gateways');
1027
+		$default_gateway  = give_get_option('default_gateway');
1028 1028
 
1029 1029
 
1030 1030
 		// Enable Test Mode.
1031
-		if ( true === WP_CLI\Utils\get_flag_value( $assoc, 'enable' ) ) {
1031
+		if (true === WP_CLI\Utils\get_flag_value($assoc, 'enable')) {
1032 1032
 
1033 1033
 			// Set `Test Mode` to `enabled`.
1034
-			give_update_option( 'test_mode', 'enabled' );
1034
+			give_update_option('test_mode', 'enabled');
1035 1035
 
1036 1036
 
1037 1037
 			// Enable `Test Donation` gateway.
1038 1038
 			$enabled_gateways['manual'] = "1";
1039
-			give_update_option( 'gateways', $enabled_gateways );
1039
+			give_update_option('gateways', $enabled_gateways);
1040 1040
 
1041 1041
 
1042 1042
 			// Set `Test Donation` as default gateway.
1043
-			add_option( 'give_test_mode_default_gateway', $default_gateway );
1044
-			give_update_option( 'default_gateway', 'manual' );
1043
+			add_option('give_test_mode_default_gateway', $default_gateway);
1044
+			give_update_option('default_gateway', 'manual');
1045 1045
 
1046 1046
 
1047 1047
 			// Show success message on completion.
1048
-			WP_CLI::success( 'Give Test mode enabled' );
1048
+			WP_CLI::success('Give Test mode enabled');
1049 1049
 		}
1050 1050
 
1051 1051
 		// Disable Test Mode.
1052
-		if ( true === WP_CLI\Utils\get_flag_value( $assoc, 'disable' ) ) {
1052
+		if (true === WP_CLI\Utils\get_flag_value($assoc, 'disable')) {
1053 1053
 
1054 1054
 			// Set `Test Mode` to `disabled`.
1055
-			give_update_option( 'test_mode', 'disabled' );
1055
+			give_update_option('test_mode', 'disabled');
1056 1056
 
1057 1057
 
1058 1058
 			// Disable `Test Donation` gateway.
1059
-			unset( $enabled_gateways['manual'] );
1060
-			give_update_option( 'gateways', $enabled_gateways );
1059
+			unset($enabled_gateways['manual']);
1060
+			give_update_option('gateways', $enabled_gateways);
1061 1061
 
1062 1062
 
1063 1063
 			// Backup `Default Gateway` setting for restore on test mode disable.
1064
-			$default_gateway_backup = get_option( 'give_test_mode_default_gateway' );
1065
-			give_update_option( 'default_gateway', $default_gateway_backup );
1066
-			delete_option( 'give_test_mode_default_gateway' );
1064
+			$default_gateway_backup = get_option('give_test_mode_default_gateway');
1065
+			give_update_option('default_gateway', $default_gateway_backup);
1066
+			delete_option('give_test_mode_default_gateway');
1067 1067
 
1068 1068
 
1069 1069
 			// Show success message on completion.
1070
-			WP_CLI::success( 'Give Test mode disabled' );
1070
+			WP_CLI::success('Give Test mode disabled');
1071 1071
 		}
1072 1072
 	}
1073 1073
 
@@ -1082,8 +1082,8 @@  discard block
 block discarded – undo
1082 1082
 	 *
1083 1083
 	 * @return boolean
1084 1084
 	 */
1085
-	private function is_git_repo( $repo_path ) {
1086
-		if ( is_dir( "{$repo_path}.git" ) ) {
1085
+	private function is_git_repo($repo_path) {
1086
+		if (is_dir("{$repo_path}.git")) {
1087 1087
 			return true;
1088 1088
 		}
1089 1089
 
@@ -1100,11 +1100,11 @@  discard block
 block discarded – undo
1100 1100
 	 *
1101 1101
 	 * @return string
1102 1102
 	 */
1103
-	private function get_git_current_branch( $repo_path ) {
1103
+	private function get_git_current_branch($repo_path) {
1104 1104
 
1105
-		exec( "cd $repo_path && git branch | grep '\*'", $branch_names );
1105
+		exec("cd $repo_path && git branch | grep '\*'", $branch_names);
1106 1106
 
1107
-		$branch_name = trim( strtolower( str_replace( '* ', '', $branch_names[0] ) ) );
1107
+		$branch_name = trim(strtolower(str_replace('* ', '', $branch_names[0])));
1108 1108
 
1109 1109
 		return $branch_name;
1110 1110
 	}
@@ -1134,59 +1134,59 @@  discard block
 block discarded – undo
1134 1134
 	 *
1135 1135
 	 * @subcommand addon-update
1136 1136
 	 */
1137
-	public function addon_update( $pos, $assoc ) {
1137
+	public function addon_update($pos, $assoc) {
1138 1138
 
1139 1139
 		/**
1140 1140
 		 * Only 1 associative argument should be passed.
1141 1141
 		 * It can be either `--name` or `--exclude`
1142 1142
 		 */
1143
-		if ( count( $assoc ) > 1 ) {
1144
-			WP_CLI::error( __( 'Too many associative arguments.', 'give' ) );
1143
+		if (count($assoc) > 1) {
1144
+			WP_CLI::error(__('Too many associative arguments.', 'give'));
1145 1145
 		}
1146 1146
 
1147 1147
 		/**
1148 1148
 		 * Update a single Give addon.
1149 1149
 		 */
1150
-		if ( false !== ( $addon_name = WP_CLI\Utils\get_flag_value( $assoc, 'name', false ) ) ) {
1151
-			$give_addon_path = glob( WP_CONTENT_DIR . "/plugins/$addon_name/" , GLOB_ONLYDIR );
1150
+		if (false !== ($addon_name = WP_CLI\Utils\get_flag_value($assoc, 'name', false))) {
1151
+			$give_addon_path = glob(WP_CONTENT_DIR."/plugins/$addon_name/", GLOB_ONLYDIR);
1152 1152
 
1153 1153
 			/**
1154 1154
 			 * Display error if the plugin (addon) name entered does
1155 1155
 			 * not exist.
1156 1156
 			 */
1157
-			if ( empty( $give_addon_path ) ) {
1158
-				WP_CLI::error( sprintf( __( "The Give addon '%s' does not exist.", 'give' ), $addon_name ) );
1157
+			if (empty($give_addon_path)) {
1158
+				WP_CLI::error(sprintf(__("The Give addon '%s' does not exist.", 'give'), $addon_name));
1159 1159
 			}
1160 1160
 
1161 1161
 			/**
1162 1162
 			 * If the directory does not contain a Git
1163 1163
 			 * repository, then display error and halt.
1164 1164
 			 */
1165
-			if ( ! $this->is_git_repo( $give_addon_path[0] ) ) {
1166
-				WP_CLI::error( __( 'This is not a Git repo', 'give' ) );
1165
+			if ( ! $this->is_git_repo($give_addon_path[0])) {
1166
+				WP_CLI::error(__('This is not a Git repo', 'give'));
1167 1167
 			}
1168 1168
 
1169 1169
 			/**
1170 1170
 			 * Get the current branch name. This branch will be updated next.
1171 1171
 			 */
1172
-			$branch_name = $this->get_git_current_branch( $give_addon_path[0] );
1172
+			$branch_name = $this->get_git_current_branch($give_addon_path[0]);
1173 1173
 
1174 1174
 			/**
1175 1175
 			 * Take the latest pull of the current branch, i.e.;
1176 1176
 			 * sync it with origin.
1177 1177
 			 */
1178
-			passthru( "cd $give_addon_path[0] && git pull origin $branch_name", $return_var );
1178
+			passthru("cd $give_addon_path[0] && git pull origin $branch_name", $return_var);
1179 1179
 
1180 1180
 			/**
1181 1181
 			 * Show success/error messages depending on whether the
1182 1182
 			 * current branch of the addon was updated or not.
1183 1183
 			 */
1184
-			if ( 0 === $return_var ) {
1185
-				WP_CLI::success( sprintf( __( "The Give addon '%s' is up-to-date with origin." ), $addon_name ) );
1184
+			if (0 === $return_var) {
1185
+				WP_CLI::success(sprintf(__("The Give addon '%s' is up-to-date with origin."), $addon_name));
1186 1186
 
1187 1187
 				return;
1188
-			} elseif ( 1 === $return_var ) {
1189
-				WP_CLI::error( sprintf( __( "The Give addon '%s' was not updated." ), $addon_name ) );
1188
+			} elseif (1 === $return_var) {
1189
+				WP_CLI::error(sprintf(__("The Give addon '%s' was not updated."), $addon_name));
1190 1190
 			}
1191 1191
 		}
1192 1192
 
@@ -1194,34 +1194,34 @@  discard block
 block discarded – undo
1194 1194
 		 * Convert the comma-separated string of Give-addons in the
1195 1195
 		 * excluded list into array.
1196 1196
 		 */
1197
-		$addon_names = WP_CLI\Utils\get_flag_value( $assoc, 'exclude', array() );
1198
-		if ( ! empty( $addon_names ) ) {
1199
-			$addon_names = array_map( 'trim', explode( ',', $addon_names ) );
1197
+		$addon_names = WP_CLI\Utils\get_flag_value($assoc, 'exclude', array());
1198
+		if ( ! empty($addon_names)) {
1199
+			$addon_names = array_map('trim', explode(',', $addon_names));
1200 1200
 		}
1201 1201
 
1202 1202
 		/**
1203 1203
 		 * Get directory paths of all the addons including
1204 1204
 		 * Give Core.
1205 1205
 		 */
1206
-		$give_addon_directories = glob( WP_CONTENT_DIR . '/plugins/[gG]ive*/' , GLOB_ONLYDIR );
1206
+		$give_addon_directories = glob(WP_CONTENT_DIR.'/plugins/[gG]ive*/', GLOB_ONLYDIR);
1207 1207
 
1208
-		foreach ( $give_addon_directories as $repo ) {
1208
+		foreach ($give_addon_directories as $repo) {
1209 1209
 
1210 1210
 			/**
1211 1211
 			 * Extract the plugin/addon folder name
1212 1212
 			 * from the absolute path.
1213 1213
 			 */
1214
-			$plugin_name = basename( $repo );
1214
+			$plugin_name = basename($repo);
1215 1215
 
1216 1216
 			/**
1217 1217
 			 * If the Give addon directory does not contain
1218 1218
 			 * a Git repo, then continue.
1219 1219
 			 */
1220
-			if ( ! $this->is_git_repo( $repo ) ) {
1220
+			if ( ! $this->is_git_repo($repo)) {
1221 1221
 				WP_CLI::line(
1222 1222
 					sprintf(
1223
-						__( "%s: '%s' does not contain git repo.", 'give' ),
1224
-						WP_CLI::colorize( '%RError%n' ),
1223
+						__("%s: '%s' does not contain git repo.", 'give'),
1224
+						WP_CLI::colorize('%RError%n'),
1225 1225
 						$plugin_name
1226 1226
 					)
1227 1227
 				);
@@ -1232,34 +1232,34 @@  discard block
 block discarded – undo
1232 1232
 			/**
1233 1233
 			 * Continue if the Give addon name is in the exlusion list.
1234 1234
 			 */
1235
-			if ( in_array( $plugin_name, $addon_names, true ) ) {
1235
+			if (in_array($plugin_name, $addon_names, true)) {
1236 1236
 				continue;
1237 1237
 			}
1238 1238
 
1239 1239
 			/* Get the current branch name */
1240
-			$branch_name = $this->get_git_current_branch( $repo );
1240
+			$branch_name = $this->get_git_current_branch($repo);
1241 1241
 
1242 1242
 			/**
1243 1243
 			 * Show a colorized (CYAN) title for each addon/plugin
1244 1244
 			 * before a pull.
1245 1245
 			 */
1246
-			WP_CLI::line( WP_CLI::colorize( "> %CUpdating $plugin_name | $branch_name%n" ) );
1246
+			WP_CLI::line(WP_CLI::colorize("> %CUpdating $plugin_name | $branch_name%n"));
1247 1247
 
1248 1248
 			/**
1249 1249
 			 * Git pull from the current branch using
1250 1250
 			 * remote `origin`.
1251 1251
 			 */
1252
-			if ( ! empty( $branch_name ) ) {
1253
-				passthru( "cd $repo && git pull origin $branch_name", $return_var );
1252
+			if ( ! empty($branch_name)) {
1253
+				passthru("cd $repo && git pull origin $branch_name", $return_var);
1254 1254
 			}
1255 1255
 
1256 1256
 			$items[] = array(
1257 1257
 				'Give Addon' => $plugin_name,
1258 1258
 				'Branch'     => $branch_name,
1259 1259
 				'Remote'     => 'origin',
1260
-				'Status'     => ( 0 === $return_var )
1261
-					? __( 'Success', 'give' )
1262
-					: __( 'Failed', 'give' ),
1260
+				'Status'     => (0 === $return_var)
1261
+					? __('Success', 'give')
1262
+					: __('Failed', 'give'),
1263 1263
 			);
1264 1264
 
1265 1265
 			/**
Please login to merge, or discard this patch.
includes/admin/shortcodes/shortcode-give-donation-grid.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  */
10 10
 
11 11
 // Exit if accessed directly.
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit;
14 14
 }
15 15
 
@@ -23,10 +23,10 @@  discard block
 block discarded – undo
23 23
 	 */
24 24
 	public function __construct() {
25 25
 
26
-		$this->shortcode['title'] = esc_html__( 'Donation Form Grid', 'give' );
27
-		$this->shortcode['label'] = esc_html__( 'Donation Form Grid', 'give' );
26
+		$this->shortcode['title'] = esc_html__('Donation Form Grid', 'give');
27
+		$this->shortcode['label'] = esc_html__('Donation Form Grid', 'give');
28 28
 
29
-		parent::__construct( 'give_form_grid' );
29
+		parent::__construct('give_form_grid');
30 30
 	}
31 31
 
32 32
 	/**
@@ -39,73 +39,73 @@  discard block
 block discarded – undo
39 39
 		return array(
40 40
 			array(
41 41
 				'type' => 'container',
42
-				'html' => sprintf( '<p class="strong margin-top">%s</p>', esc_html__( 'Optional settings', 'give' ) ),
42
+				'html' => sprintf('<p class="strong margin-top">%s</p>', esc_html__('Optional settings', 'give')),
43 43
 			),
44 44
 			array(
45 45
 				'type'        => 'textbox',
46 46
 				'name'        => 'ids',
47
-				'label'       => esc_attr__( 'Form IDs:', 'give' ),
48
-				'tooltip'     => esc_attr__( 'Enter a comma-separated list of form IDs. If empty, all published forms are displayed.', 'give' ),
49
-				'placeholder' => esc_html__( 'All Forms', 'give' )
47
+				'label'       => esc_attr__('Form IDs:', 'give'),
48
+				'tooltip'     => esc_attr__('Enter a comma-separated list of form IDs. If empty, all published forms are displayed.', 'give'),
49
+				'placeholder' => esc_html__('All Forms', 'give')
50 50
 			),
51 51
 			array(
52 52
 				'type'        => 'listbox',
53 53
 				'name'        => 'columns',
54
-				'label'       => esc_attr__( 'Columns:', 'give' ),
55
-				'tooltip'     => esc_attr__( 'Sets the number of forms per row.', 'give' ),
54
+				'label'       => esc_attr__('Columns:', 'give'),
55
+				'tooltip'     => esc_attr__('Sets the number of forms per row.', 'give'),
56 56
 				'options'     => array(
57
-					'1' => esc_html__( '1', 'give' ),
58
-					'2' => esc_html__( '2', 'give' ),
59
-					'3' => esc_html__( '3', 'give' ),
60
-					'4' => esc_html__( '4', 'give' ),
57
+					'1' => esc_html__('1', 'give'),
58
+					'2' => esc_html__('2', 'give'),
59
+					'3' => esc_html__('3', 'give'),
60
+					'4' => esc_html__('4', 'give'),
61 61
 				),
62
-				'placeholder' => esc_html__( 'Best Fit', 'give' )
62
+				'placeholder' => esc_html__('Best Fit', 'give')
63 63
 			),
64 64
 			array(
65 65
 				'type'    => 'listbox',
66 66
 				'name'    => 'show_goal',
67
-				'label'   => esc_attr__( 'Show Goal:', 'give' ),
68
-				'tooltip' => __( 'Do you want to display the goal\'s progress bar?', 'give' ),
67
+				'label'   => esc_attr__('Show Goal:', 'give'),
68
+				'tooltip' => __('Do you want to display the goal\'s progress bar?', 'give'),
69 69
 				'options' => array(
70
-					'true'  => esc_html__( 'Show', 'give' ),
71
-					'false' => esc_html__( 'Hide', 'give' ),
70
+					'true'  => esc_html__('Show', 'give'),
71
+					'false' => esc_html__('Hide', 'give'),
72 72
 				),
73 73
 			),
74 74
 			array(
75 75
 				'type'    => 'listbox',
76 76
 				'name'    => 'show_excerpt',
77
-				'label'   => esc_attr__( 'Show Excerpt:', 'give' ),
78
-				'tooltip' => esc_attr__( 'Do you want to display the excerpt?', 'give' ),
77
+				'label'   => esc_attr__('Show Excerpt:', 'give'),
78
+				'tooltip' => esc_attr__('Do you want to display the excerpt?', 'give'),
79 79
 				'options' => array(
80
-					'true'  => esc_html__( 'Show', 'give' ),
81
-					'false' => esc_html__( 'Hide', 'give' ),
80
+					'true'  => esc_html__('Show', 'give'),
81
+					'false' => esc_html__('Hide', 'give'),
82 82
 				),
83 83
 			),
84 84
 			array(
85 85
 				'type'    => 'listbox',
86 86
 				'name'    => 'show_featured_image',
87
-				'label'   => esc_attr__( 'Show Featured Image:', 'give' ),
88
-				'tooltip' => esc_attr__( 'Do you want to display the featured image?', 'give' ),
87
+				'label'   => esc_attr__('Show Featured Image:', 'give'),
88
+				'tooltip' => esc_attr__('Do you want to display the featured image?', 'give'),
89 89
 				'options' => array(
90
-					'true'  => esc_html__( 'Show', 'give' ),
91
-					'false' => esc_html__( 'Hide', 'give' ),
90
+					'true'  => esc_html__('Show', 'give'),
91
+					'false' => esc_html__('Hide', 'give'),
92 92
 				),
93 93
 			),
94 94
 			array(
95 95
 				'type'    => 'listbox',
96 96
 				'name'    => 'display_style',
97
-				'label'   => esc_attr__( 'Display Style:', 'give' ),
98
-				'tooltip' => esc_attr__( 'Show form as modal window or redirect to a new page?', 'give' ),
97
+				'label'   => esc_attr__('Display Style:', 'give'),
98
+				'tooltip' => esc_attr__('Show form as modal window or redirect to a new page?', 'give'),
99 99
 				'options' => array(
100
-					'redirect'     => esc_html__( 'Redirect', 'give' ),
101
-					'modal_reveal' => esc_html__( 'Modal', 'give' ),
100
+					'redirect'     => esc_html__('Redirect', 'give'),
101
+					'modal_reveal' => esc_html__('Modal', 'give'),
102 102
 				),
103 103
 			),
104 104
 			array(
105 105
 				'type'    => 'textbox',
106 106
 				'name'    => 'forms_per_page',
107
-				'label'   => esc_attr__( 'Forms Per Page:', 'give' ),
108
-				'tooltip' => esc_attr__( 'Sets the number of forms to display per page.', 'give' ),
107
+				'label'   => esc_attr__('Forms Per Page:', 'give'),
108
+				'tooltip' => esc_attr__('Sets the number of forms to display per page.', 'give'),
109 109
 				'value'   => 12,
110 110
 			),
111 111
 		);
Please login to merge, or discard this patch.