Completed
Push — master ( 5c06e9...0975de )
by Devin
13s
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
 
@@ -85,19 +85,19 @@  discard block
 block discarded – undo
85 85
 	 */
86 86
 	public function get_predefined_dates() {
87 87
 		$predefined = array(
88
-			'today'        => esc_html__( 'Today', 'give' ),
89
-			'yesterday'    => esc_html__( 'Yesterday', 'give' ),
90
-			'this_week'    => esc_html__( 'This Week', 'give' ),
91
-			'last_week'    => esc_html__( 'Last Week', 'give' ),
92
-			'this_month'   => esc_html__( 'This Month', 'give' ),
93
-			'last_month'   => esc_html__( 'Last Month', 'give' ),
94
-			'this_quarter' => esc_html__( 'This Quarter', 'give' ),
95
-			'last_quarter' => esc_html__( 'Last Quarter', 'give' ),
96
-			'this_year'    => esc_html__( 'This Year', 'give' ),
97
-			'last_year'    => esc_html__( 'Last Year', 'give' )
88
+			'today'        => esc_html__('Today', 'give'),
89
+			'yesterday'    => esc_html__('Yesterday', 'give'),
90
+			'this_week'    => esc_html__('This Week', 'give'),
91
+			'last_week'    => esc_html__('Last Week', 'give'),
92
+			'this_month'   => esc_html__('This Month', 'give'),
93
+			'last_month'   => esc_html__('Last Month', 'give'),
94
+			'this_quarter' => esc_html__('This Quarter', 'give'),
95
+			'last_quarter' => esc_html__('Last Quarter', 'give'),
96
+			'this_year'    => esc_html__('This Year', 'give'),
97
+			'last_year'    => esc_html__('Last Year', 'give')
98 98
 		);
99 99
 
100
-		return apply_filters( 'give_stats_predefined_dates', $predefined );
100
+		return apply_filters('give_stats_predefined_dates', $predefined);
101 101
 	}
102 102
 
103 103
 	/**
@@ -113,18 +113,18 @@  discard block
 block discarded – undo
113 113
 	 *
114 114
 	 * @return void
115 115
 	 */
116
-	public function setup_dates( $_start_date = 'this_month', $_end_date = false ) {
116
+	public function setup_dates($_start_date = 'this_month', $_end_date = false) {
117 117
 
118
-		if ( empty( $_start_date ) ) {
118
+		if (empty($_start_date)) {
119 119
 			$_start_date = 'this_month';
120 120
 		}
121 121
 
122
-		if ( empty( $_end_date ) ) {
122
+		if (empty($_end_date)) {
123 123
 			$_end_date = $_start_date;
124 124
 		}
125 125
 
126
-		$this->start_date = $this->convert_date( $_start_date );
127
-		$this->end_date   = $this->convert_date( $_end_date, true );
126
+		$this->start_date = $this->convert_date($_start_date);
127
+		$this->end_date   = $this->convert_date($_end_date, true);
128 128
 	}
129 129
 
130 130
 	/**
@@ -140,26 +140,26 @@  discard block
 block discarded – undo
140 140
 	 *
141 141
 	 * @return array|WP_Error   If the date is invalid, a WP_Error object will be returned.
142 142
 	 */
143
-	public function convert_date( $date, $end_date = false ) {
143
+	public function convert_date($date, $end_date = false) {
144 144
 
145 145
 		$this->timestamp = false;
146 146
 		$second          = $end_date ? 59 : 0;
147 147
 		$minute          = $end_date ? 59 : 0;
148 148
 		$hour            = $end_date ? 23 : 0;
149 149
 		$day             = 1;
150
-		$month           = date( 'n', current_time( 'timestamp' ) );
151
-		$year            = date( 'Y', current_time( 'timestamp' ) );
150
+		$month           = date('n', current_time('timestamp'));
151
+		$year            = date('Y', current_time('timestamp'));
152 152
 
153
-		if ( array_key_exists( $date, $this->get_predefined_dates() ) ) {
153
+		if (array_key_exists($date, $this->get_predefined_dates())) {
154 154
 
155 155
 			// This is a predefined date rate, such as last_week
156
-			switch ( $date ) {
156
+			switch ($date) {
157 157
 
158 158
 				case 'this_month' :
159 159
 
160
-					if ( $end_date ) {
160
+					if ($end_date) {
161 161
 
162
-						$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
162
+						$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
163 163
 						$hour   = 23;
164 164
 						$minute = 59;
165 165
 						$second = 59;
@@ -169,28 +169,28 @@  discard block
 block discarded – undo
169 169
 
170 170
 				case 'last_month' :
171 171
 
172
-					if ( $month == 1 ) {
172
+					if ($month == 1) {
173 173
 
174 174
 						$month = 12;
175
-						$year --;
175
+						$year--;
176 176
 
177 177
 					} else {
178 178
 
179
-						$month --;
179
+						$month--;
180 180
 
181 181
 					}
182 182
 
183
-					if ( $end_date ) {
184
-						$day = cal_days_in_month( CAL_GREGORIAN, $month, $year );
183
+					if ($end_date) {
184
+						$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
185 185
 					}
186 186
 
187 187
 					break;
188 188
 
189 189
 				case 'today' :
190 190
 
191
-					$day = date( 'd', current_time( 'timestamp' ) );
191
+					$day = date('d', current_time('timestamp'));
192 192
 
193
-					if ( $end_date ) {
193
+					if ($end_date) {
194 194
 						$hour   = 23;
195 195
 						$minute = 59;
196 196
 						$second = 59;
@@ -200,23 +200,23 @@  discard block
 block discarded – undo
200 200
 
201 201
 				case 'yesterday' :
202 202
 
203
-					$day = date( 'd', current_time( 'timestamp' ) ) - 1;
203
+					$day = date('d', current_time('timestamp')) - 1;
204 204
 
205 205
 					// Check if Today is the first day of the month (meaning subtracting one will get us 0)
206
-					if ( $day < 1 ) {
206
+					if ($day < 1) {
207 207
 
208 208
 						// If current month is 1
209
-						if ( 1 == $month ) {
209
+						if (1 == $month) {
210 210
 
211 211
 							$year -= 1; // Today is January 1, so skip back to last day of December
212 212
 							$month = 12;
213
-							$day   = cal_days_in_month( CAL_GREGORIAN, $month, $year );
213
+							$day   = cal_days_in_month(CAL_GREGORIAN, $month, $year);
214 214
 
215 215
 						} else {
216 216
 
217 217
 							// Go back one month and get the last day of the month
218 218
 							$month -= 1;
219
-							$day = cal_days_in_month( CAL_GREGORIAN, $month, $year );
219
+							$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
220 220
 
221 221
 						}
222 222
 					}
@@ -225,12 +225,12 @@  discard block
 block discarded – undo
225 225
 
226 226
 				case 'this_week' :
227 227
 
228
-					$days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24;
229
-					$today              = date( 'd', current_time( 'timestamp' ) ) * 60 * 60 * 24;
228
+					$days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24;
229
+					$today              = date('d', current_time('timestamp')) * 60 * 60 * 24;
230 230
 
231
-					if ( $today < $days_to_week_start ) {
231
+					if ($today < $days_to_week_start) {
232 232
 
233
-						if ( $month > 1 ) {
233
+						if ($month > 1) {
234 234
 							$month -= 1;
235 235
 						} else {
236 236
 							$month = 12;
@@ -238,19 +238,19 @@  discard block
 block discarded – undo
238 238
 
239 239
 					}
240 240
 
241
-					if ( ! $end_date ) {
241
+					if ( ! $end_date) {
242 242
 
243 243
 						// Getting the start day
244 244
 
245
-						$day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1;
246
-						$day += get_option( 'start_of_week' );
245
+						$day = date('d', current_time('timestamp') - $days_to_week_start) - 1;
246
+						$day += get_option('start_of_week');
247 247
 
248 248
 					} else {
249 249
 
250 250
 						// Getting the end day
251 251
 
252
-						$day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1;
253
-						$day += get_option( 'start_of_week' ) + 6;
252
+						$day = date('d', current_time('timestamp') - $days_to_week_start) - 1;
253
+						$day += get_option('start_of_week') + 6;
254 254
 
255 255
 					}
256 256
 
@@ -258,12 +258,12 @@  discard block
 block discarded – undo
258 258
 
259 259
 				case 'last_week' :
260 260
 
261
-					$days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24;
262
-					$today              = date( 'd', current_time( 'timestamp' ) ) * 60 * 60 * 24;
261
+					$days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24;
262
+					$today              = date('d', current_time('timestamp')) * 60 * 60 * 24;
263 263
 
264
-					if ( $today < $days_to_week_start ) {
264
+					if ($today < $days_to_week_start) {
265 265
 
266
-						if ( $month > 1 ) {
266
+						if ($month > 1) {
267 267
 							$month -= 1;
268 268
 						} else {
269 269
 							$month = 12;
@@ -271,19 +271,19 @@  discard block
 block discarded – undo
271 271
 
272 272
 					}
273 273
 
274
-					if ( ! $end_date ) {
274
+					if ( ! $end_date) {
275 275
 
276 276
 						// Getting the start day
277 277
 
278
-						$day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8;
279
-						$day += get_option( 'start_of_week' );
278
+						$day = date('d', current_time('timestamp') - $days_to_week_start) - 8;
279
+						$day += get_option('start_of_week');
280 280
 
281 281
 					} else {
282 282
 
283 283
 						// Getting the end day
284 284
 
285
-						$day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8;
286
-						$day += get_option( 'start_of_week' ) + 6;
285
+						$day = date('d', current_time('timestamp') - $days_to_week_start) - 8;
286
+						$day += get_option('start_of_week') + 6;
287 287
 
288 288
 					}
289 289
 
@@ -291,39 +291,39 @@  discard block
 block discarded – undo
291 291
 
292 292
 				case 'this_quarter' :
293 293
 
294
-					$month_now = date( 'n', current_time( 'timestamp' ) );
294
+					$month_now = date('n', current_time('timestamp'));
295 295
 
296
-					if ( $month_now <= 3 ) {
296
+					if ($month_now <= 3) {
297 297
 
298
-						if ( ! $end_date ) {
298
+						if ( ! $end_date) {
299 299
 							$month = 1;
300 300
 						} else {
301 301
 							$month  = 3;
302
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
302
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
303 303
 							$hour   = 23;
304 304
 							$minute = 59;
305 305
 							$second = 59;
306 306
 						}
307 307
 
308
-					} else if ( $month_now <= 6 ) {
308
+					} else if ($month_now <= 6) {
309 309
 
310
-						if ( ! $end_date ) {
310
+						if ( ! $end_date) {
311 311
 							$month = 4;
312 312
 						} else {
313 313
 							$month  = 6;
314
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
314
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
315 315
 							$hour   = 23;
316 316
 							$minute = 59;
317 317
 							$second = 59;
318 318
 						}
319 319
 
320
-					} else if ( $month_now <= 9 ) {
320
+					} else if ($month_now <= 9) {
321 321
 
322
-						if ( ! $end_date ) {
322
+						if ( ! $end_date) {
323 323
 							$month = 7;
324 324
 						} else {
325 325
 							$month  = 9;
326
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
326
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
327 327
 							$hour   = 23;
328 328
 							$minute = 59;
329 329
 							$second = 59;
@@ -331,11 +331,11 @@  discard block
 block discarded – undo
331 331
 
332 332
 					} else {
333 333
 
334
-						if ( ! $end_date ) {
334
+						if ( ! $end_date) {
335 335
 							$month = 10;
336 336
 						} else {
337 337
 							$month  = 12;
338
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
338
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
339 339
 							$hour   = 23;
340 340
 							$minute = 59;
341 341
 							$second = 59;
@@ -347,40 +347,40 @@  discard block
 block discarded – undo
347 347
 
348 348
 				case 'last_quarter' :
349 349
 
350
-					$month_now = date( 'n', current_time( 'timestamp' ) );
350
+					$month_now = date('n', current_time('timestamp'));
351 351
 
352
-					if ( $month_now <= 3 ) {
352
+					if ($month_now <= 3) {
353 353
 
354
-						if ( ! $end_date ) {
354
+						if ( ! $end_date) {
355 355
 							$month = 10;
356 356
 						} else {
357 357
 							$year -= 1;
358 358
 							$month  = 12;
359
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
359
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
360 360
 							$hour   = 23;
361 361
 							$minute = 59;
362 362
 							$second = 59;
363 363
 						}
364 364
 
365
-					} else if ( $month_now <= 6 ) {
365
+					} else if ($month_now <= 6) {
366 366
 
367
-						if ( ! $end_date ) {
367
+						if ( ! $end_date) {
368 368
 							$month = 1;
369 369
 						} else {
370 370
 							$month  = 3;
371
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
371
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
372 372
 							$hour   = 23;
373 373
 							$minute = 59;
374 374
 							$second = 59;
375 375
 						}
376 376
 
377
-					} else if ( $month_now <= 9 ) {
377
+					} else if ($month_now <= 9) {
378 378
 
379
-						if ( ! $end_date ) {
379
+						if ( ! $end_date) {
380 380
 							$month = 4;
381 381
 						} else {
382 382
 							$month  = 6;
383
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
383
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
384 384
 							$hour   = 23;
385 385
 							$minute = 59;
386 386
 							$second = 59;
@@ -388,11 +388,11 @@  discard block
 block discarded – undo
388 388
 
389 389
 					} else {
390 390
 
391
-						if ( ! $end_date ) {
391
+						if ( ! $end_date) {
392 392
 							$month = 7;
393 393
 						} else {
394 394
 							$month  = 9;
395
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
395
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
396 396
 							$hour   = 23;
397 397
 							$minute = 59;
398 398
 							$second = 59;
@@ -404,11 +404,11 @@  discard block
 block discarded – undo
404 404
 
405 405
 				case 'this_year' :
406 406
 
407
-					if ( ! $end_date ) {
407
+					if ( ! $end_date) {
408 408
 						$month = 1;
409 409
 					} else {
410 410
 						$month  = 12;
411
-						$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
411
+						$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
412 412
 						$hour   = 23;
413 413
 						$minute = 59;
414 414
 						$second = 59;
@@ -419,11 +419,11 @@  discard block
 block discarded – undo
419 419
 				case 'last_year' :
420 420
 
421 421
 					$year -= 1;
422
-					if ( ! $end_date ) {
422
+					if ( ! $end_date) {
423 423
 						$month = 1;
424 424
 					} else {
425 425
 						$month  = 12;
426
-						$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
426
+						$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
427 427
 						$hour   = 23;
428 428
 						$minute = 59;
429 429
 						$second = 59;
@@ -434,30 +434,30 @@  discard block
 block discarded – undo
434 434
 			}
435 435
 
436 436
 
437
-		} else if ( is_numeric( $date ) ) {
437
+		} else if (is_numeric($date)) {
438 438
 
439 439
 			// return $date unchanged since it is a timestamp
440 440
 			$this->timestamp = true;
441 441
 
442
-		} else if ( false !== strtotime( $date ) ) {
442
+		} else if (false !== strtotime($date)) {
443 443
 
444
-			$date  = strtotime( $date, current_time( 'timestamp' ) );
445
-			$year  = date( 'Y', $date );
446
-			$month = date( 'm', $date );
447
-			$day   = date( 'd', $date );
444
+			$date  = strtotime($date, current_time('timestamp'));
445
+			$year  = date('Y', $date);
446
+			$month = date('m', $date);
447
+			$day   = date('d', $date);
448 448
 
449 449
 		} else {
450 450
 
451
-			return new WP_Error( 'invalid_date', esc_html__( 'Improper date provided.', 'give' ) );
451
+			return new WP_Error('invalid_date', esc_html__('Improper date provided.', 'give'));
452 452
 
453 453
 		}
454 454
 
455
-		if ( false === $this->timestamp ) {
455
+		if (false === $this->timestamp) {
456 456
 			// Create an exact timestamp
457
-			$date = mktime( $hour, $minute, $second, $month, $day, $year );
457
+			$date = mktime($hour, $minute, $second, $month, $day, $year);
458 458
 		}
459 459
 
460
-		return apply_filters( 'give_stats_date', $date, $end_date, $this );
460
+		return apply_filters('give_stats_date', $date, $end_date, $this);
461 461
 
462 462
 	}
463 463
 
@@ -473,33 +473,33 @@  discard block
 block discarded – undo
473 473
 	 * 
474 474
 	 * @return string
475 475
 	 */
476
-	public function count_where( $where = '' ) {
476
+	public function count_where($where = '') {
477 477
 		// Only get payments in our date range
478 478
 
479 479
 		$start_where = '';
480 480
 		$end_where   = '';
481 481
 
482
-		if ( $this->start_date ) {
482
+		if ($this->start_date) {
483 483
 
484
-			if ( $this->timestamp ) {
484
+			if ($this->timestamp) {
485 485
 				$format = 'Y-m-d H:i:s';
486 486
 			} else {
487 487
 				$format = 'Y-m-d 00:00:00';
488 488
 			}
489 489
 
490
-			$start_date  = date( $format, $this->start_date );
490
+			$start_date  = date($format, $this->start_date);
491 491
 			$start_where = " AND p.post_date >= '{$start_date}'";
492 492
 		}
493 493
 
494
-		if ( $this->end_date ) {
494
+		if ($this->end_date) {
495 495
 
496
-			if ( $this->timestamp ) {
496
+			if ($this->timestamp) {
497 497
 				$format = 'Y-m-d H:i:s';
498 498
 			} else {
499 499
 				$format = 'Y-m-d 23:59:59';
500 500
 			}
501 501
 
502
-			$end_date = date( $format, $this->end_date );
502
+			$end_date = date($format, $this->end_date);
503 503
 
504 504
 			$end_where = " AND p.post_date <= '{$end_date}'";
505 505
 		}
@@ -521,34 +521,34 @@  discard block
 block discarded – undo
521 521
 	 *
522 522
 	 * @return string
523 523
 	 */
524
-	public function payments_where( $where = '' ) {
524
+	public function payments_where($where = '') {
525 525
 
526 526
 		global $wpdb;
527 527
 
528 528
 		$start_where = '';
529 529
 		$end_where   = '';
530 530
 
531
-		if ( ! is_wp_error( $this->start_date ) ) {
531
+		if ( ! is_wp_error($this->start_date)) {
532 532
 
533
-			if ( $this->timestamp ) {
533
+			if ($this->timestamp) {
534 534
 				$format = 'Y-m-d H:i:s';
535 535
 			} else {
536 536
 				$format = 'Y-m-d 00:00:00';
537 537
 			}
538 538
 
539
-			$start_date  = date( $format, $this->start_date );
539
+			$start_date  = date($format, $this->start_date);
540 540
 			$start_where = " AND $wpdb->posts.post_date >= '{$start_date}'";
541 541
 		}
542 542
 
543
-		if ( ! is_wp_error( $this->end_date ) ) {
543
+		if ( ! is_wp_error($this->end_date)) {
544 544
 
545
-			if ( $this->timestamp ) {
545
+			if ($this->timestamp) {
546 546
 				$format = 'Y-m-d 00:00:00';
547 547
 			} else {
548 548
 				$format = 'Y-m-d 23:59:59';
549 549
 			}
550 550
 
551
-			$end_date = date( $format, $this->end_date );
551
+			$end_date = date($format, $this->end_date);
552 552
 
553 553
 			$end_where = " AND $wpdb->posts.post_date <= '{$end_date}'";
554 554
 		}
Please login to merge, or discard this patch.
includes/emails/template.php 1 patch
Spacing   +101 added lines, -101 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
 
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
  *
42 42
  * @return string $message Fully formatted message
43 43
  */
44
-function give_email_template_tags( $message, $payment_data, $payment_id, $admin_notice = false ) {
45
-	return give_do_email_tags( $message, $payment_id );
44
+function give_email_template_tags($message, $payment_data, $payment_id, $admin_notice = false) {
45
+	return give_do_email_tags($message, $payment_id);
46 46
 }
47 47
 
48 48
 /**
@@ -56,38 +56,38 @@  discard block
 block discarded – undo
56 56
  *
57 57
  * @return string $message Fully formatted message
58 58
  */
59
-function give_email_preview_template_tags( $message ) {
59
+function give_email_preview_template_tags($message) {
60 60
 
61
-	$price = give_currency_filter( give_format_amount( 10.50 ) );
61
+	$price = give_currency_filter(give_format_amount(10.50));
62 62
 
63 63
 	$gateway = 'PayPal';
64 64
 
65
-	$receipt_id = strtolower( md5( uniqid() ) );
65
+	$receipt_id = strtolower(md5(uniqid()));
66 66
 
67
-	$payment_id = rand( 1, 100 );
67
+	$payment_id = rand(1, 100);
68 68
 
69 69
 	$receipt_link = sprintf(
70 70
 		'<a href="%1$s">%2$s</a>',
71
-		esc_url( add_query_arg( array( 'payment_key' => $receipt_id, 'give_action' => 'view_receipt' ), home_url() ) ),
72
-		esc_html__( 'View the receipt in your browser &raquo;', 'give' )
71
+		esc_url(add_query_arg(array('payment_key' => $receipt_id, 'give_action' => 'view_receipt'), home_url())),
72
+		esc_html__('View the receipt in your browser &raquo;', 'give')
73 73
 	);
74 74
 
75 75
 	$user = wp_get_current_user();
76 76
 
77
-	$message = str_replace( '{name}', $user->display_name, $message );
78
-	$message = str_replace( '{fullname}', $user->display_name, $message );
79
-	$message = str_replace( '{username}', $user->user_login, $message );
80
-	$message = str_replace( '{date}', date( get_option( 'date_format' ), current_time( 'timestamp' ) ), $message );
81
-	$message = str_replace( '{price}', $price, $message );
82
-	$message = str_replace( '{donation}', esc_html__( 'Sample Donation Form Title', 'give' ), $message );
83
-	$message = str_replace( '{receipt_id}', $receipt_id, $message );
84
-	$message = str_replace( '{payment_method}', $gateway, $message );
85
-	$message = str_replace( '{sitename}', get_bloginfo( 'name' ), $message );
86
-	$message = str_replace( '{payment_id}', $payment_id, $message );
87
-	$message = str_replace( '{receipt_link}', $receipt_link, $message );
88
-	$message = str_replace( '{pdf_receipt}', '<a href="#">Download Receipt</a>', $message );
89
-
90
-	return wpautop( apply_filters( 'give_email_preview_template_tags', $message ) );
77
+	$message = str_replace('{name}', $user->display_name, $message);
78
+	$message = str_replace('{fullname}', $user->display_name, $message);
79
+	$message = str_replace('{username}', $user->user_login, $message);
80
+	$message = str_replace('{date}', date(get_option('date_format'), current_time('timestamp')), $message);
81
+	$message = str_replace('{price}', $price, $message);
82
+	$message = str_replace('{donation}', esc_html__('Sample Donation Form Title', 'give'), $message);
83
+	$message = str_replace('{receipt_id}', $receipt_id, $message);
84
+	$message = str_replace('{payment_method}', $gateway, $message);
85
+	$message = str_replace('{sitename}', get_bloginfo('name'), $message);
86
+	$message = str_replace('{payment_id}', $payment_id, $message);
87
+	$message = str_replace('{receipt_link}', $receipt_link, $message);
88
+	$message = str_replace('{pdf_receipt}', '<a href="#">Download Receipt</a>', $message);
89
+
90
+	return wpautop(apply_filters('give_email_preview_template_tags', $message));
91 91
 }
92 92
 
93 93
 /**
@@ -99,23 +99,23 @@  discard block
 block discarded – undo
99 99
  * @since  1.0
100 100
  * @return array|bool
101 101
  */
102
-function give_email_template_preview( $array ) {
102
+function give_email_template_preview($array) {
103 103
 
104
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
104
+	if ( ! current_user_can('manage_give_settings')) {
105 105
 		return false;
106 106
 	}
107 107
 	$custom_field = array(
108
-		'name' => esc_html__( 'Preview Email', 'give' ),
109
-		'desc' => esc_html__( 'Click the buttons to preview emails.', 'give' ),
108
+		'name' => esc_html__('Preview Email', 'give'),
109
+		'desc' => esc_html__('Click the buttons to preview emails.', 'give'),
110 110
 		'id'   => 'give_email_preview_buttons',
111 111
 		'type' => 'email_preview_buttons'
112 112
 	);
113 113
 
114
-	return give_settings_array_insert( $array, 'donation_subject', array( $custom_field ) );
114
+	return give_settings_array_insert($array, 'donation_subject', array($custom_field));
115 115
 
116 116
 }
117 117
 
118
-add_filter( 'give_settings_emails', 'give_email_template_preview' );
118
+add_filter('give_settings_emails', 'give_email_template_preview');
119 119
 
120 120
 /**
121 121
  * Output Email Template Preview Buttons.
@@ -127,12 +127,12 @@  discard block
 block discarded – undo
127 127
 function give_email_preview_buttons_callback() {
128 128
 	ob_start();
129 129
 	?>
130
-	<a href="<?php echo esc_url( add_query_arg( array( 'give_action' => 'preview_email' ), home_url() ) ); ?>" class="button-secondary" target="_blank" title="<?php esc_attr_e( 'Donation Receipt Preview', 'give' ); ?> "><?php esc_html_e( 'Preview Donation Receipt', 'give' ); ?></a>
131
-	<a href="<?php echo wp_nonce_url( add_query_arg( array(
130
+	<a href="<?php echo esc_url(add_query_arg(array('give_action' => 'preview_email'), home_url())); ?>" class="button-secondary" target="_blank" title="<?php esc_attr_e('Donation Receipt Preview', 'give'); ?> "><?php esc_html_e('Preview Donation Receipt', 'give'); ?></a>
131
+	<a href="<?php echo wp_nonce_url(add_query_arg(array(
132 132
 		'give_action'  => 'send_test_email',
133 133
 		'give-message' => 'sent-test-email',
134 134
 		'tag'          => 'emails'
135
-	) ), 'give-test-email' ); ?>" title="<?php esc_attr_e( 'This will send a demo donation receipt to the emails listed below.', 'give' ); ?>" class="button-secondary"><?php esc_html_e( 'Send Test Email', 'give' ); ?></a>
135
+	)), 'give-test-email'); ?>" title="<?php esc_attr_e('This will send a demo donation receipt to the emails listed below.', 'give'); ?>" class="button-secondary"><?php esc_html_e('Send Test Email', 'give'); ?></a>
136 136
 	<?php
137 137
 	echo ob_get_clean();
138 138
 }
@@ -145,46 +145,46 @@  discard block
 block discarded – undo
145 145
  */
146 146
 function give_display_email_template_preview() {
147 147
 
148
-	if ( empty( $_GET['give_action'] ) ) {
148
+	if (empty($_GET['give_action'])) {
149 149
 		return;
150 150
 	}
151 151
 
152
-	if ( 'preview_email' !== $_GET['give_action'] ) {
152
+	if ('preview_email' !== $_GET['give_action']) {
153 153
 		return;
154 154
 	}
155 155
 
156
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
156
+	if ( ! current_user_can('manage_give_settings')) {
157 157
 		return;
158 158
 	}
159 159
 
160 160
 
161
-	Give()->emails->heading = esc_html__( 'Donation Receipt', 'give' );
161
+	Give()->emails->heading = esc_html__('Donation Receipt', 'give');
162 162
 
163
-	$payment_id = (int) isset( $_GET['preview_id'] ) ? $_GET['preview_id'] : '';
163
+	$payment_id = (int) isset($_GET['preview_id']) ? $_GET['preview_id'] : '';
164 164
 
165 165
 	echo give_get_preview_email_header();
166 166
 
167 167
 	//Are we previewing an actual payment?
168
-	if ( ! empty( $payment_id ) ) {
168
+	if ( ! empty($payment_id)) {
169 169
 
170
-		$content = give_get_email_body_content( $payment_id );
170
+		$content = give_get_email_body_content($payment_id);
171 171
 
172
-		$preview_content = give_do_email_tags( $content, $payment_id );
172
+		$preview_content = give_do_email_tags($content, $payment_id);
173 173
 
174 174
 	} else {
175 175
 
176 176
 		//No payment ID, use sample preview content
177
-		$preview_content = give_email_preview_template_tags( give_get_email_body_content( 0, array() ) );
177
+		$preview_content = give_email_preview_template_tags(give_get_email_body_content(0, array()));
178 178
 	}
179 179
 
180 180
 
181
-	echo Give()->emails->build_email( $preview_content );
181
+	echo Give()->emails->build_email($preview_content);
182 182
 
183 183
 	exit;
184 184
 
185 185
 }
186 186
 
187
-add_action( 'init', 'give_display_email_template_preview' );
187
+add_action('init', 'give_display_email_template_preview');
188 188
 
189 189
 /**
190 190
  * Email Template Body.
@@ -196,18 +196,18 @@  discard block
 block discarded – undo
196 196
  *
197 197
  * @return string $email_body Body of the email
198 198
  */
199
-function give_get_email_body_content( $payment_id = 0, $payment_data = array() ) {
199
+function give_get_email_body_content($payment_id = 0, $payment_data = array()) {
200 200
 
201 201
 	$default_email_body = give_get_default_donation_receipt_email();
202 202
 
203
-	$email_content = give_get_option( 'donation_receipt' );
204
-	$email_content = isset( $email_content ) ? stripslashes( $email_content ) : $default_email_body;
203
+	$email_content = give_get_option('donation_receipt');
204
+	$email_content = isset($email_content) ? stripslashes($email_content) : $default_email_body;
205 205
 
206
-	$email_body = wpautop( $email_content );
206
+	$email_body = wpautop($email_content);
207 207
 
208
-	$email_body = apply_filters( 'give_donation_receipt_' . Give()->emails->get_template(), $email_body, $payment_id, $payment_data );
208
+	$email_body = apply_filters('give_donation_receipt_'.Give()->emails->get_template(), $email_body, $payment_id, $payment_data);
209 209
 
210
-	return apply_filters( 'give_donation_receipt', $email_body, $payment_id, $payment_data );
210
+	return apply_filters('give_donation_receipt', $email_body, $payment_id, $payment_data);
211 211
 }
212 212
 
213 213
 /**
@@ -220,37 +220,37 @@  discard block
 block discarded – undo
220 220
  *
221 221
  * @return string $email_body Body of the email
222 222
  */
223
-function give_get_donation_notification_body_content( $payment_id = 0, $payment_data = array() ) {
223
+function give_get_donation_notification_body_content($payment_id = 0, $payment_data = array()) {
224 224
 
225
-	$user_info = maybe_unserialize( $payment_data['user_info'] );
226
-	$email     = give_get_payment_user_email( $payment_id );
225
+	$user_info = maybe_unserialize($payment_data['user_info']);
226
+	$email     = give_get_payment_user_email($payment_id);
227 227
 
228
-	if ( isset( $user_info['id'] ) && $user_info['id'] > 0 ) {
229
-		$user_data = get_userdata( $user_info['id'] );
228
+	if (isset($user_info['id']) && $user_info['id'] > 0) {
229
+		$user_data = get_userdata($user_info['id']);
230 230
 		$name      = $user_data->display_name;
231
-	} elseif ( isset( $user_info['first_name'] ) && isset( $user_info['last_name'] ) ) {
232
-		$name = $user_info['first_name'] . ' ' . $user_info['last_name'];
231
+	} elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) {
232
+		$name = $user_info['first_name'].' '.$user_info['last_name'];
233 233
 	} else {
234 234
 		$name = $email;
235 235
 	}
236 236
 
237
-	$gateway = give_get_gateway_admin_label( get_post_meta( $payment_id, '_give_payment_gateway', true ) );
237
+	$gateway = give_get_gateway_admin_label(get_post_meta($payment_id, '_give_payment_gateway', true));
238 238
 
239
-	$default_email_body = esc_html__( 'Hello', 'give' ) . "\n\n";
240
-	$default_email_body .= esc_html__( 'A donation has been made.', 'give' ) . "\n\n";
239
+	$default_email_body = esc_html__('Hello', 'give')."\n\n";
240
+	$default_email_body .= esc_html__('A donation has been made.', 'give')."\n\n";
241 241
 	/* translators: %s: form plural label */
242
-	$default_email_body .= sprintf( esc_html__( '%s sold:', 'give' ), give_get_forms_label_plural() ) . "\n\n";
243
-	$default_email_body .= esc_html__( 'Donor:', 'give' ) . ' ' . html_entity_decode( $name, ENT_COMPAT, 'UTF-8' ) . "\n";
244
-	$default_email_body .= esc_html__( 'Amount:', 'give' ) . ' ' . html_entity_decode( give_currency_filter( give_format_amount( give_get_payment_amount( $payment_id ) ) ), ENT_COMPAT, 'UTF-8' ) . "\n";
245
-	$default_email_body .= esc_html__( 'Payment Method:', 'give' ) . ' ' . $gateway . "\n\n";
246
-	$default_email_body .= esc_html__( 'Thank you', 'give' );
242
+	$default_email_body .= sprintf(esc_html__('%s sold:', 'give'), give_get_forms_label_plural())."\n\n";
243
+	$default_email_body .= esc_html__('Donor:', 'give').' '.html_entity_decode($name, ENT_COMPAT, 'UTF-8')."\n";
244
+	$default_email_body .= esc_html__('Amount:', 'give').' '.html_entity_decode(give_currency_filter(give_format_amount(give_get_payment_amount($payment_id))), ENT_COMPAT, 'UTF-8')."\n";
245
+	$default_email_body .= esc_html__('Payment Method:', 'give').' '.$gateway."\n\n";
246
+	$default_email_body .= esc_html__('Thank you', 'give');
247 247
 
248
-	$email = give_get_option( 'donation_notification' );
249
-	$email = isset( $email ) ? stripslashes( $email ) : $default_email_body;
248
+	$email = give_get_option('donation_notification');
249
+	$email = isset($email) ? stripslashes($email) : $default_email_body;
250 250
 
251
-	$email_body = give_do_email_tags( $email, $payment_id );
251
+	$email_body = give_do_email_tags($email, $payment_id);
252 252
 
253
-	return apply_filters( 'give_donation_notification', wpautop( $email_body ), $payment_id, $payment_data );
253
+	return apply_filters('give_donation_notification', wpautop($email_body), $payment_id, $payment_data);
254 254
 }
255 255
 
256 256
 /**
@@ -263,34 +263,34 @@  discard block
 block discarded – undo
263 263
  * @since  1.0
264 264
  */
265 265
 function give_render_receipt_in_browser() {
266
-	if ( ! isset( $_GET['payment_key'] ) ) {
267
-		wp_die( esc_html__( 'Missing donation payment key.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) );
266
+	if ( ! isset($_GET['payment_key'])) {
267
+		wp_die(esc_html__('Missing donation payment key.', 'give'), esc_html__('Error', 'give'), array('response' => 400));
268 268
 	}
269 269
 
270
-	$key = urlencode( $_GET['payment_key'] );
270
+	$key = urlencode($_GET['payment_key']);
271 271
 
272 272
 	ob_start();
273 273
 	//Disallows caching of the page
274
-	header( "Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . " GMT" );
275
-	header( "Cache-Control: no-store, no-cache, must-revalidate" ); // HTTP/1.1
276
-	header( "Cache-Control: post-check=0, pre-check=0", false );
277
-	header( "Pragma: no-cache" ); // HTTP/1.0
278
-	header( "Expires: Sat, 23 Oct 1977 05:00:00 PST" ); // Date in the past
274
+	header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
275
+	header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
276
+	header("Cache-Control: post-check=0, pre-check=0", false);
277
+	header("Pragma: no-cache"); // HTTP/1.0
278
+	header("Expires: Sat, 23 Oct 1977 05:00:00 PST"); // Date in the past
279 279
 	?>
280 280
 	<!DOCTYPE html>
281 281
 	<html lang="en">
282 282
 	<head>
283
-		<?php do_action( 'give_receipt_head' ); ?>
283
+		<?php do_action('give_receipt_head'); ?>
284 284
 	</head>
285
-	<body class="<?php echo apply_filters( 'give_receipt_page_body_class', 'give_receipt_page' ); ?>">
285
+	<body class="<?php echo apply_filters('give_receipt_page_body_class', 'give_receipt_page'); ?>">
286 286
 
287 287
 	<div id="give_receipt_wrapper">
288
-		<?php do_action( 'give_render_receipt_in_browser_before' ); ?>
289
-		<?php echo do_shortcode( '[give_receipt payment_key=' . $key . ']' ); ?>
290
-		<?php do_action( 'give_render_receipt_in_browser_after' ); ?>
288
+		<?php do_action('give_render_receipt_in_browser_before'); ?>
289
+		<?php echo do_shortcode('[give_receipt payment_key='.$key.']'); ?>
290
+		<?php do_action('give_render_receipt_in_browser_after'); ?>
291 291
 	</div>
292 292
 
293
-	<?php do_action( 'give_receipt_footer' ); ?>
293
+	<?php do_action('give_receipt_footer'); ?>
294 294
 	</body>
295 295
 	</html>
296 296
 	<?php
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 	die();
299 299
 }
300 300
 
301
-add_action( 'give_view_receipt', 'give_render_receipt_in_browser' );
301
+add_action('give_view_receipt', 'give_render_receipt_in_browser');
302 302
 
303 303
 
304 304
 /**
@@ -313,31 +313,31 @@  discard block
 block discarded – undo
313 313
 
314 314
 	//Payment receipt switcher
315 315
 	$payment_count = give_count_payments()->publish;
316
-	$payment_id    = (int) isset( $_GET['preview_id'] ) ? $_GET['preview_id'] : '';
316
+	$payment_id    = (int) isset($_GET['preview_id']) ? $_GET['preview_id'] : '';
317 317
 
318
-	if ( $payment_count <= 0 ) {
318
+	if ($payment_count <= 0) {
319 319
 		return false;
320 320
 	}
321 321
 
322 322
 	//Get payments.
323
-	$payments = new Give_Payments_Query( array(
323
+	$payments = new Give_Payments_Query(array(
324 324
 		'number' => 100
325
-	) );
325
+	));
326 326
 	$payments = $payments->get_payments();
327 327
 	$options  = array();
328 328
 
329 329
 	//Provide nice human readable options.
330
-	if ( $payments ) {
330
+	if ($payments) {
331 331
 		$options[0] =
332 332
 			/* translators: %s: transaction singular label */
333
-			esc_html__( '- Select a transaction -', 'give' );
334
-		foreach ( $payments as $payment ) {
333
+			esc_html__('- Select a transaction -', 'give');
334
+		foreach ($payments as $payment) {
335 335
 
336
-			$options[ $payment->ID ] = esc_html( '#' . $payment->ID . ' - ' . $payment->email . ' - ' . $payment->form_title );
336
+			$options[$payment->ID] = esc_html('#'.$payment->ID.' - '.$payment->email.' - '.$payment->form_title);
337 337
 
338 338
 		}
339 339
 	} else {
340
-		$options[0] = esc_html__( 'No Transactions Found', 'give' );
340
+		$options[0] = esc_html__('No Transactions Found', 'give');
341 341
 	}
342 342
 
343 343
 	//Start constructing HTML output.
@@ -350,16 +350,16 @@  discard block
 block discarded – undo
350 350
 			        var selected_trans = transactions.options[transactions.selectedIndex];
351 351
 				        console.log(selected_trans);
352 352
 				        if (selected_trans){
353
-				            var url_string = "' . get_bloginfo( 'url' ) . '?give_action=preview_email&preview_id=" + selected_trans.value;
353
+				            var url_string = "' . get_bloginfo('url').'?give_action=preview_email&preview_id=" + selected_trans.value;
354 354
 				                window.location = url_string;
355 355
 				        }
356 356
 				    }
357 357
 			    </script>';
358 358
 
359
-	$transaction_header .= '<label for="give_preview_email_payment_id" style="font-size:12px;color:#333;margin:0 4px 0 0;">' . esc_html__( 'Preview email with a transaction:', 'give' ) . '</label>';
359
+	$transaction_header .= '<label for="give_preview_email_payment_id" style="font-size:12px;color:#333;margin:0 4px 0 0;">'.esc_html__('Preview email with a transaction:', 'give').'</label>';
360 360
 
361 361
 	//The select field with 100 latest transactions
362
-	$transaction_header .= Give()->html->select( array(
362
+	$transaction_header .= Give()->html->select(array(
363 363
 		'name'             => 'preview_email_payment_id',
364 364
 		'selected'         => $payment_id,
365 365
 		'id'               => 'give_preview_email_payment_id',
@@ -369,12 +369,12 @@  discard block
 block discarded – undo
369 369
 		'select_atts'      => 'onchange="change_preview()">',
370 370
 		'show_option_all'  => false,
371 371
 		'show_option_none' => false
372
-	) );
372
+	));
373 373
 
374 374
 	//Closing tag
375 375
 	$transaction_header .= '</div>';
376 376
 
377
-	return apply_filters( 'give_preview_email_receipt_header', $transaction_header );
377
+	return apply_filters('give_preview_email_receipt_header', $transaction_header);
378 378
 
379 379
 }
380 380
 
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
 function give_receipt_head_content() {
389 389
 
390 390
 	//Title.
391
-	$output = '<title>' . esc_html__( 'Donation Receipt', 'give' ) . '</title>';
391
+	$output = '<title>'.esc_html__('Donation Receipt', 'give').'</title>';
392 392
 
393 393
 	//Meta.
394 394
 	$output .= '<meta charset="utf-8"/>
@@ -402,10 +402,10 @@  discard block
 block discarded – undo
402 402
 		<meta name="robots" content="noindex, nofollow"/>';
403 403
 
404 404
 	//CSS
405
-	$output .= '<link rel="stylesheet" href="' . give_get_stylesheet_uri() . '?ver=' . GIVE_VERSION . '">';
405
+	$output .= '<link rel="stylesheet" href="'.give_get_stylesheet_uri().'?ver='.GIVE_VERSION.'">';
406 406
 
407
-	echo apply_filters( 'give_receipt_head_content', $output );
407
+	echo apply_filters('give_receipt_head_content', $output);
408 408
 
409 409
 }
410 410
 
411
-add_action( 'give_receipt_head', 'give_receipt_head_content' );
412 411
\ No newline at end of file
412
+add_action('give_receipt_head', 'give_receipt_head_content');
413 413
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-give-template-loader.php 1 patch
Spacing   +25 added lines, -25 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
 
@@ -38,29 +38,29 @@  discard block
 block discarded – undo
38 38
 		/**
39 39
 		 * Templates
40 40
 		 */
41
-		add_filter( 'template_include', array( __CLASS__, 'template_loader' ) );
41
+		add_filter('template_include', array(__CLASS__, 'template_loader'));
42 42
 
43 43
 		/**
44 44
 		 * Content Wrappers
45 45
 		 */
46
-		add_action( 'give_before_main_content', 'give_output_content_wrapper', 10 );
47
-		add_action( 'give_after_main_content', 'give_output_content_wrapper_end', 10 );
46
+		add_action('give_before_main_content', 'give_output_content_wrapper', 10);
47
+		add_action('give_after_main_content', 'give_output_content_wrapper_end', 10);
48 48
 
49 49
 		/**
50 50
 		 * Entry Summary Classes
51 51
 		 */
52
-		add_filter( 'give_forms_single_summary_classes', array( $this, 'give_set_single_summary_classes' ) );
52
+		add_filter('give_forms_single_summary_classes', array($this, 'give_set_single_summary_classes'));
53 53
 
54 54
 		/**
55 55
 		 * Sidebar
56 56
 		 */
57
-		add_action( 'give_before_single_form_summary', array( $this, 'give_output_sidebar_option' ), 1 );
57
+		add_action('give_before_single_form_summary', array($this, 'give_output_sidebar_option'), 1);
58 58
 
59 59
 		/**
60 60
 		 * Single Forms Summary Box
61 61
 		 */
62
-		add_action( 'give_single_form_summary', 'give_template_single_title', 5 );
63
-		add_action( 'give_single_form_summary', 'give_get_donation_form', 10 );
62
+		add_action('give_single_form_summary', 'give_template_single_title', 5);
63
+		add_action('give_single_form_summary', 'give_get_donation_form', 10);
64 64
 
65 65
 	}
66 66
 
@@ -75,12 +75,12 @@  discard block
 block discarded – undo
75 75
 	 *
76 76
 	 * @return string $classes List of space separated class names.
77 77
 	 */
78
-	public function give_set_single_summary_classes( $classes ) {
78
+	public function give_set_single_summary_classes($classes) {
79 79
 
80
-		$sidebar_option = give_get_option( 'disable_form_sidebar' );
80
+		$sidebar_option = give_get_option('disable_form_sidebar');
81 81
 
82 82
 		//Add full width class when feature image is disabled AND no widgets are present
83
-		if ( $sidebar_option == 'on' ) {
83
+		if ($sidebar_option == 'on') {
84 84
 			$classes .= ' give-full-width';
85 85
 		}
86 86
 
@@ -100,14 +100,14 @@  discard block
 block discarded – undo
100 100
 	 */
101 101
 	public function give_output_sidebar_option() {
102 102
 
103
-		$sidebar_option = give_get_option( 'disable_form_sidebar' );
103
+		$sidebar_option = give_get_option('disable_form_sidebar');
104 104
 
105 105
 		//Add full width class when feature image is disabled AND no widgets are present
106
-		if ( $sidebar_option !== 'on' ) {
107
-			add_action( 'give_before_single_form_summary', 'give_left_sidebar_pre_wrap', 5 );
108
-			add_action( 'give_before_single_form_summary', 'give_show_form_images', 10 );
109
-			add_action( 'give_before_single_form_summary', 'give_get_forms_sidebar', 20 );
110
-			add_action( 'give_before_single_form_summary', 'give_left_sidebar_post_wrap', 30 );
106
+		if ($sidebar_option !== 'on') {
107
+			add_action('give_before_single_form_summary', 'give_left_sidebar_pre_wrap', 5);
108
+			add_action('give_before_single_form_summary', 'give_show_form_images', 10);
109
+			add_action('give_before_single_form_summary', 'give_get_forms_sidebar', 20);
110
+			add_action('give_before_single_form_summary', 'give_left_sidebar_post_wrap', 30);
111 111
 		}
112 112
 
113 113
 	}
@@ -129,20 +129,20 @@  discard block
 block discarded – undo
129 129
 	 *
130 130
 	 * @return string $template
131 131
 	 */
132
-	public static function template_loader( $template ) {
133
-		$find = array( 'give.php' );
132
+	public static function template_loader($template) {
133
+		$find = array('give.php');
134 134
 		$file = '';
135 135
 
136
-		if ( is_single() && get_post_type() == 'give_forms' ) {
136
+		if (is_single() && get_post_type() == 'give_forms') {
137 137
 			$file   = 'single-give-form.php';
138 138
 			$find[] = $file;
139
-			$find[] = apply_filters( 'give_template_path', 'give/' ) . $file;
139
+			$find[] = apply_filters('give_template_path', 'give/').$file;
140 140
 		}
141 141
 
142
-		if ( $file ) {
143
-			$template = locate_template( array_unique( $find ) );
144
-			if ( ! $template ) {
145
-				$template = GIVE_PLUGIN_DIR . '/templates/' . $file;
142
+		if ($file) {
143
+			$template = locate_template(array_unique($find));
144
+			if ( ! $template) {
145
+				$template = GIVE_PLUGIN_DIR.'/templates/'.$file;
146 146
 			}
147 147
 		}
148 148
 
Please login to merge, or discard this patch.
includes/admin/payments/actions.php 2 patches
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	// Retrieve the payment ID
38 38
 	$payment_id = absint( $data['give_payment_id'] );
39 39
 
40
-    /* @var Give_Payment $payment */
40
+	/* @var Give_Payment $payment */
41 41
 	$payment    = new Give_Payment( $payment_id );
42 42
 
43 43
 	// Retrieve existing payment meta
@@ -160,23 +160,23 @@  discard block
 block discarded – undo
160 160
 
161 161
 		if ( 'publish' == $status ) {
162 162
 
163
-            // Reduce previous user donation count and amount.
164
-            $previous_customer->decrease_purchase_count();
165
-            $previous_customer->decrease_value( $curr_total );
163
+			// Reduce previous user donation count and amount.
164
+			$previous_customer->decrease_purchase_count();
165
+			$previous_customer->decrease_value( $curr_total );
166 166
 
167
-            // If purchase was completed adjust stats of new customers.
168
-            $customer->increase_purchase_count();
167
+			// If purchase was completed adjust stats of new customers.
168
+			$customer->increase_purchase_count();
169 169
 			$customer->increase_value( $new_total );
170 170
 		}
171 171
 
172 172
 		$payment->customer_id = $customer->id;
173 173
 	} else{
174 174
 
175
-	    if( 'publish' === $status ){
176
-            // Update user donation stat.
177
-            $customer->update_donation_value( $curr_total, $new_total );
178
-        }
179
-    }
175
+		if( 'publish' === $status ){
176
+			// Update user donation stat.
177
+			$customer->update_donation_value( $curr_total, $new_total );
178
+		}
179
+	}
180 180
 
181 181
 	// Set new meta values
182 182
 	$payment->user_id    = $customer->user_id;
@@ -217,76 +217,76 @@  discard block
 block discarded – undo
217 217
 
218 218
 	$payment->save();
219 219
 
220
-    // Get new give form ID.
221
-    $new_form_id = absint( $data['forms'] );
222
-    $current_form_id = absint( $payment->get_meta( '_give_payment_form_id' ) );
220
+	// Get new give form ID.
221
+	$new_form_id = absint( $data['forms'] );
222
+	$current_form_id = absint( $payment->get_meta( '_give_payment_form_id' ) );
223 223
 
224
-    // We are adding payment transfer code in last to remove any conflict with above functionality.
225
-    // For example: above code will automatically handle form stat (increase/decrease) when payment status changes.
226
-    /* Check if user want to transfer current payment to new give form id. */
227
-    if( $new_form_id != $current_form_id  ) {
224
+	// We are adding payment transfer code in last to remove any conflict with above functionality.
225
+	// For example: above code will automatically handle form stat (increase/decrease) when payment status changes.
226
+	/* Check if user want to transfer current payment to new give form id. */
227
+	if( $new_form_id != $current_form_id  ) {
228 228
 
229
-        // Get new give form title.
230
-        $new_form_title = get_the_title( $new_form_id );
229
+		// Get new give form title.
230
+		$new_form_title = get_the_title( $new_form_id );
231 231
 
232
-        // Update new give form data in payment data.
233
-        $payment_meta = $payment->get_meta();
234
-        $payment_meta['form_title'] = $new_form_title;
235
-        $payment_meta['form_id']    = $new_form_id;
232
+		// Update new give form data in payment data.
233
+		$payment_meta = $payment->get_meta();
234
+		$payment_meta['form_title'] = $new_form_title;
235
+		$payment_meta['form_id']    = $new_form_id;
236 236
 
237
-        // Update price id post meta data for set donation form.
238
-        if( ! give_has_variable_prices( $new_form_id ) ) {
239
-            $payment_meta['price_id'] = '';
240
-        }
237
+		// Update price id post meta data for set donation form.
238
+		if( ! give_has_variable_prices( $new_form_id ) ) {
239
+			$payment_meta['price_id'] = '';
240
+		}
241 241
 
242
-        // Update payment give form meta data.
243
-        $payment->update_meta( '_give_payment_form_id', $new_form_id );
244
-        $payment->update_meta( '_give_payment_form_title', $new_form_title );
245
-        $payment->update_meta( '_give_payment_meta', $payment_meta );
242
+		// Update payment give form meta data.
243
+		$payment->update_meta( '_give_payment_form_id', $new_form_id );
244
+		$payment->update_meta( '_give_payment_form_title', $new_form_title );
245
+		$payment->update_meta( '_give_payment_meta', $payment_meta );
246 246
 
247
-        // Update price id payment metadata.
248
-        if( ! give_has_variable_prices( $new_form_id ) ) {
249
-            $payment->update_meta( '_give_payment_price_id', '' );
250
-        }
247
+		// Update price id payment metadata.
248
+		if( ! give_has_variable_prices( $new_form_id ) ) {
249
+			$payment->update_meta( '_give_payment_price_id', '' );
250
+		}
251 251
 
252 252
 
253
-        // If purchase was completed, adjust stats of forms
254
-        if ( 'publish' == $status ) {
253
+		// If purchase was completed, adjust stats of forms
254
+		if ( 'publish' == $status ) {
255 255
 
256
-            // Decrease sale of old give form. For other payment status 
257
-            $current_form = new Give_Donate_Form( $current_form_id );
258
-            $current_form->decrease_sales();
259
-            $current_form->decrease_earnings( $curr_total );
256
+			// Decrease sale of old give form. For other payment status 
257
+			$current_form = new Give_Donate_Form( $current_form_id );
258
+			$current_form->decrease_sales();
259
+			$current_form->decrease_earnings( $curr_total );
260 260
             
261
-            // Increase sale of new give form.
262
-            $new_form = new Give_Donate_Form($new_form_id);
263
-            $new_form->increase_sales();
264
-            $new_form->increase_earnings($new_total);
265
-        }
261
+			// Increase sale of new give form.
262
+			$new_form = new Give_Donate_Form($new_form_id);
263
+			$new_form->increase_sales();
264
+			$new_form->increase_earnings($new_total);
265
+		}
266 266
 
267
-        // Re setup payment to update new meta value in object.
268
-        $payment->update_payment_setup( $payment->ID );
269
-    }
267
+		// Re setup payment to update new meta value in object.
268
+		$payment->update_payment_setup( $payment->ID );
269
+	}
270 270
 
271
-    // Update price id if current form is variable form.
272
-    if( ! empty( $data['give-variable-price'] ) && give_has_variable_prices( $payment->form_id ) ) {
271
+	// Update price id if current form is variable form.
272
+	if( ! empty( $data['give-variable-price'] ) && give_has_variable_prices( $payment->form_id ) ) {
273 273
 
274
-        // Get payment meta data.
275
-        $payment_meta = $payment->get_meta();
274
+		// Get payment meta data.
275
+		$payment_meta = $payment->get_meta();
276 276
 
277
-        // Set payment id to empty string if variable price id is negative ( i.e. custom amount feature enabled ).
278
-        $data['give-variable-price'] = ( 'custom' === $data['give-variable-price'] ) ? 'custom' : ( 0 < $data['give-variable-price'] ) ? $data['give-variable-price'] : '';
277
+		// Set payment id to empty string if variable price id is negative ( i.e. custom amount feature enabled ).
278
+		$data['give-variable-price'] = ( 'custom' === $data['give-variable-price'] ) ? 'custom' : ( 0 < $data['give-variable-price'] ) ? $data['give-variable-price'] : '';
279 279
 
280
-        // Update payment meta data.
281
-        $payment_meta['price_id'] = $data['give-variable-price'];
280
+		// Update payment meta data.
281
+		$payment_meta['price_id'] = $data['give-variable-price'];
282 282
 
283
-        // Update payment give form meta data.
284
-        $payment->update_meta( '_give_payment_price_id', $data['give-variable-price'] );
285
-        $payment->update_meta( '_give_payment_meta', $payment_meta );
283
+		// Update payment give form meta data.
284
+		$payment->update_meta( '_give_payment_price_id', $data['give-variable-price'] );
285
+		$payment->update_meta( '_give_payment_meta', $payment_meta );
286 286
 
287
-        // Re setup payment to update new meta value in object.
288
-        $payment->update_payment_setup( $payment->ID );
289
-    }
287
+		// Re setup payment to update new meta value in object.
288
+		$payment->update_payment_setup( $payment->ID );
289
+	}
290 290
 
291 291
 	/**
292 292
 	 * Fires after updating edited purchase.
Please login to merge, or discard this patch.
Spacing   +118 added lines, -118 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -26,52 +26,52 @@  discard block
 block discarded – undo
26 26
  * @return      void
27 27
  *
28 28
  */
29
-function give_update_payment_details( $data ) {
29
+function give_update_payment_details($data) {
30 30
 
31
-	if ( ! current_user_can( 'edit_give_payments', $data['give_payment_id'] ) ) {
32
-		wp_die( esc_html__( 'You do not have permission to edit payment records.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
31
+	if ( ! current_user_can('edit_give_payments', $data['give_payment_id'])) {
32
+		wp_die(esc_html__('You do not have permission to edit payment records.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
33 33
 	}
34 34
 
35
-	check_admin_referer( 'give_update_payment_details_nonce' );
35
+	check_admin_referer('give_update_payment_details_nonce');
36 36
 
37 37
 	// Retrieve the payment ID
38
-	$payment_id = absint( $data['give_payment_id'] );
38
+	$payment_id = absint($data['give_payment_id']);
39 39
 
40 40
     /* @var Give_Payment $payment */
41
-	$payment    = new Give_Payment( $payment_id );
41
+	$payment    = new Give_Payment($payment_id);
42 42
 
43 43
 	// Retrieve existing payment meta
44 44
 	$meta      = $payment->get_meta();
45 45
 	$user_info = $payment->user_info;
46 46
 
47 47
 	$status = $data['give-payment-status'];
48
-	$date   = sanitize_text_field( $data['give-payment-date'] );
49
-	$hour   = sanitize_text_field( $data['give-payment-time-hour'] );
48
+	$date   = sanitize_text_field($data['give-payment-date']);
49
+	$hour   = sanitize_text_field($data['give-payment-time-hour']);
50 50
 
51 51
 	// Restrict to our high and low
52
-	if ( $hour > 23 ) {
52
+	if ($hour > 23) {
53 53
 		$hour = 23;
54
-	} elseif ( $hour < 0 ) {
54
+	} elseif ($hour < 0) {
55 55
 		$hour = 00;
56 56
 	}
57 57
 
58
-	$minute = sanitize_text_field( $data['give-payment-time-min'] );
58
+	$minute = sanitize_text_field($data['give-payment-time-min']);
59 59
 
60 60
 	// Restrict to our high and low
61
-	if ( $minute > 59 ) {
61
+	if ($minute > 59) {
62 62
 		$minute = 59;
63
-	} elseif ( $minute < 0 ) {
63
+	} elseif ($minute < 0) {
64 64
 		$minute = 00;
65 65
 	}
66 66
 
67
-	$address = array_map( 'trim', $data['give-payment-address'][0] );
67
+	$address = array_map('trim', $data['give-payment-address'][0]);
68 68
 
69
-	$curr_total = give_sanitize_amount( $payment->total );
70
-	$new_total  = give_sanitize_amount( $data['give-payment-total'] );
71
-	$date       = date( 'Y-m-d', strtotime( $date ) ) . ' ' . $hour . ':' . $minute . ':00';
69
+	$curr_total = give_sanitize_amount($payment->total);
70
+	$new_total  = give_sanitize_amount($data['give-payment-total']);
71
+	$date       = date('Y-m-d', strtotime($date)).' '.$hour.':'.$minute.':00';
72 72
 
73
-	$curr_customer_id = sanitize_text_field( $data['give-current-customer'] );
74
-	$new_customer_id  = sanitize_text_field( $data['customer-id'] );
73
+	$curr_customer_id = sanitize_text_field($data['give-current-customer']);
74
+	$new_customer_id  = sanitize_text_field($data['customer-id']);
75 75
 
76 76
 	/**
77 77
 	 * Fires before updating edited purchase.
@@ -80,62 +80,62 @@  discard block
 block discarded – undo
80 80
 	 *
81 81
 	 * @param int $payment_id The ID of the payment.
82 82
 	 */
83
-	do_action( 'give_update_edited_purchase', $payment_id );
83
+	do_action('give_update_edited_purchase', $payment_id);
84 84
 
85 85
 	$payment->date = $date;
86 86
 	$updated       = $payment->save();
87 87
 
88
-	if ( 0 === $updated ) {
89
-		wp_die( esc_html__( 'Error Updating Payment.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) );
88
+	if (0 === $updated) {
89
+		wp_die(esc_html__('Error Updating Payment.', 'give'), esc_html__('Error', 'give'), array('response' => 400));
90 90
 	}
91 91
 
92 92
 
93 93
 	$customer_changed = false;
94 94
 
95
-	if ( isset( $data['give-new-customer'] ) && $data['give-new-customer'] == '1' ) {
95
+	if (isset($data['give-new-customer']) && $data['give-new-customer'] == '1') {
96 96
 
97
-		$email = isset( $data['give-new-customer-email'] ) ? sanitize_text_field( $data['give-new-customer-email'] ) : '';
98
-		$names = isset( $data['give-new-customer-name'] ) ? sanitize_text_field( $data['give-new-customer-name'] ) : '';
97
+		$email = isset($data['give-new-customer-email']) ? sanitize_text_field($data['give-new-customer-email']) : '';
98
+		$names = isset($data['give-new-customer-name']) ? sanitize_text_field($data['give-new-customer-name']) : '';
99 99
 
100
-		if ( empty( $email ) || empty( $names ) ) {
101
-			wp_die( esc_html__( 'New Customers require a name and email address.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) );
100
+		if (empty($email) || empty($names)) {
101
+			wp_die(esc_html__('New Customers require a name and email address.', 'give'), esc_html__('Error', 'give'), array('response' => 400));
102 102
 		}
103 103
 
104
-		$customer = new Give_Customer( $email );
105
-		if ( empty( $customer->id ) ) {
106
-			$customer_data = array( 'name' => $names, 'email' => $email );
107
-			$user_id       = email_exists( $email );
108
-			if ( false !== $user_id ) {
104
+		$customer = new Give_Customer($email);
105
+		if (empty($customer->id)) {
106
+			$customer_data = array('name' => $names, 'email' => $email);
107
+			$user_id       = email_exists($email);
108
+			if (false !== $user_id) {
109 109
 				$customer_data['user_id'] = $user_id;
110 110
 			}
111 111
 
112
-			if ( ! $customer->create( $customer_data ) ) {
112
+			if ( ! $customer->create($customer_data)) {
113 113
 				// Failed to crete the new donor, assume the previous donor
114 114
 				$customer_changed = false;
115
-				$customer         = new Give_Customer( $curr_customer_id );
116
-				give_set_error( 'give-payment-new-customer-fail', esc_html__( 'Error creating new donor.', 'give' ) );
115
+				$customer         = new Give_Customer($curr_customer_id);
116
+				give_set_error('give-payment-new-customer-fail', esc_html__('Error creating new donor.', 'give'));
117 117
 			}
118 118
 		}
119 119
 
120 120
 		$new_customer_id = $customer->id;
121 121
 
122
-		$previous_customer = new Give_Customer( $curr_customer_id );
122
+		$previous_customer = new Give_Customer($curr_customer_id);
123 123
 
124 124
 		$customer_changed = true;
125 125
 
126
-	} elseif ( $curr_customer_id !== $new_customer_id ) {
126
+	} elseif ($curr_customer_id !== $new_customer_id) {
127 127
 
128
-		$customer = new Give_Customer( $new_customer_id );
128
+		$customer = new Give_Customer($new_customer_id);
129 129
 		$email    = $customer->email;
130 130
 		$names    = $customer->name;
131 131
 
132
-		$previous_customer = new Give_Customer( $curr_customer_id );
132
+		$previous_customer = new Give_Customer($curr_customer_id);
133 133
 
134 134
 		$customer_changed = true;
135 135
 
136 136
 	} else {
137 137
 
138
-		$customer = new Give_Customer( $curr_customer_id );
138
+		$customer = new Give_Customer($curr_customer_id);
139 139
 		$email    = $customer->email;
140 140
 		$names    = $customer->name;
141 141
 
@@ -143,38 +143,38 @@  discard block
 block discarded – undo
143 143
 
144 144
 
145 145
 	// Setup first and last name from input values
146
-	$names      = explode( ' ', $names );
147
-	$first_name = ! empty( $names[0] ) ? $names[0] : '';
146
+	$names      = explode(' ', $names);
147
+	$first_name = ! empty($names[0]) ? $names[0] : '';
148 148
 	$last_name  = '';
149
-	if ( ! empty( $names[1] ) ) {
150
-		unset( $names[0] );
151
-		$last_name = implode( ' ', $names );
149
+	if ( ! empty($names[1])) {
150
+		unset($names[0]);
151
+		$last_name = implode(' ', $names);
152 152
 	}
153 153
 
154 154
 
155
-	if ( $customer_changed ) {
155
+	if ($customer_changed) {
156 156
 
157 157
 		// Remove the stats and payment from the previous customer and attach it to the new customer
158
-		$previous_customer->remove_payment( $payment_id, false );
159
-		$customer->attach_payment( $payment_id, false );
158
+		$previous_customer->remove_payment($payment_id, false);
159
+		$customer->attach_payment($payment_id, false);
160 160
 
161
-		if ( 'publish' == $status ) {
161
+		if ('publish' == $status) {
162 162
 
163 163
             // Reduce previous user donation count and amount.
164 164
             $previous_customer->decrease_purchase_count();
165
-            $previous_customer->decrease_value( $curr_total );
165
+            $previous_customer->decrease_value($curr_total);
166 166
 
167 167
             // If purchase was completed adjust stats of new customers.
168 168
             $customer->increase_purchase_count();
169
-			$customer->increase_value( $new_total );
169
+			$customer->increase_value($new_total);
170 170
 		}
171 171
 
172 172
 		$payment->customer_id = $customer->id;
173
-	} else{
173
+	} else {
174 174
 
175
-	    if( 'publish' === $status ){
175
+	    if ('publish' === $status) {
176 176
             // Update user donation stat.
177
-            $customer->update_donation_value( $curr_total, $new_total );
177
+            $customer->update_donation_value($curr_total, $new_total);
178 178
         }
179 179
     }
180 180
 
@@ -188,10 +188,10 @@  discard block
 block discarded – undo
188 188
 
189 189
 
190 190
 	// Check for payment notes
191
-	if ( ! empty( $data['give-payment-note'] ) ) {
191
+	if ( ! empty($data['give-payment-note'])) {
192 192
 
193
-		$note = wp_kses( $data['give-payment-note'], array() );
194
-		give_insert_payment_note( $payment_id, $note );
193
+		$note = wp_kses($data['give-payment-note'], array());
194
+		give_insert_payment_note($payment_id, $note);
195 195
 
196 196
 	}
197 197
 
@@ -199,17 +199,17 @@  discard block
 block discarded – undo
199 199
 	$payment->status = $status;
200 200
 
201 201
 	// Adjust total store earnings if the payment total has been changed
202
-	if ( $new_total !== $curr_total && 'publish' == $status ) {
202
+	if ($new_total !== $curr_total && 'publish' == $status) {
203 203
 
204
-		if ( $new_total > $curr_total ) {
204
+		if ($new_total > $curr_total) {
205 205
 			// Increase if our new total is higher
206 206
 			$difference = $new_total - $curr_total;
207
-			give_increase_total_earnings( $difference );
207
+			give_increase_total_earnings($difference);
208 208
 
209
-		} elseif ( $curr_total > $new_total ) {
209
+		} elseif ($curr_total > $new_total) {
210 210
 			// Decrease if our new total is lower
211 211
 			$difference = $curr_total - $new_total;
212
-			give_decrease_total_earnings( $difference );
212
+			give_decrease_total_earnings($difference);
213 213
 
214 214
 		}
215 215
 
@@ -218,16 +218,16 @@  discard block
 block discarded – undo
218 218
 	$payment->save();
219 219
 
220 220
     // Get new give form ID.
221
-    $new_form_id = absint( $data['forms'] );
222
-    $current_form_id = absint( $payment->get_meta( '_give_payment_form_id' ) );
221
+    $new_form_id = absint($data['forms']);
222
+    $current_form_id = absint($payment->get_meta('_give_payment_form_id'));
223 223
 
224 224
     // We are adding payment transfer code in last to remove any conflict with above functionality.
225 225
     // For example: above code will automatically handle form stat (increase/decrease) when payment status changes.
226 226
     /* Check if user want to transfer current payment to new give form id. */
227
-    if( $new_form_id != $current_form_id  ) {
227
+    if ($new_form_id != $current_form_id) {
228 228
 
229 229
         // Get new give form title.
230
-        $new_form_title = get_the_title( $new_form_id );
230
+        $new_form_title = get_the_title($new_form_id);
231 231
 
232 232
         // Update new give form data in payment data.
233 233
         $payment_meta = $payment->get_meta();
@@ -235,28 +235,28 @@  discard block
 block discarded – undo
235 235
         $payment_meta['form_id']    = $new_form_id;
236 236
 
237 237
         // Update price id post meta data for set donation form.
238
-        if( ! give_has_variable_prices( $new_form_id ) ) {
238
+        if ( ! give_has_variable_prices($new_form_id)) {
239 239
             $payment_meta['price_id'] = '';
240 240
         }
241 241
 
242 242
         // Update payment give form meta data.
243
-        $payment->update_meta( '_give_payment_form_id', $new_form_id );
244
-        $payment->update_meta( '_give_payment_form_title', $new_form_title );
245
-        $payment->update_meta( '_give_payment_meta', $payment_meta );
243
+        $payment->update_meta('_give_payment_form_id', $new_form_id);
244
+        $payment->update_meta('_give_payment_form_title', $new_form_title);
245
+        $payment->update_meta('_give_payment_meta', $payment_meta);
246 246
 
247 247
         // Update price id payment metadata.
248
-        if( ! give_has_variable_prices( $new_form_id ) ) {
249
-            $payment->update_meta( '_give_payment_price_id', '' );
248
+        if ( ! give_has_variable_prices($new_form_id)) {
249
+            $payment->update_meta('_give_payment_price_id', '');
250 250
         }
251 251
 
252 252
 
253 253
         // If purchase was completed, adjust stats of forms
254
-        if ( 'publish' == $status ) {
254
+        if ('publish' == $status) {
255 255
 
256 256
             // Decrease sale of old give form. For other payment status 
257
-            $current_form = new Give_Donate_Form( $current_form_id );
257
+            $current_form = new Give_Donate_Form($current_form_id);
258 258
             $current_form->decrease_sales();
259
-            $current_form->decrease_earnings( $curr_total );
259
+            $current_form->decrease_earnings($curr_total);
260 260
             
261 261
             // Increase sale of new give form.
262 262
             $new_form = new Give_Donate_Form($new_form_id);
@@ -265,27 +265,27 @@  discard block
 block discarded – undo
265 265
         }
266 266
 
267 267
         // Re setup payment to update new meta value in object.
268
-        $payment->update_payment_setup( $payment->ID );
268
+        $payment->update_payment_setup($payment->ID);
269 269
     }
270 270
 
271 271
     // Update price id if current form is variable form.
272
-    if( ! empty( $data['give-variable-price'] ) && give_has_variable_prices( $payment->form_id ) ) {
272
+    if ( ! empty($data['give-variable-price']) && give_has_variable_prices($payment->form_id)) {
273 273
 
274 274
         // Get payment meta data.
275 275
         $payment_meta = $payment->get_meta();
276 276
 
277 277
         // Set payment id to empty string if variable price id is negative ( i.e. custom amount feature enabled ).
278
-        $data['give-variable-price'] = ( 'custom' === $data['give-variable-price'] ) ? 'custom' : ( 0 < $data['give-variable-price'] ) ? $data['give-variable-price'] : '';
278
+        $data['give-variable-price'] = ('custom' === $data['give-variable-price']) ? 'custom' : (0 < $data['give-variable-price']) ? $data['give-variable-price'] : '';
279 279
 
280 280
         // Update payment meta data.
281 281
         $payment_meta['price_id'] = $data['give-variable-price'];
282 282
 
283 283
         // Update payment give form meta data.
284
-        $payment->update_meta( '_give_payment_price_id', $data['give-variable-price'] );
285
-        $payment->update_meta( '_give_payment_meta', $payment_meta );
284
+        $payment->update_meta('_give_payment_price_id', $data['give-variable-price']);
285
+        $payment->update_meta('_give_payment_meta', $payment_meta);
286 286
 
287 287
         // Re setup payment to update new meta value in object.
288
-        $payment->update_payment_setup( $payment->ID );
288
+        $payment->update_payment_setup($payment->ID);
289 289
     }
290 290
 
291 291
 	/**
@@ -295,13 +295,13 @@  discard block
 block discarded – undo
295 295
 	 *
296 296
 	 * @param int $payment_id The ID of the payment.
297 297
 	 */
298
-	do_action( 'give_updated_edited_purchase', $payment_id );
298
+	do_action('give_updated_edited_purchase', $payment_id);
299 299
 
300
-	wp_safe_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&give-message=payment-updated&id=' . $payment_id ) );
300
+	wp_safe_redirect(admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&give-message=payment-updated&id='.$payment_id));
301 301
 	exit;
302 302
 }
303 303
 
304
-add_action( 'give_update_payment_details', 'give_update_payment_details' );
304
+add_action('give_update_payment_details', 'give_update_payment_details');
305 305
 
306 306
 /**
307 307
  * Trigger a Purchase Deletion
@@ -312,48 +312,48 @@  discard block
 block discarded – undo
312 312
  *
313 313
  * @return void
314 314
  */
315
-function give_trigger_purchase_delete( $data ) {
316
-	if ( wp_verify_nonce( $data['_wpnonce'], 'give_payment_nonce' ) ) {
315
+function give_trigger_purchase_delete($data) {
316
+	if (wp_verify_nonce($data['_wpnonce'], 'give_payment_nonce')) {
317 317
 
318
-		$payment_id = absint( $data['purchase_id'] );
318
+		$payment_id = absint($data['purchase_id']);
319 319
 
320
-		if ( ! current_user_can( 'edit_give_payments', $payment_id ) ) {
321
-			wp_die( esc_html__( 'You do not have permission to edit payment records.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
320
+		if ( ! current_user_can('edit_give_payments', $payment_id)) {
321
+			wp_die(esc_html__('You do not have permission to edit payment records.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
322 322
 		}
323 323
 
324
-		give_delete_purchase( $payment_id );
325
-		wp_redirect( admin_url( '/edit.php?post_type=give_forms&page=give-payment-history&give-message=payment_deleted' ) );
324
+		give_delete_purchase($payment_id);
325
+		wp_redirect(admin_url('/edit.php?post_type=give_forms&page=give-payment-history&give-message=payment_deleted'));
326 326
 		give_die();
327 327
 	}
328 328
 }
329 329
 
330
-add_action( 'give_delete_payment', 'give_trigger_purchase_delete' );
330
+add_action('give_delete_payment', 'give_trigger_purchase_delete');
331 331
 
332 332
 /**
333 333
  * AJAX Store Payment Note
334 334
  */
335 335
 function give_ajax_store_payment_note() {
336 336
 
337
-	$payment_id = absint( $_POST['payment_id'] );
338
-	$note       = wp_kses( $_POST['note'], array() );
337
+	$payment_id = absint($_POST['payment_id']);
338
+	$note       = wp_kses($_POST['note'], array());
339 339
 
340
-	if ( ! current_user_can( 'edit_give_payments', $payment_id ) ) {
341
-		wp_die( esc_html__( 'You do not have permission to edit payment records.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
340
+	if ( ! current_user_can('edit_give_payments', $payment_id)) {
341
+		wp_die(esc_html__('You do not have permission to edit payment records.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
342 342
 	}
343 343
 
344
-	if ( empty( $payment_id ) ) {
345
-		die( '-1' );
344
+	if (empty($payment_id)) {
345
+		die('-1');
346 346
 	}
347 347
 
348
-	if ( empty( $note ) ) {
349
-		die( '-1' );
348
+	if (empty($note)) {
349
+		die('-1');
350 350
 	}
351 351
 
352
-	$note_id = give_insert_payment_note( $payment_id, $note );
353
-	die( give_get_payment_note_html( $note_id ) );
352
+	$note_id = give_insert_payment_note($payment_id, $note);
353
+	die(give_get_payment_note_html($note_id));
354 354
 }
355 355
 
356
-add_action( 'wp_ajax_give_insert_payment_note', 'give_ajax_store_payment_note' );
356
+add_action('wp_ajax_give_insert_payment_note', 'give_ajax_store_payment_note');
357 357
 
358 358
 /**
359 359
  * Triggers a payment note deletion without ajax
@@ -364,24 +364,24 @@  discard block
 block discarded – undo
364 364
  *
365 365
  * @return void
366 366
  */
367
-function give_trigger_payment_note_deletion( $data ) {
367
+function give_trigger_payment_note_deletion($data) {
368 368
 
369
-	if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_delete_payment_note_' . $data['note_id'] ) ) {
369
+	if ( ! wp_verify_nonce($data['_wpnonce'], 'give_delete_payment_note_'.$data['note_id'])) {
370 370
 		return;
371 371
 	}
372 372
 
373
-	if ( ! current_user_can( 'edit_give_payments', $data['payment_id'] ) ) {
374
-		wp_die( esc_html__( 'You do not have permission to edit payment records.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
373
+	if ( ! current_user_can('edit_give_payments', $data['payment_id'])) {
374
+		wp_die(esc_html__('You do not have permission to edit payment records.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
375 375
 	}
376 376
 
377
-	$edit_order_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&give-message=payment-note-deleted&id=' . absint( $data['payment_id'] ) );
377
+	$edit_order_url = admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&give-message=payment-note-deleted&id='.absint($data['payment_id']));
378 378
 
379
-	give_delete_payment_note( $data['note_id'], $data['payment_id'] );
379
+	give_delete_payment_note($data['note_id'], $data['payment_id']);
380 380
 
381
-	wp_redirect( $edit_order_url );
381
+	wp_redirect($edit_order_url);
382 382
 }
383 383
 
384
-add_action( 'give_delete_payment_note', 'give_trigger_payment_note_deletion' );
384
+add_action('give_delete_payment_note', 'give_trigger_payment_note_deletion');
385 385
 
386 386
 /**
387 387
  * Delete a payment note deletion with ajax
@@ -392,16 +392,16 @@  discard block
 block discarded – undo
392 392
  */
393 393
 function give_ajax_delete_payment_note() {
394 394
 
395
-	if ( ! current_user_can( 'edit_give_payments', $_POST['payment_id'] ) ) {
396
-		wp_die( esc_html__( 'You do not have permission to edit payment records.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
395
+	if ( ! current_user_can('edit_give_payments', $_POST['payment_id'])) {
396
+		wp_die(esc_html__('You do not have permission to edit payment records.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
397 397
 	}
398 398
 
399
-	if ( give_delete_payment_note( $_POST['note_id'], $_POST['payment_id'] ) ) {
400
-		die( '1' );
399
+	if (give_delete_payment_note($_POST['note_id'], $_POST['payment_id'])) {
400
+		die('1');
401 401
 	} else {
402
-		die( '-1' );
402
+		die('-1');
403 403
 	}
404 404
 
405 405
 }
406 406
 
407
-add_action( 'wp_ajax_give_delete_payment_note', 'give_ajax_delete_payment_note' );
408 407
\ No newline at end of file
408
+add_action('wp_ajax_give_delete_payment_note', 'give_ajax_delete_payment_note');
409 409
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/reporting/class-export-earnings.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -38,16 +38,16 @@  discard block
 block discarded – undo
38 38
 	 * @return void
39 39
 	 */
40 40
 	public function headers() {
41
-		ignore_user_abort( true );
41
+		ignore_user_abort(true);
42 42
 
43
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
44
-			set_time_limit( 0 );
43
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
44
+			set_time_limit(0);
45 45
 		}
46 46
 
47 47
 		nocache_headers();
48
-		header( 'Content-Type: text/csv; charset=utf-8' );
49
-		header( 'Content-Disposition: attachment; filename=' . apply_filters( 'give_earnings_export_filename', 'give-export-' . $this->export_type . '-' . date( 'n' ) . '-' . date( 'Y' ) ) . '.csv' );
50
-		header( "Expires: 0" );
48
+		header('Content-Type: text/csv; charset=utf-8');
49
+		header('Content-Disposition: attachment; filename='.apply_filters('give_earnings_export_filename', 'give-export-'.$this->export_type.'-'.date('n').'-'.date('Y')).'.csv');
50
+		header("Expires: 0");
51 51
 
52 52
 	}
53 53
 
@@ -61,10 +61,10 @@  discard block
 block discarded – undo
61 61
 	public function csv_cols() {
62 62
 
63 63
 		$cols = array(
64
-			'date'      => esc_html__( 'Date', 'give' ),
65
-			'donations' => esc_html__( 'Donations', 'give' ),
64
+			'date'      => esc_html__('Date', 'give'),
65
+			'donations' => esc_html__('Donations', 'give'),
66 66
 			/* translators: %s: currency */
67
-			'earnings'  => sprintf( esc_html__( 'Income (%s)', 'give' ), html_entity_decode( give_currency_filter( '' ) ) )
67
+			'earnings'  => sprintf(esc_html__('Income (%s)', 'give'), html_entity_decode(give_currency_filter('')))
68 68
 		);
69 69
 
70 70
 		return $cols;
@@ -79,28 +79,28 @@  discard block
 block discarded – undo
79 79
 	 */
80 80
 	public function get_data() {
81 81
 
82
-		$start_year  = isset( $_POST['start_year'] ) ? absint( $_POST['start_year'] ) : date( 'Y' );
83
-		$end_year    = isset( $_POST['end_year'] ) ? absint( $_POST['end_year'] ) : date( 'Y' );
84
-		$start_month = isset( $_POST['start_month'] ) ? absint( $_POST['start_month'] ) : date( 'n' );
85
-		$end_month   = isset( $_POST['end_month'] ) ? absint( $_POST['end_month'] ) : date( 'n' );
82
+		$start_year  = isset($_POST['start_year']) ? absint($_POST['start_year']) : date('Y');
83
+		$end_year    = isset($_POST['end_year']) ? absint($_POST['end_year']) : date('Y');
84
+		$start_month = isset($_POST['start_month']) ? absint($_POST['start_month']) : date('n');
85
+		$end_month   = isset($_POST['end_month']) ? absint($_POST['end_month']) : date('n');
86 86
 
87 87
 		$data  = array();
88 88
 		$year  = $start_year;
89 89
 		$stats = new Give_Payment_Stats;
90 90
 
91
-		while ( $year <= $end_year ) {
91
+		while ($year <= $end_year) {
92 92
 
93
-			if ( $year == $start_year && $year == $end_year ) {
93
+			if ($year == $start_year && $year == $end_year) {
94 94
 
95 95
 				$m1 = $start_month;
96 96
 				$m2 = $end_month;
97 97
 
98
-			} elseif ( $year == $start_year ) {
98
+			} elseif ($year == $start_year) {
99 99
 
100 100
 				$m1 = $start_month;
101 101
 				$m2 = 12;
102 102
 
103
-			} elseif ( $year == $end_year ) {
103
+			} elseif ($year == $end_year) {
104 104
 
105 105
 				$m1 = 1;
106 106
 				$m2 = $end_month;
@@ -112,28 +112,28 @@  discard block
 block discarded – undo
112 112
 
113 113
 			}
114 114
 
115
-			while ( $m1 <= $m2 ) {
115
+			while ($m1 <= $m2) {
116 116
 
117
-				$date1 = mktime( 0, 0, 0, $m1, 1, $year );
118
-				$date2 = mktime( 0, 0, 0, $m1, cal_days_in_month( CAL_GREGORIAN, $m1, $year ), $year );
117
+				$date1 = mktime(0, 0, 0, $m1, 1, $year);
118
+				$date2 = mktime(0, 0, 0, $m1, cal_days_in_month(CAL_GREGORIAN, $m1, $year), $year);
119 119
 
120 120
 				$data[] = array(
121
-					'date'      => date_i18n( 'F Y', $date1 ),
122
-					'donations' => $stats->get_sales( 0, $date1, $date2 ),
123
-					'earnings'  => give_format_amount( $stats->get_earnings( 0, $date1, $date2 ) ),
121
+					'date'      => date_i18n('F Y', $date1),
122
+					'donations' => $stats->get_sales(0, $date1, $date2),
123
+					'earnings'  => give_format_amount($stats->get_earnings(0, $date1, $date2)),
124 124
 				);
125 125
 
126
-				$m1 ++;
126
+				$m1++;
127 127
 
128 128
 			}
129 129
 
130 130
 
131
-			$year ++;
131
+			$year++;
132 132
 
133 133
 		}
134 134
 
135
-		$data = apply_filters( 'give_export_get_data', $data );
136
-		$data = apply_filters( 'give_export_get_data_' . $this->export_type, $data );
135
+		$data = apply_filters('give_export_get_data', $data);
136
+		$data = apply_filters('give_export_get_data_'.$this->export_type, $data);
137 137
 
138 138
 		return $data;
139 139
 	}
Please login to merge, or discard this patch.
includes/admin/customers/customer-actions.php 1 patch
Spacing   +128 added lines, -128 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,15 +23,15 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * @return array $output Response messages
25 25
  */
26
-function give_edit_customer( $args ) {
26
+function give_edit_customer($args) {
27 27
 	
28
-	$customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' );
28
+	$customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments');
29 29
 
30
-	if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) {
31
-		wp_die( esc_html__( 'You do not have permission to edit this donor.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
30
+	if ( ! is_admin() || ! current_user_can($customer_edit_role)) {
31
+		wp_die(esc_html__('You do not have permission to edit this donor.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
32 32
 	}
33 33
 
34
-	if ( empty( $args ) ) {
34
+	if (empty($args)) {
35 35
 		return;
36 36
 	}
37 37
 
@@ -39,12 +39,12 @@  discard block
 block discarded – undo
39 39
 	$customer_id   = (int) $args['customerinfo']['id'];
40 40
 	$nonce         = $args['_wpnonce'];
41 41
 
42
-	if ( ! wp_verify_nonce( $nonce, 'edit-customer' ) ) {
43
-		wp_die( esc_html__( 'Cheatin\' eh?!', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) );
42
+	if ( ! wp_verify_nonce($nonce, 'edit-customer')) {
43
+		wp_die(esc_html__('Cheatin\' eh?!', 'give'), esc_html__('Error', 'give'), array('response' => 400));
44 44
 	}
45 45
 
46
-	$customer = new Give_Customer( $customer_id );
47
-	if ( empty( $customer->id ) ) {
46
+	$customer = new Give_Customer($customer_id);
47
+	if (empty($customer->id)) {
48 48
 		return false;
49 49
 	}
50 50
 
@@ -54,23 +54,23 @@  discard block
 block discarded – undo
54 54
 		'user_id' => 0
55 55
 	);
56 56
 
57
-	$customer_info = wp_parse_args( $customer_info, $defaults );
57
+	$customer_info = wp_parse_args($customer_info, $defaults);
58 58
 
59
-	if ( ! is_email( $customer_info['email'] ) ) {
60
-		give_set_error( 'give-invalid-email', esc_html__( 'Please enter a valid email address.', 'give' ) );
59
+	if ( ! is_email($customer_info['email'])) {
60
+		give_set_error('give-invalid-email', esc_html__('Please enter a valid email address.', 'give'));
61 61
 	}
62 62
 
63
-	if ( (int) $customer_info['user_id'] != (int) $customer->user_id ) {
63
+	if ((int) $customer_info['user_id'] != (int) $customer->user_id) {
64 64
 
65 65
 		// Make sure we don't already have this user attached to a customer
66
-		if ( ! empty( $customer_info['user_id'] ) && false !== Give()->customers->get_customer_by( 'user_id', $customer_info['user_id'] ) ) {
67
-			give_set_error( 'give-invalid-customer-user_id', sprintf( esc_html__( 'The User ID %d is already associated with a different donor.', 'give' ), $customer_info['user_id'] ) );
66
+		if ( ! empty($customer_info['user_id']) && false !== Give()->customers->get_customer_by('user_id', $customer_info['user_id'])) {
67
+			give_set_error('give-invalid-customer-user_id', sprintf(esc_html__('The User ID %d is already associated with a different donor.', 'give'), $customer_info['user_id']));
68 68
 		}
69 69
 
70 70
 		// Make sure it's actually a user
71
-		$user = get_user_by( 'id', $customer_info['user_id'] );
72
-		if ( ! empty( $customer_info['user_id'] ) && false === $user ) {
73
-			give_set_error( 'give-invalid-user_id', sprintf( esc_html__( 'The User ID %d does not exist. Please assign an existing user.', 'give' ), $customer_info['user_id'] ) );
71
+		$user = get_user_by('id', $customer_info['user_id']);
72
+		if ( ! empty($customer_info['user_id']) && false === $user) {
73
+			give_set_error('give-invalid-user_id', sprintf(esc_html__('The User ID %d does not exist. Please assign an existing user.', 'give'), $customer_info['user_id']));
74 74
 		}
75 75
 
76 76
 	}
@@ -78,53 +78,53 @@  discard block
 block discarded – undo
78 78
 	// Record this for later
79 79
 	$previous_user_id = $customer->user_id;
80 80
 
81
-	if ( give_get_errors() ) {
81
+	if (give_get_errors()) {
82 82
 		return;
83 83
 	}
84 84
 
85 85
 	// Setup the customer address, if present
86 86
 	$address = array();
87
-	if ( intval( $customer_info['user_id'] ) > 0 ) {
87
+	if (intval($customer_info['user_id']) > 0) {
88 88
 
89
-		$current_address = get_user_meta( $customer_info['user_id'], '_give_user_address', true );
89
+		$current_address = get_user_meta($customer_info['user_id'], '_give_user_address', true);
90 90
 
91
-		if ( false === $current_address ) {
92
-			$address['line1']   = isset( $customer_info['line1'] ) ? $customer_info['line1'] : '';
93
-			$address['line2']   = isset( $customer_info['line2'] ) ? $customer_info['line2'] : '';
94
-			$address['city']    = isset( $customer_info['city'] ) ? $customer_info['city'] : '';
95
-			$address['country'] = isset( $customer_info['country'] ) ? $customer_info['country'] : '';
96
-			$address['zip']     = isset( $customer_info['zip'] ) ? $customer_info['zip'] : '';
97
-			$address['state']   = isset( $customer_info['state'] ) ? $customer_info['state'] : '';
91
+		if (false === $current_address) {
92
+			$address['line1']   = isset($customer_info['line1']) ? $customer_info['line1'] : '';
93
+			$address['line2']   = isset($customer_info['line2']) ? $customer_info['line2'] : '';
94
+			$address['city']    = isset($customer_info['city']) ? $customer_info['city'] : '';
95
+			$address['country'] = isset($customer_info['country']) ? $customer_info['country'] : '';
96
+			$address['zip']     = isset($customer_info['zip']) ? $customer_info['zip'] : '';
97
+			$address['state']   = isset($customer_info['state']) ? $customer_info['state'] : '';
98 98
 		} else {
99
-			$current_address    = wp_parse_args( $current_address, array(
99
+			$current_address    = wp_parse_args($current_address, array(
100 100
 				'line1',
101 101
 				'line2',
102 102
 				'city',
103 103
 				'zip',
104 104
 				'state',
105 105
 				'country'
106
-			) );
107
-			$address['line1']   = isset( $customer_info['line1'] ) ? $customer_info['line1'] : $current_address['line1'];
108
-			$address['line2']   = isset( $customer_info['line2'] ) ? $customer_info['line2'] : $current_address['line2'];
109
-			$address['city']    = isset( $customer_info['city'] ) ? $customer_info['city'] : $current_address['city'];
110
-			$address['country'] = isset( $customer_info['country'] ) ? $customer_info['country'] : $current_address['country'];
111
-			$address['zip']     = isset( $customer_info['zip'] ) ? $customer_info['zip'] : $current_address['zip'];
112
-			$address['state']   = isset( $customer_info['state'] ) ? $customer_info['state'] : $current_address['state'];
106
+			));
107
+			$address['line1']   = isset($customer_info['line1']) ? $customer_info['line1'] : $current_address['line1'];
108
+			$address['line2']   = isset($customer_info['line2']) ? $customer_info['line2'] : $current_address['line2'];
109
+			$address['city']    = isset($customer_info['city']) ? $customer_info['city'] : $current_address['city'];
110
+			$address['country'] = isset($customer_info['country']) ? $customer_info['country'] : $current_address['country'];
111
+			$address['zip']     = isset($customer_info['zip']) ? $customer_info['zip'] : $current_address['zip'];
112
+			$address['state']   = isset($customer_info['state']) ? $customer_info['state'] : $current_address['state'];
113 113
 		}
114 114
 
115 115
 	}
116 116
 
117 117
 	// Sanitize the inputs
118 118
 	$customer_data            = array();
119
-	$customer_data['name']    = strip_tags( stripslashes( $customer_info['name'] ) );
119
+	$customer_data['name']    = strip_tags(stripslashes($customer_info['name']));
120 120
 	$customer_data['email']   = $customer_info['email'];
121 121
 	$customer_data['user_id'] = $customer_info['user_id'];
122 122
 
123
-	$customer_data = apply_filters( 'give_edit_customer_info', $customer_data, $customer_id );
124
-	$address       = apply_filters( 'give_edit_customer_address', $address, $customer_id );
123
+	$customer_data = apply_filters('give_edit_customer_info', $customer_data, $customer_id);
124
+	$address       = apply_filters('give_edit_customer_address', $address, $customer_id);
125 125
 
126
-	$customer_data = array_map( 'sanitize_text_field', $customer_data );
127
-	$address       = array_map( 'sanitize_text_field', $address );
126
+	$customer_data = array_map('sanitize_text_field', $customer_data);
127
+	$address       = array_map('sanitize_text_field', $address);
128 128
 
129 129
 
130 130
 	/**
@@ -136,34 +136,34 @@  discard block
 block discarded – undo
136 136
 	 * @param array $customer_data The customer data.
137 137
 	 * @param array $address       The customer address.
138 138
 	 */
139
-	do_action( 'give_pre_edit_customer', $customer_id, $customer_data, $address );
139
+	do_action('give_pre_edit_customer', $customer_id, $customer_data, $address);
140 140
 
141 141
 	$output         = array();
142 142
 	$previous_email = $customer->email;
143 143
 
144
-	if ( $customer->update( $customer_data ) ) {
144
+	if ($customer->update($customer_data)) {
145 145
 
146
-		if ( ! empty( $customer->user_id ) && $customer->user_id > 0 ) {
147
-			update_user_meta( $customer->user_id, '_give_user_address', $address );
146
+		if ( ! empty($customer->user_id) && $customer->user_id > 0) {
147
+			update_user_meta($customer->user_id, '_give_user_address', $address);
148 148
 		}
149 149
 
150 150
 		// Update some payment meta if we need to
151
-		$payments_array = explode( ',', $customer->payment_ids );
151
+		$payments_array = explode(',', $customer->payment_ids);
152 152
 
153
-		if ( $customer->email != $previous_email ) {
154
-			foreach ( $payments_array as $payment_id ) {
155
-				give_update_payment_meta( $payment_id, 'email', $customer->email );
153
+		if ($customer->email != $previous_email) {
154
+			foreach ($payments_array as $payment_id) {
155
+				give_update_payment_meta($payment_id, 'email', $customer->email);
156 156
 			}
157 157
 		}
158 158
 
159
-		if ( $customer->user_id != $previous_user_id ) {
160
-			foreach ( $payments_array as $payment_id ) {
161
-				give_update_payment_meta( $payment_id, '_give_payment_user_id', $customer->user_id );
159
+		if ($customer->user_id != $previous_user_id) {
160
+			foreach ($payments_array as $payment_id) {
161
+				give_update_payment_meta($payment_id, '_give_payment_user_id', $customer->user_id);
162 162
 			}
163 163
 		}
164 164
 
165 165
 		$output['success']       = true;
166
-		$customer_data           = array_merge( $customer_data, $address );
166
+		$customer_data           = array_merge($customer_data, $address);
167 167
 		$output['customer_info'] = $customer_data;
168 168
 
169 169
 	} else {
@@ -180,11 +180,11 @@  discard block
 block discarded – undo
180 180
 	 * @param int   $customer_id   The ID of the customer.
181 181
 	 * @param array $customer_data The customer data.
182 182
 	 */
183
-	do_action( 'give_post_edit_customer', $customer_id, $customer_data );
183
+	do_action('give_post_edit_customer', $customer_id, $customer_data);
184 184
 
185
-	if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
186
-		header( 'Content-Type: application/json' );
187
-		echo json_encode( $output );
185
+	if (defined('DOING_AJAX') && DOING_AJAX) {
186
+		header('Content-Type: application/json');
187
+		echo json_encode($output);
188 188
 		wp_die();
189 189
 	}
190 190
 
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 
193 193
 }
194 194
 
195
-add_action( 'give_edit-customer', 'give_edit_customer', 10, 1 );
195
+add_action('give_edit-customer', 'give_edit_customer', 10, 1);
196 196
 
197 197
 /**
198 198
  * Save a customer note being added
@@ -203,36 +203,36 @@  discard block
 block discarded – undo
203 203
  *
204 204
  * @return int         The Note ID that was saved, or 0 if nothing was saved
205 205
  */
206
-function give_customer_save_note( $args ) {
206
+function give_customer_save_note($args) {
207 207
 
208
-	$customer_view_role = apply_filters( 'give_view_customers_role', 'view_give_reports' );
208
+	$customer_view_role = apply_filters('give_view_customers_role', 'view_give_reports');
209 209
 
210
-	if ( ! is_admin() || ! current_user_can( $customer_view_role ) ) {
211
-		wp_die( esc_html__( 'You do not have permission to edit this donor.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
210
+	if ( ! is_admin() || ! current_user_can($customer_view_role)) {
211
+		wp_die(esc_html__('You do not have permission to edit this donor.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
212 212
 	}
213 213
 
214
-	if ( empty( $args ) ) {
214
+	if (empty($args)) {
215 215
 		return;
216 216
 	}
217 217
 
218
-	$customer_note = trim( sanitize_text_field( $args['customer_note'] ) );
218
+	$customer_note = trim(sanitize_text_field($args['customer_note']));
219 219
 	$customer_id   = (int) $args['customer_id'];
220 220
 	$nonce         = $args['add_customer_note_nonce'];
221 221
 
222
-	if ( ! wp_verify_nonce( $nonce, 'add-customer-note' ) ) {
223
-		wp_die( esc_html__( 'Cheatin\' eh?!', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) );
222
+	if ( ! wp_verify_nonce($nonce, 'add-customer-note')) {
223
+		wp_die(esc_html__('Cheatin\' eh?!', 'give'), esc_html__('Error', 'give'), array('response' => 400));
224 224
 	}
225 225
 
226
-	if ( empty( $customer_note ) ) {
227
-		give_set_error( 'empty-customer-note', esc_html__( 'A note is required.', 'give' ) );
226
+	if (empty($customer_note)) {
227
+		give_set_error('empty-customer-note', esc_html__('A note is required.', 'give'));
228 228
 	}
229 229
 
230
-	if ( give_get_errors() ) {
230
+	if (give_get_errors()) {
231 231
 		return;
232 232
 	}
233 233
 
234
-	$customer = new Give_Customer( $customer_id );
235
-	$new_note = $customer->add_note( $customer_note );
234
+	$customer = new Give_Customer($customer_id);
235
+	$new_note = $customer->add_note($customer_note);
236 236
 
237 237
 	/**
238 238
 	 * Fires before inserting customer note.
@@ -242,22 +242,22 @@  discard block
 block discarded – undo
242 242
 	 * @param int    $customer_id The ID of the customer.
243 243
 	 * @param string $new_note    Note content.
244 244
 	 */
245
-	do_action( 'give_pre_insert_customer_note', $customer_id, $new_note );
245
+	do_action('give_pre_insert_customer_note', $customer_id, $new_note);
246 246
 
247
-	if ( ! empty( $new_note ) && ! empty( $customer->id ) ) {
247
+	if ( ! empty($new_note) && ! empty($customer->id)) {
248 248
 
249 249
 		ob_start();
250 250
 		?>
251 251
 		<div class="customer-note-wrapper dashboard-comment-wrap comment-item">
252 252
 			<span class="note-content-wrap">
253
-				<?php echo stripslashes( $new_note ); ?>
253
+				<?php echo stripslashes($new_note); ?>
254 254
 			</span>
255 255
 		</div>
256 256
 		<?php
257 257
 		$output = ob_get_contents();
258 258
 		ob_end_clean();
259 259
 
260
-		if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
260
+		if (defined('DOING_AJAX') && DOING_AJAX) {
261 261
 			echo $output;
262 262
 			exit;
263 263
 		}
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 
271 271
 }
272 272
 
273
-add_action( 'give_add-customer-note', 'give_customer_save_note', 10, 1 );
273
+add_action('give_add-customer-note', 'give_customer_save_note', 10, 1);
274 274
 
275 275
 /**
276 276
  * Delete a customer
@@ -281,37 +281,37 @@  discard block
 block discarded – undo
281 281
  *
282 282
  * @return int Whether it was a successful deletion
283 283
  */
284
-function give_customer_delete( $args ) {
284
+function give_customer_delete($args) {
285 285
 
286
-	$customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' );
286
+	$customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments');
287 287
 
288
-	if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) {
289
-		wp_die( esc_html__( 'You do not have permission to delete donors.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
288
+	if ( ! is_admin() || ! current_user_can($customer_edit_role)) {
289
+		wp_die(esc_html__('You do not have permission to delete donors.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
290 290
 	}
291 291
 
292
-	if ( empty( $args ) ) {
292
+	if (empty($args)) {
293 293
 		return;
294 294
 	}
295 295
 
296 296
 	$customer_id = (int) $args['customer_id'];
297
-	$confirm     = ! empty( $args['give-customer-delete-confirm'] ) ? true : false;
298
-	$remove_data = ! empty( $args['give-customer-delete-records'] ) ? true : false;
297
+	$confirm     = ! empty($args['give-customer-delete-confirm']) ? true : false;
298
+	$remove_data = ! empty($args['give-customer-delete-records']) ? true : false;
299 299
 	$nonce       = $args['_wpnonce'];
300 300
 
301
-	if ( ! wp_verify_nonce( $nonce, 'delete-customer' ) ) {
302
-		wp_die( esc_html__( 'Cheatin\' eh?!', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) );
301
+	if ( ! wp_verify_nonce($nonce, 'delete-customer')) {
302
+		wp_die(esc_html__('Cheatin\' eh?!', 'give'), esc_html__('Error', 'give'), array('response' => 400));
303 303
 	}
304 304
 
305
-	if ( ! $confirm ) {
306
-		give_set_error( 'customer-delete-no-confirm', esc_html__( 'Please confirm you want to delete this donor.', 'give' ) );
305
+	if ( ! $confirm) {
306
+		give_set_error('customer-delete-no-confirm', esc_html__('Please confirm you want to delete this donor.', 'give'));
307 307
 	}
308 308
 
309
-	if ( give_get_errors() ) {
310
-		wp_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer_id ) );
309
+	if (give_get_errors()) {
310
+		wp_redirect(admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer_id));
311 311
 		exit;
312 312
 	}
313 313
 
314
-	$customer = new Give_Customer( $customer_id );
314
+	$customer = new Give_Customer($customer_id);
315 315
 
316 316
 	/**
317 317
 	 * Fires before deleting customer.
@@ -322,55 +322,55 @@  discard block
 block discarded – undo
322 322
 	 * @param bool $confirm     Delete confirmation.
323 323
 	 * @param bool $remove_data Records delete confirmation.
324 324
 	 */
325
-	do_action( 'give_pre_delete_customer', $customer_id, $confirm, $remove_data );
325
+	do_action('give_pre_delete_customer', $customer_id, $confirm, $remove_data);
326 326
 
327 327
 	$success = false;
328 328
 
329
-	if ( $customer->id > 0 ) {
329
+	if ($customer->id > 0) {
330 330
 
331
-		$payments_array = explode( ',', $customer->payment_ids );
332
-		$success        = Give()->customers->delete( $customer->id );
331
+		$payments_array = explode(',', $customer->payment_ids);
332
+		$success        = Give()->customers->delete($customer->id);
333 333
 
334
-		if ( $success ) {
334
+		if ($success) {
335 335
 
336
-			if ( $remove_data ) {
336
+			if ($remove_data) {
337 337
 
338 338
 				// Remove all payments, logs, etc
339
-				foreach ( $payments_array as $payment_id ) {
340
-					give_delete_purchase( $payment_id );
339
+				foreach ($payments_array as $payment_id) {
340
+					give_delete_purchase($payment_id);
341 341
 				}
342 342
 
343 343
 			} else {
344 344
 
345 345
 				// Just set the payments to customer_id of 0
346
-				foreach ( $payments_array as $payment_id ) {
347
-					give_update_payment_meta( $payment_id, '_give_payment_customer_id', 0 );
346
+				foreach ($payments_array as $payment_id) {
347
+					give_update_payment_meta($payment_id, '_give_payment_customer_id', 0);
348 348
 				}
349 349
 
350 350
 			}
351 351
 
352
-			$redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&give-message=customer-deleted' );
352
+			$redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&give-message=customer-deleted');
353 353
 
354 354
 		} else {
355 355
 
356
-			give_set_error( 'give-donor-delete-failed', esc_html__( 'Error deleting donor.', 'give' ) );
357
-			$redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $customer_id );
356
+			give_set_error('give-donor-delete-failed', esc_html__('Error deleting donor.', 'give'));
357
+			$redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$customer_id);
358 358
 
359 359
 		}
360 360
 
361 361
 	} else {
362 362
 
363
-		give_set_error( 'give-customer-delete-invalid-id', esc_html__( 'Invalid Donor ID.', 'give' ) );
364
-		$redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors' );
363
+		give_set_error('give-customer-delete-invalid-id', esc_html__('Invalid Donor ID.', 'give'));
364
+		$redirect = admin_url('edit.php?post_type=give_forms&page=give-donors');
365 365
 
366 366
 	}
367 367
 
368
-	wp_redirect( $redirect );
368
+	wp_redirect($redirect);
369 369
 	exit;
370 370
 
371 371
 }
372 372
 
373
-add_action( 'give_delete-customer', 'give_customer_delete', 10, 1 );
373
+add_action('give_delete-customer', 'give_customer_delete', 10, 1);
374 374
 
375 375
 /**
376 376
  * Disconnect a user ID from a donor
@@ -381,27 +381,27 @@  discard block
 block discarded – undo
381 381
  *
382 382
  * @return bool        If the disconnect was successful
383 383
  */
384
-function give_disconnect_customer_user_id( $args ) {
384
+function give_disconnect_customer_user_id($args) {
385 385
 
386
-	$customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' );
386
+	$customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments');
387 387
 
388
-	if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) {
389
-		wp_die( esc_html__( 'You do not have permission to edit this donor.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
388
+	if ( ! is_admin() || ! current_user_can($customer_edit_role)) {
389
+		wp_die(esc_html__('You do not have permission to edit this donor.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
390 390
 	}
391 391
 
392
-	if ( empty( $args ) ) {
392
+	if (empty($args)) {
393 393
 		return;
394 394
 	}
395 395
 
396 396
 	$customer_id = (int) $args['customer_id'];
397 397
 	$nonce       = $args['_wpnonce'];
398 398
 
399
-	if ( ! wp_verify_nonce( $nonce, 'edit-customer' ) ) {
400
-		wp_die( esc_html__( 'Cheatin\' eh?!', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) );
399
+	if ( ! wp_verify_nonce($nonce, 'edit-customer')) {
400
+		wp_die(esc_html__('Cheatin\' eh?!', 'give'), esc_html__('Error', 'give'), array('response' => 400));
401 401
 	}
402 402
 
403
-	$customer = new Give_Customer( $customer_id );
404
-	if ( empty( $customer->id ) ) {
403
+	$customer = new Give_Customer($customer_id);
404
+	if (empty($customer->id)) {
405 405
 		return false;
406 406
 	}
407 407
 
@@ -415,15 +415,15 @@  discard block
 block discarded – undo
415 415
 	 * @param int $customer_id The ID of the customer.
416 416
 	 * @param int $user_id     The ID of the user.
417 417
 	 */
418
-	do_action( 'give_pre_customer_disconnect_user_id', $customer_id, $user_id );
418
+	do_action('give_pre_customer_disconnect_user_id', $customer_id, $user_id);
419 419
 
420
-	$customer_args = array( 'user_id' => 0 );
420
+	$customer_args = array('user_id' => 0);
421 421
 
422
-	if ( $customer->update( $customer_args ) ) {
422
+	if ($customer->update($customer_args)) {
423 423
 		global $wpdb;
424 424
 
425
-		if ( ! empty( $customer->payment_ids ) ) {
426
-			$wpdb->query( "UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $customer->payment_ids )" );
425
+		if ( ! empty($customer->payment_ids)) {
426
+			$wpdb->query("UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $customer->payment_ids )");
427 427
 		}
428 428
 
429 429
 		$output['success'] = true;
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
 	} else {
432 432
 
433 433
 		$output['success'] = false;
434
-		give_set_error( 'give-disconnect-user-fail', esc_html__( 'Failed to disconnect user from donor.', 'give' ) );
434
+		give_set_error('give-disconnect-user-fail', esc_html__('Failed to disconnect user from donor.', 'give'));
435 435
 	}
436 436
 
437 437
 	/**
@@ -441,11 +441,11 @@  discard block
 block discarded – undo
441 441
 	 *
442 442
 	 * @param int $customer_id The ID of the customer.
443 443
 	 */
444
-	do_action( 'give_post_customer_disconnect_user_id', $customer_id );
444
+	do_action('give_post_customer_disconnect_user_id', $customer_id);
445 445
 
446
-	if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
447
-		header( 'Content-Type: application/json' );
448
-		echo json_encode( $output );
446
+	if (defined('DOING_AJAX') && DOING_AJAX) {
447
+		header('Content-Type: application/json');
448
+		echo json_encode($output);
449 449
 		wp_die();
450 450
 	}
451 451
 
@@ -453,4 +453,4 @@  discard block
 block discarded – undo
453 453
 
454 454
 }
455 455
 
456
-add_action( 'give_disconnect-userid', 'give_disconnect_customer_user_id', 10, 1 );
456
+add_action('give_disconnect-userid', 'give_disconnect_customer_user_id', 10, 1);
Please login to merge, or discard this patch.
includes/admin/dashboard-widgets.php 1 patch
Spacing   +33 added lines, -33 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,12 +21,12 @@  discard block
 block discarded – undo
21 21
  * @return void
22 22
  */
23 23
 function give_register_dashboard_widgets() {
24
-	if ( current_user_can( apply_filters( 'give_dashboard_stats_cap', 'view_give_reports' ) ) ) {
25
-		wp_add_dashboard_widget( 'give_dashboard_sales', esc_html__( 'Give: Donation Statistics', 'give' ), 'give_dashboard_sales_widget' );
24
+	if (current_user_can(apply_filters('give_dashboard_stats_cap', 'view_give_reports'))) {
25
+		wp_add_dashboard_widget('give_dashboard_sales', esc_html__('Give: Donation Statistics', 'give'), 'give_dashboard_sales_widget');
26 26
 	}
27 27
 }
28 28
 
29
-add_action( 'wp_dashboard_setup', 'give_register_dashboard_widgets', 10 );
29
+add_action('wp_dashboard_setup', 'give_register_dashboard_widgets', 10);
30 30
 
31 31
 /**
32 32
  * Sales Summary Dashboard Widget
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
  */
39 39
 function give_dashboard_sales_widget() {
40 40
 
41
-	if ( ! current_user_can( apply_filters( 'give_dashboard_stats_cap', 'view_give_reports' ) ) ) {
41
+	if ( ! current_user_can(apply_filters('give_dashboard_stats_cap', 'view_give_reports'))) {
42 42
 		return;
43 43
 	}
44 44
 	$stats = new Give_Payment_Stats; ?>
@@ -46,24 +46,24 @@  discard block
 block discarded – undo
46 46
 	<div class="give-dashboard-widget">
47 47
 
48 48
 		<div class="give-dashboard-today give-clearfix">
49
-			<h3 class="give-dashboard-date-today"><?php echo date( 'F j, Y' ); ?></h3>
49
+			<h3 class="give-dashboard-date-today"><?php echo date('F j, Y'); ?></h3>
50 50
 
51 51
 			<p class="give-dashboard-happy-day"><?php
52 52
 				printf(
53 53
 				/* translators: %s: day of the week */
54
-					esc_html__( 'Happy %s!', 'give' ),
55
-					date( 'l', current_time( 'timestamp' ) )
54
+					esc_html__('Happy %s!', 'give'),
55
+					date('l', current_time('timestamp'))
56 56
 				);
57 57
 				?></p>
58 58
 
59
-			<?php $earnings_today = $stats->get_earnings( 0, 'today', false ); ?>
59
+			<?php $earnings_today = $stats->get_earnings(0, 'today', false); ?>
60 60
 
61
-			<p class="give-dashboard-today-earnings"><?php echo give_currency_filter( give_format_amount( $earnings_today ) ); ?></p>
61
+			<p class="give-dashboard-today-earnings"><?php echo give_currency_filter(give_format_amount($earnings_today)); ?></p>
62 62
 
63 63
 			<p class="give-orders-today">
64
-				<?php $donations_today = $stats->get_sales( 0, 'today', false ); ?>
65
-				<?php echo give_format_amount( $donations_today, false ); ?>
66
-				<span><?php echo _x( 'donations today', 'Displays in WP admin dashboard widget after the day\'s total donations', 'give' ); ?></span>
64
+				<?php $donations_today = $stats->get_sales(0, 'today', false); ?>
65
+				<?php echo give_format_amount($donations_today, false); ?>
66
+				<span><?php echo _x('donations today', 'Displays in WP admin dashboard widget after the day\'s total donations', 'give'); ?></span>
67 67
 			</p>
68 68
 
69 69
 
@@ -73,34 +73,34 @@  discard block
 block discarded – undo
73 73
 		<table class="give-table-stats">
74 74
 			<thead style="display: none;">
75 75
 			<tr>
76
-				<th><?php esc_html_e( 'This Week', 'give' ); ?></th>
77
-				<th><?php esc_html_e( 'This Month', 'give' ); ?></th>
78
-				<th><?php esc_html_e( 'Past 30 Days', 'give' ); ?></th>
76
+				<th><?php esc_html_e('This Week', 'give'); ?></th>
77
+				<th><?php esc_html_e('This Month', 'give'); ?></th>
78
+				<th><?php esc_html_e('Past 30 Days', 'give'); ?></th>
79 79
 			</tr>
80 80
 			</thead>
81 81
 			<tbody>
82 82
 			<tr id="give-table-stats-tr-1">
83 83
 				<td>
84
-					<p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_week' ) ) ); ?></p>
84
+					<p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_week'))); ?></p>
85 85
 
86
-					<p class="give-dashboard-stat-total-label"><?php esc_html_e( 'this week', 'give' ); ?></p>
86
+					<p class="give-dashboard-stat-total-label"><?php esc_html_e('this week', 'give'); ?></p>
87 87
 				</td>
88 88
 				<td>
89
-					<p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_month' ) ) ); ?></p>
89
+					<p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_month'))); ?></p>
90 90
 
91
-					<p class="give-dashboard-stat-total-label"><?php esc_html_e( 'this month', 'give' ); ?></p>
91
+					<p class="give-dashboard-stat-total-label"><?php esc_html_e('this month', 'give'); ?></p>
92 92
 				</td>
93 93
 			</tr>
94 94
 			<tr id="give-table-stats-tr-2">
95 95
 				<td>
96
-					<p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'last_month' ) ) ) ?></p>
96
+					<p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'last_month'))) ?></p>
97 97
 
98
-					<p class="give-dashboard-stat-total-label"><?php esc_html_e( 'last month', 'give' ); ?></p>
98
+					<p class="give-dashboard-stat-total-label"><?php esc_html_e('last month', 'give'); ?></p>
99 99
 				</td>
100 100
 				<td>
101
-					<p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_year', false ) ) ) ?></p>
101
+					<p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_year', false))) ?></p>
102 102
 
103
-					<p class="give-dashboard-stat-total-label"><?php esc_html_e( 'this year', 'give' ); ?></p>
103
+					<p class="give-dashboard-stat-total-label"><?php esc_html_e('this year', 'give'); ?></p>
104 104
 				</td>
105 105
 			</tr>
106 106
 			</tbody>
@@ -120,25 +120,25 @@  discard block
 block discarded – undo
120 120
  *
121 121
  * @return array
122 122
  */
123
-function give_dashboard_at_a_glance_widget( $items ) {
124
-	$num_posts = wp_count_posts( 'give_forms' );
123
+function give_dashboard_at_a_glance_widget($items) {
124
+	$num_posts = wp_count_posts('give_forms');
125 125
 
126
-	if ( $num_posts && $num_posts->publish ) {
126
+	if ($num_posts && $num_posts->publish) {
127 127
 
128 128
 		$text = sprintf(
129 129
 		/* translators: 1: number of posts published 2: forms singular label 3: forms plural label */
130
-			_n( '%1$s Give %2$s', '%1$s Give %3$s', $num_posts->publish, 'give' ),
130
+			_n('%1$s Give %2$s', '%1$s Give %3$s', $num_posts->publish, 'give'),
131 131
 			$num_posts->publish,
132 132
 			give_get_forms_label_singular(),
133 133
 			give_get_forms_label_plural()
134 134
 		);
135 135
 
136
-		$text = sprintf( $text, number_format_i18n( $num_posts->publish ) );
136
+		$text = sprintf($text, number_format_i18n($num_posts->publish));
137 137
 
138
-		if ( current_user_can( 'edit_give_forms', get_current_user_id() ) ) {
139
-			$text = sprintf( '<a class="give-forms-count" href="edit.php?post_type=give_forms">%1$s</a>', $text );
138
+		if (current_user_can('edit_give_forms', get_current_user_id())) {
139
+			$text = sprintf('<a class="give-forms-count" href="edit.php?post_type=give_forms">%1$s</a>', $text);
140 140
 		} else {
141
-			$text = sprintf( '<span class="give-forms-count">%1$s</span>', $text );
141
+			$text = sprintf('<span class="give-forms-count">%1$s</span>', $text);
142 142
 		}
143 143
 
144 144
 		$items[] = $text;
@@ -147,4 +147,4 @@  discard block
 block discarded – undo
147 147
 	return $items;
148 148
 }
149 149
 
150
-add_filter( 'dashboard_glance_items', 'give_dashboard_at_a_glance_widget', 1, 1 );
150
+add_filter('dashboard_glance_items', 'give_dashboard_at_a_glance_widget', 1, 1);
Please login to merge, or discard this patch.
includes/gateways/actions.php 1 patch
Spacing   +13 added lines, -13 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
@@ -38,14 +38,14 @@  discard block
 block discarded – undo
38 38
  * @return void
39 39
  */
40 40
 function give_load_ajax_gateway() {
41
-	if ( isset( $_POST['give_payment_mode'] ) ) {
42
-		do_action( 'give_purchase_form', $_POST['give_form_id'] );
41
+	if (isset($_POST['give_payment_mode'])) {
42
+		do_action('give_purchase_form', $_POST['give_form_id']);
43 43
 		exit();
44 44
 	}
45 45
 }
46 46
 
47
-add_action( 'wp_ajax_give_load_gateway', 'give_load_ajax_gateway' );
48
-add_action( 'wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway' );
47
+add_action('wp_ajax_give_load_gateway', 'give_load_ajax_gateway');
48
+add_action('wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway');
49 49
 
50 50
 /**
51 51
  * Sets an error on checkout if no gateways are enabled
@@ -57,11 +57,11 @@  discard block
 block discarded – undo
57 57
 function give_no_gateway_error() {
58 58
 	$gateways = give_get_enabled_payment_gateways();
59 59
 
60
-	if ( empty( $gateways ) ) {
61
-		give_set_error( 'no_gateways', esc_html__( 'You must enable a payment gateway to use Give.', 'give' ) );
60
+	if (empty($gateways)) {
61
+		give_set_error('no_gateways', esc_html__('You must enable a payment gateway to use Give.', 'give'));
62 62
 	} else {
63
-		give_unset_error( 'no_gateways' );
63
+		give_unset_error('no_gateways');
64 64
 	}
65 65
 }
66 66
 
67
-add_action( 'init', 'give_no_gateway_error' );
67
+add_action('init', 'give_no_gateway_error');
Please login to merge, or discard this patch.
includes/class-give-db.php 2 patches
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -111,14 +111,14 @@  discard block
 block discarded – undo
111 111
 	 * @since  1.0
112 112
 	 * @access public
113 113
 	 *
114
-     * @param  int $column Column ID.
115
-     * @param  int $row_id Row ID.
116
-     *
117
-     * @return object
114
+	 * @param  int $column Column ID.
115
+	 * @param  int $row_id Row ID.
116
+	 *
117
+	 * @return object
118 118
 	 */
119 119
 	public function get_by( $column, $row_id ) {
120
-        /* @var WPDB $wpdb */
121
-        global $wpdb;
120
+		/* @var WPDB $wpdb */
121
+		global $wpdb;
122 122
 
123 123
 		$column = esc_sql( $column );
124 124
 		return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id ) );
@@ -129,15 +129,15 @@  discard block
 block discarded – undo
129 129
 	 *
130 130
 	 * @since  1.0
131 131
 	 * @access public
132
-     *
133
-     * @param  int $column Column ID.
134
-     * @param  int $row_id Row ID.
135
-     *
132
+	 *
133
+	 * @param  int $column Column ID.
134
+	 * @param  int $row_id Row ID.
135
+	 *
136 136
 	 * @return string      Column value.
137 137
 	 */
138 138
 	public function get_column( $column, $row_id ) {
139
-        /* @var WPDB $wpdb */
140
-        global $wpdb;
139
+		/* @var WPDB $wpdb */
140
+		global $wpdb;
141 141
 
142 142
 		$column = esc_sql( $column );
143 143
 		return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) );
@@ -148,16 +148,16 @@  discard block
 block discarded – undo
148 148
 	 *
149 149
 	 * @since  1.0
150 150
 	 * @access public
151
-     *
152
-     * @param  int    $column       Column ID.
153
-     * @param  string $column_where Column name.
154
-     * @param  string $column_value Column value.
155
-     *
151
+	 *
152
+	 * @param  int    $column       Column ID.
153
+	 * @param  string $column_where Column name.
154
+	 * @param  string $column_value Column value.
155
+	 *
156 156
 	 * @return string
157 157
 	 */
158 158
 	public function get_column_by( $column, $column_where, $column_value ) {
159
-        /* @var WPDB $wpdb */
160
-        global $wpdb;
159
+		/* @var WPDB $wpdb */
160
+		global $wpdb;
161 161
 
162 162
 		$column_where = esc_sql( $column_where );
163 163
 		$column       = esc_sql( $column );
@@ -169,15 +169,15 @@  discard block
 block discarded – undo
169 169
 	 *
170 170
 	 * @since  1.0
171 171
 	 * @access public
172
-     *
173
-     * @param  array  $data
174
-     * @param  string $type
175
-     *
172
+	 *
173
+	 * @param  array  $data
174
+	 * @param  string $type
175
+	 *
176 176
 	 * @return int
177 177
 	 */
178 178
 	public function insert( $data, $type = '' ) {
179
-        /* @var WPDB $wpdb */
180
-        global $wpdb;
179
+		/* @var WPDB $wpdb */
180
+		global $wpdb;
181 181
 
182 182
 		// Set default values
183 183
 		$data = wp_parse_args( $data, $this->get_column_defaults() );
@@ -209,16 +209,16 @@  discard block
 block discarded – undo
209 209
 	 *
210 210
 	 * @since  1.0
211 211
 	 * @access public
212
-     *
213
-     * @param  int    $row_id Column ID
214
-     * @param  array  $data
215
-     * @param  string $where  Column value
216
-     *
212
+	 *
213
+	 * @param  int    $row_id Column ID
214
+	 * @param  array  $data
215
+	 * @param  string $where  Column value
216
+	 *
217 217
 	 * @return bool
218 218
 	 */
219 219
 	public function update( $row_id, $data = array(), $where = '' ) {
220
-        /* @var WPDB $wpdb */
221
-        global $wpdb;
220
+		/* @var WPDB $wpdb */
221
+		global $wpdb;
222 222
 
223 223
 		// Row ID must be positive integer
224 224
 		$row_id = absint( $row_id );
@@ -256,14 +256,14 @@  discard block
 block discarded – undo
256 256
 	 *
257 257
 	 * @since  1.0
258 258
 	 * @access public
259
-     *
260
-     * @param  int $row_id Column ID.
261
-     *
259
+	 *
260
+	 * @param  int $row_id Column ID.
261
+	 *
262 262
 	 * @return bool
263 263
 	 */
264 264
 	public function delete( $row_id = 0 ) {
265
-        /* @var WPDB $wpdb */
266
-        global $wpdb;
265
+		/* @var WPDB $wpdb */
266
+		global $wpdb;
267 267
 
268 268
 		// Row ID must be positive integer
269 269
 		$row_id = absint( $row_id );
@@ -284,13 +284,13 @@  discard block
 block discarded – undo
284 284
 	 *
285 285
 	 * @since  1.3.2
286 286
 	 * @access public
287
-     *
287
+	 *
288 288
 	 * @param  string $table The table name.
289
-     *
289
+	 *
290 290
 	 * @return bool          If the table name exists.
291 291
 	 */
292 292
 	public function table_exists( $table ) {
293
-        /* @var WPDB $wpdb */
293
+		/* @var WPDB $wpdb */
294 294
 		global $wpdb;
295 295
 
296 296
 		$table = sanitize_text_field( $table );
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -98,11 +98,11 @@  discard block
 block discarded – undo
98 98
 	 *
99 99
 	 * @return object
100 100
 	 */
101
-	public function get( $row_id ) {
101
+	public function get($row_id) {
102 102
 		/* @var WPDB $wpdb */
103 103
 		global $wpdb;
104 104
 
105
-		return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) );
105
+		return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id));
106 106
 	}
107 107
 
108 108
 	/**
@@ -116,12 +116,12 @@  discard block
 block discarded – undo
116 116
      *
117 117
      * @return object
118 118
 	 */
119
-	public function get_by( $column, $row_id ) {
119
+	public function get_by($column, $row_id) {
120 120
         /* @var WPDB $wpdb */
121 121
         global $wpdb;
122 122
 
123
-		$column = esc_sql( $column );
124
-		return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id ) );
123
+		$column = esc_sql($column);
124
+		return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id));
125 125
 	}
126 126
 
127 127
 	/**
@@ -135,12 +135,12 @@  discard block
 block discarded – undo
135 135
      *
136 136
 	 * @return string      Column value.
137 137
 	 */
138
-	public function get_column( $column, $row_id ) {
138
+	public function get_column($column, $row_id) {
139 139
         /* @var WPDB $wpdb */
140 140
         global $wpdb;
141 141
 
142
-		$column = esc_sql( $column );
143
-		return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) );
142
+		$column = esc_sql($column);
143
+		return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id));
144 144
 	}
145 145
 
146 146
 	/**
@@ -155,13 +155,13 @@  discard block
 block discarded – undo
155 155
      *
156 156
 	 * @return string
157 157
 	 */
158
-	public function get_column_by( $column, $column_where, $column_value ) {
158
+	public function get_column_by($column, $column_where, $column_value) {
159 159
         /* @var WPDB $wpdb */
160 160
         global $wpdb;
161 161
 
162
-		$column_where = esc_sql( $column_where );
163
-		$column       = esc_sql( $column );
164
-		return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value ) );
162
+		$column_where = esc_sql($column_where);
163
+		$column       = esc_sql($column);
164
+		return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value));
165 165
 	}
166 166
 
167 167
 	/**
@@ -175,31 +175,31 @@  discard block
 block discarded – undo
175 175
      *
176 176
 	 * @return int
177 177
 	 */
178
-	public function insert( $data, $type = '' ) {
178
+	public function insert($data, $type = '') {
179 179
         /* @var WPDB $wpdb */
180 180
         global $wpdb;
181 181
 
182 182
 		// Set default values
183
-		$data = wp_parse_args( $data, $this->get_column_defaults() );
183
+		$data = wp_parse_args($data, $this->get_column_defaults());
184 184
 
185
-		do_action( 'give_pre_insert_' . $type, $data );
185
+		do_action('give_pre_insert_'.$type, $data);
186 186
 
187 187
 		// Initialise column format array
188 188
 		$column_formats = $this->get_columns();
189 189
 
190 190
 		// Force fields to lower case
191
-		$data = array_change_key_case( $data );
191
+		$data = array_change_key_case($data);
192 192
 
193 193
 		// White list columns
194
-		$data = array_intersect_key( $data, $column_formats );
194
+		$data = array_intersect_key($data, $column_formats);
195 195
 
196 196
 		// Reorder $column_formats to match the order of columns given in $data
197
-		$data_keys      = array_keys( $data );
198
-		$column_formats = array_merge( array_flip( $data_keys ), $column_formats );
197
+		$data_keys      = array_keys($data);
198
+		$column_formats = array_merge(array_flip($data_keys), $column_formats);
199 199
 
200
-		$wpdb->insert( $this->table_name, $data, $column_formats );
200
+		$wpdb->insert($this->table_name, $data, $column_formats);
201 201
 
202
-		do_action( 'give_post_insert_' . $type, $wpdb->insert_id, $data );
202
+		do_action('give_post_insert_'.$type, $wpdb->insert_id, $data);
203 203
 
204 204
 		return $wpdb->insert_id;
205 205
 	}
@@ -216,18 +216,18 @@  discard block
 block discarded – undo
216 216
      *
217 217
 	 * @return bool
218 218
 	 */
219
-	public function update( $row_id, $data = array(), $where = '' ) {
219
+	public function update($row_id, $data = array(), $where = '') {
220 220
         /* @var WPDB $wpdb */
221 221
         global $wpdb;
222 222
 
223 223
 		// Row ID must be positive integer
224
-		$row_id = absint( $row_id );
224
+		$row_id = absint($row_id);
225 225
 
226
-		if ( empty( $row_id ) ) {
226
+		if (empty($row_id)) {
227 227
 			return false;
228 228
 		}
229 229
 
230
-		if ( empty( $where ) ) {
230
+		if (empty($where)) {
231 231
 			$where = $this->primary_key;
232 232
 		}
233 233
 
@@ -235,16 +235,16 @@  discard block
 block discarded – undo
235 235
 		$column_formats = $this->get_columns();
236 236
 
237 237
 		// Force fields to lower case
238
-		$data = array_change_key_case( $data );
238
+		$data = array_change_key_case($data);
239 239
 
240 240
 		// White list columns
241
-		$data = array_intersect_key( $data, $column_formats );
241
+		$data = array_intersect_key($data, $column_formats);
242 242
 
243 243
 		// Reorder $column_formats to match the order of columns given in $data
244
-		$data_keys      = array_keys( $data );
245
-		$column_formats = array_merge( array_flip( $data_keys ), $column_formats );
244
+		$data_keys      = array_keys($data);
245
+		$column_formats = array_merge(array_flip($data_keys), $column_formats);
246 246
 
247
-		if ( false === $wpdb->update( $this->table_name, $data, array( $where => $row_id ), $column_formats ) ) {
247
+		if (false === $wpdb->update($this->table_name, $data, array($where => $row_id), $column_formats)) {
248 248
 			return false;
249 249
 		}
250 250
 
@@ -261,18 +261,18 @@  discard block
 block discarded – undo
261 261
      *
262 262
 	 * @return bool
263 263
 	 */
264
-	public function delete( $row_id = 0 ) {
264
+	public function delete($row_id = 0) {
265 265
         /* @var WPDB $wpdb */
266 266
         global $wpdb;
267 267
 
268 268
 		// Row ID must be positive integer
269
-		$row_id = absint( $row_id );
269
+		$row_id = absint($row_id);
270 270
 
271
-		if ( empty( $row_id ) ) {
271
+		if (empty($row_id)) {
272 272
 			return false;
273 273
 		}
274 274
 
275
-		if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id ) ) ) {
275
+		if (false === $wpdb->query($wpdb->prepare("DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id))) {
276 276
 			return false;
277 277
 		}
278 278
 
@@ -289,13 +289,13 @@  discard block
 block discarded – undo
289 289
      *
290 290
 	 * @return bool          If the table name exists.
291 291
 	 */
292
-	public function table_exists( $table ) {
292
+	public function table_exists($table) {
293 293
         /* @var WPDB $wpdb */
294 294
 		global $wpdb;
295 295
 
296
-		$table = sanitize_text_field( $table );
296
+		$table = sanitize_text_field($table);
297 297
 
298
-		return $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table ) ) === $table;
298
+		return $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE '%s'", $table)) === $table;
299 299
 	}
300 300
 
301 301
 	/**
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 	 * @return bool Returns if the customers table was installed and upgrade routine run.
308 308
 	 */
309 309
 	public function installed() {
310
-		return $this->table_exists( $this->table_name );
310
+		return $this->table_exists($this->table_name);
311 311
 	}
312 312
 
313 313
 }
Please login to merge, or discard this patch.