Test Failed
Push — master ( 1d3b59...426730 )
by Devin
01:16
created
includes/admin/tools/data/class-give-tools-delete-import-donors.php 2 patches
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 	 * Return the calculated completion percentage.
217 217
 	 *
218 218
 	 * @since 1.8.12
219
-	 * @return int
219
+	 * @return double
220 220
 	 */
221 221
 	public function get_percentage_complete() {
222 222
 		return ceil( ( 100 * $this->step_completed ) / $this->total_step );
@@ -353,6 +353,9 @@  discard block
 block discarded – undo
353 353
 		return true;
354 354
 	}
355 355
 
356
+	/**
357
+	 * @param integer $page
358
+	 */
356 359
 	public function get_delete_ids( $donation_ids, $page ) {
357 360
 		$index            = $page --;
358 361
 		$count            = count( $donation_ids );
Please login to merge, or discard this patch.
Spacing   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly.
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -116,34 +116,34 @@  discard block
 block discarded – undo
116 116
 		$donor_ids    = array();
117 117
 
118 118
 		// Check if the ajax request if running for the first time.
119
-		if ( 1 === (int) $this->step ) {
119
+		if (1 === (int) $this->step) {
120 120
 			// Delete all the form ids.
121
-			$this->delete_option( $this->form_key );
121
+			$this->delete_option($this->form_key);
122 122
 			// Delete all the donation ids.
123
-			$this->delete_option( $this->donation_key );
123
+			$this->delete_option($this->donation_key);
124 124
 			// Delete all the donor ids.
125
-			$this->delete_option( $this->donor_key );
125
+			$this->delete_option($this->donor_key);
126 126
 
127 127
 			// Delete all the step and set to 'count' which if the first step in the process of deleting the donors.
128
-			$this->update_option( $this->step_key, 'count' );
128
+			$this->update_option($this->step_key, 'count');
129 129
 
130 130
 			// Delete tha page count of the step.
131
-			$this->update_option( $this->step_on_key, '0' );
131
+			$this->update_option($this->step_on_key, '0');
132 132
 		} else {
133 133
 			// Get the old donors list.
134
-			$donor_ids = $this->get_option( $this->donor_key );
134
+			$donor_ids = $this->get_option($this->donor_key);
135 135
 
136 136
 			// Get the old donation list.
137
-			$donation_ids = $this->get_option( $this->donation_key );
137
+			$donation_ids = $this->get_option($this->donation_key);
138 138
 		}
139 139
 
140 140
 		// Get the step and check for it if it's on the first step( 'count' ) or not.
141 141
 		$step = (int) $this->get_step();
142
-		if ( 1 === $step ) {
142
+		if (1 === $step) {
143 143
 			/**
144 144
 			 * Will add or update the donation and donor data by running wp query.
145 145
 			 */
146
-			$this->count( $step, $donation_ids, $donor_ids );
146
+			$this->count($step, $donation_ids, $donor_ids);
147 147
 		}
148 148
 	}
149 149
 
@@ -154,17 +154,17 @@  discard block
 block discarded – undo
154 154
 	 * @param array $donation_ids Contain the list of all the donation id's that has being add before this
155 155
 	 * @param array $donor_ids Contain the list of all the donors id's that has being add before this
156 156
 	 */
157
-	private function count( $step, $donation_ids = array(), $donor_ids = array() ) {
157
+	private function count($step, $donation_ids = array(), $donor_ids = array()) {
158 158
 
159 159
 		// Get the Page count by default it's zero.
160 160
 		$paged = (int) $this->get_step_page();
161 161
 		// Incresed the page count by one.
162
-		++ $paged;
162
+		++$paged;
163 163
 
164 164
 		/**
165 165
 		 * Filter add to alter the argument before the wp quest run
166 166
 		 */
167
-		$args = apply_filters( 'give_tools_reset_stats_total_args', array(
167
+		$args = apply_filters('give_tools_reset_stats_total_args', array(
168 168
 			'post_type'      => 'give_payment',
169 169
 			'post_status'    => 'any',
170 170
 			'posts_per_page' => $this->per_step,
@@ -172,40 +172,40 @@  discard block
 block discarded – undo
172 172
 			'meta_key'       => '_give_payment_import',
173 173
 			'meta_value_num' => 1,
174 174
 			'meta_compare'   => '=',
175
-		) );
175
+		));
176 176
 
177 177
 		// Reset the post data.
178 178
 		wp_reset_postdata();
179 179
 		// Getting the new donation.
180
-		$donation_posts = new WP_Query( $args );
180
+		$donation_posts = new WP_Query($args);
181 181
 
182 182
 		// The Loop.
183
-		if ( $donation_posts->have_posts() ) {
184
-			while ( $donation_posts->have_posts() ) {
183
+		if ($donation_posts->have_posts()) {
184
+			while ($donation_posts->have_posts()) {
185 185
 				$add_author = true;
186 186
 				$donation_posts->the_post();
187 187
 				global $post;
188 188
 				// Add the donation id in side the array.
189 189
 				$donation_ids[] = $post->ID;
190 190
 
191
-				$donor_id = (int) get_post_meta( $post->ID, '_give_payment_customer_id', true );
192
-				if ( ! empty( $donor_id ) ) {
193
-					$donor = new Give_Donor( $donor_id );
194
-					if ( ! empty( $donor->id ) ) {
195
-						if ( empty( $donor->user_id ) && ! empty( $donor->payment_ids ) ) {
191
+				$donor_id = (int) get_post_meta($post->ID, '_give_payment_customer_id', true);
192
+				if ( ! empty($donor_id)) {
193
+					$donor = new Give_Donor($donor_id);
194
+					if ( ! empty($donor->id)) {
195
+						if (empty($donor->user_id) && ! empty($donor->payment_ids)) {
196 196
 							$add_author = false;
197
-							$count      = (int) count( $donor->payment_ids );
198
-							if ( 1 === $count ) {
199
-								Give()->donors->delete( $donor->id );
197
+							$count      = (int) count($donor->payment_ids);
198
+							if (1 === $count) {
199
+								Give()->donors->delete($donor->id);
200 200
 							} else {
201
-								$donor->remove_payment( $post->ID );
201
+								$donor->remove_payment($post->ID);
202 202
 								$donor->decrease_donation_count();
203 203
 							}
204 204
 						}
205 205
 					}
206 206
 				}
207 207
 
208
-				if ( ! empty( $add_author ) ) {
208
+				if ( ! empty($add_author)) {
209 209
 					// Add the donor id in side the array.
210 210
 					$donor_ids[] = (int) $post->post_author;
211 211
 				}
@@ -220,23 +220,23 @@  discard block
 block discarded – undo
220 220
 		$max_num_pages = (int) $donation_posts->max_num_pages;
221 221
 
222 222
 		// Check current page is less then max number of page or not
223
-		if ( $paged < $max_num_pages ) {
223
+		if ($paged < $max_num_pages) {
224 224
 			// Update the curretn page virable for the next step
225
-			$this->update_option( $this->step_on_key, $paged );
225
+			$this->update_option($this->step_on_key, $paged);
226 226
 
227 227
 			// Calculating percentage.
228 228
 			$page_remain          = $max_num_pages - $paged;
229
-			$this->total_step     = (int) $max_num_pages + ( $total_donation / $this->per_step ) + ( ( $page_remain * 2 ) * count( $donor_ids ) );
229
+			$this->total_step     = (int) $max_num_pages + ($total_donation / $this->per_step) + (($page_remain * 2) * count($donor_ids));
230 230
 			$this->step_completed = $paged;
231 231
 		} else {
232
-			$donation_ids_count = count( $donor_ids );
233
-			$this->update_option( $this->step_key, 'donation' );
234
-			$this->update_option( $this->step_on_key, '0' );
232
+			$donation_ids_count = count($donor_ids);
233
+			$this->update_option($this->step_key, 'donation');
234
+			$this->update_option($this->step_on_key, '0');
235 235
 		}
236 236
 
237
-		$donor_ids = array_unique( $donor_ids );
238
-		$this->update_option( $this->donor_key, $donor_ids );
239
-		$this->update_option( $this->donation_key, $donation_ids );
237
+		$donor_ids = array_unique($donor_ids);
238
+		$this->update_option($this->donor_key, $donor_ids);
239
+		$this->update_option($this->donation_key, $donation_ids);
240 240
 
241 241
 		wp_reset_postdata();
242 242
 	}
@@ -248,34 +248,34 @@  discard block
 block discarded – undo
248 248
 	 * @return int
249 249
 	 */
250 250
 	public function get_percentage_complete() {
251
-		return ceil( ( 100 * $this->step_completed ) / $this->total_step );
251
+		return ceil((100 * $this->step_completed) / $this->total_step);
252 252
 	}
253 253
 
254 254
 	public function process_step() {
255 255
 
256
-		if ( ! $this->can_export() ) {
257
-			wp_die( __( 'You do not have permission to delete Import transactions.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
256
+		if ( ! $this->can_export()) {
257
+			wp_die(__('You do not have permission to delete Import transactions.', 'give'), __('Error', 'give'), array('response' => 403));
258 258
 		}
259 259
 
260 260
 		$had_data = $this->get_data();
261 261
 
262
-		if ( $had_data ) {
262
+		if ($had_data) {
263 263
 			$this->done = false;
264 264
 
265 265
 			return true;
266 266
 		} else {
267
-			update_option( 'give_earnings_total', give_get_total_earnings( true ) );
268
-			Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) );
267
+			update_option('give_earnings_total', give_get_total_earnings(true));
268
+			Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats'));
269 269
 
270
-			$this->delete_option( $this->donation_key );
270
+			$this->delete_option($this->donation_key);
271 271
 
272 272
 			// Reset the sequential order numbers
273
-			if ( give_get_option( 'enable_sequential' ) ) {
274
-				delete_option( 'give_last_payment_number' );
273
+			if (give_get_option('enable_sequential')) {
274
+				delete_option('give_last_payment_number');
275 275
 			}
276 276
 
277 277
 			$this->done    = true;
278
-			$this->message = __( 'Imported donor and transactions successfully deleted.', 'give' );
278
+			$this->message = __('Imported donor and transactions successfully deleted.', 'give');
279 279
 
280 280
 			return false;
281 281
 		}
@@ -293,12 +293,12 @@  discard block
 block discarded – undo
293 293
 	public function get_data() {
294 294
 
295 295
 		// Get the donation id's.
296
-		$donation_ids = $this->get_option( $this->donation_key );
296
+		$donation_ids = $this->get_option($this->donation_key);
297 297
 
298 298
 		/**
299 299
 		 * Return false id not Import donation is found.
300 300
 		 */
301
-		if ( empty( $donation_ids ) ) {
301
+		if (empty($donation_ids)) {
302 302
 			$this->is_empty   = true;
303 303
 			$this->total_step = 1;
304 304
 
@@ -309,110 +309,110 @@  discard block
 block discarded – undo
309 309
 		$step = (int) $this->get_step();
310 310
 
311 311
 		// get teh donor ids.
312
-		$donor_ids = $this->get_option( $this->donor_key );
312
+		$donor_ids = $this->get_option($this->donor_key);
313 313
 
314 314
 		// In step to we delete all the donation in loop.
315
-		if ( 2 === $step ) {
315
+		if (2 === $step) {
316 316
 			$pass_to_donor = false;
317 317
 			$page          = (int) $this->get_step_page();
318
-			$page ++;
319
-			$count = count( $donation_ids );
318
+			$page++;
319
+			$count = count($donation_ids);
320 320
 
321
-			$this->total_step     = ( ( count( $donation_ids ) / $this->per_step ) * 2 ) + count( $donor_ids );
321
+			$this->total_step     = ((count($donation_ids) / $this->per_step) * 2) + count($donor_ids);
322 322
 			$this->step_completed = $page;
323 323
 
324 324
 
325
-			if ( $count > $this->per_step ) {
325
+			if ($count > $this->per_step) {
326 326
 
327
-				$this->update_option( $this->step_on_key, $page );
328
-				$donation_ids = $this->get_delete_ids( $donation_ids, $page );
329
-				$current_page = (int) ceil( $count / $this->per_step );
327
+				$this->update_option($this->step_on_key, $page);
328
+				$donation_ids = $this->get_delete_ids($donation_ids, $page);
329
+				$current_page = (int) ceil($count / $this->per_step);
330 330
 
331
-				if ( $page === $current_page ) {
331
+				if ($page === $current_page) {
332 332
 					$pass_to_donor = true;
333 333
 				}
334 334
 			} else {
335 335
 				$pass_to_donor = true;
336 336
 			}
337 337
 
338
-			if ( true === $pass_to_donor ) {
339
-				$this->update_option( $this->step_key, 'donor' );
340
-				$this->update_option( $this->step_on_key, '0' );
338
+			if (true === $pass_to_donor) {
339
+				$this->update_option($this->step_key, 'donor');
340
+				$this->update_option($this->step_on_key, '0');
341 341
 			}
342 342
 
343 343
 			// Get the old form list.
344
-			$form_ids = (array) $this->get_option( $this->form_key );
344
+			$form_ids = (array) $this->get_option($this->form_key);
345 345
 
346
-			foreach ( $donation_ids as $item ) {
347
-				$form_ids[] = get_post_meta( $item, '_give_payment_form_id', true );
346
+			foreach ($donation_ids as $item) {
347
+				$form_ids[] = get_post_meta($item, '_give_payment_form_id', true);
348 348
 
349 349
 				// Delete the main payment.
350
-				give_delete_donation( absint( $item ) );
350
+				give_delete_donation(absint($item));
351 351
 			}
352 352
 
353 353
 			// update the new form list.
354
-			$this->update_option( $this->form_key, $form_ids );
354
+			$this->update_option($this->form_key, $form_ids);
355 355
 		}
356 356
 
357 357
 
358 358
 		// Here we delete all the donor
359
-		if ( 3 === $step ) {
359
+		if (3 === $step) {
360 360
 
361 361
 			// Get the old form list.
362
-			$form_ids = (array) $this->get_option( $this->form_key );
363
-			if ( ! empty( $form_ids ) ) {
364
-				$form_ids = array_unique( $form_ids );
365
-				foreach ( $form_ids as $form_id ) {
366
-					give_recount_form_income_donation( (int) $form_id );
362
+			$form_ids = (array) $this->get_option($this->form_key);
363
+			if ( ! empty($form_ids)) {
364
+				$form_ids = array_unique($form_ids);
365
+				foreach ($form_ids as $form_id) {
366
+					give_recount_form_income_donation((int) $form_id);
367 367
 				}
368 368
 			}
369 369
 			// update the new form list.
370
-			$this->update_option( $this->form_key, array() );
370
+			$this->update_option($this->form_key, array());
371 371
 
372 372
 			$page  = (int) $this->get_step_page();
373
-			$count = count( $donor_ids );
373
+			$count = count($donor_ids);
374 374
 
375
-			$this->total_step     = ( ( count( $donation_ids ) / $this->per_step ) * 2 ) + count( $donor_ids );
376
-			$this->step_completed = $page + ( count( $donation_ids ) / $this->per_step );
375
+			$this->total_step     = ((count($donation_ids) / $this->per_step) * 2) + count($donor_ids);
376
+			$this->step_completed = $page + (count($donation_ids) / $this->per_step);
377 377
 
378
-			if ( ! empty( $donor_ids[ $page ] ) ) {
379
-				$args = apply_filters( 'give_tools_reset_stats_total_args', array(
378
+			if ( ! empty($donor_ids[$page])) {
379
+				$args = apply_filters('give_tools_reset_stats_total_args', array(
380 380
 					'post_status'    => 'any',
381 381
 					'posts_per_page' => 1,
382
-					'author'         => $donor_ids[ $page ]
383
-				) );
382
+					'author'         => $donor_ids[$page]
383
+				));
384 384
 
385 385
 				$donations = array();
386
-				$payments  = new Give_Payments_Query( $args );
386
+				$payments  = new Give_Payments_Query($args);
387 387
 				$payments  = $payments->get_payments();
388
-				if ( empty( $payments ) ) {
389
-					Give()->donors->delete_by_user_id( $donor_ids[ $page ] );
388
+				if (empty($payments)) {
389
+					Give()->donors->delete_by_user_id($donor_ids[$page]);
390 390
 
391 391
 					/**
392 392
 					 * If Checked then delete WP user.
393 393
 					 *
394 394
 					 * @since 1.8.14
395 395
 					 */
396
-					if ( 'on' === (string) $_REQUEST['delete-import-donors'] ) {
397
-						wp_delete_user( $donor_ids[ $page ] );
396
+					if ('on' === (string) $_REQUEST['delete-import-donors']) {
397
+						wp_delete_user($donor_ids[$page]);
398 398
 					}
399 399
 				} else {
400
-					foreach ( $payments as $payment ) {
400
+					foreach ($payments as $payment) {
401 401
 						$donations[] = $payment->ID;
402 402
 					}
403 403
 
404
-					$donor          = new Give_Donor( $donor_ids[ $page ], true );
404
+					$donor          = new Give_Donor($donor_ids[$page], true);
405 405
 					$data_to_update = array(
406
-						'purchase_count' => count( $donations ),
407
-						'payment_ids'    => implode( ',', $donations ),
406
+						'purchase_count' => count($donations),
407
+						'payment_ids'    => implode(',', $donations),
408 408
 					);
409
-					$donor->update( $data_to_update );
409
+					$donor->update($data_to_update);
410 410
 				}
411 411
 			}
412 412
 
413
-			$page ++;
414
-			$this->update_option( $this->step_on_key, $page );
415
-			if ( $count === $page ) {
413
+			$page++;
414
+			$this->update_option($this->step_on_key, $page);
415
+			if ($count === $page) {
416 416
 				$this->is_empty = false;
417 417
 
418 418
 				return false;
@@ -424,24 +424,24 @@  discard block
 block discarded – undo
424 424
 		return true;
425 425
 	}
426 426
 
427
-	public function get_delete_ids( $donation_ids, $page ) {
428
-		$index            = $page --;
429
-		$count            = count( $donation_ids );
427
+	public function get_delete_ids($donation_ids, $page) {
428
+		$index            = $page--;
429
+		$count            = count($donation_ids);
430 430
 		$temp             = 0;
431 431
 		$current_page     = 0;
432 432
 		$post_delete      = $this->per_step;
433 433
 		$page_donation_id = array();
434 434
 
435
-		foreach ( $donation_ids as $item ) {
436
-			$temp ++;
437
-			$page_donation_id[ $current_page ][] = $item;
438
-			if ( $temp === $post_delete ) {
439
-				$current_page ++;
435
+		foreach ($donation_ids as $item) {
436
+			$temp++;
437
+			$page_donation_id[$current_page][] = $item;
438
+			if ($temp === $post_delete) {
439
+				$current_page++;
440 440
 				$temp = 0;
441 441
 			}
442 442
 		}
443 443
 
444
-		return $page_donation_id[ $page ];
444
+		return $page_donation_id[$page];
445 445
 	}
446 446
 
447 447
 	/**
@@ -453,8 +453,8 @@  discard block
 block discarded – undo
453 453
 	 *
454 454
 	 * @return mixed       Returns the data from the database
455 455
 	 */
456
-	public function get_option( $key, $defalut_value = false ) {
457
-		return get_option( $key, $defalut_value );
456
+	public function get_option($key, $defalut_value = false) {
457
+		return get_option($key, $defalut_value);
458 458
 	}
459 459
 
460 460
 	/**
@@ -467,8 +467,8 @@  discard block
 block discarded – undo
467 467
 	 *
468 468
 	 * @return void
469 469
 	 */
470
-	public function update_option( $key, $value ) {
471
-		update_option( $key, $value, false );
470
+	public function update_option($key, $value) {
471
+		update_option($key, $value, false);
472 472
 	}
473 473
 
474 474
 	/**
@@ -480,8 +480,8 @@  discard block
 block discarded – undo
480 480
 	 *
481 481
 	 * @return void
482 482
 	 */
483
-	public function delete_option( $key ) {
484
-		delete_option( $key );
483
+	public function delete_option($key) {
484
+		delete_option($key);
485 485
 	}
486 486
 
487 487
 	/**
@@ -492,12 +492,12 @@  discard block
 block discarded – undo
492 492
 	 * @return int|string
493 493
 	 */
494 494
 	private function get_step() {
495
-		$step_key = (string) $this->get_option( $this->step_key, false );
496
-		if ( 'count' === $step_key ) {
495
+		$step_key = (string) $this->get_option($this->step_key, false);
496
+		if ('count' === $step_key) {
497 497
 			return 1;
498
-		} elseif ( 'donation' === $step_key ) {
498
+		} elseif ('donation' === $step_key) {
499 499
 			return 2;
500
-		} elseif ( 'donor' === $step_key ) {
500
+		} elseif ('donor' === $step_key) {
501 501
 			return 3;
502 502
 		} else {
503 503
 			return $step_key;
@@ -508,6 +508,6 @@  discard block
 block discarded – undo
508 508
 	 * Get the current $page value in the ajax.
509 509
 	 */
510 510
 	private function get_step_page() {
511
-		return $this->get_option( $this->step_on_key, false );
511
+		return $this->get_option($this->step_on_key, false);
512 512
 	}
513 513
 }
Please login to merge, or discard this patch.
includes/class-give-donor.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -918,7 +918,7 @@
 block discarded – undo
918 918
 	 * @access public
919 919
 	 *
920 920
 	 * @param  string $meta_key Metadata name. Default is empty.
921
-	 * @param  mixed $meta_value Optional. Metadata value. Default is empty.
921
+	 * @param  string $meta_value Optional. Metadata value. Default is empty.
922 922
 	 *
923 923
 	 * @return bool               False for failure. True for success.
924 924
 	 */
Please login to merge, or discard this patch.
Spacing   +253 added lines, -260 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
 
@@ -149,32 +149,32 @@  discard block
 block discarded – undo
149 149
 	 * @param int|bool $_id_or_email
150 150
 	 * @param bool     $by_user_id
151 151
 	 */
152
-	public function __construct( $_id_or_email = false, $by_user_id = false ) {
152
+	public function __construct($_id_or_email = false, $by_user_id = false) {
153 153
 
154 154
 		$this->db = Give()->donors;
155 155
 
156 156
 		if (
157 157
 			false === $_id_or_email
158
-			|| ( is_numeric( $_id_or_email ) && (int) $_id_or_email !== absint( $_id_or_email ) )
158
+			|| (is_numeric($_id_or_email) && (int) $_id_or_email !== absint($_id_or_email))
159 159
 		) {
160 160
 			return false;
161 161
 		}
162 162
 
163
-		$by_user_id = is_bool( $by_user_id ) ? $by_user_id : false;
163
+		$by_user_id = is_bool($by_user_id) ? $by_user_id : false;
164 164
 
165
-		if ( is_numeric( $_id_or_email ) ) {
165
+		if (is_numeric($_id_or_email)) {
166 166
 			$field = $by_user_id ? 'user_id' : 'id';
167 167
 		} else {
168 168
 			$field = 'email';
169 169
 		}
170 170
 
171
-		$donor = $this->db->get_donor_by( $field, $_id_or_email );
171
+		$donor = $this->db->get_donor_by($field, $_id_or_email);
172 172
 
173
-		if ( empty( $donor ) || ! is_object( $donor ) ) {
173
+		if (empty($donor) || ! is_object($donor)) {
174 174
 			return false;
175 175
 		}
176 176
 
177
-		$this->setup_donor( $donor );
177
+		$this->setup_donor($donor);
178 178
 
179 179
 	}
180 180
 
@@ -190,19 +190,19 @@  discard block
 block discarded – undo
190 190
 	 *
191 191
 	 * @return bool             If the setup was successful or not.
192 192
 	 */
193
-	private function setup_donor( $donor ) {
193
+	private function setup_donor($donor) {
194 194
 
195
-		if ( ! is_object( $donor ) ) {
195
+		if ( ! is_object($donor)) {
196 196
 			return false;
197 197
 		}
198 198
 
199 199
 		// Get cached donors.
200
-		$donor_vars = Give_Cache::get_group( $donor->id, 'give-donors' );
200
+		$donor_vars = Give_Cache::get_group($donor->id, 'give-donors');
201 201
 
202
-		if( is_null( $donor_vars ) ){
203
-			foreach ( $donor as $key => $value ) {
202
+		if (is_null($donor_vars)) {
203
+			foreach ($donor as $key => $value) {
204 204
 
205
-				switch ( $key ) {
205
+				switch ($key) {
206 206
 
207 207
 					case 'notes':
208 208
 						$this->$key = $this->get_notes();
@@ -216,20 +216,20 @@  discard block
 block discarded – undo
216 216
 			}
217 217
 
218 218
 			// Get donor's all email including primary email.
219
-			$this->emails = (array) $this->get_meta( 'additional_email', false );
220
-			$this->emails = array( 'primary' => $this->email ) + $this->emails;
219
+			$this->emails = (array) $this->get_meta('additional_email', false);
220
+			$this->emails = array('primary' => $this->email) + $this->emails;
221 221
 
222 222
 			$this->setup_address();
223 223
 
224
-			Give_Cache::set_group( $donor->id, get_object_vars( $this ), 'give-donors' );
225
-		} else{
226
-			foreach ( $donor_vars as $donor_var => $value ) {
224
+			Give_Cache::set_group($donor->id, get_object_vars($this), 'give-donors');
225
+		} else {
226
+			foreach ($donor_vars as $donor_var => $value) {
227 227
 				$this->$donor_var = $value;
228 228
 			}
229 229
 		}
230 230
 
231 231
 		// Donor ID and email are the only things that are necessary, make sure they exist.
232
-		if ( ! empty( $this->id ) && ! empty( $this->email ) ) {
232
+		if ( ! empty($this->id) && ! empty($this->email)) {
233 233
 			return true;
234 234
 		}
235 235
 
@@ -262,18 +262,18 @@  discard block
 block discarded – undo
262 262
 			ARRAY_N
263 263
 		);
264 264
 
265
-		if ( empty( $addresses ) ) {
265
+		if (empty($addresses)) {
266 266
 			return $this->address;
267 267
 		}
268 268
 
269
-		foreach ( $addresses as $address ) {
270
-			$address[0] = str_replace( '_give_donor_address_', '', $address[0] );
271
-			$address[0] = explode( '_', $address[0] );
269
+		foreach ($addresses as $address) {
270
+			$address[0] = str_replace('_give_donor_address_', '', $address[0]);
271
+			$address[0] = explode('_', $address[0]);
272 272
 
273
-			if ( 3 === count( $address[0] ) ) {
274
-				$this->address[ $address[0][0] ][ $address[0][2] ][ $address[0][1] ] = $address[1];
273
+			if (3 === count($address[0])) {
274
+				$this->address[$address[0][0]][$address[0][2]][$address[0][1]] = $address[1];
275 275
 			} else {
276
-				$this->address[ $address[0][0] ][ $address[0][1] ] = $address[1];
276
+				$this->address[$address[0][0]][$address[0][1]] = $address[1];
277 277
 			}
278 278
 		}
279 279
 	}
@@ -287,16 +287,16 @@  discard block
 block discarded – undo
287 287
 	 *
288 288
 	 * @return mixed|\WP_Error
289 289
 	 */
290
-	public function __get( $key ) {
290
+	public function __get($key) {
291 291
 
292
-		if ( method_exists( $this, 'get_' . $key ) ) {
292
+		if (method_exists($this, 'get_'.$key)) {
293 293
 
294
-			return call_user_func( array( $this, 'get_' . $key ) );
294
+			return call_user_func(array($this, 'get_'.$key));
295 295
 
296 296
 		} else {
297 297
 
298 298
 			/* translators: %s: property key */
299
-			return new WP_Error( 'give-donor-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) );
299
+			return new WP_Error('give-donor-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key));
300 300
 
301 301
 		}
302 302
 
@@ -312,9 +312,9 @@  discard block
 block discarded – undo
312 312
 	 *
313 313
 	 * @return bool|int    False if not a valid creation, donor ID if user is found or valid creation.
314 314
 	 */
315
-	public function create( $data = array() ) {
315
+	public function create($data = array()) {
316 316
 
317
-		if ( $this->id != 0 || empty( $data ) ) {
317
+		if ($this->id != 0 || empty($data)) {
318 318
 			return false;
319 319
 		}
320 320
 
@@ -322,15 +322,15 @@  discard block
 block discarded – undo
322 322
 			'payment_ids' => '',
323 323
 		);
324 324
 
325
-		$args = wp_parse_args( $data, $defaults );
326
-		$args = $this->sanitize_columns( $args );
325
+		$args = wp_parse_args($data, $defaults);
326
+		$args = $this->sanitize_columns($args);
327 327
 
328
-		if ( empty( $args['email'] ) || ! is_email( $args['email'] ) ) {
328
+		if (empty($args['email']) || ! is_email($args['email'])) {
329 329
 			return false;
330 330
 		}
331 331
 
332
-		if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) {
333
-			$args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) );
332
+		if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) {
333
+			$args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids'])));
334 334
 		}
335 335
 
336 336
 		/**
@@ -340,18 +340,18 @@  discard block
 block discarded – undo
340 340
 		 *
341 341
 		 * @param array $args Donor attributes.
342 342
 		 */
343
-		do_action( 'give_donor_pre_create', $args );
343
+		do_action('give_donor_pre_create', $args);
344 344
 
345 345
 		$created = false;
346 346
 
347 347
 		// The DB class 'add' implies an update if the donor being asked to be created already exists
348
-		if ( $this->db->add( $data ) ) {
348
+		if ($this->db->add($data)) {
349 349
 
350 350
 			// We've successfully added/updated the donor, reset the class vars with the new data
351
-			$donor = $this->db->get_donor_by( 'email', $args['email'] );
351
+			$donor = $this->db->get_donor_by('email', $args['email']);
352 352
 
353 353
 			// Setup the donor data with the values from DB
354
-			$this->setup_donor( $donor );
354
+			$this->setup_donor($donor);
355 355
 
356 356
 			$created = $this->id;
357 357
 		}
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
 		 * @param bool|int $created False if not a valid creation, donor ID if user is found or valid creation.
365 365
 		 * @param array $args Customer attributes.
366 366
 		 */
367
-		do_action( 'give_donor_post_create', $created, $args );
367
+		do_action('give_donor_post_create', $created, $args);
368 368
 
369 369
 		return $created;
370 370
 
@@ -380,13 +380,13 @@  discard block
 block discarded – undo
380 380
 	 *
381 381
 	 * @return bool        If the update was successful or not.
382 382
 	 */
383
-	public function update( $data = array() ) {
383
+	public function update($data = array()) {
384 384
 
385
-		if ( empty( $data ) ) {
385
+		if (empty($data)) {
386 386
 			return false;
387 387
 		}
388 388
 
389
-		$data = $this->sanitize_columns( $data );
389
+		$data = $this->sanitize_columns($data);
390 390
 
391 391
 		/**
392 392
 		 * Fires before updating donors.
@@ -396,15 +396,15 @@  discard block
 block discarded – undo
396 396
 		 * @param int $donor_id Donor id.
397 397
 		 * @param array $data Donor attributes.
398 398
 		 */
399
-		do_action( 'give_donor_pre_update', $this->id, $data );
399
+		do_action('give_donor_pre_update', $this->id, $data);
400 400
 
401 401
 		$updated = false;
402 402
 
403
-		if ( $this->db->update( $this->id, $data ) ) {
403
+		if ($this->db->update($this->id, $data)) {
404 404
 
405
-			$donor = $this->db->get_donor_by( 'id', $this->id );
405
+			$donor = $this->db->get_donor_by('id', $this->id);
406 406
 
407
-			$this->setup_donor( $donor );
407
+			$this->setup_donor($donor);
408 408
 
409 409
 			$updated = true;
410 410
 		}
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 		 * @param int $donor_id Donor id.
419 419
 		 * @param array $data Donor attributes.
420 420
 		 */
421
-		do_action( 'give_donor_post_update', $updated, $this->id, $data );
421
+		do_action('give_donor_post_update', $updated, $this->id, $data);
422 422
 
423 423
 		return $updated;
424 424
 	}
@@ -436,27 +436,27 @@  discard block
 block discarded – undo
436 436
 	 *
437 437
 	 * @return bool            If the attachment was successfully.
438 438
 	 */
439
-	public function attach_payment( $payment_id = 0, $update_stats = true ) {
439
+	public function attach_payment($payment_id = 0, $update_stats = true) {
440 440
 
441
-		if ( empty( $payment_id ) ) {
441
+		if (empty($payment_id)) {
442 442
 			return false;
443 443
 		}
444 444
 
445
-		if ( empty( $this->payment_ids ) ) {
445
+		if (empty($this->payment_ids)) {
446 446
 
447 447
 			$new_payment_ids = $payment_id;
448 448
 
449 449
 		} else {
450 450
 
451
-			$payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) );
451
+			$payment_ids = array_map('absint', explode(',', $this->payment_ids));
452 452
 
453
-			if ( in_array( $payment_id, $payment_ids ) ) {
453
+			if (in_array($payment_id, $payment_ids)) {
454 454
 				$update_stats = false;
455 455
 			}
456 456
 
457 457
 			$payment_ids[] = $payment_id;
458 458
 
459
-			$new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) );
459
+			$new_payment_ids = implode(',', array_unique(array_values($payment_ids)));
460 460
 
461 461
 		}
462 462
 
@@ -468,20 +468,20 @@  discard block
 block discarded – undo
468 468
 		 * @param int $payment_id Payment id.
469 469
 		 * @param int $donor_id Customer id.
470 470
 		 */
471
-		do_action( 'give_donor_pre_attach_payment', $payment_id, $this->id );
471
+		do_action('give_donor_pre_attach_payment', $payment_id, $this->id);
472 472
 
473
-		$payment_added = $this->update( array( 'payment_ids' => $new_payment_ids ) );
473
+		$payment_added = $this->update(array('payment_ids' => $new_payment_ids));
474 474
 
475
-		if ( $payment_added ) {
475
+		if ($payment_added) {
476 476
 
477 477
 			$this->payment_ids = $new_payment_ids;
478 478
 
479 479
 			// We added this payment successfully, increment the stats
480
-			if ( $update_stats ) {
481
-				$payment_amount = give_donation_amount( $payment_id, array( 'type' => 'stats' ) );
480
+			if ($update_stats) {
481
+				$payment_amount = give_donation_amount($payment_id, array('type' => 'stats'));
482 482
 
483
-				if ( ! empty( $payment_amount ) ) {
484
-					$this->increase_value( $payment_amount );
483
+				if ( ! empty($payment_amount)) {
484
+					$this->increase_value($payment_amount);
485 485
 				}
486 486
 
487 487
 				$this->increase_purchase_count();
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
 		 * @param int $payment_id Payment id.
498 498
 		 * @param int $donor_id Donor id.
499 499
 		 */
500
-		do_action( 'give_donor_post_attach_payment', $payment_added, $payment_id, $this->id );
500
+		do_action('give_donor_post_attach_payment', $payment_added, $payment_id, $this->id);
501 501
 
502 502
 		return $payment_added;
503 503
 	}
@@ -515,33 +515,33 @@  discard block
 block discarded – undo
515 515
 	 *
516 516
 	 * @return boolean               If the removal was successful.
517 517
 	 */
518
-	public function remove_payment( $payment_id = 0, $update_stats = true ) {
518
+	public function remove_payment($payment_id = 0, $update_stats = true) {
519 519
 
520
-		if ( empty( $payment_id ) ) {
520
+		if (empty($payment_id)) {
521 521
 			return false;
522 522
 		}
523 523
 
524
-		$payment = new Give_Payment( $payment_id );
524
+		$payment = new Give_Payment($payment_id);
525 525
 
526
-		if ( 'publish' !== $payment->status && 'revoked' !== $payment->status ) {
526
+		if ('publish' !== $payment->status && 'revoked' !== $payment->status) {
527 527
 			$update_stats = false;
528 528
 		}
529 529
 
530 530
 		$new_payment_ids = '';
531 531
 
532
-		if ( ! empty( $this->payment_ids ) ) {
532
+		if ( ! empty($this->payment_ids)) {
533 533
 
534
-			$payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) );
534
+			$payment_ids = array_map('absint', explode(',', $this->payment_ids));
535 535
 
536
-			$pos = array_search( $payment_id, $payment_ids );
537
-			if ( false === $pos ) {
536
+			$pos = array_search($payment_id, $payment_ids);
537
+			if (false === $pos) {
538 538
 				return false;
539 539
 			}
540 540
 
541
-			unset( $payment_ids[ $pos ] );
542
-			$payment_ids = array_filter( $payment_ids );
541
+			unset($payment_ids[$pos]);
542
+			$payment_ids = array_filter($payment_ids);
543 543
 
544
-			$new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) );
544
+			$new_payment_ids = implode(',', array_unique(array_values($payment_ids)));
545 545
 
546 546
 		}
547 547
 
@@ -553,20 +553,20 @@  discard block
 block discarded – undo
553 553
 		 * @param int $payment_id Payment id.
554 554
 		 * @param int $donor_id Customer id.
555 555
 		 */
556
-		do_action( 'give_donor_pre_remove_payment', $payment_id, $this->id );
556
+		do_action('give_donor_pre_remove_payment', $payment_id, $this->id);
557 557
 
558
-		$payment_removed = $this->update( array( 'payment_ids' => $new_payment_ids ) );
558
+		$payment_removed = $this->update(array('payment_ids' => $new_payment_ids));
559 559
 
560
-		if ( $payment_removed ) {
560
+		if ($payment_removed) {
561 561
 
562 562
 			$this->payment_ids = $new_payment_ids;
563 563
 
564
-			if ( $update_stats ) {
564
+			if ($update_stats) {
565 565
 				// We removed this payment successfully, decrement the stats
566
-				$payment_amount = give_donation_amount( $payment_id );
566
+				$payment_amount = give_donation_amount($payment_id);
567 567
 
568
-				if ( ! empty( $payment_amount ) ) {
569
-					$this->decrease_value( $payment_amount );
568
+				if ( ! empty($payment_amount)) {
569
+					$this->decrease_value($payment_amount);
570 570
 				}
571 571
 
572 572
 				$this->decrease_donation_count();
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
 		 * @param int $payment_id Payment id.
583 583
 		 * @param int $donor_id Donor id.
584 584
 		 */
585
-		do_action( 'give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id );
585
+		do_action('give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id);
586 586
 
587 587
 		return $payment_removed;
588 588
 
@@ -598,10 +598,10 @@  discard block
 block discarded – undo
598 598
 	 *
599 599
 	 * @return int        The donation count.
600 600
 	 */
601
-	public function increase_purchase_count( $count = 1 ) {
601
+	public function increase_purchase_count($count = 1) {
602 602
 
603 603
 		// Make sure it's numeric and not negative.
604
-		if ( ! is_numeric( $count ) || $count != absint( $count ) ) {
604
+		if ( ! is_numeric($count) || $count != absint($count)) {
605 605
 			return false;
606 606
 		}
607 607
 
@@ -615,9 +615,9 @@  discard block
 block discarded – undo
615 615
 		 * @param int $count The number to increase by.
616 616
 		 * @param int $donor_id Donor id.
617 617
 		 */
618
-		do_action( 'give_donor_pre_increase_donation_count', $count, $this->id );
618
+		do_action('give_donor_pre_increase_donation_count', $count, $this->id);
619 619
 
620
-		if ( $this->update( array( 'purchase_count' => $new_total ) ) ) {
620
+		if ($this->update(array('purchase_count' => $new_total))) {
621 621
 			$this->purchase_count = $new_total;
622 622
 		}
623 623
 
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
 		 * @param int $count The number increased by.
631 631
 		 * @param int $donor_id Donor id.
632 632
 		 */
633
-		do_action( 'give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id );
633
+		do_action('give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id);
634 634
 
635 635
 		return $this->purchase_count;
636 636
 	}
@@ -645,16 +645,16 @@  discard block
 block discarded – undo
645 645
 	 *
646 646
 	 * @return mixed      If successful, the new count, otherwise false.
647 647
 	 */
648
-	public function decrease_donation_count( $count = 1 ) {
648
+	public function decrease_donation_count($count = 1) {
649 649
 
650 650
 		// Make sure it's numeric and not negative
651
-		if ( ! is_numeric( $count ) || $count != absint( $count ) ) {
651
+		if ( ! is_numeric($count) || $count != absint($count)) {
652 652
 			return false;
653 653
 		}
654 654
 
655 655
 		$new_total = (int) $this->purchase_count - (int) $count;
656 656
 
657
-		if ( $new_total < 0 ) {
657
+		if ($new_total < 0) {
658 658
 			$new_total = 0;
659 659
 		}
660 660
 
@@ -666,9 +666,9 @@  discard block
 block discarded – undo
666 666
 		 * @param int $count The number to decrease by.
667 667
 		 * @param int $donor_id Customer id.
668 668
 		 */
669
-		do_action( 'give_donor_pre_decrease_donation_count', $count, $this->id );
669
+		do_action('give_donor_pre_decrease_donation_count', $count, $this->id);
670 670
 
671
-		if ( $this->update( array( 'purchase_count' => $new_total ) ) ) {
671
+		if ($this->update(array('purchase_count' => $new_total))) {
672 672
 			$this->purchase_count = $new_total;
673 673
 		}
674 674
 
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
 		 * @param int $count The number decreased by.
682 682
 		 * @param int $donor_id Donor id.
683 683
 		 */
684
-		do_action( 'give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id );
684
+		do_action('give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id);
685 685
 
686 686
 		return $this->purchase_count;
687 687
 	}
@@ -696,9 +696,9 @@  discard block
 block discarded – undo
696 696
 	 *
697 697
 	 * @return mixed        If successful, the new value, otherwise false.
698 698
 	 */
699
-	public function increase_value( $value = 0.00 ) {
699
+	public function increase_value($value = 0.00) {
700 700
 
701
-		$new_value = floatval( $this->purchase_value ) + $value;
701
+		$new_value = floatval($this->purchase_value) + $value;
702 702
 
703 703
 		/**
704 704
 		 * Fires before increasing donor lifetime value.
@@ -708,9 +708,9 @@  discard block
 block discarded – undo
708 708
 		 * @param float $value The value to increase by.
709 709
 		 * @param int $donor_id Customer id.
710 710
 		 */
711
-		do_action( 'give_donor_pre_increase_value', $value, $this->id );
711
+		do_action('give_donor_pre_increase_value', $value, $this->id);
712 712
 
713
-		if ( $this->update( array( 'purchase_value' => $new_value ) ) ) {
713
+		if ($this->update(array('purchase_value' => $new_value))) {
714 714
 			$this->purchase_value = $new_value;
715 715
 		}
716 716
 
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
 		 * @param float $value The value increased by.
724 724
 		 * @param int $donor_id Donor id.
725 725
 		 */
726
-		do_action( 'give_donor_post_increase_value', $this->purchase_value, $value, $this->id );
726
+		do_action('give_donor_post_increase_value', $this->purchase_value, $value, $this->id);
727 727
 
728 728
 		return $this->purchase_value;
729 729
 	}
@@ -738,11 +738,11 @@  discard block
 block discarded – undo
738 738
 	 *
739 739
 	 * @return mixed        If successful, the new value, otherwise false.
740 740
 	 */
741
-	public function decrease_value( $value = 0.00 ) {
741
+	public function decrease_value($value = 0.00) {
742 742
 
743
-		$new_value = floatval( $this->purchase_value ) - $value;
743
+		$new_value = floatval($this->purchase_value) - $value;
744 744
 
745
-		if ( $new_value < 0 ) {
745
+		if ($new_value < 0) {
746 746
 			$new_value = 0.00;
747 747
 		}
748 748
 
@@ -754,9 +754,9 @@  discard block
 block discarded – undo
754 754
 		 * @param float $value The value to decrease by.
755 755
 		 * @param int $donor_id Donor id.
756 756
 		 */
757
-		do_action( 'give_donor_pre_decrease_value', $value, $this->id );
757
+		do_action('give_donor_pre_decrease_value', $value, $this->id);
758 758
 
759
-		if ( $this->update( array( 'purchase_value' => $new_value ) ) ) {
759
+		if ($this->update(array('purchase_value' => $new_value))) {
760 760
 			$this->purchase_value = $new_value;
761 761
 		}
762 762
 
@@ -769,7 +769,7 @@  discard block
 block discarded – undo
769 769
 		 * @param float $value The value decreased by.
770 770
 		 * @param int $donor_id Donor id.
771 771
 		 */
772
-		do_action( 'give_donor_post_decrease_value', $this->purchase_value, $value, $this->id );
772
+		do_action('give_donor_post_decrease_value', $this->purchase_value, $value, $this->id);
773 773
 
774 774
 		return $this->purchase_value;
775 775
 	}
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
 	 *
789 789
 	 * @return mixed              If successful, the new donation stat value, otherwise false.
790 790
 	 */
791
-	public function update_donation_value( $curr_amount, $new_amount ) {
791
+	public function update_donation_value($curr_amount, $new_amount) {
792 792
 		/**
793 793
 		 * Payment total difference value can be:
794 794
 		 *  zero   (in case amount not change)
@@ -798,15 +798,15 @@  discard block
 block discarded – undo
798 798
 		$payment_total_diff = $new_amount - $curr_amount;
799 799
 
800 800
 		// We do not need to update donation stat if donation did not change.
801
-		if ( ! $payment_total_diff ) {
801
+		if ( ! $payment_total_diff) {
802 802
 			return false;
803 803
 		}
804 804
 
805
-		if ( $payment_total_diff > 0 ) {
806
-			$this->increase_value( $payment_total_diff );
805
+		if ($payment_total_diff > 0) {
806
+			$this->increase_value($payment_total_diff);
807 807
 		} else {
808 808
 			// Pass payment total difference as +ve value to decrease amount from user lifetime stat.
809
-			$this->decrease_value( - $payment_total_diff );
809
+			$this->decrease_value( -$payment_total_diff );
810 810
 		}
811 811
 
812 812
 		return $this->purchase_value;
@@ -823,15 +823,15 @@  discard block
 block discarded – undo
823 823
 	 *
824 824
 	 * @return array       The notes requested.
825 825
 	 */
826
-	public function get_notes( $length = 20, $paged = 1 ) {
826
+	public function get_notes($length = 20, $paged = 1) {
827 827
 
828
-		$length = is_numeric( $length ) ? $length : 20;
829
-		$offset = is_numeric( $paged ) && $paged != 1 ? ( ( absint( $paged ) - 1 ) * $length ) : 0;
828
+		$length = is_numeric($length) ? $length : 20;
829
+		$offset = is_numeric($paged) && $paged != 1 ? ((absint($paged) - 1) * $length) : 0;
830 830
 
831 831
 		$all_notes   = $this->get_raw_notes();
832
-		$notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) );
832
+		$notes_array = array_reverse(array_filter(explode("\n\n", $all_notes)));
833 833
 
834
-		$desired_notes = array_slice( $notes_array, $offset, $length );
834
+		$desired_notes = array_slice($notes_array, $offset, $length);
835 835
 
836 836
 		return $desired_notes;
837 837
 
@@ -848,9 +848,9 @@  discard block
 block discarded – undo
848 848
 	public function get_notes_count() {
849 849
 
850 850
 		$all_notes   = $this->get_raw_notes();
851
-		$notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) );
851
+		$notes_array = array_reverse(array_filter(explode("\n\n", $all_notes)));
852 852
 
853
-		return count( $notes_array );
853
+		return count($notes_array);
854 854
 
855 855
 	}
856 856
 
@@ -863,7 +863,7 @@  discard block
 block discarded – undo
863 863
 	 *
864 864
 	 * @return string|float
865 865
 	 */
866
-	public function get_total_donation_amount( $args = array() ) {
866
+	public function get_total_donation_amount($args = array()) {
867 867
 
868 868
 		/**
869 869
 		 * Filter total donation amount.
@@ -874,7 +874,7 @@  discard block
 block discarded – undo
874 874
 		 * @param integer      $donor_id       Donor ID.
875 875
 		 * @param array        $args           Pass additional data.
876 876
 		 */
877
-		return apply_filters( 'give_get_total_donation_amount', $this->purchase_value, $this->id, $args );
877
+		return apply_filters('give_get_total_donation_amount', $this->purchase_value, $this->id, $args);
878 878
 	}
879 879
 
880 880
 	/**
@@ -887,22 +887,22 @@  discard block
 block discarded – undo
887 887
 	 *
888 888
 	 * @return string|boolean The new note if added successfully, false otherwise.
889 889
 	 */
890
-	public function add_note( $note = '' ) {
890
+	public function add_note($note = '') {
891 891
 
892
-		$note = trim( $note );
893
-		if ( empty( $note ) ) {
892
+		$note = trim($note);
893
+		if (empty($note)) {
894 894
 			return false;
895 895
 		}
896 896
 
897 897
 		$notes = $this->get_raw_notes();
898 898
 
899
-		if ( empty( $notes ) ) {
899
+		if (empty($notes)) {
900 900
 			$notes = '';
901 901
 		}
902 902
 
903
-		$note_string = date_i18n( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $note;
904
-		$new_note    = apply_filters( 'give_customer_add_note_string', $note_string );
905
-		$notes       .= "\n\n" . $new_note;
903
+		$note_string = date_i18n('F j, Y H:i:s', current_time('timestamp')).' - '.$note;
904
+		$new_note    = apply_filters('give_customer_add_note_string', $note_string);
905
+		$notes .= "\n\n".$new_note;
906 906
 
907 907
 		/**
908 908
 		 * Fires before donor note is added.
@@ -912,11 +912,11 @@  discard block
 block discarded – undo
912 912
 		 * @param string $new_note New note to add.
913 913
 		 * @param int $donor_id Donor id.
914 914
 		 */
915
-		do_action( 'give_donor_pre_add_note', $new_note, $this->id );
915
+		do_action('give_donor_pre_add_note', $new_note, $this->id);
916 916
 
917
-		$updated = $this->update( array( 'notes' => $notes ) );
917
+		$updated = $this->update(array('notes' => $notes));
918 918
 
919
-		if ( $updated ) {
919
+		if ($updated) {
920 920
 			$this->notes = $this->get_notes();
921 921
 		}
922 922
 
@@ -929,7 +929,7 @@  discard block
 block discarded – undo
929 929
 		 * @param string $new_note New note added.
930 930
 		 * @param int $donor_id Donor id.
931 931
 		 */
932
-		do_action( 'give_donor_post_add_note', $this->notes, $new_note, $this->id );
932
+		do_action('give_donor_post_add_note', $this->notes, $new_note, $this->id);
933 933
 
934 934
 		// Return the formatted note, so we can test, as well as update any displays
935 935
 		return $new_note;
@@ -946,7 +946,7 @@  discard block
 block discarded – undo
946 946
 	 */
947 947
 	private function get_raw_notes() {
948 948
 
949
-		$all_notes = $this->db->get_column( 'notes', $this->id );
949
+		$all_notes = $this->db->get_column('notes', $this->id);
950 950
 
951 951
 		return $all_notes;
952 952
 
@@ -963,8 +963,8 @@  discard block
 block discarded – undo
963 963
 	 *
964 964
 	 * @return mixed            Will be an array if $single is false. Will be value of meta data field if $single is true.
965 965
 	 */
966
-	public function get_meta( $meta_key = '', $single = true ) {
967
-		return Give()->donor_meta->get_meta( $this->id, $meta_key, $single );
966
+	public function get_meta($meta_key = '', $single = true) {
967
+		return Give()->donor_meta->get_meta($this->id, $meta_key, $single);
968 968
 	}
969 969
 
970 970
 	/**
@@ -979,8 +979,8 @@  discard block
 block discarded – undo
979 979
 	 *
980 980
 	 * @return bool               False for failure. True for success.
981 981
 	 */
982
-	public function add_meta( $meta_key = '', $meta_value, $unique = false ) {
983
-		return Give()->donor_meta->add_meta( $this->id, $meta_key, $meta_value, $unique );
982
+	public function add_meta($meta_key = '', $meta_value, $unique = false) {
983
+		return Give()->donor_meta->add_meta($this->id, $meta_key, $meta_value, $unique);
984 984
 	}
985 985
 
986 986
 	/**
@@ -995,8 +995,8 @@  discard block
 block discarded – undo
995 995
 	 *
996 996
 	 * @return bool               False on failure, true if success.
997 997
 	 */
998
-	public function update_meta( $meta_key = '', $meta_value, $prev_value = '' ) {
999
-		return Give()->donor_meta->update_meta( $this->id, $meta_key, $meta_value, $prev_value );
998
+	public function update_meta($meta_key = '', $meta_value, $prev_value = '') {
999
+		return Give()->donor_meta->update_meta($this->id, $meta_key, $meta_value, $prev_value);
1000 1000
 	}
1001 1001
 
1002 1002
 	/**
@@ -1010,8 +1010,8 @@  discard block
 block discarded – undo
1010 1010
 	 *
1011 1011
 	 * @return bool               False for failure. True for success.
1012 1012
 	 */
1013
-	public function delete_meta( $meta_key = '', $meta_value = '' ) {
1014
-		return Give()->donor_meta->delete_meta( $this->id, $meta_key, $meta_value );
1013
+	public function delete_meta($meta_key = '', $meta_value = '') {
1014
+		return Give()->donor_meta->delete_meta($this->id, $meta_key, $meta_value);
1015 1015
 	}
1016 1016
 
1017 1017
 	/**
@@ -1024,51 +1024,51 @@  discard block
 block discarded – undo
1024 1024
 	 *
1025 1025
 	 * @return array       The sanitized data, based off column defaults.
1026 1026
 	 */
1027
-	private function sanitize_columns( $data ) {
1027
+	private function sanitize_columns($data) {
1028 1028
 
1029 1029
 		$columns        = $this->db->get_columns();
1030 1030
 		$default_values = $this->db->get_column_defaults();
1031 1031
 
1032
-		foreach ( $columns as $key => $type ) {
1032
+		foreach ($columns as $key => $type) {
1033 1033
 
1034 1034
 			// Only sanitize data that we were provided
1035
-			if ( ! array_key_exists( $key, $data ) ) {
1035
+			if ( ! array_key_exists($key, $data)) {
1036 1036
 				continue;
1037 1037
 			}
1038 1038
 
1039
-			switch ( $type ) {
1039
+			switch ($type) {
1040 1040
 
1041 1041
 				case '%s':
1042
-					if ( 'email' == $key ) {
1043
-						$data[ $key ] = sanitize_email( $data[ $key ] );
1044
-					} elseif ( 'notes' == $key ) {
1045
-						$data[ $key ] = strip_tags( $data[ $key ] );
1042
+					if ('email' == $key) {
1043
+						$data[$key] = sanitize_email($data[$key]);
1044
+					} elseif ('notes' == $key) {
1045
+						$data[$key] = strip_tags($data[$key]);
1046 1046
 					} else {
1047
-						$data[ $key ] = sanitize_text_field( $data[ $key ] );
1047
+						$data[$key] = sanitize_text_field($data[$key]);
1048 1048
 					}
1049 1049
 					break;
1050 1050
 
1051 1051
 				case '%d':
1052
-					if ( ! is_numeric( $data[ $key ] ) || (int) $data[ $key ] !== absint( $data[ $key ] ) ) {
1053
-						$data[ $key ] = $default_values[ $key ];
1052
+					if ( ! is_numeric($data[$key]) || (int) $data[$key] !== absint($data[$key])) {
1053
+						$data[$key] = $default_values[$key];
1054 1054
 					} else {
1055
-						$data[ $key ] = absint( $data[ $key ] );
1055
+						$data[$key] = absint($data[$key]);
1056 1056
 					}
1057 1057
 					break;
1058 1058
 
1059 1059
 				case '%f':
1060 1060
 					// Convert what was given to a float
1061
-					$value = floatval( $data[ $key ] );
1061
+					$value = floatval($data[$key]);
1062 1062
 
1063
-					if ( ! is_float( $value ) ) {
1064
-						$data[ $key ] = $default_values[ $key ];
1063
+					if ( ! is_float($value)) {
1064
+						$data[$key] = $default_values[$key];
1065 1065
 					} else {
1066
-						$data[ $key ] = $value;
1066
+						$data[$key] = $value;
1067 1067
 					}
1068 1068
 					break;
1069 1069
 
1070 1070
 				default:
1071
-					$data[ $key ] = sanitize_text_field( $data[ $key ] );
1071
+					$data[$key] = sanitize_text_field($data[$key]);
1072 1072
 					break;
1073 1073
 
1074 1074
 			}
@@ -1088,33 +1088,33 @@  discard block
 block discarded – undo
1088 1088
 	 *
1089 1089
 	 * @return bool            If the email was added successfully
1090 1090
 	 */
1091
-	public function add_email( $email = '', $primary = false ) {
1092
-		if ( ! is_email( $email ) ) {
1091
+	public function add_email($email = '', $primary = false) {
1092
+		if ( ! is_email($email)) {
1093 1093
 			return false;
1094 1094
 		}
1095
-		$existing = new Give_Donor( $email );
1095
+		$existing = new Give_Donor($email);
1096 1096
 
1097
-		if ( $existing->id > 0 ) {
1097
+		if ($existing->id > 0) {
1098 1098
 			// Email address already belongs to another donor
1099 1099
 			return false;
1100 1100
 		}
1101 1101
 
1102
-		if ( email_exists( $email ) ) {
1103
-			$user = get_user_by( 'email', $email );
1104
-			if ( $user->ID != $this->user_id ) {
1102
+		if (email_exists($email)) {
1103
+			$user = get_user_by('email', $email);
1104
+			if ($user->ID != $this->user_id) {
1105 1105
 				return false;
1106 1106
 			}
1107 1107
 		}
1108 1108
 
1109
-		do_action( 'give_donor_pre_add_email', $email, $this->id, $this );
1109
+		do_action('give_donor_pre_add_email', $email, $this->id, $this);
1110 1110
 
1111 1111
 		// Add is used to ensure duplicate emails are not added
1112
-		$ret = (bool) $this->add_meta( 'additional_email', $email );
1112
+		$ret = (bool) $this->add_meta('additional_email', $email);
1113 1113
 
1114
-		do_action( 'give_donor_post_add_email', $email, $this->id, $this );
1114
+		do_action('give_donor_post_add_email', $email, $this->id, $this);
1115 1115
 
1116
-		if ( $ret && true === $primary ) {
1117
-			$this->set_primary_email( $email );
1116
+		if ($ret && true === $primary) {
1117
+			$this->set_primary_email($email);
1118 1118
 		}
1119 1119
 
1120 1120
 		return $ret;
@@ -1130,16 +1130,16 @@  discard block
 block discarded – undo
1130 1130
 	 *
1131 1131
 	 * @return bool          If the email was removed successfully.
1132 1132
 	 */
1133
-	public function remove_email( $email = '' ) {
1134
-		if ( ! is_email( $email ) ) {
1133
+	public function remove_email($email = '') {
1134
+		if ( ! is_email($email)) {
1135 1135
 			return false;
1136 1136
 		}
1137 1137
 
1138
-		do_action( 'give_donor_pre_remove_email', $email, $this->id, $this );
1138
+		do_action('give_donor_pre_remove_email', $email, $this->id, $this);
1139 1139
 
1140
-		$ret = (bool) $this->delete_meta( 'additional_email', $email );
1140
+		$ret = (bool) $this->delete_meta('additional_email', $email);
1141 1141
 
1142
-		do_action( 'give_donor_post_remove_email', $email, $this->id, $this );
1142
+		do_action('give_donor_post_remove_email', $email, $this->id, $this);
1143 1143
 
1144 1144
 		return $ret;
1145 1145
 	}
@@ -1156,16 +1156,16 @@  discard block
 block discarded – undo
1156 1156
 	 *
1157 1157
 	 * @return bool                      If the email was set as primary successfully.
1158 1158
 	 */
1159
-	public function set_primary_email( $new_primary_email = '' ) {
1160
-		if ( ! is_email( $new_primary_email ) ) {
1159
+	public function set_primary_email($new_primary_email = '') {
1160
+		if ( ! is_email($new_primary_email)) {
1161 1161
 			return false;
1162 1162
 		}
1163 1163
 
1164
-		do_action( 'give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this );
1164
+		do_action('give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this);
1165 1165
 
1166
-		$existing = new Give_Donor( $new_primary_email );
1166
+		$existing = new Give_Donor($new_primary_email);
1167 1167
 
1168
-		if ( $existing->id > 0 && (int) $existing->id !== (int) $this->id ) {
1168
+		if ($existing->id > 0 && (int) $existing->id !== (int) $this->id) {
1169 1169
 			// This email belongs to another donor.
1170 1170
 			return false;
1171 1171
 		}
@@ -1173,21 +1173,21 @@  discard block
 block discarded – undo
1173 1173
 		$old_email = $this->email;
1174 1174
 
1175 1175
 		// Update donor record with new email.
1176
-		$update = $this->update( array( 'email' => $new_primary_email ) );
1176
+		$update = $this->update(array('email' => $new_primary_email));
1177 1177
 
1178 1178
 		// Remove new primary from list of additional emails.
1179
-		$remove = $this->remove_email( $new_primary_email );
1179
+		$remove = $this->remove_email($new_primary_email);
1180 1180
 
1181 1181
 		// Add old email to additional emails list.
1182
-		$add = $this->add_email( $old_email );
1182
+		$add = $this->add_email($old_email);
1183 1183
 
1184 1184
 		$ret = $update && $remove && $add;
1185 1185
 
1186
-		if ( $ret ) {
1186
+		if ($ret) {
1187 1187
 			$this->email = $new_primary_email;
1188 1188
 		}
1189 1189
 
1190
-		do_action( 'give_donor_post_set_primary_email', $new_primary_email, $this->id, $this );
1190
+		do_action('give_donor_post_set_primary_email', $new_primary_email, $this->id, $this);
1191 1191
 
1192 1192
 		return $ret;
1193 1193
 	}
@@ -1202,17 +1202,17 @@  discard block
 block discarded – undo
1202 1202
 	 *
1203 1203
 	 * @return bool
1204 1204
 	 */
1205
-	private function is_valid_address( $address ) {
1205
+	private function is_valid_address($address) {
1206 1206
 		$is_valid_address = true;
1207 1207
 		
1208 1208
 		// Address ready to process even if only one value set.
1209
-		foreach ( $address as $address_type => $value ) {
1209
+		foreach ($address as $address_type => $value) {
1210 1210
 			// @todo: Handle state field validation on basis of country.
1211
-			if( in_array( $address_type, array( 'line2', 'state' )) ) {
1211
+			if (in_array($address_type, array('line2', 'state'))) {
1212 1212
 				continue;
1213 1213
 			}
1214 1214
 
1215
-			if ( empty( $value ) ) {
1215
+			if (empty($value)) {
1216 1216
 				$is_valid_address = false;
1217 1217
 				break;
1218 1218
 			}
@@ -1239,30 +1239,27 @@  discard block
 block discarded – undo
1239 1239
 	 *
1240 1240
 	 * @return bool
1241 1241
 	 */
1242
-	public function add_address( $address_type, $address ) {
1242
+	public function add_address($address_type, $address) {
1243 1243
 		// Bailout.
1244
-		if ( empty( $address_type ) || ! $this->is_valid_address( $address ) || ! $this->id ) {
1244
+		if (empty($address_type) || ! $this->is_valid_address($address) || ! $this->id) {
1245 1245
 			return false;
1246 1246
 		}
1247 1247
 
1248 1248
 		// Check if multiple address exist or not and set params.
1249 1249
 		$multi_address_id = null;
1250
-		if( $is_multi_address = ( false !== strpos( $address_type, '[]' ) ) ) {
1251
-			$address_type  = $is_multi_address ?
1252
-				str_replace( '[]', '', $address_type ) :
1253
-				$address_type;
1254
-		} elseif ( $is_multi_address = ( false !== strpos( $address_type, '_' ) ) ){
1255
-			$multi_address_id =  $is_multi_address ?
1256
-				array_pop( explode( '_', $address_type ) ) :
1257
-				$address_type;
1258
-
1259
-			$address_type  = $is_multi_address ?
1260
-				array_shift( explode( '_', $address_type ) ) :
1261
-				$address_type;
1250
+		if ($is_multi_address = (false !== strpos($address_type, '[]'))) {
1251
+			$address_type = $is_multi_address ?
1252
+				str_replace('[]', '', $address_type) : $address_type;
1253
+		} elseif ($is_multi_address = (false !== strpos($address_type, '_'))) {
1254
+			$multi_address_id = $is_multi_address ?
1255
+				array_pop(explode('_', $address_type)) : $address_type;
1256
+
1257
+			$address_type = $is_multi_address ?
1258
+				array_shift(explode('_', $address_type)) : $address_type;
1262 1259
 		}
1263 1260
 
1264 1261
 		// Bailout: do not save duplicate orders
1265
-		if( $this->is_address_exist( $address_type, $address ) ) {
1262
+		if ($this->is_address_exist($address_type, $address)) {
1266 1263
 			return false;
1267 1264
 		}
1268 1265
 
@@ -1284,8 +1281,8 @@  discard block
 block discarded – undo
1284 1281
 		$meta_key_prefix = "_give_donor_address_{$address_type}_{address_name}";
1285 1282
 		$meta_type = Give()->donor_meta->meta_type;
1286 1283
 
1287
-		if ( $is_multi_address ) {
1288
-			if ( is_null( $multi_address_id ) ) {
1284
+		if ($is_multi_address) {
1285
+			if (is_null($multi_address_id)) {
1289 1286
 				// Get latest address key to set multi address id.
1290 1287
 				$multi_address_id = $wpdb->get_var(
1291 1288
 					$wpdb->prepare(
@@ -1302,10 +1299,10 @@  discard block
 block discarded – undo
1302 1299
 					)
1303 1300
 				);
1304 1301
 
1305
-				if( ! empty( $multi_address_id ) ) {
1306
-					$multi_address_id = absint( substr( strrchr( $multi_address_id, '_' ), 1 ) );
1302
+				if ( ! empty($multi_address_id)) {
1303
+					$multi_address_id = absint(substr(strrchr($multi_address_id, '_'), 1));
1307 1304
 					$multi_address_id++;
1308
-				} else{
1305
+				} else {
1309 1306
 					$multi_address_id = 0;
1310 1307
 				}
1311 1308
 			}
@@ -1314,9 +1311,9 @@  discard block
 block discarded – undo
1314 1311
 		}
1315 1312
 
1316 1313
 		// Save donor address.
1317
-		foreach ( $address as $type => $value ) {
1318
-			$meta_key = str_replace( '{address_name}', $type, $meta_key_prefix );
1319
-			Give()->donor_meta->update_meta( $this->id, $meta_key, $value );
1314
+		foreach ($address as $type => $value) {
1315
+			$meta_key = str_replace('{address_name}', $type, $meta_key_prefix);
1316
+			Give()->donor_meta->update_meta($this->id, $meta_key, $value);
1320 1317
 		}
1321 1318
 
1322 1319
 		$this->setup_address();
@@ -1335,23 +1332,21 @@  discard block
 block discarded – undo
1335 1332
 	 *
1336 1333
 	 * @return bool
1337 1334
 	 */
1338
-	public function remove_address( $address_id ) {
1335
+	public function remove_address($address_id) {
1339 1336
 		global $wpdb;
1340 1337
 
1341 1338
 		// Get address type.
1342
-		$is_multi_address = false !== strpos( $address_id, '_' ) ? true : false;
1339
+		$is_multi_address = false !== strpos($address_id, '_') ? true : false;
1343 1340
 
1344
-		$address_type = false !== strpos( $address_id, '_' ) ?
1345
-			array_shift( explode( '_', $address_id ) ) :
1346
-			$address_id;
1341
+		$address_type = false !== strpos($address_id, '_') ?
1342
+			array_shift(explode('_', $address_id)) : $address_id;
1347 1343
 
1348
-		$address_count = false !== strpos( $address_id, '_' ) ?
1349
-			array_pop( explode( '_', $address_id ) ) :
1350
-			null;
1344
+		$address_count = false !== strpos($address_id, '_') ?
1345
+			array_pop(explode('_', $address_id)) : null;
1351 1346
 
1352 1347
 		// Set meta key prefix.
1353 1348
 		$meta_key_prefix = "_give_donor_address_{$address_type}_%";
1354
-		if ( $is_multi_address && is_numeric( $address_count ) ) {
1349
+		if ($is_multi_address && is_numeric($address_count)) {
1355 1350
 			$meta_key_prefix .= "_{$address_count}";
1356 1351
 		}
1357 1352
 
@@ -1388,23 +1383,21 @@  discard block
 block discarded – undo
1388 1383
 	 *
1389 1384
 	 * @return bool
1390 1385
 	 */
1391
-	public function update_address( $address_id, $address ) {
1386
+	public function update_address($address_id, $address) {
1392 1387
 		global $wpdb;
1393 1388
 
1394 1389
 		// Get address type.
1395
-		$is_multi_address = false !== strpos( $address_id, '_' ) ? true : false;
1390
+		$is_multi_address = false !== strpos($address_id, '_') ? true : false;
1396 1391
 
1397
-		$address_type = false !== strpos( $address_id, '_' ) ?
1398
-			array_shift( explode( '_', $address_id ) ) :
1399
-			$address_id;
1392
+		$address_type = false !== strpos($address_id, '_') ?
1393
+			array_shift(explode('_', $address_id)) : $address_id;
1400 1394
 
1401
-		$address_count = false !== strpos( $address_id, '_' ) ?
1402
-			array_pop( explode( '_', $address_id ) ) :
1403
-			null;
1395
+		$address_count = false !== strpos($address_id, '_') ?
1396
+			array_pop(explode('_', $address_id)) : null;
1404 1397
 
1405 1398
 		// Set meta key prefix.
1406 1399
 		$meta_key_prefix = "_give_donor_address_{$address_type}_%";
1407
-		if ( $is_multi_address && is_numeric( $address_count ) ) {
1400
+		if ($is_multi_address && is_numeric($address_count)) {
1408 1401
 			$meta_key_prefix .= "_{$address_count}";
1409 1402
 		}
1410 1403
 
@@ -1425,12 +1418,12 @@  discard block
 block discarded – undo
1425 1418
 		);
1426 1419
 		
1427 1420
 		// Return result.
1428
-		if( ! count( $row_affected ) ) {
1421
+		if ( ! count($row_affected)) {
1429 1422
 			return false;
1430 1423
 		}
1431 1424
 
1432 1425
 		// Update address.
1433
-		if( ! $this->add_address( $address_id, $address ) ) {
1426
+		if ( ! $this->add_address($address_id, $address)) {
1434 1427
 			return false;
1435 1428
 		}
1436 1429
 
@@ -1449,39 +1442,39 @@  discard block
 block discarded – undo
1449 1442
 	 *
1450 1443
 	 * @return bool|null
1451 1444
 	 */
1452
-	public function is_address_exist( $current_address_type, $current_address ) {
1445
+	public function is_address_exist($current_address_type, $current_address) {
1453 1446
 		$status = false;
1454 1447
 
1455 1448
 		// Bailout.
1456
-		if( empty( $current_address_type ) || empty( $current_address ) ) {
1449
+		if (empty($current_address_type) || empty($current_address)) {
1457 1450
 			return null;
1458 1451
 		}
1459 1452
 
1460 1453
 		// Bailout.
1461
-		if( empty( $this->address ) || empty( $this->address[ $current_address_type ] ) ) {
1454
+		if (empty($this->address) || empty($this->address[$current_address_type])) {
1462 1455
 			return $status;
1463 1456
 		}
1464 1457
 
1465 1458
 		// Get address.
1466
-		$address = $this->address[ $current_address_type ];
1459
+		$address = $this->address[$current_address_type];
1467 1460
 
1468
-		switch ( true ){
1461
+		switch (true) {
1469 1462
 
1470 1463
 			// Single address.
1471
-			case is_string( end( $address ) ) :
1472
-				$status = $this->is_address_match( $current_address, $address );
1464
+			case is_string(end($address)) :
1465
+				$status = $this->is_address_match($current_address, $address);
1473 1466
 				break;
1474 1467
 
1475 1468
 			// Multi address.
1476
-			case is_array( end( $address ) ):
1469
+			case is_array(end($address)):
1477 1470
 				// Compare address.
1478
-				foreach ( $address as $saved_address ) {
1479
-					if( empty( $saved_address ) ) {
1471
+				foreach ($address as $saved_address) {
1472
+					if (empty($saved_address)) {
1480 1473
 						continue;
1481 1474
 					}
1482 1475
 
1483 1476
 					// Exit loop immediately if address exist.
1484
-					if( $status = $this->is_address_match( $current_address, $saved_address ) ) {
1477
+					if ($status = $this->is_address_match($current_address, $saved_address)) {
1485 1478
 						break;
1486 1479
 					}
1487 1480
 				}
@@ -1502,10 +1495,10 @@  discard block
 block discarded – undo
1502 1495
 	 *
1503 1496
 	 * @return bool
1504 1497
 	 */
1505
-	private function is_address_match( $address_1, $address_2 ) {
1506
-		$result = array_diff( $address_1, $address_2 );
1498
+	private function is_address_match($address_1, $address_2) {
1499
+		$result = array_diff($address_1, $address_2);
1507 1500
 
1508
-		return empty( $result );
1501
+		return empty($result);
1509 1502
 	}
1510 1503
 
1511 1504
 	/**
@@ -1515,22 +1508,22 @@  discard block
 block discarded – undo
1515 1508
 	 * @since   2.0
1516 1509
 	 * @return  object
1517 1510
 	 */
1518
-	public function split_donor_name( $id ) {
1519
-		$first_name = $last_name  = '';
1520
-		$donor      = new Give_Donor( $id );
1511
+	public function split_donor_name($id) {
1512
+		$first_name = $last_name = '';
1513
+		$donor      = new Give_Donor($id);
1521 1514
 
1522
-		$split_donor_name = explode( ' ', $donor->name, 2 );
1515
+		$split_donor_name = explode(' ', $donor->name, 2);
1523 1516
 
1524 1517
 		// Check for existence of first name after split of donor name.
1525
-		if( is_array( $split_donor_name ) && ! empty( $split_donor_name[0] ) ) {
1518
+		if (is_array($split_donor_name) && ! empty($split_donor_name[0])) {
1526 1519
 			$first_name = $split_donor_name[0];
1527 1520
 		}
1528 1521
 
1529 1522
 		// Check for existence of last name after split of donor name.
1530
-		if( is_array( $split_donor_name ) && ! empty( $split_donor_name[1] ) ) {
1523
+		if (is_array($split_donor_name) && ! empty($split_donor_name[1])) {
1531 1524
 			$last_name = $split_donor_name[1];
1532 1525
 		}
1533
-		return (object) array( 'first_name' => $first_name, 'last_name' => $last_name );
1526
+		return (object) array('first_name' => $first_name, 'last_name' => $last_name);
1534 1527
 	}
1535 1528
 
1536 1529
 	/**
@@ -1540,9 +1533,9 @@  discard block
 block discarded – undo
1540 1533
 	 * @return  string
1541 1534
 	 */
1542 1535
 	public function get_first_name() {
1543
-		$first_name = $this->get_meta( '_give_donor_first_name');
1544
-		if( ! $first_name ) {
1545
-			$first_name = $this->split_donor_name( $this->id )->first_name;
1536
+		$first_name = $this->get_meta('_give_donor_first_name');
1537
+		if ( ! $first_name) {
1538
+			$first_name = $this->split_donor_name($this->id)->first_name;
1546 1539
 		}
1547 1540
 
1548 1541
 		return $first_name;
@@ -1555,14 +1548,14 @@  discard block
 block discarded – undo
1555 1548
 	 * @return  string
1556 1549
 	 */
1557 1550
 	public function get_last_name() {
1558
-		$first_name = $this->get_meta( '_give_donor_first_name');
1559
-		$last_name = $this->get_meta( '_give_donor_last_name');
1551
+		$first_name = $this->get_meta('_give_donor_first_name');
1552
+		$last_name = $this->get_meta('_give_donor_last_name');
1560 1553
 
1561 1554
 		// This condition will prevent unnecessary splitting of donor name to fetch last name.
1562
-		if( ! $first_name && ! $last_name ) {
1563
-			$last_name = $this->split_donor_name( $this->id )->last_name;
1555
+		if ( ! $first_name && ! $last_name) {
1556
+			$last_name = $this->split_donor_name($this->id)->last_name;
1564 1557
 		}
1565 1558
 
1566
-		return ( $last_name ) ? $last_name : '';
1559
+		return ($last_name) ? $last_name : '';
1567 1560
 	}
1568 1561
 }
Please login to merge, or discard this patch.
includes/class-give-session.php 1 patch
Spacing   +76 added lines, -76 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
 
@@ -74,57 +74,57 @@  discard block
 block discarded – undo
74 74
 	public function __construct() {
75 75
 
76 76
 		$this->use_php_sessions = $this->use_php_sessions();
77
-		$this->exp_option       = give_get_option( 'session_lifetime' );
77
+		$this->exp_option       = give_get_option('session_lifetime');
78 78
 
79 79
 		// PHP Sessions.
80
-		if ( $this->use_php_sessions ) {
80
+		if ($this->use_php_sessions) {
81 81
 
82
-			if ( is_multisite() ) {
82
+			if (is_multisite()) {
83 83
 
84
-				$this->prefix = '_' . get_current_blog_id();
84
+				$this->prefix = '_'.get_current_blog_id();
85 85
 
86 86
 			}
87 87
 
88
-			add_action( 'init', array( $this, 'maybe_start_session' ), - 2 );
88
+			add_action('init', array($this, 'maybe_start_session'), - 2);
89 89
 
90 90
 		} else {
91 91
 
92
-			if ( ! $this->should_start_session() ) {
92
+			if ( ! $this->should_start_session()) {
93 93
 				return;
94 94
 			}
95 95
 
96 96
 			// Use WP_Session.
97
-			if ( ! defined( 'WP_SESSION_COOKIE' ) ) {
98
-				define( 'WP_SESSION_COOKIE', 'give_wp_session' );
97
+			if ( ! defined('WP_SESSION_COOKIE')) {
98
+				define('WP_SESSION_COOKIE', 'give_wp_session');
99 99
 			}
100 100
 
101
-			if ( ! class_exists( 'Recursive_ArrayAccess' ) ) {
102
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-recursive-arrayaccess.php';
101
+			if ( ! class_exists('Recursive_ArrayAccess')) {
102
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-recursive-arrayaccess.php';
103 103
 			}
104 104
 
105 105
 			// Include utilities class
106
-			if ( ! class_exists( 'WP_Session_Utils' ) ) {
107
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-wp-session-utils.php';
106
+			if ( ! class_exists('WP_Session_Utils')) {
107
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-wp-session-utils.php';
108 108
 			}
109
-			if ( ! class_exists( 'WP_Session' ) ) {
110
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-wp-session.php';
111
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/wp-session.php';
109
+			if ( ! class_exists('WP_Session')) {
110
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-wp-session.php';
111
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/wp-session.php';
112 112
 			}
113 113
 
114
-			add_filter( 'wp_session_expiration_variant', array( $this, 'set_expiration_variant_time' ), 99999 );
115
-			add_filter( 'wp_session_expiration', array( $this, 'set_expiration_time' ), 99999 );
114
+			add_filter('wp_session_expiration_variant', array($this, 'set_expiration_variant_time'), 99999);
115
+			add_filter('wp_session_expiration', array($this, 'set_expiration_time'), 99999);
116 116
 
117 117
 		}
118 118
 
119 119
 		// Init Session.
120
-		if ( empty( $this->session ) && ! $this->use_php_sessions ) {
121
-			add_action( 'plugins_loaded', array( $this, 'init' ), 9999 );
120
+		if (empty($this->session) && ! $this->use_php_sessions) {
121
+			add_action('plugins_loaded', array($this, 'init'), 9999);
122 122
 		} else {
123
-			add_action( 'init', array( $this, 'init' ), - 1 );
123
+			add_action('init', array($this, 'init'), - 1);
124 124
 		}
125 125
 
126 126
 		// Set cookie on Donation Completion page.
127
-		add_action( 'give_pre_process_donation', array( $this, 'set_session_cookies' ) );
127
+		add_action('give_pre_process_donation', array($this, 'set_session_cookies'));
128 128
 
129 129
 	}
130 130
 
@@ -140,8 +140,8 @@  discard block
 block discarded – undo
140 140
 	 */
141 141
 	public function init() {
142 142
 
143
-		if ( $this->use_php_sessions ) {
144
-			$this->session = isset( $_SESSION[ 'give' . $this->prefix ] ) && is_array( $_SESSION[ 'give' . $this->prefix ] ) ? $_SESSION[ 'give' . $this->prefix ] : array();
143
+		if ($this->use_php_sessions) {
144
+			$this->session = isset($_SESSION['give'.$this->prefix]) && is_array($_SESSION['give'.$this->prefix]) ? $_SESSION['give'.$this->prefix] : array();
145 145
 		} else {
146 146
 			$this->session = WP_Session::get_instance();
147 147
 		}
@@ -176,37 +176,37 @@  discard block
 block discarded – undo
176 176
 	 *
177 177
 	 * @return string|array      Session variable.
178 178
 	 */
179
-	public function get( $key ) {
180
-		$key    = sanitize_key( $key );
179
+	public function get($key) {
180
+		$key    = sanitize_key($key);
181 181
 		$return = false;
182 182
 
183
-		if ( isset( $this->session[ $key ] ) && ! empty( $this->session[ $key ] ) ) {
183
+		if (isset($this->session[$key]) && ! empty($this->session[$key])) {
184 184
 
185
-			preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $this->session[ $key ], $matches );
186
-			if ( ! empty( $matches ) ) {
187
-				$this->set( $key, null );
185
+			preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $this->session[$key], $matches);
186
+			if ( ! empty($matches)) {
187
+				$this->set($key, null);
188 188
 
189 189
 				return false;
190 190
 			}
191 191
 
192
-			if ( is_numeric( $this->session[ $key ] ) ) {
193
-				$return = $this->session[ $key ];
192
+			if (is_numeric($this->session[$key])) {
193
+				$return = $this->session[$key];
194 194
 			} else {
195 195
 
196
-				$maybe_json = json_decode( $this->session[ $key ] );
196
+				$maybe_json = json_decode($this->session[$key]);
197 197
 
198 198
 				// Since json_last_error is PHP 5.3+, we have to rely on a `null` value for failing to parse JSON.
199
-				if ( is_null( $maybe_json ) ) {
200
-					$is_serialized = is_serialized( $this->session[ $key ] );
201
-					if ( $is_serialized ) {
202
-						$value = @unserialize( $this->session[ $key ] );
203
-						$this->set( $key, (array) $value );
199
+				if (is_null($maybe_json)) {
200
+					$is_serialized = is_serialized($this->session[$key]);
201
+					if ($is_serialized) {
202
+						$value = @unserialize($this->session[$key]);
203
+						$this->set($key, (array) $value);
204 204
 						$return = $value;
205 205
 					} else {
206
-						$return = $this->session[ $key ];
206
+						$return = $this->session[$key];
207 207
 					}
208 208
 				} else {
209
-					$return = json_decode( $this->session[ $key ], true );
209
+					$return = json_decode($this->session[$key], true);
210 210
 				}
211 211
 
212 212
 			}
@@ -229,21 +229,21 @@  discard block
 block discarded – undo
229 229
 	 *
230 230
 	 * @return string        Session variable.
231 231
 	 */
232
-	public function set( $key, $value ) {
232
+	public function set($key, $value) {
233 233
 
234
-		$key = sanitize_key( $key );
234
+		$key = sanitize_key($key);
235 235
 
236
-		if ( is_array( $value ) ) {
237
-			$this->session[ $key ] = wp_json_encode( $value );
236
+		if (is_array($value)) {
237
+			$this->session[$key] = wp_json_encode($value);
238 238
 		} else {
239
-			$this->session[ $key ] = esc_attr( $value );
239
+			$this->session[$key] = esc_attr($value);
240 240
 		}
241 241
 
242
-		if ( $this->use_php_sessions ) {
243
-			$_SESSION[ 'give' . $this->prefix ] = $this->session;
242
+		if ($this->use_php_sessions) {
243
+			$_SESSION['give'.$this->prefix] = $this->session;
244 244
 		}
245 245
 
246
-		return $this->session[ $key ];
246
+		return $this->session[$key];
247 247
 	}
248 248
 
249 249
 	/**
@@ -258,10 +258,10 @@  discard block
 block discarded – undo
258 258
 	 * @hook
259 259
 	 */
260 260
 	public function set_session_cookies() {
261
-		if ( ! headers_sent() ) {
262
-			$lifetime = current_time( 'timestamp' ) + $this->set_expiration_time();
263
-			@setcookie( session_name(), session_id(), $lifetime, COOKIEPATH, COOKIE_DOMAIN, false );
264
-			@setcookie( session_name() . '_expiration', $lifetime, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false );
261
+		if ( ! headers_sent()) {
262
+			$lifetime = current_time('timestamp') + $this->set_expiration_time();
263
+			@setcookie(session_name(), session_id(), $lifetime, COOKIEPATH, COOKIE_DOMAIN, false);
264
+			@setcookie(session_name().'_expiration', $lifetime, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false);
265 265
 		}
266 266
 	}
267 267
 
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 	 */
278 278
 	public function set_expiration_variant_time() {
279 279
 
280
-		return ( ! empty( $this->exp_option ) ? ( intval( $this->exp_option ) - 3600 ) : 30 * 60 * 23 );
280
+		return ( ! empty($this->exp_option) ? (intval($this->exp_option) - 3600) : 30 * 60 * 23);
281 281
 	}
282 282
 
283 283
 	/**
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 	 */
293 293
 	public function set_expiration_time() {
294 294
 
295
-		return ( ! empty( $this->exp_option ) ? intval( $this->exp_option ) : 30 * 60 * 24 );
295
+		return ( ! empty($this->exp_option) ? intval($this->exp_option) : 30 * 60 * 24);
296 296
 	}
297 297
 
298 298
 	/**
@@ -310,21 +310,21 @@  discard block
 block discarded – undo
310 310
 		$ret = false;
311 311
 
312 312
 		// If the database variable is already set, no need to run auto detection.
313
-		$give_use_php_sessions = (bool) get_option( 'give_use_php_sessions' );
313
+		$give_use_php_sessions = (bool) get_option('give_use_php_sessions');
314 314
 
315
-		if ( ! $give_use_php_sessions ) {
315
+		if ( ! $give_use_php_sessions) {
316 316
 
317 317
 			// Attempt to detect if the server supports PHP sessions.
318
-			if ( function_exists( 'session_start' ) && ! ini_get( 'safe_mode' ) ) {
318
+			if (function_exists('session_start') && ! ini_get('safe_mode')) {
319 319
 
320
-				$this->set( 'give_use_php_sessions', 1 );
320
+				$this->set('give_use_php_sessions', 1);
321 321
 
322
-				if ( $this->get( 'give_use_php_sessions' ) ) {
322
+				if ($this->get('give_use_php_sessions')) {
323 323
 
324 324
 					$ret = true;
325 325
 
326 326
 					// Set the database option.
327
-					update_option( 'give_use_php_sessions', true );
327
+					update_option('give_use_php_sessions', true);
328 328
 
329 329
 				}
330 330
 			}
@@ -334,13 +334,13 @@  discard block
 block discarded – undo
334 334
 		}
335 335
 
336 336
 		// Enable or disable PHP Sessions based on the GIVE_USE_PHP_SESSIONS constant.
337
-		if ( defined( 'GIVE_USE_PHP_SESSIONS' ) && GIVE_USE_PHP_SESSIONS ) {
337
+		if (defined('GIVE_USE_PHP_SESSIONS') && GIVE_USE_PHP_SESSIONS) {
338 338
 			$ret = true;
339
-		} elseif ( defined( 'GIVE_USE_PHP_SESSIONS' ) && ! GIVE_USE_PHP_SESSIONS ) {
339
+		} elseif (defined('GIVE_USE_PHP_SESSIONS') && ! GIVE_USE_PHP_SESSIONS) {
340 340
 			$ret = false;
341 341
 		}
342 342
 
343
-		return (bool) apply_filters( 'give_use_php_sessions', $ret );
343
+		return (bool) apply_filters('give_use_php_sessions', $ret);
344 344
 	}
345 345
 
346 346
 	/**
@@ -357,9 +357,9 @@  discard block
 block discarded – undo
357 357
 
358 358
 		$start_session = true;
359 359
 
360
-		if ( ! empty( $_SERVER['REQUEST_URI'] ) ) {
360
+		if ( ! empty($_SERVER['REQUEST_URI'])) {
361 361
 
362
-			$blacklist = apply_filters( 'give_session_start_uri_blacklist', array(
362
+			$blacklist = apply_filters('give_session_start_uri_blacklist', array(
363 363
 				'feed',
364 364
 				'feed',
365 365
 				'feed/rss',
@@ -367,21 +367,21 @@  discard block
 block discarded – undo
367 367
 				'feed/rdf',
368 368
 				'feed/atom',
369 369
 				'comments/feed/',
370
-			) );
371
-			$uri       = ltrim( $_SERVER['REQUEST_URI'], '/' );
372
-			$uri       = untrailingslashit( $uri );
373
-			if ( in_array( $uri, $blacklist ) ) {
370
+			));
371
+			$uri       = ltrim($_SERVER['REQUEST_URI'], '/');
372
+			$uri       = untrailingslashit($uri);
373
+			if (in_array($uri, $blacklist)) {
374 374
 				$start_session = false;
375 375
 			}
376
-			if ( false !== strpos( $uri, 'feed=' ) ) {
376
+			if (false !== strpos($uri, 'feed=')) {
377 377
 				$start_session = false;
378 378
 			}
379
-			if ( is_admin() ) {
379
+			if (is_admin()) {
380 380
 				$start_session = false;
381 381
 			}
382 382
 		}
383 383
 
384
-		return apply_filters( 'give_start_session', $start_session );
384
+		return apply_filters('give_start_session', $start_session);
385 385
 	}
386 386
 
387 387
 	/**
@@ -397,11 +397,11 @@  discard block
 block discarded – undo
397 397
 	 */
398 398
 	public function maybe_start_session() {
399 399
 
400
-		if ( ! $this->should_start_session() ) {
400
+		if ( ! $this->should_start_session()) {
401 401
 			return;
402 402
 		}
403 403
 
404
-		if ( ! session_id() && ! headers_sent() ) {
404
+		if ( ! session_id() && ! headers_sent()) {
405 405
 			session_start();
406 406
 		}
407 407
 
@@ -420,9 +420,9 @@  discard block
 block discarded – undo
420 420
 
421 421
 		$expiration = false;
422 422
 
423
-		if ( session_id() && isset( $_COOKIE[ session_name() . '_expiration' ] ) ) {
423
+		if (session_id() && isset($_COOKIE[session_name().'_expiration'])) {
424 424
 
425
-			$expiration = date( 'D, d M Y h:i:s', intval( $_COOKIE[ session_name() . '_expiration' ] ) );
425
+			$expiration = date('D, d M Y h:i:s', intval($_COOKIE[session_name().'_expiration']));
426 426
 
427 427
 		}
428 428
 
Please login to merge, or discard this patch.
includes/admin/class-blank-slate.php 1 patch
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  * @since       1.8.13
10 10
  */
11 11
 
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit;
14 14
 }
15 15
 
@@ -75,63 +75,63 @@  discard block
 block discarded – undo
75 75
 	 */
76 76
 	public function init() {
77 77
 		// Bail early if screen cannot be detected.
78
-		if ( empty( $this->screen ) ) {
78
+		if (empty($this->screen)) {
79 79
 			return null;
80 80
 		}
81 81
 
82 82
 		$content = array();
83 83
 
84 84
 		// Define content and hook into the appropriate action.
85
-		switch ( $this->screen ) {
85
+		switch ($this->screen) {
86 86
 			// Forms screen.
87 87
 			case 'edit-give_forms':
88
-				$this->form = $this->post_exists( 'give_forms' );
88
+				$this->form = $this->post_exists('give_forms');
89 89
 
90
-				if ( $this->form ) {
90
+				if ($this->form) {
91 91
 					// Form exists. Bail out.
92 92
 					return false;
93 93
 				} else {
94 94
 					// No forms exist.
95
-					$content = $this->get_content( 'no_forms' );
95
+					$content = $this->get_content('no_forms');
96 96
 				}
97 97
 
98
-				add_action( 'manage_posts_extra_tablenav', array( $this, 'render' ) );
98
+				add_action('manage_posts_extra_tablenav', array($this, 'render'));
99 99
 				break;
100 100
 			// Donations screen.
101 101
 			case 'give_forms_page_give-payment-history':
102
-				$this->form     = $this->post_exists( 'give_forms' );
103
-				$this->donation = $this->post_exists( 'give_payment' );
102
+				$this->form     = $this->post_exists('give_forms');
103
+				$this->donation = $this->post_exists('give_payment');
104 104
 
105
-				if ( $this->donation ) {
105
+				if ($this->donation) {
106 106
 					// Donation exists. Bail out.
107 107
 					return false;
108
-				} elseif ( ! $this->form ) {
108
+				} elseif ( ! $this->form) {
109 109
 					// No forms and no donations exist.
110
-					$content = $this->get_content( 'no_donations_or_forms' );
110
+					$content = $this->get_content('no_donations_or_forms');
111 111
 				} else {
112 112
 					// No donations exist but a form does exist.
113
-					$content = $this->get_content( 'no_donations' );
113
+					$content = $this->get_content('no_donations');
114 114
 				}
115 115
 
116
-				add_action( 'give_payments_page_bottom', array( $this, 'render' ) );
116
+				add_action('give_payments_page_bottom', array($this, 'render'));
117 117
 				break;
118 118
 			// Donors screen.
119 119
 			case 'give_forms_page_give-donors':
120
-				$this->form  = $this->post_exists( 'give_forms' );
120
+				$this->form  = $this->post_exists('give_forms');
121 121
 				$this->donor = $this->donor_exists();
122 122
 
123
-				if ( $this->donor ) {
123
+				if ($this->donor) {
124 124
 					// Donor exists. Bail out.
125 125
 					return false;
126
-				} elseif ( ! $this->form ) {
126
+				} elseif ( ! $this->form) {
127 127
 					// No forms and no donors exist.
128
-					$content = $this->get_content( 'no_donors_or_forms' );
128
+					$content = $this->get_content('no_donors_or_forms');
129 129
 				} else {
130 130
 					// No donors exist but a form does exist.
131
-					$content = $this->get_content( 'no_donors' );
131
+					$content = $this->get_content('no_donors');
132 132
 				}
133 133
 
134
-				add_action( 'give_donors_table_bottom', array( $this, 'render' ) );
134
+				add_action('give_donors_table_bottom', array($this, 'render'));
135 135
 				break;
136 136
 			default:
137 137
 				return null;
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 		$this->content = $content;
141 141
 
142 142
 		// Hide non-essential UI elements.
143
-		add_action( 'admin_head', array( $this, 'hide_ui' ) );
143
+		add_action('admin_head', array($this, 'hide_ui'));
144 144
 	}
145 145
 
146 146
 	/**
@@ -150,9 +150,9 @@  discard block
 block discarded – undo
150 150
 	 *
151 151
 	 * @param string $which The location of the list table hook: 'top' or 'bottom'.
152 152
 	 */
153
-	public function render( $which = 'bottom') {
153
+	public function render($which = 'bottom') {
154 154
 		// Bail out to prevent content from rendering twice.
155
-		if ( 'top' === $which ) {
155
+		if ('top' === $which) {
156 156
 			return null;
157 157
 		}
158 158
 
@@ -177,9 +177,9 @@  discard block
 block discarded – undo
177 177
 		 *
178 178
 		 * @param string $screen The current screen ID.
179 179
 		 */
180
-		$content = apply_filters( 'give_blank_slate_content', $this->content, $screen );
180
+		$content = apply_filters('give_blank_slate_content', $this->content, $screen);
181 181
 
182
-		$template_path = GIVE_PLUGIN_DIR . 'includes/admin/views/blank-slate.php';
182
+		$template_path = GIVE_PLUGIN_DIR.'includes/admin/views/blank-slate.php';
183 183
 
184 184
 		include $template_path;
185 185
 	}
@@ -201,17 +201,17 @@  discard block
 block discarded – undo
201 201
 	 * @param string $post_type Post type used in the query.
202 202
 	 * @return bool True if post exists, otherwise false.
203 203
 	 */
204
-	private function post_exists( $post_type ) {
204
+	private function post_exists($post_type) {
205 205
 		// Attempt to get a single post of the post type.
206
-		$query = new WP_Query( array(
206
+		$query = new WP_Query(array(
207 207
 			'post_type'              => $post_type,
208 208
 			'posts_per_page'         => 1,
209 209
 			'no_found_rows'          => false,
210 210
 			'update_post_meta_cache' => false,
211 211
 			'update_post_term_cache' => false,
212 212
 			'fields'                 => 'ids',
213
-			'post_status'            => array( 'any', 'trash' ),
214
-		) );
213
+			'post_status'            => array('any', 'trash'),
214
+		));
215 215
 
216 216
 		return $query->have_posts();
217 217
 	}
@@ -224,9 +224,9 @@  discard block
 block discarded – undo
224 224
 	 * @return bool True if donor exists, otherwise false.
225 225
 	 */
226 226
 	private function donor_exists() {
227
-		$donors = Give()->donors->get_donors( array( 'number' => 1 ) );
227
+		$donors = Give()->donors->get_donors(array('number' => 1));
228 228
 
229
-		return ! empty( $donors );
229
+		return ! empty($donors);
230 230
 	}
231 231
 
232 232
 	/**
@@ -237,17 +237,17 @@  discard block
 block discarded – undo
237 237
 	 * @param string $context The key used to determine which content is returned.
238 238
 	 * @return array Blank slate content.
239 239
 	 */
240
-	private function get_content( $context ) {
240
+	private function get_content($context) {
241 241
 		// Define default content.
242 242
 		$defaults = array(
243
-			'image_url' => GIVE_PLUGIN_URL . 'assets/images/svg/give-icon-full-circle.svg',
244
-			'image_alt' => __( 'Give Icon', 'give' ),
245
-			'heading'   => __( 'No donation forms  found.', 'give' ),
246
-			'message'   => __( 'The first step towards accepting online donations is to create a form.', 'give' ),
247
-			'cta_text'  => __( 'Create Donation Form', 'give' ),
248
-			'cta_link'  => admin_url( 'post-new.php?post_type=give_forms' ),
243
+			'image_url' => GIVE_PLUGIN_URL.'assets/images/svg/give-icon-full-circle.svg',
244
+			'image_alt' => __('Give Icon', 'give'),
245
+			'heading'   => __('No donation forms  found.', 'give'),
246
+			'message'   => __('The first step towards accepting online donations is to create a form.', 'give'),
247
+			'cta_text'  => __('Create Donation Form', 'give'),
248
+			'cta_link'  => admin_url('post-new.php?post_type=give_forms'),
249 249
 			'help'      => sprintf(
250
-				__( 'Need help? Get started with %sGive 101%s.', 'wbpr' ),
250
+				__('Need help? Get started with %sGive 101%s.', 'wbpr'),
251 251
 				'<a href="http://docs.givewp.com/give101/" target="_blank">',
252 252
 				'</a>'
253 253
 			),
@@ -256,40 +256,40 @@  discard block
 block discarded – undo
256 256
 		// Define contextual content.
257 257
 		$content = array(
258 258
 			'no_donations_or_forms' => array(
259
-				'heading' => __( 'No donations found.', 'give' ),
260
-				'message' => __( 'Your donation history will appear here, but first, you need a donation form!', 'give' ),
259
+				'heading' => __('No donations found.', 'give'),
260
+				'message' => __('Your donation history will appear here, but first, you need a donation form!', 'give'),
261 261
 			),
262 262
 			'no_donations'          => array(
263
-				'heading'  => __( 'No donations found.', 'give' ),
264
-				'message'  => __( 'When your first donation arrives, a record of the donation will appear here.', 'give' ),
265
-				'cta_text' => __( 'View All Forms', 'give' ),
266
-				'cta_link' => admin_url( 'edit.php?post_type=give_forms' ),
263
+				'heading'  => __('No donations found.', 'give'),
264
+				'message'  => __('When your first donation arrives, a record of the donation will appear here.', 'give'),
265
+				'cta_text' => __('View All Forms', 'give'),
266
+				'cta_link' => admin_url('edit.php?post_type=give_forms'),
267 267
 				'help'     => sprintf(
268
-					__( 'Need help? Learn more about %sDonations%s.', 'wbpr' ),
268
+					__('Need help? Learn more about %sDonations%s.', 'wbpr'),
269 269
 					'<a href="http://docs.givewp.com/core-donations/">',
270 270
 					'</a>'
271 271
 				),
272 272
 			),
273 273
 			'no_donors_or_forms'    => array(
274
-				'heading' => __( 'No donors  found.', 'give' ),
275
-				'message' => __( 'Your donor history will appear here, but first, you need a donation form!', 'give' ),
274
+				'heading' => __('No donors  found.', 'give'),
275
+				'message' => __('Your donor history will appear here, but first, you need a donation form!', 'give'),
276 276
 			),
277 277
 			'no_donors'             => array(
278
-				'heading'  => __( 'No donors found.', 'give' ),
279
-				'message'  => __( 'When your first donation arrives, the donor will appear here.', 'give' ),
280
-				'cta_text' => __( 'View All Forms', 'give' ),
281
-				'cta_link' => admin_url( 'edit.php?post_type=give_forms' ),
278
+				'heading'  => __('No donors found.', 'give'),
279
+				'message'  => __('When your first donation arrives, the donor will appear here.', 'give'),
280
+				'cta_text' => __('View All Forms', 'give'),
281
+				'cta_link' => admin_url('edit.php?post_type=give_forms'),
282 282
 				'help'     => sprintf(
283
-					__( 'Need help? Learn more about %sDonors%s.', 'wbpr' ),
283
+					__('Need help? Learn more about %sDonors%s.', 'wbpr'),
284 284
 					'<a href="http://docs.givewp.com/core-donors/">',
285 285
 					'</a>'
286 286
 				),
287 287
 			),
288 288
 		);
289 289
 
290
-		if ( isset( $content[ $context ] ) ) {
290
+		if (isset($content[$context])) {
291 291
 			// Merge contextual content with defaults.
292
-			return wp_parse_args( $content[ $context ], $defaults );
292
+			return wp_parse_args($content[$context], $defaults);
293 293
 		} else {
294 294
 			// Return defaults if context is undefined.
295 295
 			return $defaults;
Please login to merge, or discard this patch.
includes/admin/views/html-admin-settings.php 2 patches
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -95,5 +95,8 @@
 block discarded – undo
95 95
 		<?php endif; ?>
96 96
 		<?php echo $form_close_tag; ?>
97 97
 	</div>
98
-<?php else : echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>'; ?>
98
+<?php else {
99
+	: echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>';
100
+}
101
+?>
99 102
 <?php endif; ?>
100 103
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -2,12 +2,12 @@  discard block
 block discarded – undo
2 2
 /**
3 3
  * Admin View: Settings
4 4
  */
5
-if ( ! defined( 'ABSPATH' ) ) {
5
+if ( ! defined('ABSPATH')) {
6 6
 	exit;
7 7
 }
8 8
 
9 9
 // Bailout: Do not output anything if setting tab is not defined.
10
-if ( ! empty( $tabs ) && array_key_exists( give_get_current_setting_tab(), $tabs ) ) :
10
+if ( ! empty($tabs) && array_key_exists(give_get_current_setting_tab(), $tabs)) :
11 11
 	/**
12 12
 	 * Filter the form action.
13 13
 	 *
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 	 *
18 18
 	 * @since 1.8
19 19
 	 */
20
-	$form_method = apply_filters( self::$setting_filter_prefix . '_form_method_tab_' . $current_tab, 'post' );
20
+	$form_method = apply_filters(self::$setting_filter_prefix.'_form_method_tab_'.$current_tab, 'post');
21 21
 
22 22
 	/**
23 23
 	 * Filter the main form tab.
@@ -29,14 +29,14 @@  discard block
 block discarded – undo
29 29
 	 *
30 30
 	 * @since 1.8
31 31
 	 */
32
-	$form_open_tag  = apply_filters( self::$setting_filter_prefix . '_open_form', '<form method="' . $form_method . '" id="give-mainform" action="" enctype="multipart/form-data">' );
33
-	$form_close_tag = apply_filters( self::$setting_filter_prefix . '_close_form', '</form>' );
32
+	$form_open_tag  = apply_filters(self::$setting_filter_prefix.'_open_form', '<form method="'.$form_method.'" id="give-mainform" action="" enctype="multipart/form-data">');
33
+	$form_close_tag = apply_filters(self::$setting_filter_prefix.'_close_form', '</form>');
34 34
 
35
-	$wrapper_class = implode( ' ',
35
+	$wrapper_class = implode(' ',
36 36
 		array(
37
-			self::$setting_filter_prefix . '-setting-page',
38
-			self::$setting_filter_prefix . '-' . give_get_current_setting_section() . '-section',
39
-			self::$setting_filter_prefix . '-' . give_get_current_setting_tab() . '-tab',
37
+			self::$setting_filter_prefix.'-setting-page',
38
+			self::$setting_filter_prefix.'-'.give_get_current_setting_section().'-section',
39
+			self::$setting_filter_prefix.'-'.give_get_current_setting_tab().'-tab',
40 40
 		)
41 41
 	);
42 42
 	?>
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 
47 47
 		/* @var Give_Settings_Page $current_setting_obj */
48 48
 		if (
49
-			! empty( $current_setting_obj ) &&
50
-			method_exists( $current_setting_obj, 'get_heading_html' )
49
+			! empty($current_setting_obj) &&
50
+			method_exists($current_setting_obj, 'get_heading_html')
51 51
 		) {
52 52
 			echo $current_setting_obj->get_heading_html();
53 53
 		} else {
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 			// Backward compatibility.
56 56
 			echo sprintf(
57 57
 				'<h1 class="wp-heading-inline">%s</h1><hr class="wp-header-end">',
58
-				esc_html( $tabs[ $current_tab ] )
58
+				esc_html($tabs[$current_tab])
59 59
 			);
60 60
 		}
61 61
 
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
 		?>
64 64
 		<div class="nav-tab-wrapper give-nav-tab-wrapper">
65 65
 			<?php
66
-			foreach ( $tabs as $name => $label ) {
67
-				echo '<a href="' . admin_url( "edit.php?post_type=give_forms&page=" . self::$setting_filter_prefix . "&tab={$name}" ) . '" class="nav-tab ' . ( $current_tab === $name ? 'nav-tab-active' : 'give-mobile-hidden' ) . '">' . $label . '</a>';
66
+			foreach ($tabs as $name => $label) {
67
+				echo '<a href="'.admin_url("edit.php?post_type=give_forms&page=".self::$setting_filter_prefix."&tab={$name}").'" class="nav-tab '.($current_tab === $name ? 'nav-tab-active' : 'give-mobile-hidden').'">'.$label.'</a>';
68 68
 			}
69 69
 
70 70
 			/**
@@ -76,10 +76,10 @@  discard block
 block discarded – undo
76 76
 			 *
77 77
 			 * @since 1.8
78 78
 			 */
79
-			do_action( self::$setting_filter_prefix . '_tabs' );
79
+			do_action(self::$setting_filter_prefix.'_tabs');
80 80
 			?>
81 81
 			<div class="give-sub-nav-tab-wrapper">
82
-				<a href="#" id="give-show-sub-nav" class="nav-tab give-not-tab" title="<?php _e( 'View remaining setting tabs', 'give' ); ?>"><span class="dashicons dashicons-arrow-down-alt2"></span></span>
82
+				<a href="#" id="give-show-sub-nav" class="nav-tab give-not-tab" title="<?php _e('View remaining setting tabs', 'give'); ?>"><span class="dashicons dashicons-arrow-down-alt2"></span></span>
83 83
 				</a>
84 84
 				<nav class="give-sub-nav-tab give-hidden"></nav>
85 85
 			</div>
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 		 *
96 96
 		 * @since 1.8
97 97
 		 */
98
-		do_action( self::$setting_filter_prefix . "_sections_{$current_tab}_page" );
98
+		do_action(self::$setting_filter_prefix."_sections_{$current_tab}_page");
99 99
 
100 100
 		/**
101 101
 		 * Trigger Action.
@@ -106,15 +106,15 @@  discard block
 block discarded – undo
106 106
 		 *
107 107
 		 * @since 1.8
108 108
 		 */
109
-		do_action( self::$setting_filter_prefix . "_settings_{$current_tab}_page" );
109
+		do_action(self::$setting_filter_prefix."_settings_{$current_tab}_page");
110 110
 
111
-		if ( empty( $GLOBALS['give_hide_save_button'] ) ) : ?>
111
+		if (empty($GLOBALS['give_hide_save_button'])) : ?>
112 112
 			<div class="give-submit-wrap">
113
-				<?php wp_nonce_field( 'give-save-settings', '_give-save-settings' ); ?>
114
-				<input name="save" class="button-primary give-save-button" type="submit" value="<?php _e( 'Save changes', 'give' ); ?>"/>
113
+				<?php wp_nonce_field('give-save-settings', '_give-save-settings'); ?>
114
+				<input name="save" class="button-primary give-save-button" type="submit" value="<?php _e('Save changes', 'give'); ?>"/>
115 115
 			</div>
116 116
 		<?php endif; ?>
117 117
 		<?php echo $form_close_tag; ?>
118 118
 	</div>
119
-<?php else : echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>'; ?>
119
+<?php else : echo '<div class="error"><p>'.__('Oops, this settings page does not exist.', 'give').'</p></div>'; ?>
120 120
 <?php endif; ?>
121 121
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/views/blank-slate.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -17,23 +17,23 @@  discard block
 block discarded – undo
17 17
 ?>
18 18
 
19 19
 <div class="give-blank-slate">
20
-	<?php if ( ! empty( $content['image_url'] ) ) : ?>
21
-		<img class="give-blank-slate__image" src="<?php echo esc_url( $content['image_url'] ); ?>" alt="<?php echo esc_attr( $content['image_alt'] ); ?>">
20
+	<?php if ( ! empty($content['image_url'])) : ?>
21
+		<img class="give-blank-slate__image" src="<?php echo esc_url($content['image_url']); ?>" alt="<?php echo esc_attr($content['image_alt']); ?>">
22 22
 	<?php endif; ?>
23 23
 
24
-	<?php if ( ! empty( $content['heading'] ) ) : ?>
25
-		<h2 class="give-blank-slate__heading"><?php esc_html_e( $content['heading'] ); ?></h2>
24
+	<?php if ( ! empty($content['heading'])) : ?>
25
+		<h2 class="give-blank-slate__heading"><?php esc_html_e($content['heading']); ?></h2>
26 26
 	<?php endif; ?>
27 27
 
28
-	<?php if ( ! empty( $content['message'] ) ) : ?>
29
-		<p class="give-blank-slate__message"><?php esc_html_e( $content['message'] ); ?></p>
28
+	<?php if ( ! empty($content['message'])) : ?>
29
+		<p class="give-blank-slate__message"><?php esc_html_e($content['message']); ?></p>
30 30
 	<?php endif; ?>
31 31
 
32
-	<?php if ( ! empty( $content['cta_text']) && ! empty( $content['cta_link'] ) ) : ?>
33
-		<a class="give-blank-slate__cta button button-primary" href="<?php echo esc_url( $content['cta_link'] ); ?>"><?php esc_html_e( $content['cta_text'] ); ?></a>
32
+	<?php if ( ! empty($content['cta_text']) && ! empty($content['cta_link'])) : ?>
33
+		<a class="give-blank-slate__cta button button-primary" href="<?php echo esc_url($content['cta_link']); ?>"><?php esc_html_e($content['cta_text']); ?></a>
34 34
 	<?php endif; ?>
35 35
 
36
-	<?php if ( ! empty( $content['help'] ) ) : ?>
36
+	<?php if ( ! empty($content['help'])) : ?>
37 37
 		<p class="give-blank-slate__help">
38 38
 			<?php
39 39
 			$allowed_html = array(
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 				'code'   => array(),
48 48
 			);
49 49
 
50
-			echo wp_kses( $content['help'], $allowed_html );
50
+			echo wp_kses($content['help'], $allowed_html);
51 51
 			?>
52 52
 		</p>
53 53
 	<?php endif; ?>
Please login to merge, or discard this patch.
includes/admin/tools/data/tools-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
 
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -20,10 +20,10 @@  discard block
 block discarded – undo
20 20
  * @since  1.5
21 21
  */
22 22
 function give_register_batch_recount_export_classes() {
23
-	add_action( 'give_batch_export_class_include', 'give_include_batch_export_class', 10, 1 );
23
+	add_action('give_batch_export_class_include', 'give_include_batch_export_class', 10, 1);
24 24
 }
25 25
 
26
-add_action( 'give_register_batch_exporter', 'give_register_batch_recount_export_classes', 10 );
26
+add_action('give_register_batch_exporter', 'give_register_batch_recount_export_classes', 10);
27 27
 
28 28
 
29 29
 /**
@@ -35,39 +35,39 @@  discard block
 block discarded – undo
35 35
  *
36 36
  * @return void
37 37
  */
38
-function give_include_batch_export_class( $class ) {
39
-	switch ( $class ) {
38
+function give_include_batch_export_class($class) {
39
+	switch ($class) {
40 40
 
41 41
 		case 'Give_Tools_Delete_Donors':
42
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-delete-test-donors.php';
42
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-delete-test-donors.php';
43 43
 			break;
44 44
 
45 45
 		case 'Give_Tools_Import_Donors':
46
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-delete-import-donors.php';
46
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-delete-import-donors.php';
47 47
 			break;
48 48
 
49 49
 		case 'Give_Tools_Delete_Test_Transactions':
50
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-delete-test-transactions.php';
50
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-delete-test-transactions.php';
51 51
 			break;
52 52
 
53 53
 		case 'Give_Tools_Recount_Donor_Stats':
54
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-donor-stats.php';
54
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-donor-stats.php';
55 55
 			break;
56 56
 
57 57
 		case 'Give_Tools_Reset_Stats':
58
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-reset-stats.php';
58
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-reset-stats.php';
59 59
 			break;
60 60
 
61 61
 		case 'Give_Tools_Recount_All_Stats':
62
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-all-stats.php';
62
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-all-stats.php';
63 63
 			break;
64 64
 
65 65
 		case 'Give_Tools_Recount_Form_Stats':
66
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-form-stats.php';
66
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-form-stats.php';
67 67
 			break;
68 68
 
69 69
 		case 'Give_Tools_Recount_Income':
70
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-income.php';
70
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-income.php';
71 71
 			break;
72 72
 	}
73 73
 }
Please login to merge, or discard this patch.
includes/payments/class-give-payment.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1012,7 +1012,7 @@
 block discarded – undo
1012 1012
 					// Find a match between price_id and level_id.
1013 1013
 					// First verify array keys exists THEN make the match.
1014 1014
 					if ( ( isset( $args['price_id'] ) && isset( $price['_give_id']['level_id'] ) )
1015
-					     && $args['price_id'] == $price['_give_id']['level_id']
1015
+						 && $args['price_id'] == $price['_give_id']['level_id']
1016 1016
 					) {
1017 1017
 						$donation_amount = $price['_give_amount'];
1018 1018
 					}
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
 	 *
392 392
 	 * @param  int|bool $payment_id A given payment
393 393
 	 *
394
-	 * @return mixed void|false
394
+	 * @return false|null void|false
395 395
 	 */
396 396
 	public function __construct( $payment_id = false ) {
397 397
 
@@ -1115,7 +1115,7 @@  discard block
 block discarded – undo
1115 1115
 	 *
1116 1116
 	 * @param  string|bool $note The note to add
1117 1117
 	 *
1118
-	 * @return bool           If the note was specified or not
1118
+	 * @return false|null           If the note was specified or not
1119 1119
 	 */
1120 1120
 	public function add_note( $note = false ) {
1121 1121
 		// Bail if no note specified.
Please login to merge, or discard this patch.
Spacing   +292 added lines, -293 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
 
@@ -395,13 +395,13 @@  discard block
 block discarded – undo
395 395
 	 *
396 396
 	 * @return mixed void|false
397 397
 	 */
398
-	public function __construct( $payment_id = false ) {
398
+	public function __construct($payment_id = false) {
399 399
 
400
-		if ( empty( $payment_id ) ) {
400
+		if (empty($payment_id)) {
401 401
 			return false;
402 402
 		}
403 403
 
404
-		$this->setup_payment( $payment_id );
404
+		$this->setup_payment($payment_id);
405 405
 	}
406 406
 
407 407
 	/**
@@ -414,11 +414,11 @@  discard block
 block discarded – undo
414 414
 	 *
415 415
 	 * @return mixed        The value.
416 416
 	 */
417
-	public function __get( $key ) {
417
+	public function __get($key) {
418 418
 
419
-		if ( method_exists( $this, 'get_' . $key ) ) {
419
+		if (method_exists($this, 'get_'.$key)) {
420 420
 
421
-			$value = call_user_func( array( $this, 'get_' . $key ) );
421
+			$value = call_user_func(array($this, 'get_'.$key));
422 422
 
423 423
 		} else {
424 424
 
@@ -440,18 +440,18 @@  discard block
 block discarded – undo
440 440
 	 * @param  string $key   The property name
441 441
 	 * @param  mixed  $value The value of the property
442 442
 	 */
443
-	public function __set( $key, $value ) {
444
-		$ignore = array( '_ID' );
443
+	public function __set($key, $value) {
444
+		$ignore = array('_ID');
445 445
 
446
-		if ( 'status' === $key ) {
446
+		if ('status' === $key) {
447 447
 			$this->old_status = $this->status;
448 448
 		}
449 449
 
450
-		if ( ! in_array( $key, $ignore ) ) {
451
-			$this->pending[ $key ] = $value;
450
+		if ( ! in_array($key, $ignore)) {
451
+			$this->pending[$key] = $value;
452 452
 		}
453 453
 
454
-		if ( '_ID' !== $key ) {
454
+		if ('_ID' !== $key) {
455 455
 			$this->$key = $value;
456 456
 		}
457 457
 	}
@@ -466,9 +466,9 @@  discard block
 block discarded – undo
466 466
 	 *
467 467
 	 * @return boolean|null       If the item is set or not
468 468
 	 */
469
-	public function __isset( $name ) {
470
-		if ( property_exists( $this, $name ) ) {
471
-			return false === empty( $this->$name );
469
+	public function __isset($name) {
470
+		if (property_exists($this, $name)) {
471
+			return false === empty($this->$name);
472 472
 		} else {
473 473
 			return null;
474 474
 		}
@@ -484,20 +484,20 @@  discard block
 block discarded – undo
484 484
 	 *
485 485
 	 * @return bool            If the setup was successful or not
486 486
 	 */
487
-	private function setup_payment( $payment_id ) {
487
+	private function setup_payment($payment_id) {
488 488
 		$this->pending = array();
489 489
 
490
-		if ( empty( $payment_id ) ) {
490
+		if (empty($payment_id)) {
491 491
 			return false;
492 492
 		}
493 493
 
494
-		$payment = get_post( absint( $payment_id ) );
494
+		$payment = get_post(absint($payment_id));
495 495
 
496
-		if ( ! $payment || is_wp_error( $payment ) ) {
496
+		if ( ! $payment || is_wp_error($payment)) {
497 497
 			return false;
498 498
 		}
499 499
 
500
-		if ( 'give_payment' !== $payment->post_type ) {
500
+		if ('give_payment' !== $payment->post_type) {
501 501
 			return false;
502 502
 		}
503 503
 
@@ -511,17 +511,17 @@  discard block
 block discarded – undo
511 511
 		 * @param Give_Payment $this       Payment object.
512 512
 		 * @param int          $payment_id The ID of the payment.
513 513
 		 */
514
-		do_action( 'give_pre_setup_payment', $this, $payment_id );
514
+		do_action('give_pre_setup_payment', $this, $payment_id);
515 515
 
516 516
 		// Get payment from cache.
517
-		$donation_vars = Give_Cache::get_group( $payment_id, 'give-donations' );
517
+		$donation_vars = Give_Cache::get_group($payment_id, 'give-donations');
518 518
 
519
-		if ( is_null( $donation_vars ) ) {
519
+		if (is_null($donation_vars)) {
520 520
 			// Primary Identifier.
521
-			$this->ID = absint( $payment_id );
521
+			$this->ID = absint($payment_id);
522 522
 
523 523
 			// Protected ID that can never be changed.
524
-			$this->_ID = absint( $payment_id );
524
+			$this->_ID = absint($payment_id);
525 525
 
526 526
 			// We have a payment, get the generic payment_meta item to reduce calls to it.
527 527
 			$this->payment_meta = $this->get_meta();
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
 			$this->parent_payment = $payment->post_parent;
538 538
 
539 539
 			$all_payment_statuses  = give_get_payment_statuses();
540
-			$this->status_nicename = array_key_exists( $this->status, $all_payment_statuses ) ? $all_payment_statuses[ $this->status ] : ucfirst( $this->status );
540
+			$this->status_nicename = array_key_exists($this->status, $all_payment_statuses) ? $all_payment_statuses[$this->status] : ucfirst($this->status);
541 541
 
542 542
 			// Currency Based.
543 543
 			$this->total    = $this->setup_total();
@@ -566,10 +566,10 @@  discard block
 block discarded – undo
566 566
 			$this->key        = $this->setup_payment_key();
567 567
 			$this->number     = $this->setup_payment_number();
568 568
 
569
-			Give_Cache::set_group( $this->ID, get_object_vars( $this ), 'give-donations' );
569
+			Give_Cache::set_group($this->ID, get_object_vars($this), 'give-donations');
570 570
 		} else {
571 571
 
572
-			foreach ( $donation_vars as $donation_var => $value ) {
572
+			foreach ($donation_vars as $donation_var => $value) {
573 573
 				$this->$donation_var = $value;
574 574
 			}
575 575
 		}
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
 		 * @param Give_Payment $this       Payment object.
585 585
 		 * @param int          $payment_id The ID of the payment.
586 586
 		 */
587
-		do_action( 'give_setup_payment', $this, $payment_id );
587
+		do_action('give_setup_payment', $this, $payment_id);
588 588
 
589 589
 		return true;
590 590
 	}
@@ -603,11 +603,11 @@  discard block
 block discarded – undo
603 603
 	 *
604 604
 	 * @return void
605 605
 	 */
606
-	public function update_payment_setup( $payment_id ) {
606
+	public function update_payment_setup($payment_id) {
607 607
 		// Delete cache.
608
-		Give_Cache::delete_group( $this->ID,'give-donations' );
608
+		Give_Cache::delete_group($this->ID, 'give-donations');
609 609
 		
610
-		$this->setup_payment( $payment_id );
610
+		$this->setup_payment($payment_id);
611 611
 	}
612 612
 
613 613
 	/**
@@ -622,24 +622,24 @@  discard block
 block discarded – undo
622 622
 
623 623
 		// Construct the payment title.
624 624
 		$payment_title = '';
625
-		if ( ! empty( $this->first_name ) && ! empty( $this->last_name ) ) {
626
-			$payment_title = $this->first_name . ' ' . $this->last_name;
627
-		} elseif ( ! empty( $this->first_name ) && empty( $this->last_name ) ) {
625
+		if ( ! empty($this->first_name) && ! empty($this->last_name)) {
626
+			$payment_title = $this->first_name.' '.$this->last_name;
627
+		} elseif ( ! empty($this->first_name) && empty($this->last_name)) {
628 628
 			$payment_title = $this->first_name;
629
-		} elseif ( ! empty( $this->email ) && is_email( $this->email ) ) {
629
+		} elseif ( ! empty($this->email) && is_email($this->email)) {
630 630
 			$payment_title = $this->email;
631 631
 		}
632 632
 
633 633
 		// Set Key.
634
-		if ( empty( $this->key ) ) {
634
+		if (empty($this->key)) {
635 635
 
636
-			$auth_key             = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
637
-			$this->key            = strtolower( md5( $this->email . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) );  // Unique key
636
+			$auth_key             = defined('AUTH_KEY') ? AUTH_KEY : '';
637
+			$this->key            = strtolower(md5($this->email.date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); // Unique key
638 638
 			$this->pending['key'] = $this->key;
639 639
 		}
640 640
 
641 641
 		// Set IP.
642
-		if ( empty( $this->ip ) ) {
642
+		if (empty($this->ip)) {
643 643
 
644 644
 			$this->ip            = give_get_ip();
645 645
 			$this->pending['ip'] = $this->ip;
@@ -668,19 +668,19 @@  discard block
 block discarded – undo
668 668
 			'status'       => $this->status,
669 669
 		);
670 670
 
671
-		$args = apply_filters( 'give_insert_payment_args', array(
671
+		$args = apply_filters('give_insert_payment_args', array(
672 672
 			'post_title'    => $payment_title,
673 673
 			'post_status'   => $this->status,
674 674
 			'post_type'     => 'give_payment',
675
-			'post_date'     => ! empty( $this->date ) ? $this->date : null,
676
-			'post_date_gmt' => ! empty( $this->date ) ? get_gmt_from_date( $this->date ) : null,
675
+			'post_date'     => ! empty($this->date) ? $this->date : null,
676
+			'post_date_gmt' => ! empty($this->date) ? get_gmt_from_date($this->date) : null,
677 677
 			'post_parent'   => $this->parent_payment,
678
-		), $payment_data );
678
+		), $payment_data);
679 679
 
680 680
 		// Create a blank payment
681
-		$payment_id = wp_insert_post( $args );
681
+		$payment_id = wp_insert_post($args);
682 682
 
683
-		if ( ! empty( $payment_id ) ) {
683
+		if ( ! empty($payment_id)) {
684 684
 
685 685
 			$this->ID  = $payment_id;
686 686
 			$this->_ID = $payment_id;
@@ -692,42 +692,42 @@  discard block
 block discarded – undo
692 692
 			 *
693 693
 			 * @since 1.8.13
694 694
 			 */
695
-			$donor = apply_filters( 'give_update_donor_information', $donor, $payment_id, $payment_data, $args );
695
+			$donor = apply_filters('give_update_donor_information', $donor, $payment_id, $payment_data, $args);
696 696
 
697
-			if ( did_action( 'give_pre_process_donation' ) && is_user_logged_in() ) {
698
-				$donor = new Give_Donor( get_current_user_id(), true );
697
+			if (did_action('give_pre_process_donation') && is_user_logged_in()) {
698
+				$donor = new Give_Donor(get_current_user_id(), true);
699 699
 
700 700
 				// Donor is logged in but used a different email to purchase with so assign to their donor record.
701
-				if ( ! empty( $donor->id ) && $this->email !== $donor->email ) {
702
-					$donor->add_email( $this->email );
701
+				if ( ! empty($donor->id) && $this->email !== $donor->email) {
702
+					$donor->add_email($this->email);
703 703
 				}
704 704
 			}
705 705
 
706
-			if ( empty( $donor->id ) ) {
707
-				$donor = new Give_Donor( $this->email );
706
+			if (empty($donor->id)) {
707
+				$donor = new Give_Donor($this->email);
708 708
 			}
709 709
 
710
-			if ( empty( $donor->id ) ) {
710
+			if (empty($donor->id)) {
711 711
 
712 712
 				$donor_data = array(
713
-					'name'    => ! is_email( $payment_title ) ? $this->first_name . ' ' . $this->last_name : '',
713
+					'name'    => ! is_email($payment_title) ? $this->first_name.' '.$this->last_name : '',
714 714
 					'email'   => $this->email,
715 715
 					'user_id' => $this->user_id,
716 716
 				);
717 717
 
718
-				$donor->create( $donor_data );
718
+				$donor->create($donor_data);
719 719
 
720 720
 			}
721 721
 
722 722
 			// Update Donor Meta once donor is created.
723
-			$donor->update_meta( '_give_donor_first_name', $this->first_name );
724
-			$donor->update_meta( '_give_donor_last_name', $this->last_name );
723
+			$donor->update_meta('_give_donor_first_name', $this->first_name);
724
+			$donor->update_meta('_give_donor_last_name', $this->last_name);
725 725
 
726 726
 			$this->customer_id            = $donor->id;
727 727
 			$this->pending['customer_id'] = $this->customer_id;
728
-			$donor->attach_payment( $this->ID, false );
728
+			$donor->attach_payment($this->ID, false);
729 729
 
730
-			$this->payment_meta = apply_filters( 'give_payment_meta', $this->payment_meta, $payment_data );
730
+			$this->payment_meta = apply_filters('give_payment_meta', $this->payment_meta, $payment_data);
731 731
 
732 732
 			/*
733 733
 			 * _give_payment_meta backward compatibility.
@@ -735,14 +735,14 @@  discard block
 block discarded – undo
735 735
 			 * @since 2.0.1
736 736
 			 */
737 737
 			$custom_payment_meta = array_diff(
738
-				array_map( 'maybe_serialize', $this->payment_meta ),
739
-				array_map( 'maybe_serialize', $payment_data )
738
+				array_map('maybe_serialize', $this->payment_meta),
739
+				array_map('maybe_serialize', $payment_data)
740 740
 			);
741 741
 
742
-			if( ! empty( $custom_payment_meta ) ) {
743
-				give_doing_it_wrong( '_give_payment_meta', __( 'This custom meta key deprecated. We are not using this meta key for storing payment meta but your custom meta data will be store because we added backward compatibility. Please change your logic because in future we can remove it.', 'give' ), '2.0.0' );
742
+			if ( ! empty($custom_payment_meta)) {
743
+				give_doing_it_wrong('_give_payment_meta', __('This custom meta key deprecated. We are not using this meta key for storing payment meta but your custom meta data will be store because we added backward compatibility. Please change your logic because in future we can remove it.', 'give'), '2.0.0');
744 744
 
745
-				$this->update_meta( '_give_payment_meta', array_map( 'maybe_unserialize', $custom_payment_meta ) );
745
+				$this->update_meta('_give_payment_meta', array_map('maybe_unserialize', $custom_payment_meta));
746 746
 			}
747 747
 
748 748
 			$this->new = true;
@@ -765,11 +765,11 @@  discard block
 block discarded – undo
765 765
 		$saved = false;
766 766
 
767 767
 		// Must have an ID.
768
-		if ( empty( $this->ID ) ) {
768
+		if (empty($this->ID)) {
769 769
 
770 770
 			$payment_id = $this->insert_payment();
771 771
 
772
-			if ( false === $payment_id ) {
772
+			if (false === $payment_id) {
773 773
 				$saved = false;
774 774
 			} else {
775 775
 				$this->ID = $payment_id;
@@ -777,42 +777,42 @@  discard block
 block discarded – undo
777 777
 		}
778 778
 
779 779
 		// Set ID if not matching.
780
-		if ( $this->ID !== $this->_ID ) {
780
+		if ($this->ID !== $this->_ID) {
781 781
 			$this->ID = $this->_ID;
782 782
 		}
783 783
 
784 784
 		// If we have something pending, let's save it.
785
-		if ( ! empty( $this->pending ) ) {
785
+		if ( ! empty($this->pending)) {
786 786
 
787 787
 			$total_increase = 0;
788 788
 			$total_decrease = 0;
789 789
 
790
-			foreach ( $this->pending as $key => $value ) {
790
+			foreach ($this->pending as $key => $value) {
791 791
 
792
-				switch ( $key ) {
792
+				switch ($key) {
793 793
 
794 794
 					case 'donations':
795 795
 						// Update totals for pending donations.
796
-						foreach ( $this->pending[ $key ] as $item ) {
796
+						foreach ($this->pending[$key] as $item) {
797 797
 
798
-							$quantity = isset( $item['quantity'] ) ? $item['quantity'] : 1;
799
-							$price_id = isset( $item['price_id'] ) ? $item['price_id'] : 0;
798
+							$quantity = isset($item['quantity']) ? $item['quantity'] : 1;
799
+							$price_id = isset($item['price_id']) ? $item['price_id'] : 0;
800 800
 
801
-							switch ( $item['action'] ) {
801
+							switch ($item['action']) {
802 802
 
803 803
 								case 'add':
804 804
 
805 805
 									$price = $item['price'];
806 806
 
807
-									if ( 'publish' === $this->status || 'complete' === $this->status ) {
807
+									if ('publish' === $this->status || 'complete' === $this->status) {
808 808
 
809 809
 										// Add donation to logs.
810
-										$log_date = date_i18n( 'Y-m-d G:i:s', current_time( 'timestamp' ) );
811
-										give_record_donation_in_log( $item['id'], $this->ID, $price_id, $log_date );
810
+										$log_date = date_i18n('Y-m-d G:i:s', current_time('timestamp'));
811
+										give_record_donation_in_log($item['id'], $this->ID, $price_id, $log_date);
812 812
 
813
-										$form = new Give_Donate_Form( $item['id'] );
814
-										$form->increase_sales( $quantity );
815
-										$form->increase_earnings( $price );
813
+										$form = new Give_Donate_Form($item['id']);
814
+										$form->increase_sales($quantity);
815
+										$form->increase_earnings($price);
816 816
 
817 817
 										$total_increase += $price;
818 818
 									}
@@ -820,10 +820,10 @@  discard block
 block discarded – undo
820 820
 
821 821
 								case 'remove':
822 822
 									$this->delete_sales_logs();
823
-									if ( 'publish' === $this->status || 'complete' === $this->status ) {
824
-										$form = new Give_Donate_Form( $item['id'] );
825
-										$form->decrease_sales( $quantity );
826
-										$form->decrease_earnings( $item['amount'] );
823
+									if ('publish' === $this->status || 'complete' === $this->status) {
824
+										$form = new Give_Donate_Form($item['id']);
825
+										$form->decrease_sales($quantity);
826
+										$form->decrease_earnings($item['amount']);
827 827
 
828 828
 										$total_decrease += $item['amount'];
829 829
 									}
@@ -834,27 +834,27 @@  discard block
 block discarded – undo
834 834
 						break;
835 835
 
836 836
 					case 'status':
837
-						$this->update_status( $this->status );
837
+						$this->update_status($this->status);
838 838
 						break;
839 839
 
840 840
 					case 'gateway':
841
-						$this->update_meta( '_give_payment_gateway', $this->gateway );
841
+						$this->update_meta('_give_payment_gateway', $this->gateway);
842 842
 						break;
843 843
 
844 844
 					case 'mode':
845
-						$this->update_meta( '_give_payment_mode', $this->mode );
845
+						$this->update_meta('_give_payment_mode', $this->mode);
846 846
 						break;
847 847
 
848 848
 					case 'transaction_id':
849
-						$this->update_meta( '_give_payment_transaction_id', $this->transaction_id );
849
+						$this->update_meta('_give_payment_transaction_id', $this->transaction_id);
850 850
 						break;
851 851
 
852 852
 					case 'ip':
853
-						$this->update_meta( '_give_payment_donor_ip', $this->ip );
853
+						$this->update_meta('_give_payment_donor_ip', $this->ip);
854 854
 						break;
855 855
 
856 856
 					case 'customer_id':
857
-						$this->update_meta( '_give_payment_donor_id', $this->customer_id );
857
+						$this->update_meta('_give_payment_donor_id', $this->customer_id);
858 858
 						break;
859 859
 
860 860
 					// case 'user_id':
@@ -862,58 +862,58 @@  discard block
 block discarded – undo
862 862
 					// 	break;
863 863
 
864 864
 					case 'form_title':
865
-						$this->update_meta( '_give_payment_form_title', $this->form_title );
865
+						$this->update_meta('_give_payment_form_title', $this->form_title);
866 866
 						break;
867 867
 
868 868
 					case 'form_id':
869
-						$this->update_meta( '_give_payment_form_id', $this->form_id );
869
+						$this->update_meta('_give_payment_form_id', $this->form_id);
870 870
 						break;
871 871
 
872 872
 					case 'price_id':
873
-						$this->update_meta( '_give_payment_price_id', $this->price_id );
873
+						$this->update_meta('_give_payment_price_id', $this->price_id);
874 874
 						break;
875 875
 
876 876
 					case 'first_name':
877
-						$this->update_meta( '_give_donor_billing_first_name', $this->first_name );
877
+						$this->update_meta('_give_donor_billing_first_name', $this->first_name);
878 878
 						break;
879 879
 
880 880
 					case 'last_name':
881
-						$this->update_meta( '_give_donor_billing_last_name', $this->last_name );
881
+						$this->update_meta('_give_donor_billing_last_name', $this->last_name);
882 882
 						break;
883 883
 
884 884
 					case 'currency':
885
-						$this->update_meta( '_give_payment_currency', $this->currency );
885
+						$this->update_meta('_give_payment_currency', $this->currency);
886 886
 						break;
887 887
 
888 888
 					case 'address':
889
-						if ( ! empty( $this->address ) ) {
890
-							foreach ( $this->address as $address_name => $address ) {
891
-								switch ( $address_name ) {
889
+						if ( ! empty($this->address)) {
890
+							foreach ($this->address as $address_name => $address) {
891
+								switch ($address_name) {
892 892
 									case 'line1':
893
-										$this->update_meta( '_give_donor_billing_address1', $address );
893
+										$this->update_meta('_give_donor_billing_address1', $address);
894 894
 										break;
895 895
 
896 896
 									case 'line2':
897
-										$this->update_meta( '_give_donor_billing_address2', $address );
897
+										$this->update_meta('_give_donor_billing_address2', $address);
898 898
 										break;
899 899
 
900 900
 									default:
901
-										$this->update_meta( "_give_donor_billing_{$address_name}", $address );
901
+										$this->update_meta("_give_donor_billing_{$address_name}", $address);
902 902
 								}
903 903
 							}
904 904
 						}
905 905
 						break;
906 906
 
907 907
 					case 'email':
908
-						$this->update_meta( '_give_payment_donor_email', $this->email );
908
+						$this->update_meta('_give_payment_donor_email', $this->email);
909 909
 						break;
910 910
 
911 911
 					case 'key':
912
-						$this->update_meta( '_give_payment_purchase_key', $this->key );
912
+						$this->update_meta('_give_payment_purchase_key', $this->key);
913 913
 						break;
914 914
 
915 915
 					case 'number':
916
-						$this->update_meta( '_give_payment_number', $this->number );
916
+						$this->update_meta('_give_payment_number', $this->number);
917 917
 						break;
918 918
 
919 919
 					case 'date':
@@ -923,11 +923,11 @@  discard block
 block discarded – undo
923 923
 							'edit_date' => true,
924 924
 						);
925 925
 
926
-						wp_update_post( $args );
926
+						wp_update_post($args);
927 927
 						break;
928 928
 
929 929
 					case 'completed_date':
930
-						$this->update_meta( '_give_completed_date', $this->completed_date );
930
+						$this->update_meta('_give_completed_date', $this->completed_date);
931 931
 						break;
932 932
 
933 933
 					case 'parent_payment':
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
 							'post_parent' => $this->parent_payment,
937 937
 						);
938 938
 
939
-						wp_update_post( $args );
939
+						wp_update_post($args);
940 940
 						break;
941 941
 
942 942
 					default:
@@ -947,40 +947,40 @@  discard block
 block discarded – undo
947 947
 						 *
948 948
 						 * @param Give_Payment $this Payment object.
949 949
 						 */
950
-						do_action( 'give_payment_save', $this, $key );
950
+						do_action('give_payment_save', $this, $key);
951 951
 						break;
952 952
 				}// End switch().
953 953
 			}// End foreach().
954 954
 
955
-			if ( 'pending' !== $this->status ) {
955
+			if ('pending' !== $this->status) {
956 956
 
957
-				$donor = new Give_Donor( $this->customer_id );
957
+				$donor = new Give_Donor($this->customer_id);
958 958
 
959 959
 				$total_change = $total_increase - $total_decrease;
960
-				if ( $total_change < 0 ) {
960
+				if ($total_change < 0) {
961 961
 
962
-					$total_change = - ( $total_change );
962
+					$total_change = - ($total_change);
963 963
 					// Decrease the donor's donation stats.
964
-					$donor->decrease_value( $total_change );
965
-					give_decrease_total_earnings( $total_change );
964
+					$donor->decrease_value($total_change);
965
+					give_decrease_total_earnings($total_change);
966 966
 
967
-				} elseif ( $total_change > 0 ) {
967
+				} elseif ($total_change > 0) {
968 968
 
969 969
 					// Increase the donor's donation stats.
970
-					$donor->increase_value( $total_change );
971
-					give_increase_total_earnings( $total_change );
970
+					$donor->increase_value($total_change);
971
+					give_increase_total_earnings($total_change);
972 972
 
973 973
 				}
974 974
 			}
975 975
 
976
-			$this->update_meta( '_give_payment_total', give_sanitize_amount_for_db( $this->total ) );
976
+			$this->update_meta('_give_payment_total', give_sanitize_amount_for_db($this->total));
977 977
 
978 978
 			$this->pending = array();
979 979
 			$saved         = true;
980 980
 		}// End if().
981 981
 
982
-		if ( true === $saved ) {
983
-			$this->setup_payment( $this->ID );
982
+		if (true === $saved) {
983
+			$this->setup_payment($this->ID);
984 984
 		}
985 985
 
986 986
 		return $saved;
@@ -998,12 +998,12 @@  discard block
 block discarded – undo
998 998
 	 *
999 999
 	 * @return bool           True when successful, false otherwise
1000 1000
 	 */
1001
-	public function add_donation( $form_id = 0, $args = array(), $options = array() ) {
1001
+	public function add_donation($form_id = 0, $args = array(), $options = array()) {
1002 1002
 
1003
-		$donation = new Give_Donate_Form( $form_id );
1003
+		$donation = new Give_Donate_Form($form_id);
1004 1004
 
1005 1005
 		// Bail if this post isn't a give donation form.
1006
-		if ( ! $donation || $donation->post_type !== 'give_forms' ) {
1006
+		if ( ! $donation || $donation->post_type !== 'give_forms') {
1007 1007
 			return false;
1008 1008
 		}
1009 1009
 
@@ -1013,59 +1013,59 @@  discard block
 block discarded – undo
1013 1013
 			'price_id' => false,
1014 1014
 		);
1015 1015
 
1016
-		$args = wp_parse_args( apply_filters( 'give_payment_add_donation_args', $args, $donation->ID ), $defaults );
1016
+		$args = wp_parse_args(apply_filters('give_payment_add_donation_args', $args, $donation->ID), $defaults);
1017 1017
 
1018 1018
 		// Allow overriding the price.
1019
-		if ( false !== $args['price'] ) {
1019
+		if (false !== $args['price']) {
1020 1020
 			$donation_amount = $args['price'];
1021 1021
 		} else {
1022 1022
 
1023 1023
 			// Deal with variable pricing.
1024
-			if ( give_has_variable_prices( $donation->ID ) ) {
1025
-				$prices          = give_get_meta( $form_id, '_give_donation_levels', true );
1024
+			if (give_has_variable_prices($donation->ID)) {
1025
+				$prices          = give_get_meta($form_id, '_give_donation_levels', true);
1026 1026
 				$donation_amount = '';
1027 1027
 				// Loop through prices.
1028
-				foreach ( $prices as $price ) {
1028
+				foreach ($prices as $price) {
1029 1029
 					// Find a match between price_id and level_id.
1030 1030
 					// First verify array keys exists THEN make the match.
1031
-					if ( ( isset( $args['price_id'] ) && isset( $price['_give_id']['level_id'] ) )
1031
+					if ((isset($args['price_id']) && isset($price['_give_id']['level_id']))
1032 1032
 					     && $args['price_id'] == $price['_give_id']['level_id']
1033 1033
 					) {
1034 1034
 						$donation_amount = $price['_give_amount'];
1035 1035
 					}
1036 1036
 				}
1037 1037
 				// Fallback to the lowest price point.
1038
-				if ( $donation_amount == '' ) {
1039
-					$donation_amount  = give_get_lowest_price_option( $donation->ID );
1040
-					$args['price_id'] = give_get_lowest_price_id( $donation->ID );
1038
+				if ($donation_amount == '') {
1039
+					$donation_amount  = give_get_lowest_price_option($donation->ID);
1040
+					$args['price_id'] = give_get_lowest_price_id($donation->ID);
1041 1041
 				}
1042 1042
 			} else {
1043 1043
 				// Simple form price.
1044
-				$donation_amount = give_get_form_price( $donation->ID );
1044
+				$donation_amount = give_get_form_price($donation->ID);
1045 1045
 			}
1046 1046
 		}
1047 1047
 
1048 1048
 		// Sanitizing the price here so we don't have a dozen calls later.
1049
-		$donation_amount = give_maybe_sanitize_amount( $donation_amount );
1050
-		$total           = round( $donation_amount, give_get_price_decimals( $this->ID ) );
1049
+		$donation_amount = give_maybe_sanitize_amount($donation_amount);
1050
+		$total           = round($donation_amount, give_get_price_decimals($this->ID));
1051 1051
 
1052 1052
 		// Add Options.
1053 1053
 		$default_options = array();
1054
-		if ( false !== $args['price_id'] ) {
1054
+		if (false !== $args['price_id']) {
1055 1055
 			$default_options['price_id'] = (int) $args['price_id'];
1056 1056
 		}
1057
-		$options = wp_parse_args( $options, $default_options );
1057
+		$options = wp_parse_args($options, $default_options);
1058 1058
 
1059 1059
 		// Do not allow totals to go negative.
1060
-		if ( $total < 0 ) {
1060
+		if ($total < 0) {
1061 1061
 			$total = 0;
1062 1062
 		}
1063 1063
 
1064 1064
 		$donation = array(
1065 1065
 			'name'     => $donation->post_title,
1066 1066
 			'id'       => $donation->ID,
1067
-			'price'    => round( $total, give_get_price_decimals( $this->ID ) ),
1068
-			'subtotal' => round( $total, give_get_price_decimals( $this->ID ) ),
1067
+			'price'    => round($total, give_get_price_decimals($this->ID)),
1068
+			'subtotal' => round($total, give_get_price_decimals($this->ID)),
1069 1069
 			'price_id' => $args['price_id'],
1070 1070
 			'action'   => 'add',
1071 1071
 			'options'  => $options,
@@ -1073,7 +1073,7 @@  discard block
 block discarded – undo
1073 1073
 
1074 1074
 		$this->pending['donations'][] = $donation;
1075 1075
 
1076
-		$this->increase_subtotal( $total );
1076
+		$this->increase_subtotal($total);
1077 1077
 
1078 1078
 		return true;
1079 1079
 
@@ -1090,7 +1090,7 @@  discard block
 block discarded – undo
1090 1090
 	 *
1091 1091
 	 * @return bool           If the item was removed or not
1092 1092
 	 */
1093
-	public function remove_donation( $form_id, $args = array() ) {
1093
+	public function remove_donation($form_id, $args = array()) {
1094 1094
 
1095 1095
 		// Set some defaults.
1096 1096
 		$defaults = array(
@@ -1098,12 +1098,12 @@  discard block
 block discarded – undo
1098 1098
 			'price'    => false,
1099 1099
 			'price_id' => false,
1100 1100
 		);
1101
-		$args     = wp_parse_args( $args, $defaults );
1101
+		$args = wp_parse_args($args, $defaults);
1102 1102
 
1103
-		$form = new Give_Donate_Form( $form_id );
1103
+		$form = new Give_Donate_Form($form_id);
1104 1104
 
1105 1105
 		// Bail if this post isn't a valid give donation form.
1106
-		if ( ! $form || $form->post_type !== 'give_forms' ) {
1106
+		if ( ! $form || $form->post_type !== 'give_forms') {
1107 1107
 			return false;
1108 1108
 		}
1109 1109
 
@@ -1116,7 +1116,7 @@  discard block
 block discarded – undo
1116 1116
 
1117 1117
 		$this->pending['donations'][] = $pending_args;
1118 1118
 
1119
-		$this->decrease_subtotal( $this->total );
1119
+		$this->decrease_subtotal($this->total);
1120 1120
 
1121 1121
 		return true;
1122 1122
 	}
@@ -1132,13 +1132,13 @@  discard block
 block discarded – undo
1132 1132
 	 *
1133 1133
 	 * @return bool           If the note was specified or not
1134 1134
 	 */
1135
-	public function add_note( $note = false ) {
1135
+	public function add_note($note = false) {
1136 1136
 		// Bail if no note specified.
1137
-		if ( ! $note ) {
1137
+		if ( ! $note) {
1138 1138
 			return false;
1139 1139
 		}
1140 1140
 
1141
-		give_insert_payment_note( $this->ID, $note );
1141
+		give_insert_payment_note($this->ID, $note);
1142 1142
 	}
1143 1143
 
1144 1144
 	/**
@@ -1151,8 +1151,8 @@  discard block
 block discarded – undo
1151 1151
 	 *
1152 1152
 	 * @return void
1153 1153
 	 */
1154
-	private function increase_subtotal( $amount = 0.00 ) {
1155
-		$amount         = (float) $amount;
1154
+	private function increase_subtotal($amount = 0.00) {
1155
+		$amount = (float) $amount;
1156 1156
 		$this->subtotal += $amount;
1157 1157
 
1158 1158
 		$this->recalculate_total();
@@ -1168,11 +1168,11 @@  discard block
 block discarded – undo
1168 1168
 	 *
1169 1169
 	 * @return void
1170 1170
 	 */
1171
-	private function decrease_subtotal( $amount = 0.00 ) {
1172
-		$amount         = (float) $amount;
1171
+	private function decrease_subtotal($amount = 0.00) {
1172
+		$amount = (float) $amount;
1173 1173
 		$this->subtotal -= $amount;
1174 1174
 
1175
-		if ( $this->subtotal < 0 ) {
1175
+		if ($this->subtotal < 0) {
1176 1176
 			$this->subtotal = 0;
1177 1177
 		}
1178 1178
 
@@ -1201,24 +1201,24 @@  discard block
 block discarded – undo
1201 1201
 	 *
1202 1202
 	 * @return bool   $updated Returns if the status was successfully updated.
1203 1203
 	 */
1204
-	public function update_status( $status = false ) {
1204
+	public function update_status($status = false) {
1205 1205
 
1206 1206
 		// standardize the 'complete(d)' status.
1207
-		if ( $status == 'completed' || $status == 'complete' ) {
1207
+		if ($status == 'completed' || $status == 'complete') {
1208 1208
 			$status = 'publish';
1209 1209
 		}
1210 1210
 
1211
-		$old_status = ! empty( $this->old_status ) ? $this->old_status : false;
1211
+		$old_status = ! empty($this->old_status) ? $this->old_status : false;
1212 1212
 
1213
-		if ( $old_status === $status ) {
1213
+		if ($old_status === $status) {
1214 1214
 			return false; // Don't permit status changes that aren't changes.
1215 1215
 		}
1216 1216
 
1217
-		$do_change = apply_filters( 'give_should_update_payment_status', true, $this->ID, $status, $old_status );
1217
+		$do_change = apply_filters('give_should_update_payment_status', true, $this->ID, $status, $old_status);
1218 1218
 
1219 1219
 		$updated = false;
1220 1220
 
1221
-		if ( $do_change ) {
1221
+		if ($do_change) {
1222 1222
 
1223 1223
 			/**
1224 1224
 			 * Fires before changing payment status.
@@ -1229,21 +1229,21 @@  discard block
 block discarded – undo
1229 1229
 			 * @param string $status     The new status.
1230 1230
 			 * @param string $old_status The old status.
1231 1231
 			 */
1232
-			do_action( 'give_before_payment_status_change', $this->ID, $status, $old_status );
1232
+			do_action('give_before_payment_status_change', $this->ID, $status, $old_status);
1233 1233
 
1234 1234
 			$update_fields = array(
1235 1235
 				'ID'          => $this->ID,
1236 1236
 				'post_status' => $status,
1237
-				'edit_date'   => current_time( 'mysql' ),
1237
+				'edit_date'   => current_time('mysql'),
1238 1238
 			);
1239 1239
 
1240
-			$updated = wp_update_post( apply_filters( 'give_update_payment_status_fields', $update_fields ) );
1240
+			$updated = wp_update_post(apply_filters('give_update_payment_status_fields', $update_fields));
1241 1241
 
1242 1242
 			$all_payment_statuses  = give_get_payment_statuses();
1243
-			$this->status_nicename = array_key_exists( $status, $all_payment_statuses ) ? $all_payment_statuses[ $status ] : ucfirst( $status );
1243
+			$this->status_nicename = array_key_exists($status, $all_payment_statuses) ? $all_payment_statuses[$status] : ucfirst($status);
1244 1244
 
1245 1245
 			// Process any specific status functions.
1246
-			switch ( $status ) {
1246
+			switch ($status) {
1247 1247
 				case 'refunded':
1248 1248
 					$this->process_refund();
1249 1249
 					break;
@@ -1270,7 +1270,7 @@  discard block
 block discarded – undo
1270 1270
 			 * @param string $status     The new status.
1271 1271
 			 * @param string $old_status The old status.
1272 1272
 			 */
1273
-			do_action( 'give_update_payment_status', $this->ID, $status, $old_status );
1273
+			do_action('give_update_payment_status', $this->ID, $status, $old_status);
1274 1274
 
1275 1275
 		}// End if().
1276 1276
 
@@ -1305,24 +1305,24 @@  discard block
 block discarded – undo
1305 1305
 	 *
1306 1306
 	 * @return mixed             The value from the post meta
1307 1307
 	 */
1308
-	public function get_meta( $meta_key = '_give_payment_meta', $single = true ) {
1309
-		if( ! has_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta' ) && ! doing_filter( 'get_post_metadata' ) ) {
1310
-			add_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4 );
1308
+	public function get_meta($meta_key = '_give_payment_meta', $single = true) {
1309
+		if ( ! has_filter('get_post_metadata', 'give_bc_v20_get_payment_meta') && ! doing_filter('get_post_metadata')) {
1310
+			add_filter('get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4);
1311 1311
 		}
1312 1312
 
1313
-		$meta = give_get_meta( $this->ID, $meta_key, $single );
1313
+		$meta = give_get_meta($this->ID, $meta_key, $single);
1314 1314
 
1315 1315
 		/**
1316 1316
 		 * Filter the specific meta key value.
1317 1317
 		 *
1318 1318
 		 * @since 1.5
1319 1319
 		 */
1320
-		$meta = apply_filters( "give_get_payment_meta_{$meta_key}", $meta, $this->ID );
1320
+		$meta = apply_filters("give_get_payment_meta_{$meta_key}", $meta, $this->ID);
1321 1321
 
1322 1322
 		// Security check.
1323
-		if ( is_serialized( $meta ) ) {
1324
-			preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $meta, $matches );
1325
-			if ( ! empty( $matches ) ) {
1323
+		if (is_serialized($meta)) {
1324
+			preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $meta, $matches);
1325
+			if ( ! empty($matches)) {
1326 1326
 				$meta = array();
1327 1327
 			}
1328 1328
 		}
@@ -1332,7 +1332,7 @@  discard block
 block discarded – undo
1332 1332
 		 *
1333 1333
 		 * @since 1.5
1334 1334
 		 */
1335
-		return apply_filters( 'give_get_payment_meta', $meta, $this->ID, $meta_key );
1335
+		return apply_filters('give_get_payment_meta', $meta, $this->ID, $meta_key);
1336 1336
 	}
1337 1337
 
1338 1338
 	/**
@@ -1347,8 +1347,8 @@  discard block
 block discarded – undo
1347 1347
 	 *
1348 1348
 	 * @return int|bool           Meta ID if the key didn't exist, true on successful update, false on failure
1349 1349
 	 */
1350
-	public function update_meta( $meta_key = '', $meta_value = '', $prev_value = '' ) {
1351
-		if ( empty( $meta_key ) ) {
1350
+	public function update_meta($meta_key = '', $meta_value = '', $prev_value = '') {
1351
+		if (empty($meta_key)) {
1352 1352
 			return false;
1353 1353
 		}
1354 1354
 
@@ -1358,9 +1358,9 @@  discard block
 block discarded – undo
1358 1358
 		 *
1359 1359
 		 * @since 1.5
1360 1360
 		 */
1361
-		$meta_value = apply_filters( "give_update_payment_meta_{$meta_key}", $meta_value, $this->ID );
1361
+		$meta_value = apply_filters("give_update_payment_meta_{$meta_key}", $meta_value, $this->ID);
1362 1362
 
1363
-		return give_update_meta( $this->ID, $meta_key, $meta_value, $prev_value );
1363
+		return give_update_meta($this->ID, $meta_key, $meta_value, $prev_value);
1364 1364
 	}
1365 1365
 
1366 1366
 	/**
@@ -1375,14 +1375,14 @@  discard block
 block discarded – undo
1375 1375
 		$process_refund = true;
1376 1376
 
1377 1377
 		// If the payment was not in publish or revoked status, don't decrement stats as they were never incremented.
1378
-		if ( 'publish' != $this->old_status || 'refunded' != $this->status ) {
1378
+		if ('publish' != $this->old_status || 'refunded' != $this->status) {
1379 1379
 			$process_refund = false;
1380 1380
 		}
1381 1381
 
1382 1382
 		// Allow extensions to filter for their own payment types, Example: Recurring Payments.
1383
-		$process_refund = apply_filters( 'give_should_process_refund', $process_refund, $this );
1383
+		$process_refund = apply_filters('give_should_process_refund', $process_refund, $this);
1384 1384
 
1385
-		if ( false === $process_refund ) {
1385
+		if (false === $process_refund) {
1386 1386
 			return;
1387 1387
 		}
1388 1388
 
@@ -1393,13 +1393,13 @@  discard block
 block discarded – undo
1393 1393
 		 *
1394 1394
 		 * @param Give_Payment $this Payment object.
1395 1395
 		 */
1396
-		do_action( 'give_pre_refund_payment', $this );
1396
+		do_action('give_pre_refund_payment', $this);
1397 1397
 
1398
-		$decrease_earnings       = apply_filters( 'give_decrease_store_earnings_on_refund', true, $this );
1399
-		$decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_refund', true, $this );
1400
-		$decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_refund', true, $this );
1398
+		$decrease_earnings       = apply_filters('give_decrease_store_earnings_on_refund', true, $this);
1399
+		$decrease_customer_value = apply_filters('give_decrease_customer_value_on_refund', true, $this);
1400
+		$decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_refund', true, $this);
1401 1401
 
1402
-		$this->maybe_alter_stats( $decrease_earnings, $decrease_customer_value, $decrease_purchase_count );
1402
+		$this->maybe_alter_stats($decrease_earnings, $decrease_customer_value, $decrease_purchase_count);
1403 1403
 		$this->delete_sales_logs();
1404 1404
 
1405 1405
 		// @todo: Refresh only range related stat cache
@@ -1412,7 +1412,7 @@  discard block
 block discarded – undo
1412 1412
 		 *
1413 1413
 		 * @param Give_Payment $this Payment object.
1414 1414
 		 */
1415
-		do_action( 'give_post_refund_payment', $this );
1415
+		do_action('give_post_refund_payment', $this);
1416 1416
 	}
1417 1417
 
1418 1418
 	/**
@@ -1439,26 +1439,26 @@  discard block
 block discarded – undo
1439 1439
 		$process_pending = true;
1440 1440
 
1441 1441
 		// If the payment was not in publish or revoked status, don't decrement stats as they were never incremented.
1442
-		if ( 'publish' != $this->old_status || 'pending' != $this->status ) {
1442
+		if ('publish' != $this->old_status || 'pending' != $this->status) {
1443 1443
 			$process_pending = false;
1444 1444
 		}
1445 1445
 
1446 1446
 		// Allow extensions to filter for their own payment types, Example: Recurring Payments.
1447
-		$process_pending = apply_filters( 'give_should_process_pending', $process_pending, $this );
1447
+		$process_pending = apply_filters('give_should_process_pending', $process_pending, $this);
1448 1448
 
1449
-		if ( false === $process_pending ) {
1449
+		if (false === $process_pending) {
1450 1450
 			return;
1451 1451
 		}
1452 1452
 
1453
-		$decrease_earnings       = apply_filters( 'give_decrease_earnings_on_pending', true, $this );
1454
-		$decrease_donor_value    = apply_filters( 'give_decrease_donor_value_on_pending', true, $this );
1455
-		$decrease_donation_count = apply_filters( 'give_decrease_donors_donation_count_on_pending', true, $this );
1453
+		$decrease_earnings       = apply_filters('give_decrease_earnings_on_pending', true, $this);
1454
+		$decrease_donor_value    = apply_filters('give_decrease_donor_value_on_pending', true, $this);
1455
+		$decrease_donation_count = apply_filters('give_decrease_donors_donation_count_on_pending', true, $this);
1456 1456
 
1457
-		$this->maybe_alter_stats( $decrease_earnings, $decrease_donor_value, $decrease_donation_count );
1457
+		$this->maybe_alter_stats($decrease_earnings, $decrease_donor_value, $decrease_donation_count);
1458 1458
 		$this->delete_sales_logs();
1459 1459
 
1460 1460
 		$this->completed_date = false;
1461
-		$this->update_meta( '_give_completed_date', '' );
1461
+		$this->update_meta('_give_completed_date', '');
1462 1462
 
1463 1463
 		// @todo: Refresh only range related stat cache
1464 1464
 		give_delete_donation_stats();
@@ -1476,26 +1476,26 @@  discard block
 block discarded – undo
1476 1476
 		$process_cancelled = true;
1477 1477
 
1478 1478
 		// If the payment was not in publish or revoked status, don't decrement stats as they were never incremented.
1479
-		if ( 'publish' != $this->old_status || 'cancelled' != $this->status ) {
1479
+		if ('publish' != $this->old_status || 'cancelled' != $this->status) {
1480 1480
 			$process_cancelled = false;
1481 1481
 		}
1482 1482
 
1483 1483
 		// Allow extensions to filter for their own payment types, Example: Recurring Payments.
1484
-		$process_cancelled = apply_filters( 'give_should_process_cancelled', $process_cancelled, $this );
1484
+		$process_cancelled = apply_filters('give_should_process_cancelled', $process_cancelled, $this);
1485 1485
 
1486
-		if ( false === $process_cancelled ) {
1486
+		if (false === $process_cancelled) {
1487 1487
 			return;
1488 1488
 		}
1489 1489
 
1490
-		$decrease_earnings       = apply_filters( 'give_decrease_earnings_on_cancelled', true, $this );
1491
-		$decrease_donor_value    = apply_filters( 'give_decrease_donor_value_on_cancelled', true, $this );
1492
-		$decrease_donation_count = apply_filters( 'give_decrease_donors_donation_count_on_cancelled', true, $this );
1490
+		$decrease_earnings       = apply_filters('give_decrease_earnings_on_cancelled', true, $this);
1491
+		$decrease_donor_value    = apply_filters('give_decrease_donor_value_on_cancelled', true, $this);
1492
+		$decrease_donation_count = apply_filters('give_decrease_donors_donation_count_on_cancelled', true, $this);
1493 1493
 
1494
-		$this->maybe_alter_stats( $decrease_earnings, $decrease_donor_value, $decrease_donation_count );
1494
+		$this->maybe_alter_stats($decrease_earnings, $decrease_donor_value, $decrease_donation_count);
1495 1495
 		$this->delete_sales_logs();
1496 1496
 
1497 1497
 		$this->completed_date = false;
1498
-		$this->update_meta( '_give_completed_date', '' );
1498
+		$this->update_meta('_give_completed_date', '');
1499 1499
 
1500 1500
 		// @todo: Refresh only range related stat cache
1501 1501
 		give_delete_donation_stats();
@@ -1511,26 +1511,26 @@  discard block
 block discarded – undo
1511 1511
 		$process_revoked = true;
1512 1512
 
1513 1513
 		// If the payment was not in publish, don't decrement stats as they were never incremented.
1514
-		if ( 'publish' != $this->old_status || 'revoked' != $this->status ) {
1514
+		if ('publish' != $this->old_status || 'revoked' != $this->status) {
1515 1515
 			$process_revoked = false;
1516 1516
 		}
1517 1517
 
1518 1518
 		// Allow extensions to filter for their own payment types, Example: Recurring Payments.
1519
-		$process_revoked = apply_filters( 'give_should_process_revoked', $process_revoked, $this );
1519
+		$process_revoked = apply_filters('give_should_process_revoked', $process_revoked, $this);
1520 1520
 
1521
-		if ( false === $process_revoked ) {
1521
+		if (false === $process_revoked) {
1522 1522
 			return;
1523 1523
 		}
1524 1524
 
1525
-		$decrease_earnings       = apply_filters( 'give_decrease_earnings_on_revoked', true, $this );
1526
-		$decrease_donor_value    = apply_filters( 'give_decrease_donor_value_on_revoked', true, $this );
1527
-		$decrease_donation_count = apply_filters( 'give_decrease_donors_donation_count_on_revoked', true, $this );
1525
+		$decrease_earnings       = apply_filters('give_decrease_earnings_on_revoked', true, $this);
1526
+		$decrease_donor_value    = apply_filters('give_decrease_donor_value_on_revoked', true, $this);
1527
+		$decrease_donation_count = apply_filters('give_decrease_donors_donation_count_on_revoked', true, $this);
1528 1528
 
1529
-		$this->maybe_alter_stats( $decrease_earnings, $decrease_donor_value, $decrease_donation_count );
1529
+		$this->maybe_alter_stats($decrease_earnings, $decrease_donor_value, $decrease_donation_count);
1530 1530
 		$this->delete_sales_logs();
1531 1531
 
1532 1532
 		$this->completed_date = false;
1533
-		$this->update_meta( '_give_completed_date', '' );
1533
+		$this->update_meta('_give_completed_date', '');
1534 1534
 
1535 1535
 		// @todo: Refresh only range related stat cache
1536 1536
 		give_delete_donation_stats();
@@ -1548,25 +1548,25 @@  discard block
 block discarded – undo
1548 1548
 	 *
1549 1549
 	 * @return void
1550 1550
 	 */
1551
-	private function maybe_alter_stats( $alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count ) {
1551
+	private function maybe_alter_stats($alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count) {
1552 1552
 
1553
-		give_undo_donation( $this->ID );
1553
+		give_undo_donation($this->ID);
1554 1554
 
1555 1555
 		// Decrease store earnings.
1556
-		if ( true === $alter_store_earnings ) {
1557
-			give_decrease_total_earnings( $this->total );
1556
+		if (true === $alter_store_earnings) {
1557
+			give_decrease_total_earnings($this->total);
1558 1558
 		}
1559 1559
 
1560 1560
 		// Decrement the stats for the donor.
1561
-		if ( ! empty( $this->customer_id ) ) {
1561
+		if ( ! empty($this->customer_id)) {
1562 1562
 
1563
-			$donor = new Give_Donor( $this->customer_id );
1563
+			$donor = new Give_Donor($this->customer_id);
1564 1564
 
1565
-			if ( true === $alter_customer_value ) {
1566
-				$donor->decrease_value( $this->total );
1565
+			if (true === $alter_customer_value) {
1566
+				$donor->decrease_value($this->total);
1567 1567
 			}
1568 1568
 
1569
-			if ( true === $alter_customer_purchase_count ) {
1569
+			if (true === $alter_customer_purchase_count) {
1570 1570
 				$donor->decrease_donation_count();
1571 1571
 			}
1572 1572
 		}
@@ -1583,7 +1583,7 @@  discard block
 block discarded – undo
1583 1583
 	 */
1584 1584
 	private function delete_sales_logs() {
1585 1585
 		// Remove related sale log entries.
1586
-		Give()->logs->delete_logs( $this->ID );
1586
+		Give()->logs->delete_logs($this->ID);
1587 1587
 	}
1588 1588
 
1589 1589
 	/**
@@ -1604,13 +1604,13 @@  discard block
 block discarded – undo
1604 1604
 	 * @return string The date the payment was completed
1605 1605
 	 */
1606 1606
 	private function setup_completed_date() {
1607
-		$payment = get_post( $this->ID );
1607
+		$payment = get_post($this->ID);
1608 1608
 
1609
-		if ( 'pending' == $payment->post_status || 'preapproved' == $payment->post_status ) {
1609
+		if ('pending' == $payment->post_status || 'preapproved' == $payment->post_status) {
1610 1610
 			return false; // This payment was never completed.
1611 1611
 		}
1612 1612
 
1613
-		$date = ( $date = $this->get_meta( '_give_completed_date', true ) ) ? $date : $payment->modified_date;
1613
+		$date = ($date = $this->get_meta('_give_completed_date', true)) ? $date : $payment->modified_date;
1614 1614
 
1615 1615
 		return $date;
1616 1616
 	}
@@ -1624,7 +1624,7 @@  discard block
 block discarded – undo
1624 1624
 	 * @return string The payment mode
1625 1625
 	 */
1626 1626
 	private function setup_mode() {
1627
-		return $this->get_meta( '_give_payment_mode' );
1627
+		return $this->get_meta('_give_payment_mode');
1628 1628
 	}
1629 1629
 
1630 1630
 	/**
@@ -1636,7 +1636,7 @@  discard block
 block discarded – undo
1636 1636
 	 * @return bool The payment import
1637 1637
 	 */
1638 1638
 	private function setup_import() {
1639
-		return (bool) $this->get_meta( '_give_payment_import' );
1639
+		return (bool) $this->get_meta('_give_payment_import');
1640 1640
 	}
1641 1641
 
1642 1642
 	/**
@@ -1648,9 +1648,9 @@  discard block
 block discarded – undo
1648 1648
 	 * @return float The payment total
1649 1649
 	 */
1650 1650
 	private function setup_total() {
1651
-		$amount = $this->get_meta( '_give_payment_total', true );
1651
+		$amount = $this->get_meta('_give_payment_total', true);
1652 1652
 
1653
-		return round( floatval( $amount ), give_get_price_decimals( $this->ID ) );
1653
+		return round(floatval($amount), give_get_price_decimals($this->ID));
1654 1654
 	}
1655 1655
 
1656 1656
 	/**
@@ -1677,17 +1677,16 @@  discard block
 block discarded – undo
1677 1677
 	 * @return string The currency for the payment
1678 1678
 	 */
1679 1679
 	private function setup_currency() {
1680
-		$currency = $this->get_meta( '_give_payment_currency', true );
1681
-		$currency = ! empty( $currency ) ?
1682
-			$currency :
1683
-			/**
1680
+		$currency = $this->get_meta('_give_payment_currency', true);
1681
+		$currency = ! empty($currency) ?
1682
+			$currency : /**
1684 1683
 			 * Filter the default donation currency
1685 1684
 			 *
1686 1685
 			 * @since 1.5
1687 1686
 			 */
1688 1687
 			apply_filters(
1689 1688
 				'give_payment_currency_default',
1690
-				give_get_currency( $this->form_id, $this ),
1689
+				give_get_currency($this->form_id, $this),
1691 1690
 				$this
1692 1691
 			);
1693 1692
 
@@ -1703,7 +1702,7 @@  discard block
 block discarded – undo
1703 1702
 	 * @return string The gateway
1704 1703
 	 */
1705 1704
 	private function setup_gateway() {
1706
-		$gateway = $this->get_meta( '_give_payment_gateway', true );
1705
+		$gateway = $this->get_meta('_give_payment_gateway', true);
1707 1706
 
1708 1707
 		return $gateway;
1709 1708
 	}
@@ -1717,11 +1716,11 @@  discard block
 block discarded – undo
1717 1716
 	 * @return string The donation ID
1718 1717
 	 */
1719 1718
 	private function setup_transaction_id() {
1720
-		$transaction_id = $this->get_meta( '_give_payment_transaction_id', true );
1719
+		$transaction_id = $this->get_meta('_give_payment_transaction_id', true);
1721 1720
 
1722
-		if ( empty( $transaction_id ) ) {
1721
+		if (empty($transaction_id)) {
1723 1722
 			$gateway        = $this->gateway;
1724
-			$transaction_id = apply_filters( "give_get_payment_transaction_id-{$gateway}", $this->ID );
1723
+			$transaction_id = apply_filters("give_get_payment_transaction_id-{$gateway}", $this->ID);
1725 1724
 		}
1726 1725
 
1727 1726
 		return $transaction_id;
@@ -1737,7 +1736,7 @@  discard block
 block discarded – undo
1737 1736
 	 * @return string The IP address for the payment
1738 1737
 	 */
1739 1738
 	private function setup_ip() {
1740
-		$ip = $this->get_meta( '_give_payment_donor_ip', true );
1739
+		$ip = $this->get_meta('_give_payment_donor_ip', true);
1741 1740
 
1742 1741
 		return $ip;
1743 1742
 	}
@@ -1752,7 +1751,7 @@  discard block
 block discarded – undo
1752 1751
 	 * @return int The Donor ID.
1753 1752
 	 */
1754 1753
 	private function setup_donor_id() {
1755
-		$donor_id = $this->get_meta( '_give_payment_donor_id', true );
1754
+		$donor_id = $this->get_meta('_give_payment_donor_id', true);
1756 1755
 
1757 1756
 		return $donor_id;
1758 1757
 	}
@@ -1769,8 +1768,8 @@  discard block
 block discarded – undo
1769 1768
 	 */
1770 1769
 	private function setup_user_id() {
1771 1770
 
1772
-		$donor   = Give()->customers->get_customer_by( 'id', $this->customer_id );
1773
-		$user_id = $donor ? absint( $donor->user_id ) : 0;
1771
+		$donor   = Give()->customers->get_customer_by('id', $this->customer_id);
1772
+		$user_id = $donor ? absint($donor->user_id) : 0;
1774 1773
 
1775 1774
 
1776 1775
 		return $user_id;
@@ -1787,10 +1786,10 @@  discard block
 block discarded – undo
1787 1786
 	 * @return string The email address for the payment.
1788 1787
 	 */
1789 1788
 	private function setup_email() {
1790
-		$email = $this->get_meta( '_give_payment_donor_email', true );
1789
+		$email = $this->get_meta('_give_payment_donor_email', true);
1791 1790
 
1792
-		if ( empty( $email ) && $this->customer_id ) {
1793
-			$email = Give()->donors->get_column( 'email', $this->customer_id );
1791
+		if (empty($email) && $this->customer_id) {
1792
+			$email = Give()->donors->get_column('email', $this->customer_id);
1794 1793
 		}
1795 1794
 
1796 1795
 		return $email;
@@ -1810,22 +1809,22 @@  discard block
 block discarded – undo
1810 1809
 			'last_name'  => $this->last_name,
1811 1810
 		);
1812 1811
 
1813
-		$user_info = isset( $this->payment_meta['user_info'] ) ? $this->payment_meta['user_info'] : array();
1812
+		$user_info = isset($this->payment_meta['user_info']) ? $this->payment_meta['user_info'] : array();
1814 1813
 
1815
-		if ( is_serialized( $user_info ) ) {
1816
-			preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches );
1817
-			if ( ! empty( $matches ) ) {
1814
+		if (is_serialized($user_info)) {
1815
+			preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches);
1816
+			if ( ! empty($matches)) {
1818 1817
 				$user_info = array();
1819 1818
 			}
1820 1819
 		}
1821 1820
 
1822
-		$user_info = wp_parse_args( $user_info, $defaults );
1821
+		$user_info = wp_parse_args($user_info, $defaults);
1823 1822
 
1824
-		if ( empty( $user_info ) ) {
1823
+		if (empty($user_info)) {
1825 1824
 			// Get the donor, but only if it's been created.
1826
-			$donor = new Give_Donor( $this->customer_id );
1825
+			$donor = new Give_Donor($this->customer_id);
1827 1826
 
1828
-			if ( $donor->id > 0 ) {
1827
+			if ($donor->id > 0) {
1829 1828
 				$user_info = array(
1830 1829
 					'first_name' => $donor->get_first_name(),
1831 1830
 					'last_name'  => $donor->get_last_name(),
@@ -1835,25 +1834,25 @@  discard block
 block discarded – undo
1835 1834
 			}
1836 1835
 		} else {
1837 1836
 			// Get the donor, but only if it's been created.
1838
-			$donor = new Give_Donor( $this->customer_id );
1837
+			$donor = new Give_Donor($this->customer_id);
1839 1838
 
1840
-			if ( $donor->id > 0 ) {
1841
-				foreach ( $user_info as $key => $value ) {
1842
-					if ( ! empty( $value ) ) {
1839
+			if ($donor->id > 0) {
1840
+				foreach ($user_info as $key => $value) {
1841
+					if ( ! empty($value)) {
1843 1842
 						continue;
1844 1843
 					}
1845 1844
 
1846
-					switch ( $key ) {
1845
+					switch ($key) {
1847 1846
 						case 'first_name':
1848
-							$user_info[ $key ] = $donor->get_first_name();
1847
+							$user_info[$key] = $donor->get_first_name();
1849 1848
 							break;
1850 1849
 
1851 1850
 						case 'last_name':
1852
-							$user_info[ $key ] = $donor->get_last_name();
1851
+							$user_info[$key] = $donor->get_last_name();
1853 1852
 							break;
1854 1853
 
1855 1854
 						case 'email':
1856
-							$user_info[ $key ] = $donor->email;
1855
+							$user_info[$key] = $donor->email;
1857 1856
 							break;
1858 1857
 					}
1859 1858
 				}
@@ -1873,12 +1872,12 @@  discard block
 block discarded – undo
1873 1872
 	 * @return array The Address information for the payment.
1874 1873
 	 */
1875 1874
 	private function setup_address() {
1876
-		$address['line1']   = give_get_meta( $this->ID, '_give_donor_billing_address1', true, '' );
1877
-		$address['line2']   = give_get_meta( $this->ID, '_give_donor_billing_address2', true, '' );
1878
-		$address['city']    = give_get_meta( $this->ID, '_give_donor_billing_city', true, '' );
1879
-		$address['state']   = give_get_meta( $this->ID, '_give_donor_billing_state', true, '' );
1880
-		$address['zip']     = give_get_meta( $this->ID, '_give_donor_billing_zip', true, '' );
1881
-		$address['country'] = give_get_meta( $this->ID, '_give_donor_billing_country', true, '' );
1875
+		$address['line1']   = give_get_meta($this->ID, '_give_donor_billing_address1', true, '');
1876
+		$address['line2']   = give_get_meta($this->ID, '_give_donor_billing_address2', true, '');
1877
+		$address['city']    = give_get_meta($this->ID, '_give_donor_billing_city', true, '');
1878
+		$address['state']   = give_get_meta($this->ID, '_give_donor_billing_state', true, '');
1879
+		$address['zip']     = give_get_meta($this->ID, '_give_donor_billing_zip', true, '');
1880
+		$address['country'] = give_get_meta($this->ID, '_give_donor_billing_country', true, '');
1882 1881
 
1883 1882
 		return $address;
1884 1883
 	}
@@ -1893,7 +1892,7 @@  discard block
 block discarded – undo
1893 1892
 	 */
1894 1893
 	private function setup_form_title() {
1895 1894
 
1896
-		$form_id = $this->get_meta( '_give_payment_form_title', true );
1895
+		$form_id = $this->get_meta('_give_payment_form_title', true);
1897 1896
 
1898 1897
 		return $form_id;
1899 1898
 	}
@@ -1908,7 +1907,7 @@  discard block
 block discarded – undo
1908 1907
 	 */
1909 1908
 	private function setup_form_id() {
1910 1909
 
1911
-		$form_id = $this->get_meta( '_give_payment_form_id', true );
1910
+		$form_id = $this->get_meta('_give_payment_form_id', true);
1912 1911
 
1913 1912
 		return $form_id;
1914 1913
 	}
@@ -1922,7 +1921,7 @@  discard block
 block discarded – undo
1922 1921
 	 * @return int The Form Price ID.
1923 1922
 	 */
1924 1923
 	private function setup_price_id() {
1925
-		$price_id = $this->get_meta( '_give_payment_price_id', true );
1924
+		$price_id = $this->get_meta('_give_payment_price_id', true);
1926 1925
 
1927 1926
 		return $price_id;
1928 1927
 	}
@@ -1936,7 +1935,7 @@  discard block
 block discarded – undo
1936 1935
 	 * @return string The Payment Key.
1937 1936
 	 */
1938 1937
 	private function setup_payment_key() {
1939
-		$key = $this->get_meta( '_give_payment_purchase_key', true );
1938
+		$key = $this->get_meta('_give_payment_purchase_key', true);
1940 1939
 
1941 1940
 		return $key;
1942 1941
 	}
@@ -1952,11 +1951,11 @@  discard block
 block discarded – undo
1952 1951
 	private function setup_payment_number() {
1953 1952
 		$number = $this->ID;
1954 1953
 
1955
-		if ( give_get_option( 'enable_sequential' ) ) {
1954
+		if (give_get_option('enable_sequential')) {
1956 1955
 
1957
-			$number = $this->get_meta( '_give_payment_number', true );
1956
+			$number = $this->get_meta('_give_payment_number', true);
1958 1957
 
1959
-			if ( ! $number ) {
1958
+			if ( ! $number) {
1960 1959
 
1961 1960
 				$number = $this->ID;
1962 1961
 
@@ -1974,7 +1973,7 @@  discard block
 block discarded – undo
1974 1973
 	 * @return array The payment object as an array.
1975 1974
 	 */
1976 1975
 	public function array_convert() {
1977
-		return get_object_vars( $this );
1976
+		return get_object_vars($this);
1978 1977
 	}
1979 1978
 
1980 1979
 
@@ -1987,7 +1986,7 @@  discard block
 block discarded – undo
1987 1986
 	 * @return bool
1988 1987
 	 */
1989 1988
 	public function is_completed() {
1990
-		return ( 'publish' === $this->status && $this->completed_date );
1989
+		return ('publish' === $this->status && $this->completed_date);
1991 1990
 	}
1992 1991
 
1993 1992
 	/**
@@ -1999,7 +1998,7 @@  discard block
 block discarded – undo
1999 1998
 	 * @return string Date payment was completed.
2000 1999
 	 */
2001 2000
 	private function get_completed_date() {
2002
-		return apply_filters( 'give_payment_completed_date', $this->completed_date, $this->ID, $this );
2001
+		return apply_filters('give_payment_completed_date', $this->completed_date, $this->ID, $this);
2003 2002
 	}
2004 2003
 
2005 2004
 	/**
@@ -2011,7 +2010,7 @@  discard block
 block discarded – undo
2011 2010
 	 * @return float Payment subtotal.
2012 2011
 	 */
2013 2012
 	private function get_subtotal() {
2014
-		return apply_filters( 'give_get_payment_subtotal', $this->subtotal, $this->ID, $this );
2013
+		return apply_filters('give_get_payment_subtotal', $this->subtotal, $this->ID, $this);
2015 2014
 	}
2016 2015
 
2017 2016
 	/**
@@ -2023,7 +2022,7 @@  discard block
 block discarded – undo
2023 2022
 	 * @return string Payment currency code.
2024 2023
 	 */
2025 2024
 	private function get_currency() {
2026
-		return apply_filters( 'give_payment_currency_code', $this->currency, $this->ID, $this );
2025
+		return apply_filters('give_payment_currency_code', $this->currency, $this->ID, $this);
2027 2026
 	}
2028 2027
 
2029 2028
 	/**
@@ -2035,7 +2034,7 @@  discard block
 block discarded – undo
2035 2034
 	 * @return string Gateway used.
2036 2035
 	 */
2037 2036
 	private function get_gateway() {
2038
-		return apply_filters( 'give_payment_gateway', $this->gateway, $this->ID, $this );
2037
+		return apply_filters('give_payment_gateway', $this->gateway, $this->ID, $this);
2039 2038
 	}
2040 2039
 
2041 2040
 	/**
@@ -2047,7 +2046,7 @@  discard block
 block discarded – undo
2047 2046
 	 * @return string Donation ID from merchant processor.
2048 2047
 	 */
2049 2048
 	private function get_transaction_id() {
2050
-		return apply_filters( 'give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this );
2049
+		return apply_filters('give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this);
2051 2050
 	}
2052 2051
 
2053 2052
 	/**
@@ -2059,7 +2058,7 @@  discard block
 block discarded – undo
2059 2058
 	 * @return string Payment IP address
2060 2059
 	 */
2061 2060
 	private function get_ip() {
2062
-		return apply_filters( 'give_payment_user_ip', $this->ip, $this->ID, $this );
2061
+		return apply_filters('give_payment_user_ip', $this->ip, $this->ID, $this);
2063 2062
 	}
2064 2063
 
2065 2064
 	/**
@@ -2071,7 +2070,7 @@  discard block
 block discarded – undo
2071 2070
 	 * @return int Payment donor ID.
2072 2071
 	 */
2073 2072
 	private function get_donor_id() {
2074
-		return apply_filters( 'give_payment_customer_id', $this->customer_id, $this->ID, $this );
2073
+		return apply_filters('give_payment_customer_id', $this->customer_id, $this->ID, $this);
2075 2074
 	}
2076 2075
 
2077 2076
 	/**
@@ -2083,7 +2082,7 @@  discard block
 block discarded – undo
2083 2082
 	 * @return int Payment user ID.
2084 2083
 	 */
2085 2084
 	private function get_user_id() {
2086
-		return apply_filters( 'give_payment_user_id', $this->user_id, $this->ID, $this );
2085
+		return apply_filters('give_payment_user_id', $this->user_id, $this->ID, $this);
2087 2086
 	}
2088 2087
 
2089 2088
 	/**
@@ -2095,7 +2094,7 @@  discard block
 block discarded – undo
2095 2094
 	 * @return string Payment donor email.
2096 2095
 	 */
2097 2096
 	private function get_email() {
2098
-		return apply_filters( 'give_payment_user_email', $this->email, $this->ID, $this );
2097
+		return apply_filters('give_payment_user_email', $this->email, $this->ID, $this);
2099 2098
 	}
2100 2099
 
2101 2100
 	/**
@@ -2107,7 +2106,7 @@  discard block
 block discarded – undo
2107 2106
 	 * @return array Payment user info.
2108 2107
 	 */
2109 2108
 	private function get_user_info() {
2110
-		return apply_filters( 'give_payment_meta_user_info', $this->user_info, $this->ID, $this );
2109
+		return apply_filters('give_payment_meta_user_info', $this->user_info, $this->ID, $this);
2111 2110
 	}
2112 2111
 
2113 2112
 	/**
@@ -2119,7 +2118,7 @@  discard block
 block discarded – undo
2119 2118
 	 * @return array Payment billing address.
2120 2119
 	 */
2121 2120
 	private function get_address() {
2122
-		return apply_filters( 'give_payment_address', $this->address, $this->ID, $this );
2121
+		return apply_filters('give_payment_address', $this->address, $this->ID, $this);
2123 2122
 	}
2124 2123
 
2125 2124
 	/**
@@ -2131,7 +2130,7 @@  discard block
 block discarded – undo
2131 2130
 	 * @return string Payment key.
2132 2131
 	 */
2133 2132
 	private function get_key() {
2134
-		return apply_filters( 'give_payment_key', $this->key, $this->ID, $this );
2133
+		return apply_filters('give_payment_key', $this->key, $this->ID, $this);
2135 2134
 	}
2136 2135
 
2137 2136
 	/**
@@ -2143,7 +2142,7 @@  discard block
 block discarded – undo
2143 2142
 	 * @return string Payment form id
2144 2143
 	 */
2145 2144
 	private function get_form_id() {
2146
-		return apply_filters( 'give_payment_form_id', $this->form_id, $this->ID, $this );
2145
+		return apply_filters('give_payment_form_id', $this->form_id, $this->ID, $this);
2147 2146
 	}
2148 2147
 
2149 2148
 	/**
@@ -2155,6 +2154,6 @@  discard block
 block discarded – undo
2155 2154
 	 * @return int|string Payment number
2156 2155
 	 */
2157 2156
 	private function get_number() {
2158
-		return apply_filters( 'give_payment_number', $this->number, $this->ID, $this );
2157
+		return apply_filters('give_payment_number', $this->number, $this->ID, $this);
2159 2158
 	}
2160 2159
 }
Please login to merge, or discard this patch.
includes/template-functions.php 1 patch
Spacing   +81 added lines, -81 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,7 +21,7 @@  discard block
 block discarded – undo
21 21
  * @return string
22 22
  */
23 23
 function give_get_templates_dir() {
24
-	return GIVE_PLUGIN_DIR . 'templates';
24
+	return GIVE_PLUGIN_DIR.'templates';
25 25
 }
26 26
 
27 27
 /**
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
  * @return string
32 32
  */
33 33
 function give_get_templates_url() {
34
-	return GIVE_PLUGIN_URL . 'templates';
34
+	return GIVE_PLUGIN_URL.'templates';
35 35
 }
36 36
 
37 37
 /**
@@ -44,24 +44,24 @@  discard block
 block discarded – undo
44 44
  * @param string $template_path Template file path. Default is empty.
45 45
  * @param string $default_path  Default path. Default is empty.
46 46
  */
47
-function give_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
48
-	if ( ! empty( $args ) && is_array( $args ) ) {
49
-		extract( $args );
47
+function give_get_template($template_name, $args = array(), $template_path = '', $default_path = '') {
48
+	if ( ! empty($args) && is_array($args)) {
49
+		extract($args);
50 50
 	}
51 51
 
52
-	$template_names = array( $template_name . '.php' );
52
+	$template_names = array($template_name.'.php');
53 53
 
54
-	$located = give_locate_template( $template_names, $template_path, $default_path );
54
+	$located = give_locate_template($template_names, $template_path, $default_path);
55 55
 
56
-	if ( ! file_exists( $located ) ) {
56
+	if ( ! file_exists($located)) {
57 57
 		/* translators: %s: the template */
58
-		Give()->notices->print_frontend_notice( sprintf( __( 'The %s template was not found.', 'give' ), $located ), true );
58
+		Give()->notices->print_frontend_notice(sprintf(__('The %s template was not found.', 'give'), $located), true);
59 59
 
60 60
 		return;
61 61
 	}
62 62
 
63 63
 	// Allow 3rd party plugin filter template file from their plugin.
64
-	$located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path );
64
+	$located = apply_filters('give_get_template', $located, $template_name, $args, $template_path, $default_path);
65 65
 
66 66
 	/**
67 67
 	 * Fires in give template, before the file is included.
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
 	 * @param string $located       Template file filter by 3rd party plugin.
76 76
 	 * @param array  $args          Passed arguments.
77 77
 	 */
78
-	do_action( 'give_before_template_part', $template_name, $template_path, $located, $args );
78
+	do_action('give_before_template_part', $template_name, $template_path, $located, $args);
79 79
 
80
-	include( $located );
80
+	include($located);
81 81
 
82 82
 	/**
83 83
 	 * Fires in give template, after the file is included.
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	 * @param string $located       Template file filter by 3rd party plugin.
92 92
 	 * @param array  $args          Passed arguments.
93 93
 	 */
94
-	do_action( 'give_after_template_part', $template_name, $template_path, $located, $args );
94
+	do_action('give_after_template_part', $template_name, $template_path, $located, $args);
95 95
 }
96 96
 
97 97
 /**
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
  *
108 108
  * @return string
109 109
  */
110
-function give_get_template_part( $slug, $name = null, $load = true ) {
110
+function give_get_template_part($slug, $name = null, $load = true) {
111 111
 
112 112
 	/**
113 113
 	 * Fires in give template part, before the template part is retrieved.
@@ -119,20 +119,20 @@  discard block
 block discarded – undo
119 119
 	 * @param string $slug Template part file slug {slug}.php.
120 120
 	 * @param string $name Template part file name {slug}-{name}.php.
121 121
 	 */
122
-	do_action( "get_template_part_{$slug}", $slug, $name );
122
+	do_action("get_template_part_{$slug}", $slug, $name);
123 123
 
124 124
 	// Setup possible parts
125 125
 	$templates = array();
126
-	if ( isset( $name ) ) {
127
-		$templates[] = $slug . '-' . $name . '.php';
126
+	if (isset($name)) {
127
+		$templates[] = $slug.'-'.$name.'.php';
128 128
 	}
129
-	$templates[] = $slug . '.php';
129
+	$templates[] = $slug.'.php';
130 130
 
131 131
 	// Allow template parts to be filtered
132
-	$templates = apply_filters( 'give_get_template_part', $templates, $slug, $name );
132
+	$templates = apply_filters('give_get_template_part', $templates, $slug, $name);
133 133
 
134 134
 	// Return the part that is found
135
-	return give_locate_template( $templates, $load, false );
135
+	return give_locate_template($templates, $load, false);
136 136
 }
137 137
 
138 138
 /**
@@ -153,37 +153,37 @@  discard block
 block discarded – undo
153 153
  *
154 154
  * @return string The template filename if one is located.
155 155
  */
156
-function give_locate_template( $template_names, $load = false, $require_once = true ) {
156
+function give_locate_template($template_names, $load = false, $require_once = true) {
157 157
 	// No file found yet
158 158
 	$located = false;
159 159
 
160 160
 	// Try to find a template file
161
-	foreach ( (array) $template_names as $template_name ) {
161
+	foreach ((array) $template_names as $template_name) {
162 162
 
163 163
 		// Continue if template is empty
164
-		if ( empty( $template_name ) ) {
164
+		if (empty($template_name)) {
165 165
 			continue;
166 166
 		}
167 167
 
168 168
 		// Trim off any slashes from the template name
169
-		$template_name = ltrim( $template_name, '/' );
169
+		$template_name = ltrim($template_name, '/');
170 170
 
171 171
 		// try locating this template file by looping through the template paths
172
-		foreach ( give_get_theme_template_paths() as $template_path ) {
172
+		foreach (give_get_theme_template_paths() as $template_path) {
173 173
 
174
-			if ( file_exists( $template_path . $template_name ) ) {
175
-				$located = $template_path . $template_name;
174
+			if (file_exists($template_path.$template_name)) {
175
+				$located = $template_path.$template_name;
176 176
 				break;
177 177
 			}
178 178
 		}
179 179
 
180
-		if ( $located ) {
180
+		if ($located) {
181 181
 			break;
182 182
 		}
183 183
 	}
184 184
 
185
-	if ( ( true == $load ) && ! empty( $located ) ) {
186
-		load_template( $located, $require_once );
185
+	if ((true == $load) && ! empty($located)) {
186
+		load_template($located, $require_once);
187 187
 	}
188 188
 
189 189
 	return $located;
@@ -200,17 +200,17 @@  discard block
 block discarded – undo
200 200
 	$template_dir = give_get_theme_template_dir_name();
201 201
 
202 202
 	$file_paths = array(
203
-		1   => trailingslashit( get_stylesheet_directory() ) . $template_dir,
204
-		10  => trailingslashit( get_template_directory() ) . $template_dir,
203
+		1   => trailingslashit(get_stylesheet_directory()).$template_dir,
204
+		10  => trailingslashit(get_template_directory()).$template_dir,
205 205
 		100 => give_get_templates_dir(),
206 206
 	);
207 207
 
208
-	$file_paths = apply_filters( 'give_template_paths', $file_paths );
208
+	$file_paths = apply_filters('give_template_paths', $file_paths);
209 209
 
210 210
 	// sort the file paths based on priority
211
-	ksort( $file_paths, SORT_NUMERIC );
211
+	ksort($file_paths, SORT_NUMERIC);
212 212
 
213
-	return array_map( 'trailingslashit', $file_paths );
213
+	return array_map('trailingslashit', $file_paths);
214 214
 }
215 215
 
216 216
 /**
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
  * @return string
223 223
  */
224 224
 function give_get_theme_template_dir_name() {
225
-	return trailingslashit( apply_filters( 'give_templates_dir', 'give' ) );
225
+	return trailingslashit(apply_filters('give_templates_dir', 'give'));
226 226
 }
227 227
 
228 228
 /**
@@ -232,10 +232,10 @@  discard block
 block discarded – undo
232 232
  * @return void
233 233
  */
234 234
 function give_version_in_header() {
235
-	echo '<meta name="generator" content="Give v' . GIVE_VERSION . '" />' . "\n";
235
+	echo '<meta name="generator" content="Give v'.GIVE_VERSION.'" />'."\n";
236 236
 }
237 237
 
238
-add_action( 'wp_head', 'give_version_in_header' );
238
+add_action('wp_head', 'give_version_in_header');
239 239
 
240 240
 /**
241 241
  * Determines if we're currently on the Donations History page.
@@ -245,9 +245,9 @@  discard block
 block discarded – undo
245 245
  */
246 246
 function give_is_donation_history_page() {
247 247
 
248
-	$ret = is_page( give_get_option( 'history_page' ) );
248
+	$ret = is_page(give_get_option('history_page'));
249 249
 
250
-	return apply_filters( 'give_is_donation_history_page', $ret );
250
+	return apply_filters('give_is_donation_history_page', $ret);
251 251
 }
252 252
 
253 253
 /**
@@ -259,25 +259,25 @@  discard block
 block discarded – undo
259 259
  *
260 260
  * @return array Modified array of classes
261 261
  */
262
-function give_add_body_classes( $class ) {
262
+function give_add_body_classes($class) {
263 263
 	$classes = (array) $class;
264 264
 
265
-	if ( give_is_success_page() ) {
265
+	if (give_is_success_page()) {
266 266
 		$classes[] = 'give-success';
267 267
 		$classes[] = 'give-page';
268 268
 	}
269 269
 
270
-	if ( give_is_failed_transaction_page() ) {
270
+	if (give_is_failed_transaction_page()) {
271 271
 		$classes[] = 'give-failed-transaction';
272 272
 		$classes[] = 'give-page';
273 273
 	}
274 274
 
275
-	if ( give_is_donation_history_page() ) {
275
+	if (give_is_donation_history_page()) {
276 276
 		$classes[] = 'give-donation-history';
277 277
 		$classes[] = 'give-page';
278 278
 	}
279 279
 
280
-	if ( give_is_test_mode() ) {
280
+	if (give_is_test_mode()) {
281 281
 		$classes[] = 'give-test-mode';
282 282
 		$classes[] = 'give-page';
283 283
 	}
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 	/* @var WP_Theme $current_theme */
287 287
 	$current_theme = wp_get_theme();
288 288
 
289
-	switch ( $current_theme->get_template() ) {
289
+	switch ($current_theme->get_template()) {
290 290
 
291 291
 		case 'Divi':
292 292
 			$classes[] = 'give-divi';
@@ -303,10 +303,10 @@  discard block
 block discarded – undo
303 303
 
304 304
 	}
305 305
 
306
-	return array_unique( $classes );
306
+	return array_unique($classes);
307 307
 }
308 308
 
309
-add_filter( 'body_class', 'give_add_body_classes' );
309
+add_filter('body_class', 'give_add_body_classes');
310 310
 
311 311
 
312 312
 /**
@@ -322,22 +322,22 @@  discard block
 block discarded – undo
322 322
  *
323 323
  * @return array
324 324
  */
325
-function give_add_post_class( $classes, $class = '', $post_id = '' ) {
326
-	if ( ! $post_id || 'give_forms' !== get_post_type( $post_id ) ) {
325
+function give_add_post_class($classes, $class = '', $post_id = '') {
326
+	if ( ! $post_id || 'give_forms' !== get_post_type($post_id)) {
327 327
 		return $classes;
328 328
 	}
329 329
 
330 330
 	//@TODO: Add classes for custom taxonomy and form configurations (multi vs single donations, etc).
331 331
 
332
-	if ( false !== ( $key = array_search( 'hentry', $classes ) ) ) {
333
-		unset( $classes[ $key ] );
332
+	if (false !== ($key = array_search('hentry', $classes))) {
333
+		unset($classes[$key]);
334 334
 	}
335 335
 
336 336
 	return $classes;
337 337
 }
338 338
 
339 339
 
340
-add_filter( 'post_class', 'give_add_post_class', 20, 3 );
340
+add_filter('post_class', 'give_add_post_class', 20, 3);
341 341
 
342 342
 /**
343 343
  * Get the placeholder image URL for forms etc
@@ -347,74 +347,74 @@  discard block
 block discarded – undo
347 347
  */
348 348
 function give_get_placeholder_img_src() {
349 349
 
350
-	$placeholder_url = '//placehold.it/600x600&text=' . urlencode( esc_attr__( 'Give Placeholder Image', 'give' ) );
350
+	$placeholder_url = '//placehold.it/600x600&text='.urlencode(esc_attr__('Give Placeholder Image', 'give'));
351 351
 
352
-	return apply_filters( 'give_placeholder_img_src', $placeholder_url );
352
+	return apply_filters('give_placeholder_img_src', $placeholder_url);
353 353
 }
354 354
 
355 355
 
356 356
 /**
357 357
  * Global
358 358
  */
359
-if ( ! function_exists( 'give_output_content_wrapper' ) ) {
359
+if ( ! function_exists('give_output_content_wrapper')) {
360 360
 
361 361
 	/**
362 362
 	 * Output the start of the page wrapper.
363 363
 	 */
364 364
 	function give_output_content_wrapper() {
365
-		give_get_template_part( 'global/wrapper-start' );
365
+		give_get_template_part('global/wrapper-start');
366 366
 	}
367 367
 }
368
-if ( ! function_exists( 'give_output_content_wrapper_end' ) ) {
368
+if ( ! function_exists('give_output_content_wrapper_end')) {
369 369
 
370 370
 	/**
371 371
 	 * Output the end of the page wrapper.
372 372
 	 */
373 373
 	function give_output_content_wrapper_end() {
374
-		give_get_template_part( 'global/wrapper-end' );
374
+		give_get_template_part('global/wrapper-end');
375 375
 	}
376 376
 }
377 377
 
378 378
 /**
379 379
  * Single Give Form
380 380
  */
381
-if ( ! function_exists( 'give_left_sidebar_pre_wrap' ) ) {
381
+if ( ! function_exists('give_left_sidebar_pre_wrap')) {
382 382
 	function give_left_sidebar_pre_wrap() {
383
-		echo apply_filters( 'give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">' );
383
+		echo apply_filters('give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">');
384 384
 	}
385 385
 }
386 386
 
387
-if ( ! function_exists( 'give_left_sidebar_post_wrap' ) ) {
387
+if ( ! function_exists('give_left_sidebar_post_wrap')) {
388 388
 	function give_left_sidebar_post_wrap() {
389
-		echo apply_filters( 'give_left_sidebar_post_wrap', '</div>' );
389
+		echo apply_filters('give_left_sidebar_post_wrap', '</div>');
390 390
 	}
391 391
 }
392 392
 
393
-if ( ! function_exists( 'give_get_forms_sidebar' ) ) {
393
+if ( ! function_exists('give_get_forms_sidebar')) {
394 394
 	function give_get_forms_sidebar() {
395
-		give_get_template_part( 'single-give-form/sidebar' );
395
+		give_get_template_part('single-give-form/sidebar');
396 396
 	}
397 397
 }
398 398
 
399
-if ( ! function_exists( 'give_show_form_images' ) ) {
399
+if ( ! function_exists('give_show_form_images')) {
400 400
 
401 401
 	/**
402 402
 	 * Output the donation form featured image.
403 403
 	 */
404 404
 	function give_show_form_images() {
405
-		if ( give_is_setting_enabled( give_get_option( 'form_featured_img' ) ) ) {
406
-			give_get_template_part( 'single-give-form/featured-image' );
405
+		if (give_is_setting_enabled(give_get_option('form_featured_img'))) {
406
+			give_get_template_part('single-give-form/featured-image');
407 407
 		}
408 408
 	}
409 409
 }
410 410
 
411
-if ( ! function_exists( 'give_template_single_title' ) ) {
411
+if ( ! function_exists('give_template_single_title')) {
412 412
 
413 413
 	/**
414 414
 	 * Output the form title.
415 415
 	 */
416 416
 	function give_template_single_title() {
417
-		give_get_template_part( 'single-give-form/title' );
417
+		give_get_template_part('single-give-form/title');
418 418
 	}
419 419
 }
420 420
 
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
  * Conditional Functions
423 423
  */
424 424
 
425
-if ( ! function_exists( 'is_give_form' ) ) {
425
+if ( ! function_exists('is_give_form')) {
426 426
 
427 427
 	/**
428 428
 	 * is_give_form
@@ -434,11 +434,11 @@  discard block
 block discarded – undo
434 434
 	 * @return bool
435 435
 	 */
436 436
 	function is_give_form() {
437
-		return is_singular( array( 'give_form' ) );
437
+		return is_singular(array('give_form'));
438 438
 	}
439 439
 }
440 440
 
441
-if ( ! function_exists( 'is_give_category' ) ) {
441
+if ( ! function_exists('is_give_category')) {
442 442
 
443 443
 	/**
444 444
 	 * is_give_category
@@ -453,12 +453,12 @@  discard block
 block discarded – undo
453 453
 	 *
454 454
 	 * @return bool
455 455
 	 */
456
-	function is_give_category( $term = '' ) {
457
-		return is_tax( 'give_forms_category', $term );
456
+	function is_give_category($term = '') {
457
+		return is_tax('give_forms_category', $term);
458 458
 	}
459 459
 }
460 460
 
461
-if ( ! function_exists( 'is_give_tag' ) ) {
461
+if ( ! function_exists('is_give_tag')) {
462 462
 
463 463
 	/**
464 464
 	 * is_give_tag
@@ -473,12 +473,12 @@  discard block
 block discarded – undo
473 473
 	 *
474 474
 	 * @return bool
475 475
 	 */
476
-	function is_give_tag( $term = '' ) {
477
-		return is_tax( 'give_forms_tag', $term );
476
+	function is_give_tag($term = '') {
477
+		return is_tax('give_forms_tag', $term);
478 478
 	}
479 479
 }
480 480
 
481
-if ( ! function_exists( 'is_give_taxonomy' ) ) {
481
+if ( ! function_exists('is_give_taxonomy')) {
482 482
 
483 483
 	/**
484 484
 	 * is_give_taxonomy
@@ -490,6 +490,6 @@  discard block
 block discarded – undo
490 490
 	 * @return bool
491 491
 	 */
492 492
 	function is_give_taxonomy() {
493
-		return is_tax( get_object_taxonomies( 'give_form' ) );
493
+		return is_tax(get_object_taxonomies('give_form'));
494 494
 	}
495 495
 }
Please login to merge, or discard this patch.