Test Failed
Push — master ( eece2d...16421a )
by Devin
11:50
created
includes/ajax-functions.php 1 patch
Spacing   +152 added lines, -152 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly.
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -26,31 +26,31 @@  discard block
 block discarded – undo
26 26
  */
27 27
 function give_test_ajax_works() {
28 28
 	// Handle ajax.
29
-	if ( doing_action( 'wp_ajax_nopriv_give_test_ajax' ) ) {
30
-		wp_die( 0, 200 );
29
+	if (doing_action('wp_ajax_nopriv_give_test_ajax')) {
30
+		wp_die(0, 200);
31 31
 	}
32 32
 
33 33
 	// Check if the Airplane Mode plugin is installed.
34
-	if ( class_exists( 'Airplane_Mode_Core' ) ) {
34
+	if (class_exists('Airplane_Mode_Core')) {
35 35
 
36 36
 		$airplane = Airplane_Mode_Core::getInstance();
37 37
 
38
-		if ( method_exists( $airplane, 'enabled' ) ) {
38
+		if (method_exists($airplane, 'enabled')) {
39 39
 
40
-			if ( $airplane->enabled() ) {
40
+			if ($airplane->enabled()) {
41 41
 				return true;
42 42
 			}
43 43
 		} else {
44 44
 
45
-			if ( 'on' === $airplane->check_status() ) {
45
+			if ('on' === $airplane->check_status()) {
46 46
 				return true;
47 47
 			}
48 48
 		}
49 49
 	}
50 50
 
51
-	add_filter( 'block_local_requests', '__return_false' );
51
+	add_filter('block_local_requests', '__return_false');
52 52
 
53
-	if ( Give_Cache::get( '_give_ajax_works', true ) ) {
53
+	if (Give_Cache::get('_give_ajax_works', true)) {
54 54
 		return true;
55 55
 	}
56 56
 
@@ -62,41 +62,41 @@  discard block
 block discarded – undo
62 62
 		),
63 63
 	);
64 64
 
65
-	$ajax = wp_remote_post( give_get_ajax_url(), $params );
65
+	$ajax = wp_remote_post(give_get_ajax_url(), $params);
66 66
 
67 67
 	$works = true;
68 68
 
69
-	if ( is_wp_error( $ajax ) ) {
69
+	if (is_wp_error($ajax)) {
70 70
 
71 71
 		$works = false;
72 72
 
73 73
 	} else {
74 74
 
75
-		if ( empty( $ajax['response'] ) ) {
75
+		if (empty($ajax['response'])) {
76 76
 			$works = false;
77 77
 		}
78 78
 
79
-		if ( empty( $ajax['response']['code'] ) || 200 !== (int) $ajax['response']['code'] ) {
79
+		if (empty($ajax['response']['code']) || 200 !== (int) $ajax['response']['code']) {
80 80
 			$works = false;
81 81
 		}
82 82
 
83
-		if ( empty( $ajax['response']['message'] ) || 'OK' !== $ajax['response']['message'] ) {
83
+		if (empty($ajax['response']['message']) || 'OK' !== $ajax['response']['message']) {
84 84
 			$works = false;
85 85
 		}
86 86
 
87
-		if ( ! isset( $ajax['body'] ) || 0 !== (int) $ajax['body'] ) {
87
+		if ( ! isset($ajax['body']) || 0 !== (int) $ajax['body']) {
88 88
 			$works = false;
89 89
 		}
90 90
 	}
91 91
 
92
-	if ( $works ) {
93
-		Give_Cache::set( '_give_ajax_works', '1', DAY_IN_SECONDS, true );
92
+	if ($works) {
93
+		Give_Cache::set('_give_ajax_works', '1', DAY_IN_SECONDS, true);
94 94
 	}
95 95
 
96
-	return apply_filters( 'give_test_ajax_works', $works );
96
+	return apply_filters('give_test_ajax_works', $works);
97 97
 }
98 98
 
99
-add_action( 'wp_ajax_nopriv_give_test_ajax', 'give_test_ajax_works' );
99
+add_action('wp_ajax_nopriv_give_test_ajax', 'give_test_ajax_works');
100 100
 
101 101
 /**
102 102
  * Get AJAX URL
@@ -107,21 +107,21 @@  discard block
 block discarded – undo
107 107
  *
108 108
  * @return string
109 109
  */
110
-function give_get_ajax_url( $query = array() ) {
111
-	$scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin';
110
+function give_get_ajax_url($query = array()) {
111
+	$scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin';
112 112
 
113 113
 	$current_url = give_get_current_page_url();
114
-	$ajax_url    = admin_url( 'admin-ajax.php', $scheme );
114
+	$ajax_url    = admin_url('admin-ajax.php', $scheme);
115 115
 
116
-	if ( preg_match( '/^https/', $current_url ) && ! preg_match( '/^https/', $ajax_url ) ) {
117
-		$ajax_url = preg_replace( '/^http/', 'https', $ajax_url );
116
+	if (preg_match('/^https/', $current_url) && ! preg_match('/^https/', $ajax_url)) {
117
+		$ajax_url = preg_replace('/^http/', 'https', $ajax_url);
118 118
 	}
119 119
 
120
-	if ( ! empty( $query ) ) {
121
-		$ajax_url = add_query_arg( $query, $ajax_url );
120
+	if ( ! empty($query)) {
121
+		$ajax_url = add_query_arg($query, $ajax_url);
122 122
 	}
123 123
 
124
-	return apply_filters( 'give_ajax_url', $ajax_url );
124
+	return apply_filters('give_ajax_url', $ajax_url);
125 125
 }
126 126
 
127 127
 /**
@@ -137,12 +137,12 @@  discard block
 block discarded – undo
137 137
 	 *
138 138
 	 * @since 1.7
139 139
 	 */
140
-	do_action( 'give_donation_form_login_fields' );
140
+	do_action('give_donation_form_login_fields');
141 141
 
142 142
 	give_die();
143 143
 }
144 144
 
145
-add_action( 'wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields' );
145
+add_action('wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields');
146 146
 
147 147
 /**
148 148
  * Load Checkout Fields
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
  * @return void
153 153
  */
154 154
 function give_load_checkout_fields() {
155
-	$form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : '';
155
+	$form_id = isset($_POST['form_id']) ? $_POST['form_id'] : '';
156 156
 
157 157
 	ob_start();
158 158
 
@@ -161,18 +161,18 @@  discard block
 block discarded – undo
161 161
 	 *
162 162
 	 * @since 1.7
163 163
 	 */
164
-	do_action( 'give_donation_form_register_login_fields', $form_id );
164
+	do_action('give_donation_form_register_login_fields', $form_id);
165 165
 
166 166
 	$fields = ob_get_clean();
167 167
 
168
-	wp_send_json( array(
169
-		'fields' => wp_json_encode( $fields ),
170
-		'submit' => wp_json_encode( give_get_donation_form_submit_button( $form_id ) ),
171
-	) );
168
+	wp_send_json(array(
169
+		'fields' => wp_json_encode($fields),
170
+		'submit' => wp_json_encode(give_get_donation_form_submit_button($form_id)),
171
+	));
172 172
 }
173 173
 
174
-add_action( 'wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields' );
175
-add_action( 'wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields' );
174
+add_action('wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields');
175
+add_action('wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields');
176 176
 
177 177
 /**
178 178
  * Get Form Title via AJAX (used only in WordPress Admin)
@@ -182,9 +182,9 @@  discard block
 block discarded – undo
182 182
  * @return void
183 183
  */
184 184
 function give_ajax_get_form_title() {
185
-	if ( isset( $_POST['form_id'] ) ) {
186
-		$title = get_the_title( $_POST['form_id'] );
187
-		if ( $title ) {
185
+	if (isset($_POST['form_id'])) {
186
+		$title = get_the_title($_POST['form_id']);
187
+		if ($title) {
188 188
 			echo $title;
189 189
 		} else {
190 190
 			echo 'fail';
@@ -193,8 +193,8 @@  discard block
 block discarded – undo
193 193
 	give_die();
194 194
 }
195 195
 
196
-add_action( 'wp_ajax_give_get_form_title', 'give_ajax_get_form_title' );
197
-add_action( 'wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title' );
196
+add_action('wp_ajax_give_get_form_title', 'give_ajax_get_form_title');
197
+add_action('wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title');
198 198
 
199 199
 /**
200 200
  * Retrieve a states drop down
@@ -208,41 +208,41 @@  discard block
 block discarded – undo
208 208
 	$show_field     = true;
209 209
 	$states_require = true;
210 210
 	// Get the Country code from the $_POST.
211
-	$country = sanitize_text_field( $_POST['country'] );
211
+	$country = sanitize_text_field($_POST['country']);
212 212
 
213 213
 	// Get the field name from the $_POST.
214
-	$field_name = sanitize_text_field( $_POST['field_name'] );
214
+	$field_name = sanitize_text_field($_POST['field_name']);
215 215
 
216
-	$label        = __( 'State', 'give' );
216
+	$label        = __('State', 'give');
217 217
 	$states_label = give_get_states_label();
218 218
 
219 219
 	$default_state = '';
220
-	if ( $country === give_get_country() ) {
220
+	if ($country === give_get_country()) {
221 221
 		$default_state = give_get_state();
222 222
 	}
223 223
 
224 224
 	// Check if $country code exists in the array key for states label.
225
-	if ( array_key_exists( $country, $states_label ) ) {
226
-		$label = $states_label[ $country ];
225
+	if (array_key_exists($country, $states_label)) {
226
+		$label = $states_label[$country];
227 227
 	}
228 228
 
229
-	if ( empty( $country ) ) {
229
+	if (empty($country)) {
230 230
 		$country = give_get_country();
231 231
 	}
232 232
 
233
-	$states = give_get_states( $country );
234
-	if ( ! empty( $states ) ) {
235
-		$args         = array(
233
+	$states = give_get_states($country);
234
+	if ( ! empty($states)) {
235
+		$args = array(
236 236
 			'name'             => $field_name,
237 237
 			'id'               => $field_name,
238
-			'class'            => $field_name . '  give-select',
238
+			'class'            => $field_name.'  give-select',
239 239
 			'options'          => $states,
240 240
 			'show_option_all'  => false,
241 241
 			'show_option_none' => false,
242 242
 			'placeholder'      => $label,
243 243
 			'selected'         => $default_state,
244 244
 		);
245
-		$data         = Give()->html->select( $args );
245
+		$data         = Give()->html->select($args);
246 246
 		$states_found = true;
247 247
 	} else {
248 248
 		$data = 'nostates';
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 		$no_states_country = give_no_states_country_list();
252 252
 
253 253
 		// Check if $country code exists in the array key.
254
-		if ( array_key_exists( $country, $no_states_country ) ) {
254
+		if (array_key_exists($country, $no_states_country)) {
255 255
 			$show_field = false;
256 256
 		}
257 257
 
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 		$states_not_required_country_list = give_states_not_required_country_list();
260 260
 
261 261
 		// Check if $country code exists in the array key.
262
-		if ( array_key_exists( $country, $states_not_required_country_list ) ) {
262
+		if (array_key_exists($country, $states_not_required_country_list)) {
263 263
 			$states_require = false;
264 264
 		}
265 265
 	}
@@ -272,11 +272,11 @@  discard block
 block discarded – undo
272 272
 		'data'           => $data,
273 273
 		'default_state'  => $default_state,
274 274
 	);
275
-	wp_send_json( $response );
275
+	wp_send_json($response);
276 276
 }
277 277
 
278
-add_action( 'wp_ajax_give_get_states', 'give_ajax_get_states_field' );
279
-add_action( 'wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field' );
278
+add_action('wp_ajax_give_get_states', 'give_ajax_get_states_field');
279
+add_action('wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field');
280 280
 
281 281
 /**
282 282
  * Retrieve donation forms via AJAX for chosen dropdown search field.
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
  */
288 288
 function give_ajax_form_search() {
289 289
 	$results = array();
290
-	$search  = esc_sql( sanitize_text_field( $_POST['s'] ) );
290
+	$search  = esc_sql(sanitize_text_field($_POST['s']));
291 291
 
292 292
 	$args = array(
293 293
 		'post_type'              => 'give_forms',
@@ -308,12 +308,12 @@  discard block
 block discarded – undo
308 308
 	 *
309 309
 	 * @return array $args Query argument for WP_query
310 310
 	 */
311
-	$args = (array) apply_filters( 'give_ajax_form_search_args', $args );
311
+	$args = (array) apply_filters('give_ajax_form_search_args', $args);
312 312
 
313 313
 	// get all the donation form.
314
-	$query = new WP_Query( $args );
315
-	if ( $query->have_posts() ) {
316
-		while ( $query->have_posts() ) {
314
+	$query = new WP_Query($args);
315
+	if ($query->have_posts()) {
316
+		while ($query->have_posts()) {
317 317
 			$query->the_post();
318 318
 			global $post;
319 319
 
@@ -334,13 +334,13 @@  discard block
 block discarded – undo
334 334
 	 *
335 335
 	 * @return array $results Contain the Donation Form id
336 336
 	 */
337
-	$results = (array) apply_filters( 'give_ajax_form_search_responce', $results );
337
+	$results = (array) apply_filters('give_ajax_form_search_responce', $results);
338 338
 
339
-	wp_send_json( $results );
339
+	wp_send_json($results);
340 340
 }
341 341
 
342
-add_action( 'wp_ajax_give_form_search', 'give_ajax_form_search' );
343
-add_action( 'wp_ajax_nopriv_give_form_search', 'give_ajax_form_search' );
342
+add_action('wp_ajax_give_form_search', 'give_ajax_form_search');
343
+add_action('wp_ajax_nopriv_give_form_search', 'give_ajax_form_search');
344 344
 
345 345
 /**
346 346
  * Search the donors database via Ajax
@@ -352,28 +352,28 @@  discard block
 block discarded – undo
352 352
 function give_ajax_donor_search() {
353 353
 	global $wpdb;
354 354
 
355
-	$search  = esc_sql( sanitize_text_field( $_POST['s'] ) );
355
+	$search  = esc_sql(sanitize_text_field($_POST['s']));
356 356
 	$results = array();
357
-	if ( ! current_user_can( 'view_give_reports' ) ) {
357
+	if ( ! current_user_can('view_give_reports')) {
358 358
 		$donors = array();
359 359
 	} else {
360
-		$donors = $wpdb->get_results( "SELECT id,name,email FROM $wpdb->donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50" );
360
+		$donors = $wpdb->get_results("SELECT id,name,email FROM $wpdb->donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50");
361 361
 	}
362 362
 
363
-	if ( $donors ) {
364
-		foreach ( $donors as $donor ) {
363
+	if ($donors) {
364
+		foreach ($donors as $donor) {
365 365
 
366 366
 			$results[] = array(
367 367
 				'id'   => $donor->id,
368
-				'name' => $donor->name . ' (' . $donor->email . ')',
368
+				'name' => $donor->name.' ('.$donor->email.')',
369 369
 			);
370 370
 		}
371 371
 	}
372 372
 
373
-	wp_send_json( $results );
373
+	wp_send_json($results);
374 374
 }
375 375
 
376
-add_action( 'wp_ajax_give_donor_search', 'give_ajax_donor_search' );
376
+add_action('wp_ajax_give_donor_search', 'give_ajax_donor_search');
377 377
 
378 378
 
379 379
 /**
@@ -386,37 +386,37 @@  discard block
 block discarded – undo
386 386
 function give_ajax_search_users() {
387 387
 	$results = array();
388 388
 
389
-	if ( current_user_can( 'manage_give_settings' ) ) {
389
+	if (current_user_can('manage_give_settings')) {
390 390
 
391
-		$search = esc_sql( sanitize_text_field( $_POST['s'] ) );
391
+		$search = esc_sql(sanitize_text_field($_POST['s']));
392 392
 
393 393
 		$get_users_args = array(
394 394
 			'number' => 9999,
395
-			'search' => $search . '*',
395
+			'search' => $search.'*',
396 396
 		);
397 397
 
398
-		$get_users_args = apply_filters( 'give_search_users_args', $get_users_args );
398
+		$get_users_args = apply_filters('give_search_users_args', $get_users_args);
399 399
 
400
-		$found_users = apply_filters( 'give_ajax_found_users', get_users( $get_users_args ), $search );
400
+		$found_users = apply_filters('give_ajax_found_users', get_users($get_users_args), $search);
401 401
 		$results     = array();
402 402
 
403
-		if ( $found_users ) {
403
+		if ($found_users) {
404 404
 
405
-			foreach ( $found_users as $user ) {
405
+			foreach ($found_users as $user) {
406 406
 
407 407
 				$results[] = array(
408 408
 					'id'   => $user->ID,
409
-					'name' => esc_html( $user->user_login . ' (' . $user->user_email . ')' ),
409
+					'name' => esc_html($user->user_login.' ('.$user->user_email.')'),
410 410
 				);
411 411
 			}
412 412
 		}
413 413
 	}// End if().
414 414
 
415
-	wp_send_json( $results );
415
+	wp_send_json($results);
416 416
 
417 417
 }
418 418
 
419
-add_action( 'wp_ajax_give_user_search', 'give_ajax_search_users' );
419
+add_action('wp_ajax_give_user_search', 'give_ajax_search_users');
420 420
 
421 421
 
422 422
 /**
@@ -432,14 +432,14 @@  discard block
 block discarded – undo
432 432
 	$data = array();
433 433
 	$args = array(
434 434
 		'post_type' => 'page',
435
-		's'         => give_clean( $_POST['s'] ),
435
+		's'         => give_clean($_POST['s']),
436 436
 	);
437 437
 
438
-	$query = new WP_Query( $args );
438
+	$query = new WP_Query($args);
439 439
 
440 440
 	// Query posts by title.
441
-	if ( $query->have_posts() ) {
442
-		while ( $query->have_posts() ) {
441
+	if ($query->have_posts()) {
442
+		while ($query->have_posts()) {
443 443
 			$query->the_post();
444 444
 
445 445
 			$data[] = array(
@@ -449,10 +449,10 @@  discard block
 block discarded – undo
449 449
 		}
450 450
 	}
451 451
 
452
-	wp_send_json( $data );
452
+	wp_send_json($data);
453 453
 }
454 454
 
455
-add_action( 'wp_ajax_give_pages_search', 'give_ajax_pages_search' );
455
+add_action('wp_ajax_give_pages_search', 'give_ajax_pages_search');
456 456
 
457 457
 /**
458 458
  * Retrieve Categories via AJAX for chosen dropdown search field.
@@ -473,14 +473,14 @@  discard block
 block discarded – undo
473 473
 	 *
474 474
 	 * @return array $args argument for get_terms
475 475
 	 */
476
-	$args = (array) apply_filters( 'give_forms_categories_dropdown_args', array(
476
+	$args = (array) apply_filters('give_forms_categories_dropdown_args', array(
477 477
 		'number'     => 30,
478
-		'name__like' => esc_sql( sanitize_text_field( $_POST['s'] ) )
479
-	) );
478
+		'name__like' => esc_sql(sanitize_text_field($_POST['s']))
479
+	));
480 480
 
481
-	$categories = get_terms( 'give_forms_category', $args );
481
+	$categories = get_terms('give_forms_category', $args);
482 482
 
483
-	foreach ( $categories as $category ) {
483
+	foreach ($categories as $category) {
484 484
 		$results[] = array(
485 485
 			'id'   => $category->term_id,
486 486
 			'name' => $category->name,
@@ -496,12 +496,12 @@  discard block
 block discarded – undo
496 496
 	 *
497 497
 	 * @return array $results Contain the categories id and name
498 498
 	 */
499
-	$results = (array) apply_filters( 'give_forms_categories_dropdown_responce', $results );
499
+	$results = (array) apply_filters('give_forms_categories_dropdown_responce', $results);
500 500
 
501
-	wp_send_json( $results );
501
+	wp_send_json($results);
502 502
 }
503 503
 
504
-add_action( 'wp_ajax_give_categories_search', 'give_ajax_categories_search' );
504
+add_action('wp_ajax_give_categories_search', 'give_ajax_categories_search');
505 505
 
506 506
 /**
507 507
  * Retrieve Tags via AJAX for chosen dropdown search field.
@@ -522,14 +522,14 @@  discard block
 block discarded – undo
522 522
 	 *
523 523
 	 * @return array $args argument for get_terms
524 524
 	 */
525
-	$args = (array) apply_filters( 'give_forms_tags_dropdown_args', array(
525
+	$args = (array) apply_filters('give_forms_tags_dropdown_args', array(
526 526
 		'number'     => 30,
527
-		'name__like' => esc_sql( sanitize_text_field( $_POST['s'] ) )
528
-	) );
527
+		'name__like' => esc_sql(sanitize_text_field($_POST['s']))
528
+	));
529 529
 
530
-	$categories = get_terms( 'give_forms_tag', $args );
530
+	$categories = get_terms('give_forms_tag', $args);
531 531
 
532
-	foreach ( $categories as $category ) {
532
+	foreach ($categories as $category) {
533 533
 		$results[] = array(
534 534
 			'id'   => $category->term_id,
535 535
 			'name' => $category->name,
@@ -545,12 +545,12 @@  discard block
 block discarded – undo
545 545
 	 *
546 546
 	 * @return array $results Contain the tags id and name
547 547
 	 */
548
-	$results = (array) apply_filters( 'give_forms_tags_dropdown_responce', $results );
548
+	$results = (array) apply_filters('give_forms_tags_dropdown_responce', $results);
549 549
 
550
-	wp_send_json( $results );
550
+	wp_send_json($results);
551 551
 }
552 552
 
553
-add_action( 'wp_ajax_give_tags_search', 'give_ajax_tags_search' );
553
+add_action('wp_ajax_give_tags_search', 'give_ajax_tags_search');
554 554
 
555 555
 /**
556 556
  * Check for Price Variations (Multi-level donation forms)
@@ -561,32 +561,32 @@  discard block
 block discarded – undo
561 561
  */
562 562
 function give_check_for_form_price_variations() {
563 563
 
564
-	if ( ! current_user_can( 'edit_give_forms', get_current_user_id() ) ) {
565
-		die( '-1' );
564
+	if ( ! current_user_can('edit_give_forms', get_current_user_id())) {
565
+		die('-1');
566 566
 	}
567 567
 
568
-	$form_id = intval( $_POST['form_id'] );
569
-	$form    = get_post( $form_id );
568
+	$form_id = intval($_POST['form_id']);
569
+	$form    = get_post($form_id);
570 570
 
571
-	if ( 'give_forms' !== $form->post_type ) {
572
-		die( '-2' );
571
+	if ('give_forms' !== $form->post_type) {
572
+		die('-2');
573 573
 	}
574 574
 
575
-	if ( give_has_variable_prices( $form_id ) ) {
576
-		$variable_prices = give_get_variable_prices( $form_id );
575
+	if (give_has_variable_prices($form_id)) {
576
+		$variable_prices = give_get_variable_prices($form_id);
577 577
 
578
-		if ( $variable_prices ) {
578
+		if ($variable_prices) {
579 579
 			$ajax_response = '<select class="give_price_options_select give-select give-select" name="give_price_option">';
580 580
 
581
-			if ( isset( $_POST['all_prices'] ) ) {
582
-				$ajax_response .= '<option value="all">' . esc_html__( 'All Levels', 'give' ) . '</option>';
581
+			if (isset($_POST['all_prices'])) {
582
+				$ajax_response .= '<option value="all">'.esc_html__('All Levels', 'give').'</option>';
583 583
 			}
584 584
 
585
-			foreach ( $variable_prices as $key => $price ) {
585
+			foreach ($variable_prices as $key => $price) {
586 586
 
587
-				$level_text = ! empty( $price['_give_text'] ) ? esc_html( $price['_give_text'] ) : give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) );
587
+				$level_text = ! empty($price['_give_text']) ? esc_html($price['_give_text']) : give_currency_filter(give_format_amount($price['_give_amount'], array('sanitize' => false)));
588 588
 
589
-				$ajax_response .= '<option value="' . esc_attr( $price['_give_id']['level_id'] ) . '">' . $level_text . '</option>';
589
+				$ajax_response .= '<option value="'.esc_attr($price['_give_id']['level_id']).'">'.$level_text.'</option>';
590 590
 			}
591 591
 			$ajax_response .= '</select>';
592 592
 			echo $ajax_response;
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
 	give_die();
597 597
 }
598 598
 
599
-add_action( 'wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations' );
599
+add_action('wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations');
600 600
 
601 601
 
602 602
 /**
@@ -607,28 +607,28 @@  discard block
 block discarded – undo
607 607
  * @return void
608 608
  */
609 609
 function give_check_for_form_price_variations_html() {
610
-	if ( ! current_user_can( 'edit_give_payments', get_current_user_id() ) ) {
610
+	if ( ! current_user_can('edit_give_payments', get_current_user_id())) {
611 611
 		wp_die();
612 612
 	}
613 613
 
614
-	$form_id    = ! empty( $_POST['form_id'] ) ? intval( $_POST['form_id'] ) : false;
615
-	$payment_id = ! empty( $_POST['payment_id'] ) ? intval( $_POST['payment_id'] ) : false;
616
-	if ( empty( $form_id ) || empty( $payment_id ) ) {
614
+	$form_id    = ! empty($_POST['form_id']) ? intval($_POST['form_id']) : false;
615
+	$payment_id = ! empty($_POST['payment_id']) ? intval($_POST['payment_id']) : false;
616
+	if (empty($form_id) || empty($payment_id)) {
617 617
 		wp_die();
618 618
 	}
619 619
 
620
-	$form = get_post( $form_id );
621
-	if ( ! empty( $form->post_type ) && 'give_forms' !== $form->post_type ) {
620
+	$form = get_post($form_id);
621
+	if ( ! empty($form->post_type) && 'give_forms' !== $form->post_type) {
622 622
 		wp_die();
623 623
 	}
624 624
 
625
-	if ( ! give_has_variable_prices( $form_id ) || ! $form_id ) {
626
-		esc_html_e( 'n/a', 'give' );
625
+	if ( ! give_has_variable_prices($form_id) || ! $form_id) {
626
+		esc_html_e('n/a', 'give');
627 627
 	} else {
628 628
 		$prices_atts = array();
629
-		if ( $variable_prices = give_get_variable_prices( $form_id ) ) {
630
-			foreach ( $variable_prices as $variable_price ) {
631
-				$prices_atts[ $variable_price['_give_id']['level_id'] ] = give_format_amount( $variable_price['_give_amount'], array( 'sanitize' => false ) );
629
+		if ($variable_prices = give_get_variable_prices($form_id)) {
630
+			foreach ($variable_prices as $variable_price) {
631
+				$prices_atts[$variable_price['_give_id']['level_id']] = give_format_amount($variable_price['_give_amount'], array('sanitize' => false));
632 632
 			}
633 633
 		}
634 634
 
@@ -639,12 +639,12 @@  discard block
 block discarded – undo
639 639
 			'chosen'           => true,
640 640
 			'show_option_all'  => '',
641 641
 			'show_option_none' => '',
642
-			'select_atts'      => 'data-prices=' . esc_attr( json_encode( $prices_atts ) ),
642
+			'select_atts'      => 'data-prices='.esc_attr(json_encode($prices_atts)),
643 643
 		);
644 644
 
645
-		if ( $payment_id ) {
645
+		if ($payment_id) {
646 646
 			// Payment object.
647
-			$payment = new Give_Payment( $payment_id );
647
+			$payment = new Give_Payment($payment_id);
648 648
 
649 649
 			// Payment meta.
650 650
 			$payment_meta                               = $payment->get_meta();
@@ -652,13 +652,13 @@  discard block
 block discarded – undo
652 652
 		}
653 653
 
654 654
 		// Render variable prices select tag html.
655
-		give_get_form_variable_price_dropdown( $variable_price_dropdown_option, true );
655
+		give_get_form_variable_price_dropdown($variable_price_dropdown_option, true);
656 656
 	}
657 657
 
658 658
 	give_die();
659 659
 }
660 660
 
661
-add_action( 'wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html' );
661
+add_action('wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html');
662 662
 
663 663
 /**
664 664
  * Send Confirmation Email For Complete Donation History Access.
@@ -670,30 +670,30 @@  discard block
 block discarded – undo
670 670
 function give_confirm_email_for_donation_access() {
671 671
 
672 672
 	// Verify Security using Nonce.
673
-	if ( ! check_ajax_referer( 'give_ajax_nonce', 'nonce' ) ) {
673
+	if ( ! check_ajax_referer('give_ajax_nonce', 'nonce')) {
674 674
 		return false;
675 675
 	}
676 676
 
677 677
 	// Bail Out, if email is empty.
678
-	if ( empty( $_POST['email'] ) ) {
678
+	if (empty($_POST['email'])) {
679 679
 		return false;
680 680
 	}
681 681
 
682
-	$donor = Give()->donors->get_donor_by( 'email', give_clean( $_POST['email'] ) );
683
-	if ( Give()->email_access->can_send_email( $donor->id ) ) {
682
+	$donor = Give()->donors->get_donor_by('email', give_clean($_POST['email']));
683
+	if (Give()->email_access->can_send_email($donor->id)) {
684 684
 		$return     = array();
685
-		$email_sent = Give()->email_access->send_email( $donor->id, $donor->email );
685
+		$email_sent = Give()->email_access->send_email($donor->id, $donor->email);
686 686
 
687
-		if ( ! $email_sent ) {
687
+		if ( ! $email_sent) {
688 688
 			$return['status']  = 'error';
689 689
 			$return['message'] = Give()->notices->print_frontend_notice(
690
-				__( 'Unable to send email. Please try again.', 'give' ),
690
+				__('Unable to send email. Please try again.', 'give'),
691 691
 				false,
692 692
 				'error'
693 693
 			);
694 694
 		}
695 695
 
696
-		$return['status']  = 'success';
696
+		$return['status'] = 'success';
697 697
 
698 698
 		/**
699 699
 		 * Filter to modify access mail send notice
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
 		 *
705 705
 		 * @return  string $message Send notice message for email access.
706 706
 		 */
707
-		$message = (string) apply_filters( 'give_email_access_mail_send_notice', __( 'Please check your email and click on the link to access your complete donation history.', 'give' ) );
707
+		$message = (string) apply_filters('give_email_access_mail_send_notice', __('Please check your email and click on the link to access your complete donation history.', 'give'));
708 708
 
709 709
 		$return['message'] = Give()->notices->print_frontend_notice(
710 710
 			$message,
@@ -730,8 +730,8 @@  discard block
 block discarded – undo
730 730
 		$message = (string) apply_filters(
731 731
 			'give_email_access_requests_exceed_notice',
732 732
 			sprintf(
733
-				__( 'Too many access email requests detected. Please wait %s before requesting a new donation history access link.', 'give' ),
734
-				sprintf( _n( '%s minute', '%s minutes', $value, 'give' ), $value )
733
+				__('Too many access email requests detected. Please wait %s before requesting a new donation history access link.', 'give'),
734
+				sprintf(_n('%s minute', '%s minutes', $value, 'give'), $value)
735 735
 			),
736 736
 			$value
737 737
 		);
@@ -743,8 +743,8 @@  discard block
 block discarded – undo
743 743
 		);
744 744
 	}
745 745
 
746
-	echo json_encode( $return );
746
+	echo json_encode($return);
747 747
 	give_die();
748 748
 }
749 749
 
750
-add_action( 'wp_ajax_nopriv_give_confirm_email_for_donations_access', 'give_confirm_email_for_donation_access' );
751 750
\ No newline at end of file
751
+add_action('wp_ajax_nopriv_give_confirm_email_for_donations_access', 'give_confirm_email_for_donation_access');
752 752
\ No newline at end of file
Please login to merge, or discard this patch.
includes/process-donation.php 1 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
 
@@ -28,18 +28,18 @@  discard block
 block discarded – undo
28 28
  */
29 29
 function give_process_donation_form() {
30 30
 
31
-	$post_data = give_clean( $_POST ); // WPCS: input var ok, CSRF ok.
32
-	$is_ajax   = isset( $post_data['give_ajax'] );
31
+	$post_data = give_clean($_POST); // WPCS: input var ok, CSRF ok.
32
+	$is_ajax   = isset($post_data['give_ajax']);
33 33
 
34 34
 	// Verify donation form nonce.
35
-	if ( ! give_verify_donation_form_nonce( $post_data['give-form-hash'], $post_data['give-form-id'] ) ) {
36
-		if ( $is_ajax ) {
35
+	if ( ! give_verify_donation_form_nonce($post_data['give-form-hash'], $post_data['give-form-id'])) {
36
+		if ($is_ajax) {
37 37
 			/**
38 38
 			 * Fires when AJAX sends back errors from the donation form.
39 39
 			 *
40 40
 			 * @since 1.0
41 41
 			 */
42
-			do_action( 'give_ajax_donation_errors' );
42
+			do_action('give_ajax_donation_errors');
43 43
 			give_die();
44 44
 		} else {
45 45
 			give_send_back_to_checkout();
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	 *
52 52
 	 * @since 1.0
53 53
 	 */
54
-	do_action( 'give_pre_process_donation' );
54
+	do_action('give_pre_process_donation');
55 55
 
56 56
 	// Validate the form $_POST data.
57 57
 	$valid_data = give_donation_form_validate_fields();
@@ -67,24 +67,24 @@  discard block
 block discarded – undo
67 67
 	 * @param array $deprecated Deprecated Since 2.0.2. Use $_POST instead.
68 68
 	 */
69 69
 	$deprecated = $post_data;
70
-	do_action( 'give_checkout_error_checks', $valid_data, $deprecated );
70
+	do_action('give_checkout_error_checks', $valid_data, $deprecated);
71 71
 
72 72
 	// Process the login form.
73
-	if ( isset( $post_data['give_login_submit'] ) ) {
73
+	if (isset($post_data['give_login_submit'])) {
74 74
 		give_process_form_login();
75 75
 	}
76 76
 
77 77
 	// Validate the user.
78
-	$user = give_get_donation_form_user( $valid_data );
78
+	$user = give_get_donation_form_user($valid_data);
79 79
 
80
-	if ( false === $valid_data || give_get_errors() || ! $user ) {
81
-		if ( $is_ajax ) {
80
+	if (false === $valid_data || give_get_errors() || ! $user) {
81
+		if ($is_ajax) {
82 82
 			/**
83 83
 			 * Fires when AJAX sends back errors from the donation form.
84 84
 			 *
85 85
 			 * @since 1.0
86 86
 			 */
87
-			do_action( 'give_ajax_donation_errors' );
87
+			do_action('give_ajax_donation_errors');
88 88
 			give_die();
89 89
 		} else {
90 90
 			return false;
@@ -92,17 +92,17 @@  discard block
 block discarded – undo
92 92
 	}
93 93
 
94 94
 	// If AJAX send back success to proceed with form submission.
95
-	if ( $is_ajax ) {
95
+	if ($is_ajax) {
96 96
 		echo 'success';
97 97
 		give_die();
98 98
 	}
99 99
 
100 100
 	// After AJAX: Setup session if not using php_sessions.
101
-	if ( ! Give()->session->use_php_sessions() ) {
101
+	if ( ! Give()->session->use_php_sessions()) {
102 102
 		// Double-check that set_cookie is publicly accessible.
103 103
 		// we're using a slightly modified class-wp-sessions.php.
104
-		$session_reflection = new ReflectionMethod( 'WP_Session', 'set_cookie' );
105
-		if ( $session_reflection->isPublic() ) {
104
+		$session_reflection = new ReflectionMethod('WP_Session', 'set_cookie');
105
+		if ($session_reflection->isPublic()) {
106 106
 			// Manually set the cookie.
107 107
 			Give()->session->init()->set_cookie();
108 108
 		}
@@ -117,20 +117,19 @@  discard block
 block discarded – undo
117 117
 		'address'    => $user['address'],
118 118
 	);
119 119
 
120
-	$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
120
+	$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
121 121
 
122
-	$price    = isset( $post_data['give-amount'] ) ?
123
-		(float) apply_filters( 'give_donation_total', give_maybe_sanitize_amount( $post_data['give-amount'] ) ) :
124
-		'0.00';
125
-	$purchase_key = strtolower( md5( $user['user_email'] . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) );
122
+	$price    = isset($post_data['give-amount']) ?
123
+		(float) apply_filters('give_donation_total', give_maybe_sanitize_amount($post_data['give-amount'])) : '0.00';
124
+	$purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true)));
126 125
 
127 126
 	// Setup donation information.
128 127
 	$donation_data = array(
129 128
 		'price'         => $price,
130 129
 		'purchase_key'  => $purchase_key,
131 130
 		'user_email'    => $user['user_email'],
132
-		'date'          => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ),
133
-		'user_info'     => stripslashes_deep( $user_info ),
131
+		'date'          => date('Y-m-d H:i:s', current_time('timestamp')),
132
+		'user_info'     => stripslashes_deep($user_info),
134 133
 		'post_data'     => $post_data,
135 134
 		'gateway'       => $valid_data['gateway'],
136 135
 		'card_info'     => $valid_data['cc_info'],
@@ -150,10 +149,10 @@  discard block
 block discarded – undo
150 149
 	 * @param array      $user_info  Array containing basic user information.
151 150
 	 * @param bool|array $valid_data Validate fields.
152 151
 	 */
153
-	do_action( 'give_checkout_before_gateway', $post_data, $user_info, $valid_data );
152
+	do_action('give_checkout_before_gateway', $post_data, $user_info, $valid_data);
154 153
 
155 154
 	// Sanity check for price.
156
-	if ( ! $donation_data['price'] ) {
155
+	if ( ! $donation_data['price']) {
157 156
 		// Revert to manual.
158 157
 		$donation_data['gateway'] = 'manual';
159 158
 		$_POST['give-gateway']    = 'manual';
@@ -164,26 +163,26 @@  discard block
 block discarded – undo
164 163
 	 *
165 164
 	 * @since 1.7
166 165
 	 */
167
-	$donation_data = apply_filters( 'give_donation_data_before_gateway', $donation_data, $valid_data );
166
+	$donation_data = apply_filters('give_donation_data_before_gateway', $donation_data, $valid_data);
168 167
 
169 168
 	// Setup the data we're storing in the donation session.
170 169
 	$session_data = $donation_data;
171 170
 
172 171
 	// Make sure credit card numbers are never stored in sessions.
173
-	unset( $session_data['card_info']['card_number'] );
174
-	unset( $session_data['post_data']['card_number'] );
172
+	unset($session_data['card_info']['card_number']);
173
+	unset($session_data['post_data']['card_number']);
175 174
 
176 175
 	// Used for showing data to non logged-in users after donation, and for other plugins needing donation data.
177
-	give_set_purchase_session( $session_data );
176
+	give_set_purchase_session($session_data);
178 177
 
179 178
 	// Send info to the gateway for payment processing.
180
-	give_send_to_gateway( $donation_data['gateway'], $donation_data );
179
+	give_send_to_gateway($donation_data['gateway'], $donation_data);
181 180
 	give_die();
182 181
 }
183 182
 
184
-add_action( 'give_purchase', 'give_process_donation_form' );
185
-add_action( 'wp_ajax_give_process_donation', 'give_process_donation_form' );
186
-add_action( 'wp_ajax_nopriv_give_process_donation', 'give_process_donation_form' );
183
+add_action('give_purchase', 'give_process_donation_form');
184
+add_action('wp_ajax_give_process_donation', 'give_process_donation_form');
185
+add_action('wp_ajax_nopriv_give_process_donation', 'give_process_donation_form');
187 186
 
188 187
 /**
189 188
  * Verify that when a logged in user makes a donation that the email address used doesn't belong to a different customer.
@@ -194,27 +193,27 @@  discard block
 block discarded – undo
194 193
  *
195 194
  * @return void
196 195
  */
197
-function give_check_logged_in_user_for_existing_email( $valid_data ) {
196
+function give_check_logged_in_user_for_existing_email($valid_data) {
198 197
 
199 198
 	// Verify that the email address belongs to this customer.
200
-	if ( is_user_logged_in() ) {
199
+	if (is_user_logged_in()) {
201 200
 
202 201
 		$submitted_email = $valid_data['logged_in_user']['user_email'];
203
-		$donor           = new Give_Donor( get_current_user_id(), true );
202
+		$donor           = new Give_Donor(get_current_user_id(), true);
204 203
 
205 204
 		// If this email address is not registered with this customer, see if it belongs to any other customer.
206 205
 		if (
207 206
 			$submitted_email !== $donor->email
208
-			&& ( is_array( $donor->emails ) && ! in_array( $submitted_email, $donor->emails, true ) )
207
+			&& (is_array($donor->emails) && ! in_array($submitted_email, $donor->emails, true))
209 208
 		) {
210
-			$found_donor = new Give_Donor( $submitted_email );
209
+			$found_donor = new Give_Donor($submitted_email);
211 210
 
212
-			if ( $found_donor->id > 0 ) {
211
+			if ($found_donor->id > 0) {
213 212
 				give_set_error(
214 213
 					'give-customer-email-exists',
215 214
 					sprintf(
216 215
 						/* translators: 1. Donor Email, 2. Submitted Email */
217
-						__( 'You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.', 'give' ),
216
+						__('You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.', 'give'),
218 217
 						$donor->email,
219 218
 						$submitted_email
220 219
 					)
@@ -224,7 +223,7 @@  discard block
 block discarded – undo
224 223
 	}
225 224
 }
226 225
 
227
-add_action( 'give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 1 );
226
+add_action('give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 1);
228 227
 
229 228
 /**
230 229
  * Process the checkout login form
@@ -236,49 +235,49 @@  discard block
 block discarded – undo
236 235
  */
237 236
 function give_process_form_login() {
238 237
 
239
-	$is_ajax   = ! empty( $_POST['give_ajax'] ) ? give_clean( $_POST['give_ajax'] ) : 0; // WPCS: input var ok, sanitization ok, CSRF ok.
238
+	$is_ajax   = ! empty($_POST['give_ajax']) ? give_clean($_POST['give_ajax']) : 0; // WPCS: input var ok, sanitization ok, CSRF ok.
240 239
 	$referrer  = wp_get_referer();
241 240
 	$user_data = give_donation_form_validate_user_login();
242 241
 
243
-	if ( give_get_errors() || $user_data['user_id'] < 1 ) {
244
-		if ( $is_ajax ) {
242
+	if (give_get_errors() || $user_data['user_id'] < 1) {
243
+		if ($is_ajax) {
245 244
 			/**
246 245
 			 * Fires when AJAX sends back errors from the donation form.
247 246
 			 *
248 247
 			 * @since 1.0
249 248
 			 */
250 249
 			ob_start();
251
-			do_action( 'give_ajax_donation_errors' );
250
+			do_action('give_ajax_donation_errors');
252 251
 			$message = ob_get_contents();
253 252
 			ob_end_clean();
254
-			wp_send_json_error( $message );
253
+			wp_send_json_error($message);
255 254
 		} else {
256
-			wp_safe_redirect( $referrer );
255
+			wp_safe_redirect($referrer);
257 256
 			exit;
258 257
 		}
259 258
 	}
260 259
 
261
-	give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] );
260
+	give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']);
262 261
 
263
-	if ( $is_ajax ) {
262
+	if ($is_ajax) {
264 263
 		$message = Give()->notices->print_frontend_notice(
265 264
 			sprintf(
266 265
 				/* translators: %s: user first name */
267
-				esc_html__( 'Welcome %s! You have successfully logged into your account.', 'give' ),
268
-				( ! empty( $user_data['user_first'] ) ) ? $user_data['user_first'] : $user_data['user_login']
266
+				esc_html__('Welcome %s! You have successfully logged into your account.', 'give'),
267
+				( ! empty($user_data['user_first'])) ? $user_data['user_first'] : $user_data['user_login']
269 268
 			),
270 269
 			false,
271 270
 			'success'
272 271
 		);
273 272
 
274
-		wp_send_json_success( $message );
273
+		wp_send_json_success($message);
275 274
 	} else {
276
-		wp_safe_redirect( $referrer );
275
+		wp_safe_redirect($referrer);
277 276
 	}
278 277
 }
279 278
 
280
-add_action( 'wp_ajax_give_process_donation_login', 'give_process_form_login' );
281
-add_action( 'wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login' );
279
+add_action('wp_ajax_give_process_donation_login', 'give_process_form_login');
280
+add_action('wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login');
282 281
 
283 282
 /**
284 283
  * Donation Form Validate Fields.
@@ -290,49 +289,49 @@  discard block
 block discarded – undo
290 289
  */
291 290
 function give_donation_form_validate_fields() {
292 291
 
293
-	$post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok.
292
+	$post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok.
294 293
 
295 294
 	// Validate Honeypot First.
296
-	if ( ! empty( $post_data['give-honeypot'] ) ) {
297
-		give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) );
295
+	if ( ! empty($post_data['give-honeypot'])) {
296
+		give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give'));
298 297
 	}
299 298
 
300 299
 	// Check spam detect.
301 300
 	if (
302
-		isset( $post_data['action'] ) &&
303
-		give_is_setting_enabled( give_get_option( 'akismet_spam_protection' ) ) &&
301
+		isset($post_data['action']) &&
302
+		give_is_setting_enabled(give_get_option('akismet_spam_protection')) &&
304 303
 		give_is_spam_donation()
305 304
 	) {
306
-		give_set_error( 'spam_donation', __( 'This donation has been flagged as spam. Please try again.', 'give' ) );
305
+		give_set_error('spam_donation', __('This donation has been flagged as spam. Please try again.', 'give'));
307 306
 	}
308 307
 
309 308
 	// Start an array to collect valid data.
310 309
 	$valid_data = array(
311 310
 		'gateway'          => give_donation_form_validate_gateway(), // Gateway fallback (amount is validated here).
312
-		'need_new_user'    => false,     // New user flag.
313
-		'need_user_login'  => false,     // Login user flag.
314
-		'logged_user_data' => array(),   // Logged user collected data.
315
-		'new_user_data'    => array(),   // New user collected data.
316
-		'login_user_data'  => array(),   // Login user collected data.
317
-		'guest_user_data'  => array(),   // Guest user collected data.
311
+		'need_new_user'    => false, // New user flag.
312
+		'need_user_login'  => false, // Login user flag.
313
+		'logged_user_data' => array(), // Logged user collected data.
314
+		'new_user_data'    => array(), // New user collected data.
315
+		'login_user_data'  => array(), // Login user collected data.
316
+		'guest_user_data'  => array(), // Guest user collected data.
318 317
 		'cc_info'          => give_donation_form_validate_cc(), // Credit card info.
319 318
 	);
320 319
 
321
-	$form_id = intval( $post_data['give-form-id'] );
320
+	$form_id = intval($post_data['give-form-id']);
322 321
 
323 322
 	// Validate agree to terms.
324
-	if ( give_is_terms_enabled( $form_id ) ) {
323
+	if (give_is_terms_enabled($form_id)) {
325 324
 		give_donation_form_validate_agree_to_terms();
326 325
 	}
327 326
 
328
-	if ( is_user_logged_in() ) {
327
+	if (is_user_logged_in()) {
329 328
 
330 329
 		// Collect logged in user data.
331 330
 		$valid_data['logged_in_user'] = give_donation_form_validate_logged_in_user();
332 331
 	} elseif (
333
-		isset( $post_data['give-purchase-var'] ) &&
332
+		isset($post_data['give-purchase-var']) &&
334 333
 		'needs-to-register' === $post_data['give-purchase-var'] &&
335
-		! empty( $post_data['give_create_account'] )
334
+		! empty($post_data['give_create_account'])
336 335
 	) {
337 336
 
338 337
 		// Set new user registration as required.
@@ -341,7 +340,7 @@  discard block
 block discarded – undo
341 340
 		// Validate new user data.
342 341
 		$valid_data['new_user_data'] = give_donation_form_validate_new_user();
343 342
 	} elseif (
344
-		isset( $post_data['give-purchase-var'] ) &&
343
+		isset($post_data['give-purchase-var']) &&
345 344
 		'needs-to-login' === $post_data['give-purchase-var']
346 345
 	) {
347 346
 
@@ -370,14 +369,14 @@  discard block
 block discarded – undo
370 369
 function give_is_spam_donation() {
371 370
 	$spam = false;
372 371
 
373
-	$user_agent = (string) isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : '';
372
+	$user_agent = (string) isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
374 373
 
375
-	if ( strlen( $user_agent ) < 2 ) {
374
+	if (strlen($user_agent) < 2) {
376 375
 		$spam = true;
377 376
 	}
378 377
 
379 378
 	// Allow developer to customized Akismet spam detect API call and it's response.
380
-	return apply_filters( 'give_spam', $spam );
379
+	return apply_filters('give_spam', $spam);
381 380
 }
382 381
 
383 382
 /**
@@ -392,33 +391,33 @@  discard block
 block discarded – undo
392 391
  */
393 392
 function give_donation_form_validate_gateway() {
394 393
 
395
-	$post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok.
396
-	$form_id   = ! empty( $post_data['give-form-id'] ) ? $post_data['give-form-id'] : 0;
397
-	$amount    = ! empty( $post_data['give-amount'] ) ? give_maybe_sanitize_amount( $post_data['give-amount'] ) : 0;
398
-	$gateway   = ! empty( $post_data['give-gateway'] ) ? $post_data['give-gateway'] : 0;
394
+	$post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok.
395
+	$form_id   = ! empty($post_data['give-form-id']) ? $post_data['give-form-id'] : 0;
396
+	$amount    = ! empty($post_data['give-amount']) ? give_maybe_sanitize_amount($post_data['give-amount']) : 0;
397
+	$gateway   = ! empty($post_data['give-gateway']) ? $post_data['give-gateway'] : 0;
399 398
 
400 399
 	// Bailout, if payment gateway is not submitted with donation form data.
401
-	if ( empty( $gateway ) ) {
400
+	if (empty($gateway)) {
402 401
 
403
-		give_set_error( 'empty_gateway', __( 'The donation form will process with a valid payment gateway.', 'give' ) );
402
+		give_set_error('empty_gateway', __('The donation form will process with a valid payment gateway.', 'give'));
404 403
 
405
-	} elseif ( ! give_is_gateway_active( $gateway ) ) {
404
+	} elseif ( ! give_is_gateway_active($gateway)) {
406 405
 
407
-		give_set_error( 'invalid_gateway', __( 'The selected payment gateway is not enabled.', 'give' ) );
406
+		give_set_error('invalid_gateway', __('The selected payment gateway is not enabled.', 'give'));
408 407
 
409
-	} elseif ( empty( $amount ) ) {
408
+	} elseif (empty($amount)) {
410 409
 
411
-		give_set_error( 'invalid_donation_amount', __( 'Please insert a valid donation amount.', 'give' ) );
410
+		give_set_error('invalid_donation_amount', __('Please insert a valid donation amount.', 'give'));
412 411
 
413
-	} elseif ( ! give_verify_minimum_price( 'minimum' ) ) {
412
+	} elseif ( ! give_verify_minimum_price('minimum')) {
414 413
 
415 414
 		give_set_error(
416 415
 			'invalid_donation_minimum',
417 416
 			sprintf(
418 417
 				/* translators: %s: minimum donation amount */
419
-				__( 'This form has a minimum donation amount of %s.', 'give' ),
418
+				__('This form has a minimum donation amount of %s.', 'give'),
420 419
 				give_currency_filter(
421
-					give_format_amount( give_get_form_minimum_price( $form_id ),
420
+					give_format_amount(give_get_form_minimum_price($form_id),
422 421
 						array(
423 422
 							'sanitize' => false,
424 423
 						)
@@ -426,15 +425,15 @@  discard block
 block discarded – undo
426 425
 				)
427 426
 			)
428 427
 		);
429
-	} elseif ( ! give_verify_minimum_price( 'maximum' ) ) {
428
+	} elseif ( ! give_verify_minimum_price('maximum')) {
430 429
 
431 430
 		give_set_error(
432 431
 			'invalid_donation_maximum',
433 432
 			sprintf(
434 433
 				/* translators: %s: Maximum donation amount */
435
-				__( 'This form has a maximum donation amount of %s.', 'give' ),
434
+				__('This form has a maximum donation amount of %s.', 'give'),
436 435
 				give_currency_filter(
437
-					give_format_amount( give_get_form_maximum_price( $form_id ),
436
+					give_format_amount(give_get_form_maximum_price($form_id),
438 437
 						array(
439 438
 							'sanitize' => false,
440 439
 						)
@@ -460,33 +459,33 @@  discard block
 block discarded – undo
460 459
  *
461 460
  * @return bool
462 461
  */
463
-function give_verify_minimum_price( $amount_range = 'minimum' ) {
462
+function give_verify_minimum_price($amount_range = 'minimum') {
464 463
 
465
-	$post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok.
466
-	$amount    = ! empty( $post_data['give-amount'] ) ? give_maybe_sanitize_amount( $post_data['give-amount'] ) : 0;
467
-	$form_id   = ! empty( $post_data['give-form-id'] ) ? $post_data['give-form-id'] : 0;
468
-	$price_id  = isset( $post_data['give-price-id'] ) ? absint( $post_data['give-price-id'] ) : '';
464
+	$post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok.
465
+	$amount    = ! empty($post_data['give-amount']) ? give_maybe_sanitize_amount($post_data['give-amount']) : 0;
466
+	$form_id   = ! empty($post_data['give-form-id']) ? $post_data['give-form-id'] : 0;
467
+	$price_id  = isset($post_data['give-price-id']) ? absint($post_data['give-price-id']) : '';
469 468
 
470
-	$variable_prices = give_has_variable_prices( $form_id );
471
-	$price_ids       = array_map( 'absint', give_get_variable_price_ids( $form_id ) );
469
+	$variable_prices = give_has_variable_prices($form_id);
470
+	$price_ids       = array_map('absint', give_get_variable_price_ids($form_id));
472 471
 	$verified_stat   = false;
473 472
 
474
-	if ( $variable_prices && in_array( $price_id, $price_ids, true ) ) {
473
+	if ($variable_prices && in_array($price_id, $price_ids, true)) {
475 474
 
476
-		$price_level_amount = give_get_price_option_amount( $form_id, $price_id );
475
+		$price_level_amount = give_get_price_option_amount($form_id, $price_id);
477 476
 
478
-		if ( $price_level_amount == $amount ) {
477
+		if ($price_level_amount == $amount) {
479 478
 			$verified_stat = true;
480 479
 		}
481 480
 	}
482 481
 
483
-	if ( ! $verified_stat ) {
484
-		switch ( $amount_range ) {
482
+	if ( ! $verified_stat) {
483
+		switch ($amount_range) {
485 484
 			case 'minimum' :
486
-				$verified_stat = ( give_get_form_minimum_price( $form_id ) > $amount ) ? false : true;
485
+				$verified_stat = (give_get_form_minimum_price($form_id) > $amount) ? false : true;
487 486
 				break;
488 487
 			case 'maximum' :
489
-				$verified_stat = ( give_get_form_maximum_price( $form_id ) < $amount ) ? false : true;
488
+				$verified_stat = (give_get_form_maximum_price($form_id) < $amount) ? false : true;
490 489
 				break;
491 490
 		}
492 491
 	}
@@ -500,7 +499,7 @@  discard block
 block discarded – undo
500 499
 	 * @param string  $amount_range  Type of the amount.
501 500
 	 * @param integer $form_id       Give Donation Form ID.
502 501
 	 */
503
-	return apply_filters( 'give_verify_minimum_maximum_price', $verified_stat, $amount_range, $form_id );
502
+	return apply_filters('give_verify_minimum_maximum_price', $verified_stat, $amount_range, $form_id);
504 503
 }
505 504
 
506 505
 /**
@@ -513,13 +512,13 @@  discard block
 block discarded – undo
513 512
  */
514 513
 function give_donation_form_validate_agree_to_terms() {
515 514
 
516
-	$agree_to_terms = ! empty( $_POST['give_agree_to_terms'] ) ? give_clean( $_POST['give_agree_to_terms'] ) : 0; // WPCS: input var ok, sanitization ok, CSRF ok.
515
+	$agree_to_terms = ! empty($_POST['give_agree_to_terms']) ? give_clean($_POST['give_agree_to_terms']) : 0; // WPCS: input var ok, sanitization ok, CSRF ok.
517 516
 
518 517
 	// Proceed only, if donor agreed to terms.
519
-	if ( ! $agree_to_terms ) {
518
+	if ( ! $agree_to_terms) {
520 519
 
521 520
 		// User did not agree.
522
-		give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', __( 'You must agree to the terms and conditions.', 'give' ) ) );
521
+		give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', __('You must agree to the terms and conditions.', 'give')));
523 522
 	}
524 523
 }
525 524
 
@@ -533,84 +532,84 @@  discard block
 block discarded – undo
533 532
  *
534 533
  * @return array
535 534
  */
536
-function give_get_required_fields( $form_id ) {
535
+function give_get_required_fields($form_id) {
537 536
 
538
-	$payment_mode = give_get_chosen_gateway( $form_id );
537
+	$payment_mode = give_get_chosen_gateway($form_id);
539 538
 
540 539
 	$required_fields = array(
541 540
 		'give_email' => array(
542 541
 			'error_id'      => 'invalid_email',
543
-			'error_message' => __( 'Please enter a valid email address.', 'give' ),
542
+			'error_message' => __('Please enter a valid email address.', 'give'),
544 543
 		),
545 544
 		'give_first' => array(
546 545
 			'error_id'      => 'invalid_first_name',
547
-			'error_message' => __( 'Please enter your first name.', 'give' ),
546
+			'error_message' => __('Please enter your first name.', 'give'),
548 547
 		),
549 548
 	);
550 549
 
551
-	$require_address = give_require_billing_address( $payment_mode );
550
+	$require_address = give_require_billing_address($payment_mode);
552 551
 
553
-	if ( $require_address ) {
554
-		$required_fields['card_address']    = array(
552
+	if ($require_address) {
553
+		$required_fields['card_address'] = array(
555 554
 			'error_id'      => 'invalid_card_address',
556
-			'error_message' => __( 'Please enter your primary billing address.', 'give' ),
555
+			'error_message' => __('Please enter your primary billing address.', 'give'),
557 556
 		);
558
-		$required_fields['card_zip']        = array(
557
+		$required_fields['card_zip'] = array(
559 558
 			'error_id'      => 'invalid_zip_code',
560
-			'error_message' => __( 'Please enter your zip / postal code.', 'give' ),
559
+			'error_message' => __('Please enter your zip / postal code.', 'give'),
561 560
 		);
562
-		$required_fields['card_city']       = array(
561
+		$required_fields['card_city'] = array(
563 562
 			'error_id'      => 'invalid_city',
564
-			'error_message' => __( 'Please enter your billing city.', 'give' ),
563
+			'error_message' => __('Please enter your billing city.', 'give'),
565 564
 		);
566 565
 		$required_fields['billing_country'] = array(
567 566
 			'error_id'      => 'invalid_country',
568
-			'error_message' => __( 'Please select your billing country.', 'give' ),
567
+			'error_message' => __('Please select your billing country.', 'give'),
569 568
 		);
570 569
 
571 570
 
572 571
 		$required_fields['card_state'] = array(
573 572
 			'error_id'      => 'invalid_state',
574
-			'error_message' => __( 'Please enter billing state / province / County.', 'give' ),
573
+			'error_message' => __('Please enter billing state / province / County.', 'give'),
575 574
 		);
576 575
 
577
-		$country = ! empty( $_POST['billing_country'] ) ? give_clean( $_POST['billing_country'] ) : 0; // WPCS: input var ok, sanitization ok, CSRF ok.
576
+		$country = ! empty($_POST['billing_country']) ? give_clean($_POST['billing_country']) : 0; // WPCS: input var ok, sanitization ok, CSRF ok.
578 577
 
579 578
 		// Check if billing country already exists.
580
-		if ( $country ) {
579
+		if ($country) {
581 580
 
582 581
 			// Get the country list that does not required any states init.
583 582
 			$states_country = give_states_not_required_country_list();
584 583
 
585 584
 			// Check if states is empty or not.
586
-			if ( array_key_exists( $country, $states_country ) ) {
585
+			if (array_key_exists($country, $states_country)) {
587 586
 				// If states is empty remove the required fields of state in billing cart.
588
-				unset( $required_fields['card_state'] );
587
+				unset($required_fields['card_state']);
589 588
 			}
590 589
 		}
591 590
 	} // End if().
592 591
 
593
-	if ( give_is_company_field_enabled( $form_id ) ) {
594
-		$form_option    = give_get_meta( $form_id, '_give_company_field', true );
595
-		$global_setting = give_get_option( 'company_field' );
592
+	if (give_is_company_field_enabled($form_id)) {
593
+		$form_option    = give_get_meta($form_id, '_give_company_field', true);
594
+		$global_setting = give_get_option('company_field');
596 595
 
597 596
 		$is_company_field_required = false;
598 597
 
599
-		if ( ! empty( $form_option ) && give_is_setting_enabled( $form_option, array( 'required' ) ) ) {
598
+		if ( ! empty($form_option) && give_is_setting_enabled($form_option, array('required'))) {
600 599
 			$is_company_field_required = true;
601 600
 
602
-		} elseif ( 'global' === $form_option && give_is_setting_enabled( $global_setting, array( 'required' ) ) ) {
601
+		} elseif ('global' === $form_option && give_is_setting_enabled($global_setting, array('required'))) {
603 602
 			$is_company_field_required = true;
604 603
 
605
-		} elseif ( empty( $form_option ) && give_is_setting_enabled( $global_setting, array( 'required' ) ) ) {
604
+		} elseif (empty($form_option) && give_is_setting_enabled($global_setting, array('required'))) {
606 605
 			$is_company_field_required = true;
607 606
 
608 607
 		}
609 608
 
610
-		if ( $is_company_field_required ) {
609
+		if ($is_company_field_required) {
611 610
 			$required_fields['give_company_name'] = array(
612 611
 				'error_id'      => 'invalid_company',
613
-				'error_message' => __( 'Please enter Company Name.', 'give' ),
612
+				'error_message' => __('Please enter Company Name.', 'give'),
614 613
 			);
615 614
 		}
616 615
 	}
@@ -620,7 +619,7 @@  discard block
 block discarded – undo
620 619
 	 *
621 620
 	 * @since 1.7
622 621
 	 */
623
-	$required_fields = apply_filters( 'give_donation_form_required_fields', $required_fields, $form_id );
622
+	$required_fields = apply_filters('give_donation_form_required_fields', $required_fields, $form_id);
624 623
 
625 624
 	return $required_fields;
626 625
 
@@ -635,17 +634,17 @@  discard block
 block discarded – undo
635 634
  *
636 635
  * @return bool
637 636
  */
638
-function give_require_billing_address( $payment_mode ) {
637
+function give_require_billing_address($payment_mode) {
639 638
 
640 639
 	$return          = false;
641
-	$billing_country = ! empty( $_POST['billing_country'] ) ? give_clean( $_POST['billing_country'] ) : 0; // WPCS: input var ok, sanitization ok, CSRF ok.
640
+	$billing_country = ! empty($_POST['billing_country']) ? give_clean($_POST['billing_country']) : 0; // WPCS: input var ok, sanitization ok, CSRF ok.
642 641
 
643
-	if ( $billing_country || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) {
642
+	if ($billing_country || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) {
644 643
 		$return = true;
645 644
 	}
646 645
 
647 646
 	// Let payment gateways and other extensions determine if address fields should be required.
648
-	return apply_filters( 'give_require_billing_address', $return );
647
+	return apply_filters('give_require_billing_address', $return);
649 648
 
650 649
 }
651 650
 
@@ -659,47 +658,47 @@  discard block
 block discarded – undo
659 658
  */
660 659
 function give_donation_form_validate_logged_in_user() {
661 660
 
662
-	$post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok.
661
+	$post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok.
663 662
 	$user_id   = get_current_user_id();
664
-	$form_id   = ! empty( $post_data['give-form-id'] ) ? $post_data['give-form-id'] : 0;
663
+	$form_id   = ! empty($post_data['give-form-id']) ? $post_data['give-form-id'] : 0;
665 664
 
666 665
 	// Start empty array to collect valid user data.
667 666
 	$valid_user_data = array(
668 667
 
669 668
 		// Assume there will be errors.
670
-		'user_id' => - 1,
669
+		'user_id' => -1,
671 670
 	);
672 671
 
673 672
 	// Proceed on;y, if valid $user_id found.
674
-	if ( $user_id > 0 ) {
673
+	if ($user_id > 0) {
675 674
 
676 675
 		// Get the logged in user data.
677
-		$user_data = get_userdata( $user_id );
676
+		$user_data = get_userdata($user_id);
678 677
 
679 678
 		// Validate Required Form Fields.
680
-		give_validate_required_form_fields( $form_id );
679
+		give_validate_required_form_fields($form_id);
681 680
 
682 681
 		// Verify data.
683
-		if ( is_object( $user_data ) && $user_data->ID > 0 ) {
682
+		if (is_object($user_data) && $user_data->ID > 0) {
684 683
 
685 684
 			// Collected logged in user data.
686 685
 			$valid_user_data = array(
687 686
 				'user_id'    => $user_id,
688
-				'user_email' => ! empty( $post_data['give_email'] ) ? sanitize_email( $post_data['give_email'] ) : $user_data->user_email,
689
-				'user_first' => ! empty( $post_data['give_first'] ) ? $post_data['give_first'] : $user_data->first_name,
690
-				'user_last'  => ! empty( $post_data['give_last'] ) ? $post_data['give_last'] : $user_data->last_name,
687
+				'user_email' => ! empty($post_data['give_email']) ? sanitize_email($post_data['give_email']) : $user_data->user_email,
688
+				'user_first' => ! empty($post_data['give_first']) ? $post_data['give_first'] : $user_data->first_name,
689
+				'user_last'  => ! empty($post_data['give_last']) ? $post_data['give_last'] : $user_data->last_name,
691 690
 			);
692 691
 
693 692
 			// Validate essential form fields.
694
-			give_donation_form_validate_name_fields( $post_data );
693
+			give_donation_form_validate_name_fields($post_data);
695 694
 
696
-			if ( ! is_email( $valid_user_data['user_email'] ) ) {
697
-				give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
695
+			if ( ! is_email($valid_user_data['user_email'])) {
696
+				give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
698 697
 			}
699 698
 		} else {
700 699
 
701 700
 			// Set invalid user information error.
702
-			give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) );
701
+			give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give'));
703 702
 		}
704 703
 	}
705 704
 
@@ -717,12 +716,12 @@  discard block
 block discarded – undo
717 716
  */
718 717
 function give_donation_form_validate_new_user() {
719 718
 
720
-	$post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok.
721
-	$nonce     = ! empty( $post_data['give-form-user-register-hash'] ) ? $post_data['give-form-user-register-hash'] : '';
719
+	$post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok.
720
+	$nonce     = ! empty($post_data['give-form-user-register-hash']) ? $post_data['give-form-user-register-hash'] : '';
722 721
 
723 722
 	// Validate user creation nonce.
724
-	if ( ! wp_verify_nonce( $nonce, 'give_form_create_user_nonce' ) ) {
725
-		give_set_error( 'invalid_nonce', __( 'Nonce verification has failed.', 'give' ) );
723
+	if ( ! wp_verify_nonce($nonce, 'give_form_create_user_nonce')) {
724
+		give_set_error('invalid_nonce', __('Nonce verification has failed.', 'give'));
726 725
 	}
727 726
 
728 727
 	$auto_generated_password = wp_generate_password();
@@ -730,7 +729,7 @@  discard block
 block discarded – undo
730 729
 	// Default user data.
731 730
 	$default_user_data = array(
732 731
 		'give-form-id'           => '',
733
-		'user_id'                => - 1, // Assume there will be errors.
732
+		'user_id'                => -1, // Assume there will be errors.
734 733
 		'user_first'             => '',
735 734
 		'user_last'              => '',
736 735
 		'give_user_login'        => false,
@@ -740,17 +739,17 @@  discard block
 block discarded – undo
740 739
 	);
741 740
 
742 741
 	// Get user data.
743
-	$user_data            = wp_parse_args( $post_data, $default_user_data );
742
+	$user_data            = wp_parse_args($post_data, $default_user_data);
744 743
 	$registering_new_user = false;
745
-	$form_id              = absint( $user_data['give-form-id'] );
744
+	$form_id              = absint($user_data['give-form-id']);
746 745
 
747
-	give_donation_form_validate_name_fields( $user_data );
746
+	give_donation_form_validate_name_fields($user_data);
748 747
 
749 748
 	// Start an empty array to collect valid user data.
750 749
 	$valid_user_data = array(
751 750
 
752 751
 		// Assume there will be errors.
753
-		'user_id'    => - 1,
752
+		'user_id'    => -1,
754 753
 
755 754
 		// Get first name.
756 755
 		'user_first' => $user_data['give_first'],
@@ -763,13 +762,13 @@  discard block
 block discarded – undo
763 762
 	);
764 763
 
765 764
 	// Validate Required Form Fields.
766
-	give_validate_required_form_fields( $form_id );
765
+	give_validate_required_form_fields($form_id);
767 766
 
768 767
 	// Set Email as Username.
769 768
 	$valid_user_data['user_login'] = $user_data['give_email'];
770 769
 
771 770
 	// Check if we have an email to verify.
772
-	if ( give_validate_user_email( $user_data['give_email'], $registering_new_user ) ) {
771
+	if (give_validate_user_email($user_data['give_email'], $registering_new_user)) {
773 772
 		$valid_user_data['user_email'] = $user_data['give_email'];
774 773
 	}
775 774
 
@@ -786,47 +785,47 @@  discard block
 block discarded – undo
786 785
  */
787 786
 function give_donation_form_validate_user_login() {
788 787
 
789
-	$post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok.
788
+	$post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok.
790 789
 
791 790
 	// Start an array to collect valid user data.
792 791
 	$valid_user_data = array(
793 792
 
794 793
 		// Assume there will be errors.
795
-		'user_id' => - 1,
794
+		'user_id' => -1,
796 795
 	);
797 796
 
798 797
 	// Bailout, if Username is empty.
799
-	if ( empty( $post_data['give_user_login'] ) ) {
800
-		give_set_error( 'must_log_in', __( 'You must register or login to complete your donation.', 'give' ) );
798
+	if (empty($post_data['give_user_login'])) {
799
+		give_set_error('must_log_in', __('You must register or login to complete your donation.', 'give'));
801 800
 
802 801
 		return $valid_user_data;
803 802
 	}
804 803
 
805 804
 	// Get the user by login.
806
-	$user_data = get_user_by( 'login', strip_tags( $post_data['give_user_login'] ) );
805
+	$user_data = get_user_by('login', strip_tags($post_data['give_user_login']));
807 806
 
808 807
 	// Check if user exists.
809
-	if ( $user_data ) {
808
+	if ($user_data) {
810 809
 
811 810
 		// Get password.
812
-		$user_pass = ! empty( $post_data['give_user_pass'] ) ? $post_data['give_user_pass'] : false;
811
+		$user_pass = ! empty($post_data['give_user_pass']) ? $post_data['give_user_pass'] : false;
813 812
 
814 813
 		// Check user_pass.
815
-		if ( $user_pass ) {
814
+		if ($user_pass) {
816 815
 
817 816
 			// Check if password is valid.
818
-			if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) {
817
+			if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) {
819 818
 
820
-				$current_page_url = site_url() . '/' . get_page_uri();
819
+				$current_page_url = site_url().'/'.get_page_uri();
821 820
 
822 821
 				// Incorrect password.
823 822
 				give_set_error(
824 823
 					'password_incorrect',
825 824
 					sprintf(
826 825
 						'%1$s <a href="%2$s">%3$s</a>',
827
-						__( 'The password you entered is incorrect.', 'give' ),
828
-						wp_lostpassword_url( $current_page_url ),
829
-						__( 'Reset Password', 'give' )
826
+						__('The password you entered is incorrect.', 'give'),
827
+						wp_lostpassword_url($current_page_url),
828
+						__('Reset Password', 'give')
830 829
 					)
831 830
 				);
832 831
 
@@ -844,11 +843,11 @@  discard block
 block discarded – undo
844 843
 			}
845 844
 		} else {
846 845
 			// Empty password.
847
-			give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) );
846
+			give_set_error('password_empty', __('Enter a password.', 'give'));
848 847
 		}
849 848
 	} else {
850 849
 		// No username.
851
-		give_set_error( 'username_incorrect', __( 'The username you entered does not exist.', 'give' ) );
850
+		give_set_error('username_incorrect', __('The username you entered does not exist.', 'give'));
852 851
 	} // End if().
853 852
 
854 853
 	return $valid_user_data;
@@ -864,8 +863,8 @@  discard block
 block discarded – undo
864 863
  */
865 864
 function give_donation_form_validate_guest_user() {
866 865
 
867
-	$post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok.
868
-	$form_id   = ! empty( $post_data['give-form-id'] ) ? $post_data['give-form-id'] : 0;
866
+	$post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok.
867
+	$form_id   = ! empty($post_data['give-form-id']) ? $post_data['give-form-id'] : 0;
869 868
 
870 869
 	// Start an array to collect valid user data.
871 870
 	$valid_user_data = array(
@@ -874,22 +873,22 @@  discard block
 block discarded – undo
874 873
 	);
875 874
 
876 875
 	// Validate name fields.
877
-	give_donation_form_validate_name_fields( $post_data );
876
+	give_donation_form_validate_name_fields($post_data);
878 877
 
879 878
 	// Validate Required Form Fields.
880
-	give_validate_required_form_fields( $form_id );
879
+	give_validate_required_form_fields($form_id);
881 880
 
882 881
 	// Get the guest email.
883
-	$guest_email = ! empty( $post_data['give_email'] ) ? $post_data['give_email'] : false;
882
+	$guest_email = ! empty($post_data['give_email']) ? $post_data['give_email'] : false;
884 883
 
885 884
 	// Check email.
886
-	if ( $guest_email && strlen( $guest_email ) > 0 ) {
885
+	if ($guest_email && strlen($guest_email) > 0) {
887 886
 
888 887
 		// Validate email.
889
-		if ( ! is_email( $guest_email ) ) {
888
+		if ( ! is_email($guest_email)) {
890 889
 
891 890
 			// Invalid email.
892
-			give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) );
891
+			give_set_error('email_invalid', __('Invalid email.', 'give'));
893 892
 
894 893
 		} else {
895 894
 
@@ -897,15 +896,15 @@  discard block
 block discarded – undo
897 896
 			$valid_user_data['user_email'] = $guest_email;
898 897
 
899 898
 			// Get user_id from donor if exist.
900
-			$donor = new Give_Donor( $guest_email );
899
+			$donor = new Give_Donor($guest_email);
901 900
 
902
-			if ( $donor->id && $donor->user_id ) {
901
+			if ($donor->id && $donor->user_id) {
903 902
 				$valid_user_data['user_id'] = $donor->user_id;
904 903
 			}
905 904
 		}
906 905
 	} else {
907 906
 		// No email.
908
-		give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) );
907
+		give_set_error('email_empty', __('Enter an email.', 'give'));
909 908
 	}
910 909
 
911 910
 	return $valid_user_data;
@@ -921,36 +920,36 @@  discard block
 block discarded – undo
921 920
  *
922 921
  * @return  integer
923 922
  */
924
-function give_register_and_login_new_user( $user_data = array() ) {
923
+function give_register_and_login_new_user($user_data = array()) {
925 924
 	// Verify the array.
926
-	if ( empty( $user_data ) ) {
927
-		return - 1;
925
+	if (empty($user_data)) {
926
+		return -1;
928 927
 	}
929 928
 
930
-	if ( give_get_errors() ) {
931
-		return - 1;
929
+	if (give_get_errors()) {
930
+		return -1;
932 931
 	}
933 932
 
934
-	$user_args = apply_filters( 'give_insert_user_args', array(
935
-		'user_login'      => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '',
936
-		'user_pass'       => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '',
937
-		'user_email'      => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '',
938
-		'first_name'      => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '',
939
-		'last_name'       => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '',
940
-		'user_registered' => date( 'Y-m-d H:i:s' ),
941
-		'role'            => give_get_option( 'donor_default_user_role', 'give_donor' ),
942
-	), $user_data );
933
+	$user_args = apply_filters('give_insert_user_args', array(
934
+		'user_login'      => isset($user_data['user_login']) ? $user_data['user_login'] : '',
935
+		'user_pass'       => isset($user_data['user_pass']) ? $user_data['user_pass'] : '',
936
+		'user_email'      => isset($user_data['user_email']) ? $user_data['user_email'] : '',
937
+		'first_name'      => isset($user_data['user_first']) ? $user_data['user_first'] : '',
938
+		'last_name'       => isset($user_data['user_last']) ? $user_data['user_last'] : '',
939
+		'user_registered' => date('Y-m-d H:i:s'),
940
+		'role'            => give_get_option('donor_default_user_role', 'give_donor'),
941
+	), $user_data);
943 942
 
944 943
 	// Insert new user.
945
-	$user_id = wp_insert_user( $user_args );
944
+	$user_id = wp_insert_user($user_args);
946 945
 
947 946
 	// Validate inserted user.
948
-	if ( is_wp_error( $user_id ) ) {
949
-		return - 1;
947
+	if (is_wp_error($user_id)) {
948
+		return -1;
950 949
 	}
951 950
 
952 951
 	// Allow themes and plugins to filter the user data.
953
-	$user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args );
952
+	$user_data = apply_filters('give_insert_user_data', $user_data, $user_args);
954 953
 
955 954
 	/**
956 955
 	 * Fires after inserting user.
@@ -960,7 +959,7 @@  discard block
 block discarded – undo
960 959
 	 * @param int $user_id User id.
961 960
 	 * @param array $user_data Array containing user data.
962 961
 	 */
963
-	do_action( 'give_insert_user', $user_id, $user_data );
962
+	do_action('give_insert_user', $user_id, $user_data);
964 963
 
965 964
 	/**
966 965
 	 * Filter allow user to alter if user when to login or not when user is register for the first time.
@@ -969,9 +968,9 @@  discard block
 block discarded – undo
969 968
 	 *
970 969
 	 * return bool True if login with registration and False if only want to register.
971 970
 	 */
972
-	if ( true === (bool) apply_filters( 'give_log_user_in_on_register', true ) ) {
971
+	if (true === (bool) apply_filters('give_log_user_in_on_register', true)) {
973 972
 		// Login new user.
974
-		give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] );
973
+		give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']);
975 974
 	}
976 975
 
977 976
 	// Return user id.
@@ -988,33 +987,33 @@  discard block
 block discarded – undo
988 987
  *
989 988
  * @return  array|bool
990 989
  */
991
-function give_get_donation_form_user( $valid_data = array() ) {
990
+function give_get_donation_form_user($valid_data = array()) {
992 991
 
993 992
 	// Initialize user.
994 993
 	$user      = false;
995
-	$is_ajax   = defined( 'DOING_AJAX' ) && DOING_AJAX;
996
-	$post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok.
994
+	$is_ajax   = defined('DOING_AJAX') && DOING_AJAX;
995
+	$post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok.
997 996
 
998
-	if ( $is_ajax ) {
997
+	if ($is_ajax) {
999 998
 
1000 999
 		// Do not create or login the user during the ajax submission (check for errors only).
1001 1000
 		return true;
1002
-	} elseif ( is_user_logged_in() ) {
1001
+	} elseif (is_user_logged_in()) {
1003 1002
 
1004 1003
 		// Set the valid user as the logged in collected data.
1005 1004
 		$user = $valid_data['logged_in_user'];
1006
-	} elseif ( true === $valid_data['need_new_user'] || true === $valid_data['need_user_login'] ) {
1005
+	} elseif (true === $valid_data['need_new_user'] || true === $valid_data['need_user_login']) {
1007 1006
 
1008 1007
 		// New user registration.
1009
-		if ( true === $valid_data['need_new_user'] ) {
1008
+		if (true === $valid_data['need_new_user']) {
1010 1009
 
1011 1010
 			// Set user.
1012 1011
 			$user = $valid_data['new_user_data'];
1013 1012
 
1014 1013
 			// Register and login new user.
1015
-			$user['user_id'] = give_register_and_login_new_user( $user );
1014
+			$user['user_id'] = give_register_and_login_new_user($user);
1016 1015
 
1017
-		} elseif ( true === $valid_data['need_user_login'] && ! $is_ajax ) {
1016
+		} elseif (true === $valid_data['need_user_login'] && ! $is_ajax) {
1018 1017
 
1019 1018
 			/**
1020 1019
 			 * The login form is now processed in the give_process_donation_login() function.
@@ -1026,42 +1025,42 @@  discard block
 block discarded – undo
1026 1025
 			$user = $valid_data['login_user_data'];
1027 1026
 
1028 1027
 			// Login user.
1029
-			give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] );
1028
+			give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']);
1030 1029
 		}
1031 1030
 	} // End if().
1032 1031
 
1033 1032
 	// Check guest checkout.
1034
-	if ( false === $user && false === give_logged_in_only( $post_data['give-form-id'] ) ) {
1033
+	if (false === $user && false === give_logged_in_only($post_data['give-form-id'])) {
1035 1034
 
1036 1035
 		// Set user.
1037 1036
 		$user = $valid_data['guest_user_data'];
1038 1037
 	}
1039 1038
 
1040 1039
 	// Verify we have an user.
1041
-	if ( false === $user || empty( $user ) ) {
1040
+	if (false === $user || empty($user)) {
1042 1041
 		return false;
1043 1042
 	}
1044 1043
 
1045 1044
 	// Get user first name.
1046
-	if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) {
1047
-		$user['user_first'] = isset( $post_data['give_first'] ) ? strip_tags( trim( $post_data['give_first'] ) ) : '';
1045
+	if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) {
1046
+		$user['user_first'] = isset($post_data['give_first']) ? strip_tags(trim($post_data['give_first'])) : '';
1048 1047
 	}
1049 1048
 
1050 1049
 	// Get user last name.
1051
-	if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) {
1052
-		$user['user_last'] = isset( $post_data['give_last'] ) ? strip_tags( trim( $post_data['give_last'] ) ) : '';
1050
+	if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) {
1051
+		$user['user_last'] = isset($post_data['give_last']) ? strip_tags(trim($post_data['give_last'])) : '';
1053 1052
 	}
1054 1053
 
1055 1054
 	// Get the user's billing address details.
1056 1055
 	$user['address']            = array();
1057
-	$user['address']['line1']   = ! empty( $post_data['card_address'] ) ? $post_data['card_address'] : false;
1058
-	$user['address']['line2']   = ! empty( $post_data['card_address_2'] ) ? $post_data['card_address_2'] : false;
1059
-	$user['address']['city']    = ! empty( $post_data['card_city'] ) ? $post_data['card_city'] : false;
1060
-	$user['address']['state']   = ! empty( $post_data['card_state'] ) ? $post_data['card_state'] : false;
1061
-	$user['address']['zip']     = ! empty( $post_data['card_zip'] ) ? $post_data['card_zip'] : false;
1062
-	$user['address']['country'] = ! empty( $post_data['billing_country'] ) ? $post_data['billing_country'] : false;
1063
-
1064
-	if ( empty( $user['address']['country'] ) ) {
1056
+	$user['address']['line1']   = ! empty($post_data['card_address']) ? $post_data['card_address'] : false;
1057
+	$user['address']['line2']   = ! empty($post_data['card_address_2']) ? $post_data['card_address_2'] : false;
1058
+	$user['address']['city']    = ! empty($post_data['card_city']) ? $post_data['card_city'] : false;
1059
+	$user['address']['state']   = ! empty($post_data['card_state']) ? $post_data['card_state'] : false;
1060
+	$user['address']['zip']     = ! empty($post_data['card_zip']) ? $post_data['card_zip'] : false;
1061
+	$user['address']['country'] = ! empty($post_data['billing_country']) ? $post_data['billing_country'] : false;
1062
+
1063
+	if (empty($user['address']['country'])) {
1065 1064
 		$user['address'] = false;
1066 1065
 	} // End if().
1067 1066
 
@@ -1082,16 +1081,16 @@  discard block
 block discarded – undo
1082 1081
 	$card_data = give_get_donation_cc_info();
1083 1082
 
1084 1083
 	// Validate the card zip.
1085
-	if ( ! empty( $card_data['card_zip'] ) ) {
1086
-		if ( ! give_donation_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) {
1087
-			give_set_error( 'invalid_cc_zip', __( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) );
1084
+	if ( ! empty($card_data['card_zip'])) {
1085
+		if ( ! give_donation_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) {
1086
+			give_set_error('invalid_cc_zip', __('The zip / postal code you entered for your billing address is invalid.', 'give'));
1088 1087
 		}
1089 1088
 	}
1090 1089
 
1091 1090
 	// Ensure no spaces.
1092
-	if ( ! empty( $card_data['card_number'] ) ) {
1093
-		$card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); // no "+" signs.
1094
-		$card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces.
1091
+	if ( ! empty($card_data['card_number'])) {
1092
+		$card_data['card_number'] = str_replace('+', '', $card_data['card_number']); // no "+" signs.
1093
+		$card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces.
1095 1094
 	}
1096 1095
 
1097 1096
 	// This should validate card numbers at some point too.
@@ -1109,20 +1108,20 @@  discard block
 block discarded – undo
1109 1108
 function give_get_donation_cc_info() {
1110 1109
 
1111 1110
 	// Sanitize the values submitted with donation form.
1112
-	$post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok.
1111
+	$post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok.
1113 1112
 
1114 1113
 	$cc_info                   = array();
1115
-	$cc_info['card_name']      = ! empty( $post_data['card_name'] ) ? $post_data['card_name'] : '';
1116
-	$cc_info['card_number']    = ! empty( $post_data['card_number'] ) ? $post_data['card_number'] : '';
1117
-	$cc_info['card_cvc']       = ! empty( $post_data['card_cvc'] ) ? $post_data['card_cvc'] : '';
1118
-	$cc_info['card_exp_month'] = ! empty( $post_data['card_exp_month'] ) ? $post_data['card_exp_month'] : '';
1119
-	$cc_info['card_exp_year']  = ! empty( $post_data['card_exp_year'] ) ? $post_data['card_exp_year'] : '';
1120
-	$cc_info['card_address']   = ! empty( $post_data['card_address'] ) ? $post_data['card_address'] : '';
1121
-	$cc_info['card_address_2'] = ! empty( $post_data['card_address_2'] ) ? $post_data['card_address_2'] : '';
1122
-	$cc_info['card_city']      = ! empty( $post_data['card_city'] ) ? $post_data['card_city'] : '';
1123
-	$cc_info['card_state']     = ! empty( $post_data['card_state'] ) ? $post_data['card_state'] : '';
1124
-	$cc_info['card_country']   = ! empty( $post_data['billing_country'] ) ? $post_data['billing_country'] : '';
1125
-	$cc_info['card_zip']       = ! empty( $post_data['card_zip'] ) ? $post_data['card_zip'] : '';
1114
+	$cc_info['card_name']      = ! empty($post_data['card_name']) ? $post_data['card_name'] : '';
1115
+	$cc_info['card_number']    = ! empty($post_data['card_number']) ? $post_data['card_number'] : '';
1116
+	$cc_info['card_cvc']       = ! empty($post_data['card_cvc']) ? $post_data['card_cvc'] : '';
1117
+	$cc_info['card_exp_month'] = ! empty($post_data['card_exp_month']) ? $post_data['card_exp_month'] : '';
1118
+	$cc_info['card_exp_year']  = ! empty($post_data['card_exp_year']) ? $post_data['card_exp_year'] : '';
1119
+	$cc_info['card_address']   = ! empty($post_data['card_address']) ? $post_data['card_address'] : '';
1120
+	$cc_info['card_address_2'] = ! empty($post_data['card_address_2']) ? $post_data['card_address_2'] : '';
1121
+	$cc_info['card_city']      = ! empty($post_data['card_city']) ? $post_data['card_city'] : '';
1122
+	$cc_info['card_state']     = ! empty($post_data['card_state']) ? $post_data['card_state'] : '';
1123
+	$cc_info['card_country']   = ! empty($post_data['billing_country']) ? $post_data['billing_country'] : '';
1124
+	$cc_info['card_zip']       = ! empty($post_data['card_zip']) ? $post_data['card_zip'] : '';
1126 1125
 
1127 1126
 	// Return cc info.
1128 1127
 	return $cc_info;
@@ -1138,14 +1137,14 @@  discard block
 block discarded – undo
1138 1137
  *
1139 1138
  * @return bool|mixed
1140 1139
  */
1141
-function give_donation_form_validate_cc_zip( $zip = 0, $country_code = '' ) {
1140
+function give_donation_form_validate_cc_zip($zip = 0, $country_code = '') {
1142 1141
 	$ret = false;
1143 1142
 
1144
-	if ( empty( $zip ) || empty( $country_code ) ) {
1143
+	if (empty($zip) || empty($country_code)) {
1145 1144
 		return $ret;
1146 1145
 	}
1147 1146
 
1148
-	$country_code = strtoupper( $country_code );
1147
+	$country_code = strtoupper($country_code);
1149 1148
 
1150 1149
 	$zip_regex = array(
1151 1150
 		'AD' => 'AD\d{3}',
@@ -1305,11 +1304,11 @@  discard block
 block discarded – undo
1305 1304
 		'ZM' => '\d{5}',
1306 1305
 	);
1307 1306
 
1308
-	if ( ! isset( $zip_regex[ $country_code ] ) || preg_match( '/' . $zip_regex[ $country_code ] . '/i', $zip ) ) {
1307
+	if ( ! isset($zip_regex[$country_code]) || preg_match('/'.$zip_regex[$country_code].'/i', $zip)) {
1309 1308
 		$ret = true;
1310 1309
 	}
1311 1310
 
1312
-	return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code );
1311
+	return apply_filters('give_is_zip_valid', $ret, $zip, $country_code);
1313 1312
 }
1314 1313
 
1315 1314
 /**
@@ -1321,60 +1320,60 @@  discard block
 block discarded – undo
1321 1320
  *
1322 1321
  * @return bool
1323 1322
  */
1324
-function give_validate_donation_amount( $valid_data ) {
1323
+function give_validate_donation_amount($valid_data) {
1325 1324
 
1326
-	$post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok.
1325
+	$post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok.
1327 1326
 
1328 1327
 	/* @var Give_Donate_Form $form */
1329
-	$form = new Give_Donate_Form( $post_data['give-form-id'] );
1328
+	$form = new Give_Donate_Form($post_data['give-form-id']);
1330 1329
 
1331 1330
 	// Get the form currency.
1332
-	$form_currency = give_get_currency( $post_data['give-form-id'] );
1331
+	$form_currency = give_get_currency($post_data['give-form-id']);
1333 1332
 
1334 1333
 	$donation_level_matched = false;
1335 1334
 
1336
-	if ( $form->is_set_type_donation_form() ) {
1335
+	if ($form->is_set_type_donation_form()) {
1337 1336
 
1338 1337
 		// Sanitize donation amount.
1339
-		$post_data['give-amount'] = give_maybe_sanitize_amount( $post_data['give-amount'], array( 'currency' => $form_currency ) );
1338
+		$post_data['give-amount'] = give_maybe_sanitize_amount($post_data['give-amount'], array('currency' => $form_currency));
1340 1339
 
1341 1340
 		// Backward compatibility.
1342
-		if ( $form->is_custom_price( $post_data['give-amount'] ) ) {
1341
+		if ($form->is_custom_price($post_data['give-amount'])) {
1343 1342
 			$post_data['give-price-id'] = 'custom';
1344 1343
 		}
1345 1344
 
1346 1345
 		$donation_level_matched = true;
1347 1346
 
1348
-	} elseif ( $form->is_multi_type_donation_form() ) {
1347
+	} elseif ($form->is_multi_type_donation_form()) {
1349 1348
 
1350 1349
 		$variable_prices = $form->get_prices();
1351 1350
 
1352 1351
 		// Bailout.
1353
-		if ( ! $variable_prices ) {
1352
+		if ( ! $variable_prices) {
1354 1353
 			return false;
1355 1354
 		}
1356 1355
 
1357 1356
 		// Sanitize donation amount.
1358
-		$post_data['give-amount']     = give_maybe_sanitize_amount( $post_data['give-amount'], array( 'currency' => $form_currency ) );
1359
-		$variable_price_option_amount = give_maybe_sanitize_amount( give_get_price_option_amount( $post_data['give-form-id'], $post_data['give-price-id'] ), array( 'currency' => $form_currency ) );
1357
+		$post_data['give-amount']     = give_maybe_sanitize_amount($post_data['give-amount'], array('currency' => $form_currency));
1358
+		$variable_price_option_amount = give_maybe_sanitize_amount(give_get_price_option_amount($post_data['give-form-id'], $post_data['give-price-id']), array('currency' => $form_currency));
1360 1359
 		$new_price_id                 = '';
1361 1360
 
1362
-		if ( $post_data['give-amount'] === $variable_price_option_amount ) {
1361
+		if ($post_data['give-amount'] === $variable_price_option_amount) {
1363 1362
 			return true;
1364 1363
 		}
1365 1364
 
1366
-		if ( $form->is_custom_price( $post_data['give-amount'] ) ) {
1365
+		if ($form->is_custom_price($post_data['give-amount'])) {
1367 1366
 			$new_price_id = 'custom';
1368 1367
 		} else {
1369 1368
 
1370 1369
 			// Find correct donation level from all donation levels.
1371
-			foreach ( $variable_prices as $variable_price ) {
1370
+			foreach ($variable_prices as $variable_price) {
1372 1371
 
1373 1372
 				// Sanitize level amount.
1374
-				$variable_price['_give_amount'] = give_maybe_sanitize_amount( $variable_price['_give_amount'] );
1373
+				$variable_price['_give_amount'] = give_maybe_sanitize_amount($variable_price['_give_amount']);
1375 1374
 
1376 1375
 				// Set first match donation level ID.
1377
-				if ( $post_data['give-amount'] === $variable_price['_give_amount'] ) {
1376
+				if ($post_data['give-amount'] === $variable_price['_give_amount']) {
1378 1377
 					$new_price_id = $variable_price['_give_id']['level_id'];
1379 1378
 					break;
1380 1379
 				}
@@ -1383,26 +1382,26 @@  discard block
 block discarded – undo
1383 1382
 
1384 1383
 		// If donation amount is not find in donation levels then check if form has custom donation feature enable or not.
1385 1384
 		// If yes then set price id to custom if amount is greater then custom minimum amount (if any).
1386
-		if ( $post_data['give-price-id'] === $new_price_id ) {
1385
+		if ($post_data['give-price-id'] === $new_price_id) {
1387 1386
 			$donation_level_matched = true;
1388 1387
 		}
1389 1388
 	} // End if().
1390 1389
 
1391
-	if ( ! $donation_level_matched ) {
1390
+	if ( ! $donation_level_matched) {
1392 1391
 		give_set_error(
1393 1392
 			'invalid_donation_amount',
1394 1393
 			sprintf(
1395 1394
 			/* translators: %s: invalid donation amount */
1396
-				__( 'Donation amount %s is invalid.', 'give' ),
1395
+				__('Donation amount %s is invalid.', 'give'),
1397 1396
 				give_currency_filter(
1398
-					give_format_amount( $post_data['give-amount'], array( 'sanitize' => false, ) )
1397
+					give_format_amount($post_data['give-amount'], array('sanitize' => false,))
1399 1398
 				)
1400 1399
 			)
1401 1400
 		);
1402 1401
 	}
1403 1402
 }
1404 1403
 
1405
-add_action( 'give_checkout_error_checks', 'give_validate_donation_amount', 10, 1 );
1404
+add_action('give_checkout_error_checks', 'give_validate_donation_amount', 10, 1);
1406 1405
 
1407 1406
 /**
1408 1407
  * Validate Required Form Fields.
@@ -1411,20 +1410,20 @@  discard block
 block discarded – undo
1411 1410
  *
1412 1411
  * @since 2.0
1413 1412
  */
1414
-function give_validate_required_form_fields( $form_id ) {
1413
+function give_validate_required_form_fields($form_id) {
1415 1414
 
1416 1415
 	// Sanitize values submitted with donation form.
1417
-	$post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok.
1416
+	$post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok.
1418 1417
 
1419 1418
 	// Loop through required fields and show error messages.
1420
-	foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) {
1419
+	foreach (give_get_required_fields($form_id) as $field_name => $value) {
1421 1420
 
1422 1421
 		// Clean Up Data of the input fields.
1423
-		$field_value = $post_data[ $field_name ];
1422
+		$field_value = $post_data[$field_name];
1424 1423
 
1425 1424
 		// Check whether the required field is empty, then show the error message.
1426
-		if ( in_array( $value, give_get_required_fields( $form_id ), true ) && empty( $field_value ) ) {
1427
-			give_set_error( $value['error_id'], $value['error_message'] );
1425
+		if (in_array($value, give_get_required_fields($form_id), true) && empty($field_value)) {
1426
+			give_set_error($value['error_id'], $value['error_message']);
1428 1427
 		}
1429 1428
 	}
1430 1429
 }
@@ -1438,12 +1437,12 @@  discard block
 block discarded – undo
1438 1437
  *
1439 1438
  * @return void
1440 1439
  */
1441
-function give_donation_form_validate_name_fields( $post_data ) {
1440
+function give_donation_form_validate_name_fields($post_data) {
1442 1441
 
1443
-	$is_alpha_first_name = ( ! is_email( $post_data['give_first'] ) && ! preg_match( '~[0-9]~', $post_data['give_first'] ) );
1444
-	$is_alpha_last_name  = ( ! is_email( $post_data['give_last'] ) && ! preg_match( '~[0-9]~', $post_data['give_last'] ) );
1442
+	$is_alpha_first_name = ( ! is_email($post_data['give_first']) && ! preg_match('~[0-9]~', $post_data['give_first']));
1443
+	$is_alpha_last_name  = ( ! is_email($post_data['give_last']) && ! preg_match('~[0-9]~', $post_data['give_last']));
1445 1444
 
1446
-	if ( ! $is_alpha_first_name || ( ! empty( $post_data['give_last'] ) && ! $is_alpha_last_name ) ) {
1447
-		give_set_error( 'invalid_name', esc_html__( 'The First Name and Last Name fields cannot contain an email address or numbers.', 'give' ) );
1445
+	if ( ! $is_alpha_first_name || ( ! empty($post_data['give_last']) && ! $is_alpha_last_name)) {
1446
+		give_set_error('invalid_name', esc_html__('The First Name and Last Name fields cannot contain an email address or numbers.', 'give'));
1448 1447
 	}
1449 1448
 }
Please login to merge, or discard this patch.
templates/shortcode-receipt.php 1 patch
Spacing   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -6,26 +6,26 @@  discard block
 block discarded – undo
6 6
 global $give_receipt_args, $payment;
7 7
 
8 8
 // Validation: Ensure $payment var is set.
9
-if ( empty( $payment ) ) {
10
-	$payment = ! empty( $give_receipt_args['id'] ) ? get_post( $give_receipt_args['id'] ) : 0;
9
+if (empty($payment)) {
10
+	$payment = ! empty($give_receipt_args['id']) ? get_post($give_receipt_args['id']) : 0;
11 11
 }
12 12
 
13 13
 // Double-Validation: Check for $payment global.
14
-if ( empty( $payment ) ) {
15
-	Give()->notices->print_frontend_notice( __( 'The specified receipt ID appears to be invalid.', 'give' ) );
14
+if (empty($payment)) {
15
+	Give()->notices->print_frontend_notice(__('The specified receipt ID appears to be invalid.', 'give'));
16 16
 
17 17
 	return;
18 18
 }
19 19
 
20 20
 $donation_id  = $payment->ID;
21
-$donation_number = Give()->seq_donation_number->get_serial_code( $payment->ID );
22
-$form_id      = give_get_payment_meta( $donation_id, '_give_payment_form_id', true );
23
-$donation     = give_get_donation_form_title( $donation_id );
24
-$user         = give_get_payment_meta_user_info( $donation_id );
25
-$email        = give_get_payment_user_email( $donation_id );
21
+$donation_number = Give()->seq_donation_number->get_serial_code($payment->ID);
22
+$form_id      = give_get_payment_meta($donation_id, '_give_payment_form_id', true);
23
+$donation     = give_get_donation_form_title($donation_id);
24
+$user         = give_get_payment_meta_user_info($donation_id);
25
+$email        = give_get_payment_user_email($donation_id);
26 26
 $status       = $payment->post_status;
27
-$status_label = give_get_payment_status( $payment, true );
28
-$company_name = give_get_payment_meta( $donation_id, '_give_donation_company', true );
27
+$status_label = give_get_payment_status($payment, true);
28
+$company_name = give_get_payment_meta($donation_id, '_give_donation_company', true);
29 29
 
30 30
 /**
31 31
  * Generate Donation Receipt Arguments.
@@ -36,8 +36,8 @@  discard block
 block discarded – undo
36 36
  * @since 1.8.8
37 37
  */
38 38
 $give_receipt_args['donation_receipt']['donor'] = array(
39
-	'name'    => __( 'Donor', 'give' ),
40
-	'value'   => $user['first_name'] . ' ' . $user['last_name'],
39
+	'name'    => __('Donor', 'give'),
40
+	'value'   => $user['first_name'].' '.$user['last_name'],
41 41
 	'display' => $give_receipt_args['donor'],
42 42
 );
43 43
 
@@ -51,51 +51,51 @@  discard block
 block discarded – undo
51 51
  * @return bool show/hide company name in donation receipt page.
52 52
  */
53 53
 $give_receipt_args['donation_receipt']['company_name'] = array(
54
-	'name'    => __( 'Company Name', 'give' ),
55
-	'value'   => esc_attr( $company_name ),
54
+	'name'    => __('Company Name', 'give'),
55
+	'value'   => esc_attr($company_name),
56 56
 	// Do not show company field if empty
57
-	'display' => empty( $company_name ) ? false : $give_receipt_args['company_name'],
57
+	'display' => empty($company_name) ? false : $give_receipt_args['company_name'],
58 58
 );
59 59
 
60 60
 $give_receipt_args['donation_receipt']['date'] = array(
61
-	'name'    => __( 'Date', 'give' ),
62
-	'value'   => date_i18n( give_date_format(), strtotime( give_get_payment_completed_date( $donation_id ) ) ),
61
+	'name'    => __('Date', 'give'),
62
+	'value'   => date_i18n(give_date_format(), strtotime(give_get_payment_completed_date($donation_id))),
63 63
 	'display' => $give_receipt_args['date'],
64 64
 );
65 65
 
66 66
 $give_receipt_args['donation_receipt']['total_donation'] = array(
67
-	'name'    => __( 'Total Donation', 'give' ),
68
-	'value'   => give_donation_amount( $donation_id, array( 'currency' => true, 'amount' => true, 'type' => 'receipt' ) ),
67
+	'name'    => __('Total Donation', 'give'),
68
+	'value'   => give_donation_amount($donation_id, array('currency' => true, 'amount' => true, 'type' => 'receipt')),
69 69
 	'display' => $give_receipt_args['price'],
70 70
 );
71 71
 
72 72
 $give_receipt_args['donation_receipt']['donation'] = array(
73
-	'name'    => __( 'Donation', 'give' ),
73
+	'name'    => __('Donation', 'give'),
74 74
 	'value'   => $donation,
75 75
 	'display' => true,
76 76
 );
77 77
 
78 78
 $give_receipt_args['donation_receipt']['donation_status'] = array(
79
-	'name'    => __( 'Donation Status', 'give' ),
80
-	'value'   => esc_attr( $status_label ),
79
+	'name'    => __('Donation Status', 'give'),
80
+	'value'   => esc_attr($status_label),
81 81
 	'display' => $give_receipt_args['payment_status'],
82 82
 );
83 83
 
84 84
 $give_receipt_args['donation_receipt']['donation_id'] = array(
85
-	'name'    => __( 'Donation ID', 'give' ),
85
+	'name'    => __('Donation ID', 'give'),
86 86
 	'value'   => $donation_number,
87 87
 	'display' => $give_receipt_args['payment_id'],
88 88
 );
89 89
 
90 90
 $give_receipt_args['donation_receipt']['payment_key'] = array(
91
-	'name'    => __( 'Payment Key', 'give' ),
92
-	'value'   => get_post_meta( $donation_id, '_give_payment_purchase_key', true ),
91
+	'name'    => __('Payment Key', 'give'),
92
+	'value'   => get_post_meta($donation_id, '_give_payment_purchase_key', true),
93 93
 	'display' => $give_receipt_args['payment_key'],
94 94
 );
95 95
 
96 96
 $give_receipt_args['donation_receipt']['payment_method'] = array(
97
-	'name'    => __( 'Payment Method', 'give' ),
98
-	'value'   => give_get_gateway_checkout_label( give_get_payment_gateway( $donation_id ) ),
97
+	'name'    => __('Payment Method', 'give'),
98
+	'value'   => give_get_gateway_checkout_label(give_get_payment_gateway($donation_id)),
99 99
 	'display' => $give_receipt_args['payment_method'],
100 100
 );
101 101
 
@@ -110,10 +110,10 @@  discard block
 block discarded – undo
110 110
  *
111 111
  * @since 1.8.8
112 112
  */
113
-$give_receipt_args['donation_receipt'] = apply_filters( 'give_donation_receipt_args', $give_receipt_args['donation_receipt'], $donation_id, $form_id );
113
+$give_receipt_args['donation_receipt'] = apply_filters('give_donation_receipt_args', $give_receipt_args['donation_receipt'], $donation_id, $form_id);
114 114
 
115 115
 // When the donation were made through offline donation, We won't show receipt and payment status though.
116
-if ( 'offline' === give_get_payment_gateway( $payment->ID ) && 'pending' === $status ) {
116
+if ('offline' === give_get_payment_gateway($payment->ID) && 'pending' === $status) {
117 117
 
118 118
 	/**
119 119
 	 * Before the offline donation receipt content starts.
@@ -123,13 +123,13 @@  discard block
 block discarded – undo
123 123
 	 * @param Give_Payment $payment           Donation payment object.
124 124
 	 * @param array        $give_receipt_args Receipt Arguments.
125 125
 	 */
126
-	do_action( 'give_receipt_before_offline_payment', $payment, $give_receipt_args );
126
+	do_action('give_receipt_before_offline_payment', $payment, $give_receipt_args);
127 127
 	?>
128
-	<h2><?php echo apply_filters( 'give_receipt_offline_payment_heading', __( 'Your Donation is Almost Complete!', 'give' ) ); ?></h2>
129
-	<div id="give_donation_receipt" class="<?php echo esc_attr( apply_filters( 'give_receipt_offline_payment_classes', 'give_receipt_offline_payment' ) ); ?>">
128
+	<h2><?php echo apply_filters('give_receipt_offline_payment_heading', __('Your Donation is Almost Complete!', 'give')); ?></h2>
129
+	<div id="give_donation_receipt" class="<?php echo esc_attr(apply_filters('give_receipt_offline_payment_classes', 'give_receipt_offline_payment')); ?>">
130 130
 		<?php
131 131
 		// Instruction for offline donation.
132
-		$offline_instruction = give_get_offline_payment_instruction( $form_id, true );
132
+		$offline_instruction = give_get_offline_payment_instruction($form_id, true);
133 133
 
134 134
 		/**
135 135
 		 * Instruction for the offline donation.
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 		 * @param Give_Payment $payment             Payment object.
141 141
 		 * @param integer      $form_id             Donation form id.
142 142
 		 */
143
-		echo apply_filters( 'give_receipt_offline_payment_instruction', $offline_instruction, $payment, $form_id );
143
+		echo apply_filters('give_receipt_offline_payment_instruction', $offline_instruction, $payment, $form_id);
144 144
 		?>
145 145
 	</div>
146 146
 	<?php
@@ -152,52 +152,52 @@  discard block
 block discarded – undo
152 152
 	 * @param Give_Payment $payment           Donation payment object.
153 153
 	 * @param array        $give_receipt_args Receipt Arguments.
154 154
 	 */
155
-	do_action( 'give_receipt_after_offline_payment', $payment, $give_receipt_args );
155
+	do_action('give_receipt_after_offline_payment', $payment, $give_receipt_args);
156 156
 
157 157
 	return;
158 158
 }
159 159
 
160 160
 // Show payment status notice based on shortcode attribute.
161
-if ( filter_var( $give_receipt_args['status_notice'], FILTER_VALIDATE_BOOLEAN ) ) {
161
+if (filter_var($give_receipt_args['status_notice'], FILTER_VALIDATE_BOOLEAN)) {
162 162
 	$notice_message = '';
163 163
 	$notice_type    = 'warning';
164 164
 
165
-	switch ( $status ) {
165
+	switch ($status) {
166 166
 		case 'publish':
167
-			$notice_message = __( 'Payment Complete: Thank you for your donation.', 'give' );
167
+			$notice_message = __('Payment Complete: Thank you for your donation.', 'give');
168 168
 			$notice_type    = 'success';
169 169
 			break;
170 170
 		case 'pending':
171
-			$notice_message = __( 'Payment Pending: Your donation is currently processing.', 'give' );
171
+			$notice_message = __('Payment Pending: Your donation is currently processing.', 'give');
172 172
 			$notice_type    = 'warning';
173 173
 			break;
174 174
 		case 'refunded':
175
-			$notice_message = __( 'Payment Refunded: Your donation has been refunded.', 'give' );
175
+			$notice_message = __('Payment Refunded: Your donation has been refunded.', 'give');
176 176
 			$notice_type    = 'warning';
177 177
 			break;
178 178
 		case 'preapproval':
179
-			$notice_message = __( 'Payment Preapproved: Thank you for your donation.', 'give' );
179
+			$notice_message = __('Payment Preapproved: Thank you for your donation.', 'give');
180 180
 			$notice_type    = 'warning';
181 181
 			break;
182 182
 		case 'failed':
183
-			$notice_message = __( 'Payment Failed: Please contact the site owner for assistance.', 'give' );
183
+			$notice_message = __('Payment Failed: Please contact the site owner for assistance.', 'give');
184 184
 			$notice_type    = 'error';
185 185
 			break;
186 186
 		case 'cancelled':
187
-			$notice_message = __( 'Payment Cancelled: Your donation has been cancelled.', 'give' );
187
+			$notice_message = __('Payment Cancelled: Your donation has been cancelled.', 'give');
188 188
 			$notice_type    = 'error';
189 189
 			break;
190 190
 		case 'abandoned':
191
-			$notice_message = __( 'Payment Abandoned: This donation has not been completed.', 'give' );
191
+			$notice_message = __('Payment Abandoned: This donation has not been completed.', 'give');
192 192
 			$notice_type    = 'error';
193 193
 			break;
194 194
 		case 'revoked':
195
-			$notice_message = __( 'Payment Revoked: Please contact the site owner for assistance.', 'give' );
195
+			$notice_message = __('Payment Revoked: Please contact the site owner for assistance.', 'give');
196 196
 			$notice_type    = 'error';
197 197
 			break;
198 198
 	}
199 199
 
200
-	if ( ! empty( $notice_message ) ) {
200
+	if ( ! empty($notice_message)) {
201 201
 		/**
202 202
 		 * Filters payment status notice for receipts.
203 203
 		 *
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 		 * @param string $status Payment status.
213 213
 		 * @param int $donation_id Donation ID.
214 214
 		 */
215
-		echo apply_filters( 'give_receipt_status_notice', Give()->notices->print_frontend_notice( $notice_message, false, $notice_type ), $id, $status, $donation_id );
215
+		echo apply_filters('give_receipt_status_notice', Give()->notices->print_frontend_notice($notice_message, false, $notice_type), $id, $status, $donation_id);
216 216
 	}
217 217
 }// End if().
218 218
 
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
  * @param object $payment           The payment object.
227 227
  * @param array  $give_receipt_args Receipt_argument.
228 228
  */
229
-do_action( 'give_payment_receipt_before_table', $payment, $give_receipt_args );
229
+do_action('give_payment_receipt_before_table', $payment, $give_receipt_args);
230 230
 ?>
231 231
 
232 232
 <table id="give_donation_receipt" class="give-table">
@@ -242,11 +242,11 @@  discard block
 block discarded – undo
242 242
 	 * @param object $payment           The payment object.
243 243
 	 * @param array  $give_receipt_args Receipt_argument.
244 244
 	 */
245
-	do_action( 'give_payment_receipt_header_before', $payment, $give_receipt_args );
245
+	do_action('give_payment_receipt_header_before', $payment, $give_receipt_args);
246 246
 	?>
247 247
 	<tr>
248 248
 		<th scope="colgroup" colspan="2">
249
-			<span class="give-receipt-thead-text"><?php esc_html_e( 'Donation Receipt', 'give' ) ?></span>
249
+			<span class="give-receipt-thead-text"><?php esc_html_e('Donation Receipt', 'give') ?></span>
250 250
 		</th>
251 251
 	</tr>
252 252
 	<?php
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 	 * @param object $payment           The payment object.
261 261
 	 * @param array  $give_receipt_args Receipt_argument.
262 262
 	 */
263
-	do_action( 'give_payment_receipt_header_after', $payment, $give_receipt_args );
263
+	do_action('give_payment_receipt_header_after', $payment, $give_receipt_args);
264 264
 	?>
265 265
 	</thead>
266 266
 
@@ -276,11 +276,11 @@  discard block
 block discarded – undo
276 276
 	 * @param object $payment           The payment object.
277 277
 	 * @param array  $give_receipt_args Receipt_argument.
278 278
 	 */
279
-	do_action( 'give_payment_receipt_before', $payment, $give_receipt_args );
279
+	do_action('give_payment_receipt_before', $payment, $give_receipt_args);
280 280
 	?>
281 281
 
282
-	<?php foreach ( $give_receipt_args['donation_receipt'] as $receipt_item ) { ?>
283
-		<?php if ( filter_var( $receipt_item['display'], FILTER_VALIDATE_BOOLEAN ) ) : ?>
282
+	<?php foreach ($give_receipt_args['donation_receipt'] as $receipt_item) { ?>
283
+		<?php if (filter_var($receipt_item['display'], FILTER_VALIDATE_BOOLEAN)) : ?>
284 284
 			<tr>
285 285
 				<td scope="row"><strong><?php echo $receipt_item['name']; ?></strong></td>
286 286
 				<td><?php echo $receipt_item['value']; ?></td>
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 	 * @param object $payment           The payment object.
300 300
 	 * @param array  $give_receipt_args Receipt_argument.
301 301
 	 */
302
-	do_action( 'give_payment_receipt_after', $payment, $give_receipt_args );
302
+	do_action('give_payment_receipt_after', $payment, $give_receipt_args);
303 303
 	?>
304 304
 	</tbody>
305 305
 </table>
@@ -315,5 +315,5 @@  discard block
 block discarded – undo
315 315
  * @param object $payment           The payment object.
316 316
  * @param array  $give_receipt_args Receipt_argument.
317 317
  */
318
-do_action( 'give_payment_receipt_after_table', $payment, $give_receipt_args );
318
+do_action('give_payment_receipt_after_table', $payment, $give_receipt_args);
319 319
 ?>
Please login to merge, or discard this patch.
give.php 1 patch
Spacing   +185 added lines, -185 removed lines patch added patch discarded remove patch
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
39 39
  */
40 40
 
41 41
 // Exit if accessed directly.
42
-if ( ! defined( 'ABSPATH' ) ) {
42
+if ( ! defined('ABSPATH')) {
43 43
 	exit;
44 44
 }
45 45
 
46
-if ( ! class_exists( 'Give' ) ) :
46
+if ( ! class_exists('Give')) :
47 47
 
48 48
 	/**
49 49
 	 * Main Give Class
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 		 * @return    Give
262 262
 		 */
263 263
 		public static function instance() {
264
-			if ( is_null( self::$_instance ) ) {
264
+			if (is_null(self::$_instance)) {
265 265
 				self::$_instance = new self();
266 266
 			}
267 267
 
@@ -273,13 +273,13 @@  discard block
 block discarded – undo
273 273
 		 */
274 274
 		public function __construct() {
275 275
 			// PHP version
276
-			if ( ! defined( 'GIVE_REQUIRED_PHP_VERSION' ) ) {
277
-				define( 'GIVE_REQUIRED_PHP_VERSION', '5.3' );
276
+			if ( ! defined('GIVE_REQUIRED_PHP_VERSION')) {
277
+				define('GIVE_REQUIRED_PHP_VERSION', '5.3');
278 278
 			}
279 279
 
280 280
 			// Bailout: Need minimum php version to load plugin.
281
-			if ( function_exists( 'phpversion' ) && version_compare( GIVE_REQUIRED_PHP_VERSION, phpversion(), '>' ) ) {
282
-				add_action( 'admin_notices', array( $this, 'minimum_phpversion_notice' ) );
281
+			if (function_exists('phpversion') && version_compare(GIVE_REQUIRED_PHP_VERSION, phpversion(), '>')) {
282
+				add_action('admin_notices', array($this, 'minimum_phpversion_notice'));
283 283
 
284 284
 				return;
285 285
 			}
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 			$this->includes();
289 289
 			$this->init_hooks();
290 290
 
291
-			do_action( 'give_loaded' );
291
+			do_action('give_loaded');
292 292
 		}
293 293
 
294 294
 		/**
@@ -297,11 +297,11 @@  discard block
 block discarded – undo
297 297
 		 * @since  1.8.9
298 298
 		 */
299 299
 		private function init_hooks() {
300
-			register_activation_hook( GIVE_PLUGIN_FILE, 'give_install' );
301
-			add_action( 'plugins_loaded', array( $this, 'init' ), 0 );
300
+			register_activation_hook(GIVE_PLUGIN_FILE, 'give_install');
301
+			add_action('plugins_loaded', array($this, 'init'), 0);
302 302
 
303 303
 			// Set up localization on init Hook.
304
-			add_action( 'init', array( $this, 'load_textdomain' ), 0 );
304
+			add_action('init', array($this, 'load_textdomain'), 0);
305 305
 		}
306 306
 
307 307
 
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 			 *
318 318
 			 * @since 1.8.9
319 319
 			 */
320
-			do_action( 'before_give_init' );
320
+			do_action('before_give_init');
321 321
 
322 322
 			// Set up localization.
323 323
 			$this->load_textdomain();
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 			 *
351 351
 			 * @since 1.8.7
352 352
 			 */
353
-			do_action( 'give_init', $this );
353
+			do_action('give_init', $this);
354 354
 
355 355
 		}
356 356
 
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
 		 */
368 368
 		public function __clone() {
369 369
 			// Cloning instances of the class is forbidden.
370
-			give_doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'give' ), '1.0' );
370
+			give_doing_it_wrong(__FUNCTION__, __('Cheatin&#8217; huh?', 'give'), '1.0');
371 371
 		}
372 372
 
373 373
 		/**
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 		 */
381 381
 		public function __wakeup() {
382 382
 			// Unserializing instances of the class is forbidden.
383
-			give_doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'give' ), '1.0' );
383
+			give_doing_it_wrong(__FUNCTION__, __('Cheatin&#8217; huh?', 'give'), '1.0');
384 384
 		}
385 385
 
386 386
 		/**
@@ -394,33 +394,33 @@  discard block
 block discarded – undo
394 394
 		private function setup_constants() {
395 395
 
396 396
 			// Plugin version
397
-			if ( ! defined( 'GIVE_VERSION' ) ) {
398
-				define( 'GIVE_VERSION', '2.1.5' );
397
+			if ( ! defined('GIVE_VERSION')) {
398
+				define('GIVE_VERSION', '2.1.5');
399 399
 			}
400 400
 
401 401
 			// Plugin Root File
402
-			if ( ! defined( 'GIVE_PLUGIN_FILE' ) ) {
403
-				define( 'GIVE_PLUGIN_FILE', __FILE__ );
402
+			if ( ! defined('GIVE_PLUGIN_FILE')) {
403
+				define('GIVE_PLUGIN_FILE', __FILE__);
404 404
 			}
405 405
 
406 406
 			// Plugin Folder Path
407
-			if ( ! defined( 'GIVE_PLUGIN_DIR' ) ) {
408
-				define( 'GIVE_PLUGIN_DIR', plugin_dir_path( GIVE_PLUGIN_FILE ) );
407
+			if ( ! defined('GIVE_PLUGIN_DIR')) {
408
+				define('GIVE_PLUGIN_DIR', plugin_dir_path(GIVE_PLUGIN_FILE));
409 409
 			}
410 410
 
411 411
 			// Plugin Folder URL
412
-			if ( ! defined( 'GIVE_PLUGIN_URL' ) ) {
413
-				define( 'GIVE_PLUGIN_URL', plugin_dir_url( GIVE_PLUGIN_FILE ) );
412
+			if ( ! defined('GIVE_PLUGIN_URL')) {
413
+				define('GIVE_PLUGIN_URL', plugin_dir_url(GIVE_PLUGIN_FILE));
414 414
 			}
415 415
 
416 416
 			// Plugin Basename aka: "give/give.php"
417
-			if ( ! defined( 'GIVE_PLUGIN_BASENAME' ) ) {
418
-				define( 'GIVE_PLUGIN_BASENAME', plugin_basename( GIVE_PLUGIN_FILE ) );
417
+			if ( ! defined('GIVE_PLUGIN_BASENAME')) {
418
+				define('GIVE_PLUGIN_BASENAME', plugin_basename(GIVE_PLUGIN_FILE));
419 419
 			}
420 420
 
421 421
 			// Make sure CAL_GREGORIAN is defined
422
-			if ( ! defined( 'CAL_GREGORIAN' ) ) {
423
-				define( 'CAL_GREGORIAN', 1 );
422
+			if ( ! defined('CAL_GREGORIAN')) {
423
+				define('CAL_GREGORIAN', 1);
424 424
 			}
425 425
 		}
426 426
 
@@ -438,161 +438,161 @@  discard block
 block discarded – undo
438 438
 			/**
439 439
 			 * Load libraries.
440 440
 			 */
441
-			if ( ! class_exists( 'WP_Async_Request' ) ) {
442
-				include_once( GIVE_PLUGIN_DIR . 'includes/libraries/wp-async-request.php' );
441
+			if ( ! class_exists('WP_Async_Request')) {
442
+				include_once(GIVE_PLUGIN_DIR.'includes/libraries/wp-async-request.php');
443 443
 			}
444 444
 
445
-			if ( ! class_exists( 'WP_Background_Process' ) ) {
446
-				include_once( GIVE_PLUGIN_DIR . 'includes/libraries/wp-background-process.php' );
445
+			if ( ! class_exists('WP_Background_Process')) {
446
+				include_once(GIVE_PLUGIN_DIR.'includes/libraries/wp-background-process.php');
447 447
 			}
448 448
 
449 449
 			/**
450 450
 			 * Load plugin files
451 451
 			 */
452
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/class-admin-settings.php';
453
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/class-give-settings.php';
452
+			require_once GIVE_PLUGIN_DIR.'includes/admin/class-admin-settings.php';
453
+			require_once GIVE_PLUGIN_DIR.'includes/admin/class-give-settings.php';
454 454
 			$give_options = give_get_settings();
455 455
 
456
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-cron.php';
457
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-async-process.php';
458
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/give-metabox-functions.php';
459
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-cache.php';
460
-			require_once GIVE_PLUGIN_DIR . 'includes/post-types.php';
461
-			require_once GIVE_PLUGIN_DIR . 'includes/ajax-functions.php';
462
-			require_once GIVE_PLUGIN_DIR . 'includes/actions.php';
463
-			require_once GIVE_PLUGIN_DIR . 'includes/filters.php';
464
-			require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api.php';
465
-			require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api-v2.php';
466
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-tooltips.php';
467
-			require_once GIVE_PLUGIN_DIR . 'includes/class-notices.php';
468
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-translation.php';
469
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-readme-parser.php';
470
-
471
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-scripts.php';
472
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-roles.php';
473
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-template-loader.php';
474
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-donate-form.php';
475
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-db.php';
476
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-meta.php';
477
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-donors.php';
478
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-donor-meta.php';
479
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-donor.php';
480
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-stats.php';
481
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-session.php';
482
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-html-elements.php';
483
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-logging.php';
484
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-license-handler.php';
485
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-email-access.php';
486
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-payment-meta.php';
487
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-form-meta.php';
488
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-sequential-ordering.php';
489
-
490
-			require_once GIVE_PLUGIN_DIR . 'includes/country-functions.php';
491
-			require_once GIVE_PLUGIN_DIR . 'includes/template-functions.php';
492
-			require_once GIVE_PLUGIN_DIR . 'includes/misc-functions.php';
493
-			require_once GIVE_PLUGIN_DIR . 'includes/import-functions.php';
494
-			require_once GIVE_PLUGIN_DIR . 'includes/forms/functions.php';
495
-			require_once GIVE_PLUGIN_DIR . 'includes/forms/template.php';
496
-			require_once GIVE_PLUGIN_DIR . 'includes/forms/widget.php';
497
-			require_once GIVE_PLUGIN_DIR . 'includes/shortcodes.php';
498
-			require_once GIVE_PLUGIN_DIR . 'includes/formatting.php';
499
-			require_once GIVE_PLUGIN_DIR . 'includes/currency-functions.php';
500
-			require_once GIVE_PLUGIN_DIR . 'includes/price-functions.php';
501
-			require_once GIVE_PLUGIN_DIR . 'includes/error-tracking.php';
502
-			require_once GIVE_PLUGIN_DIR . 'includes/process-donation.php';
503
-			require_once GIVE_PLUGIN_DIR . 'includes/login-register.php';
504
-			require_once GIVE_PLUGIN_DIR . 'includes/user-functions.php';
505
-			require_once GIVE_PLUGIN_DIR . 'includes/plugin-compatibility.php';
506
-			require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-classes.php';
507
-			require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-functions.php';
508
-			require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-actions.php';
509
-			require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-filters.php';
510
-
511
-			require_once GIVE_PLUGIN_DIR . 'includes/payments/backward-compatibility.php';
512
-			require_once GIVE_PLUGIN_DIR . 'includes/payments/functions.php';
513
-			require_once GIVE_PLUGIN_DIR . 'includes/payments/actions.php';
514
-			require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payment-stats.php';
515
-			require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payments-query.php';
516
-			require_once GIVE_PLUGIN_DIR . 'includes/payments/class-give-payment.php';
517
-			require_once GIVE_PLUGIN_DIR . 'includes/payments/class-give-sequential-donation-number.php';
518
-
519
-			require_once GIVE_PLUGIN_DIR . 'includes/gateways/functions.php';
520
-			require_once GIVE_PLUGIN_DIR . 'includes/gateways/actions.php';
521
-			require_once GIVE_PLUGIN_DIR . 'includes/gateways/paypal-standard.php';
522
-			require_once GIVE_PLUGIN_DIR . 'includes/gateways/offline-donations.php';
523
-			require_once GIVE_PLUGIN_DIR . 'includes/gateways/manual.php';
524
-
525
-			require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-emails.php';
526
-			require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-email-tags.php';
527
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/emails/class-email-notifications.php';
528
-			require_once GIVE_PLUGIN_DIR . 'includes/emails/functions.php';
529
-			require_once GIVE_PLUGIN_DIR . 'includes/emails/template.php';
530
-			require_once GIVE_PLUGIN_DIR . 'includes/emails/actions.php';
531
-
532
-			require_once GIVE_PLUGIN_DIR . 'includes/donors/class-give-donors-query.php';
533
-			require_once GIVE_PLUGIN_DIR . 'includes/donors/backward-compatibility.php';
534
-
535
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/class-give-updates.php';
536
-
537
-			require_once GIVE_PLUGIN_DIR . 'blocks/load.php';
538
-
539
-			if ( defined( 'WP_CLI' ) && WP_CLI ) {
540
-				require_once GIVE_PLUGIN_DIR . 'includes/class-give-cli-commands.php';
456
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-cron.php';
457
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-async-process.php';
458
+			require_once GIVE_PLUGIN_DIR.'includes/admin/give-metabox-functions.php';
459
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-cache.php';
460
+			require_once GIVE_PLUGIN_DIR.'includes/post-types.php';
461
+			require_once GIVE_PLUGIN_DIR.'includes/ajax-functions.php';
462
+			require_once GIVE_PLUGIN_DIR.'includes/actions.php';
463
+			require_once GIVE_PLUGIN_DIR.'includes/filters.php';
464
+			require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api.php';
465
+			require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api-v2.php';
466
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-tooltips.php';
467
+			require_once GIVE_PLUGIN_DIR.'includes/class-notices.php';
468
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-translation.php';
469
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-readme-parser.php';
470
+
471
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-scripts.php';
472
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-roles.php';
473
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-template-loader.php';
474
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-donate-form.php';
475
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-db.php';
476
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-db-meta.php';
477
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-db-donors.php';
478
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-db-donor-meta.php';
479
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-donor.php';
480
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-stats.php';
481
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-session.php';
482
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-html-elements.php';
483
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-logging.php';
484
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-license-handler.php';
485
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-email-access.php';
486
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-db-payment-meta.php';
487
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-db-form-meta.php';
488
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-db-sequential-ordering.php';
489
+
490
+			require_once GIVE_PLUGIN_DIR.'includes/country-functions.php';
491
+			require_once GIVE_PLUGIN_DIR.'includes/template-functions.php';
492
+			require_once GIVE_PLUGIN_DIR.'includes/misc-functions.php';
493
+			require_once GIVE_PLUGIN_DIR.'includes/import-functions.php';
494
+			require_once GIVE_PLUGIN_DIR.'includes/forms/functions.php';
495
+			require_once GIVE_PLUGIN_DIR.'includes/forms/template.php';
496
+			require_once GIVE_PLUGIN_DIR.'includes/forms/widget.php';
497
+			require_once GIVE_PLUGIN_DIR.'includes/shortcodes.php';
498
+			require_once GIVE_PLUGIN_DIR.'includes/formatting.php';
499
+			require_once GIVE_PLUGIN_DIR.'includes/currency-functions.php';
500
+			require_once GIVE_PLUGIN_DIR.'includes/price-functions.php';
501
+			require_once GIVE_PLUGIN_DIR.'includes/error-tracking.php';
502
+			require_once GIVE_PLUGIN_DIR.'includes/process-donation.php';
503
+			require_once GIVE_PLUGIN_DIR.'includes/login-register.php';
504
+			require_once GIVE_PLUGIN_DIR.'includes/user-functions.php';
505
+			require_once GIVE_PLUGIN_DIR.'includes/plugin-compatibility.php';
506
+			require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-classes.php';
507
+			require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-functions.php';
508
+			require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-actions.php';
509
+			require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-filters.php';
510
+
511
+			require_once GIVE_PLUGIN_DIR.'includes/payments/backward-compatibility.php';
512
+			require_once GIVE_PLUGIN_DIR.'includes/payments/functions.php';
513
+			require_once GIVE_PLUGIN_DIR.'includes/payments/actions.php';
514
+			require_once GIVE_PLUGIN_DIR.'includes/payments/class-payment-stats.php';
515
+			require_once GIVE_PLUGIN_DIR.'includes/payments/class-payments-query.php';
516
+			require_once GIVE_PLUGIN_DIR.'includes/payments/class-give-payment.php';
517
+			require_once GIVE_PLUGIN_DIR.'includes/payments/class-give-sequential-donation-number.php';
518
+
519
+			require_once GIVE_PLUGIN_DIR.'includes/gateways/functions.php';
520
+			require_once GIVE_PLUGIN_DIR.'includes/gateways/actions.php';
521
+			require_once GIVE_PLUGIN_DIR.'includes/gateways/paypal-standard.php';
522
+			require_once GIVE_PLUGIN_DIR.'includes/gateways/offline-donations.php';
523
+			require_once GIVE_PLUGIN_DIR.'includes/gateways/manual.php';
524
+
525
+			require_once GIVE_PLUGIN_DIR.'includes/emails/class-give-emails.php';
526
+			require_once GIVE_PLUGIN_DIR.'includes/emails/class-give-email-tags.php';
527
+			require_once GIVE_PLUGIN_DIR.'includes/admin/emails/class-email-notifications.php';
528
+			require_once GIVE_PLUGIN_DIR.'includes/emails/functions.php';
529
+			require_once GIVE_PLUGIN_DIR.'includes/emails/template.php';
530
+			require_once GIVE_PLUGIN_DIR.'includes/emails/actions.php';
531
+
532
+			require_once GIVE_PLUGIN_DIR.'includes/donors/class-give-donors-query.php';
533
+			require_once GIVE_PLUGIN_DIR.'includes/donors/backward-compatibility.php';
534
+
535
+			require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/class-give-updates.php';
536
+
537
+			require_once GIVE_PLUGIN_DIR.'blocks/load.php';
538
+
539
+			if (defined('WP_CLI') && WP_CLI) {
540
+				require_once GIVE_PLUGIN_DIR.'includes/class-give-cli-commands.php';
541 541
 			}
542 542
 
543
-			if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
544
-
545
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-footer.php';
546
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/welcome.php';
547
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-pages.php';
548
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/class-api-keys-table.php';
549
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/class-i18n-module.php';
550
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-actions.php';
551
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-filters.php';
552
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/add-ons.php';
553
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/plugins.php';
554
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/dashboard-widgets.php';
555
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/class-blank-slate.php';
556
-
557
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/actions.php';
558
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/payments-history.php';
559
-
560
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/donors/donors.php';
561
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/donors/donor-functions.php';
562
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/donors/donor-actions.php';
563
-
564
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/metabox.php';
565
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/class-metabox-form-data.php';
566
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/dashboard-columns.php';
567
-
568
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/export-functions.php';
569
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/class-export.php';
570
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/export-actions.php';
571
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/pdf-reports.php';
572
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/give-export-donations-functions.php';
573
-
574
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/reports/reports.php';
575
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/reports/class-give-graph.php';
576
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/reports/graphing.php';
577
-
578
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/logs/logs.php';
579
-
580
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/tools-actions.php';
581
-
582
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/abstract-shortcode-generator.php';
583
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/class-shortcode-button.php';
584
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-form.php';
585
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-goal.php';
586
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-login.php';
587
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-register.php';
588
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-profile-editor.php';
589
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-donation-grid.php';
590
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-donation-history.php';
591
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-receipt.php';
592
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-totals.php';
543
+			if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
544
+
545
+				require_once GIVE_PLUGIN_DIR.'includes/admin/admin-footer.php';
546
+				require_once GIVE_PLUGIN_DIR.'includes/admin/welcome.php';
547
+				require_once GIVE_PLUGIN_DIR.'includes/admin/admin-pages.php';
548
+				require_once GIVE_PLUGIN_DIR.'includes/admin/class-api-keys-table.php';
549
+				require_once GIVE_PLUGIN_DIR.'includes/admin/class-i18n-module.php';
550
+				require_once GIVE_PLUGIN_DIR.'includes/admin/admin-actions.php';
551
+				require_once GIVE_PLUGIN_DIR.'includes/admin/admin-filters.php';
552
+				require_once GIVE_PLUGIN_DIR.'includes/admin/add-ons.php';
553
+				require_once GIVE_PLUGIN_DIR.'includes/admin/plugins.php';
554
+				require_once GIVE_PLUGIN_DIR.'includes/admin/dashboard-widgets.php';
555
+				require_once GIVE_PLUGIN_DIR.'includes/admin/class-blank-slate.php';
556
+
557
+				require_once GIVE_PLUGIN_DIR.'includes/admin/payments/actions.php';
558
+				require_once GIVE_PLUGIN_DIR.'includes/admin/payments/payments-history.php';
559
+
560
+				require_once GIVE_PLUGIN_DIR.'includes/admin/donors/donors.php';
561
+				require_once GIVE_PLUGIN_DIR.'includes/admin/donors/donor-functions.php';
562
+				require_once GIVE_PLUGIN_DIR.'includes/admin/donors/donor-actions.php';
563
+
564
+				require_once GIVE_PLUGIN_DIR.'includes/admin/forms/metabox.php';
565
+				require_once GIVE_PLUGIN_DIR.'includes/admin/forms/class-metabox-form-data.php';
566
+				require_once GIVE_PLUGIN_DIR.'includes/admin/forms/dashboard-columns.php';
567
+
568
+				require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/export-functions.php';
569
+				require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/class-export.php';
570
+				require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/export-actions.php';
571
+				require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/pdf-reports.php';
572
+				require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/give-export-donations-functions.php';
573
+
574
+				require_once GIVE_PLUGIN_DIR.'includes/admin/reports/reports.php';
575
+				require_once GIVE_PLUGIN_DIR.'includes/admin/reports/class-give-graph.php';
576
+				require_once GIVE_PLUGIN_DIR.'includes/admin/reports/graphing.php';
577
+
578
+				require_once GIVE_PLUGIN_DIR.'includes/admin/tools/logs/logs.php';
579
+
580
+				require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/tools-actions.php';
581
+
582
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/abstract-shortcode-generator.php';
583
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/class-shortcode-button.php';
584
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-form.php';
585
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-goal.php';
586
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-login.php';
587
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-register.php';
588
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-profile-editor.php';
589
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-donation-grid.php';
590
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-donation-history.php';
591
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-receipt.php';
592
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-totals.php';
593 593
 			}// End if().
594 594
 
595
-			require_once GIVE_PLUGIN_DIR . 'includes/install.php';
595
+			require_once GIVE_PLUGIN_DIR.'includes/install.php';
596 596
 
597 597
 		}
598 598
 
@@ -607,16 +607,16 @@  discard block
 block discarded – undo
607 607
 		public function load_textdomain() {
608 608
 
609 609
 			// Set filter for Give's languages directory
610
-			$give_lang_dir = dirname( plugin_basename( GIVE_PLUGIN_FILE ) ) . '/languages/';
611
-			$give_lang_dir = apply_filters( 'give_languages_directory', $give_lang_dir );
610
+			$give_lang_dir = dirname(plugin_basename(GIVE_PLUGIN_FILE)).'/languages/';
611
+			$give_lang_dir = apply_filters('give_languages_directory', $give_lang_dir);
612 612
 
613 613
 			// Traditional WordPress plugin locale filter.
614
-			$locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
615
-			$locale = apply_filters( 'plugin_locale', $locale, 'give' );
614
+			$locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale();
615
+			$locale = apply_filters('plugin_locale', $locale, 'give');
616 616
 
617
-			unload_textdomain( 'give' );
618
-			load_textdomain( 'give', WP_LANG_DIR . '/give/give-' . $locale . '.mo' );
619
-			load_plugin_textdomain( 'give', false, $give_lang_dir );
617
+			unload_textdomain('give');
618
+			load_textdomain('give', WP_LANG_DIR.'/give/give-'.$locale.'.mo');
619
+			load_plugin_textdomain('give', false, $give_lang_dir);
620 620
 
621 621
 		}
622 622
 
@@ -629,21 +629,21 @@  discard block
 block discarded – undo
629 629
 		 */
630 630
 		public function minimum_phpversion_notice() {
631 631
 			// Bailout.
632
-			if ( ! is_admin() ) {
632
+			if ( ! is_admin()) {
633 633
 				return;
634 634
 			}
635 635
 
636
-			$notice_desc  = '<p><strong>' . __( 'Your site could be faster and more secure with a newer PHP version.', 'give' ) . '</strong></p>';
637
-			$notice_desc .= '<p>' . __( 'Hey, we\'ve noticed that you\'re running an outdated version of PHP. PHP is the programming language that WordPress and Give are built on. The version that is currently used for your site is no longer supported. Newer versions of PHP are both faster and more secure. In fact, your version of PHP no longer receives security updates, which is why we\'re sending you this notice.', 'give' ) . '</p>';
638
-			$notice_desc .= '<p>' . __( 'Hosts have the ability to update your PHP version, but sometimes they don\'t dare to do that because they\'re afraid they\'ll break your site.', 'give' ) . '</p>';
639
-			$notice_desc .= '<p><strong>' . __( 'To which version should I update?', 'give' ) . '</strong></p>';
640
-			$notice_desc .= '<p>' . __( 'You should update your PHP version to either 5.6 or to 7.0 or 7.1. On a normal WordPress site, switching to PHP 5.6 should never cause issues. We would however actually recommend you switch to PHP7. There are some plugins that are not ready for PHP7 though, so do some testing first. PHP7 is much faster than PHP 5.6. It\'s also the only PHP version still in active development and therefore the better option for your site in the long run.', 'give' ) . '</p>';
641
-			$notice_desc .= '<p><strong>' . __( 'Can\'t update? Ask your host!', 'give' ) . '</strong></p>';
642
-			$notice_desc .= '<p>' . sprintf( __( 'If you cannot upgrade your PHP version yourself, you can send an email to your host. If they don\'t want to upgrade your PHP version, we would suggest you switch hosts. Have a look at one of the recommended %1$sWordPress hosting partners%2$s.', 'give' ), sprintf( '<a href="%1$s" target="_blank">', esc_url( 'https://wordpress.org/hosting/' ) ), '</a>' ) . '</p>';
636
+			$notice_desc  = '<p><strong>'.__('Your site could be faster and more secure with a newer PHP version.', 'give').'</strong></p>';
637
+			$notice_desc .= '<p>'.__('Hey, we\'ve noticed that you\'re running an outdated version of PHP. PHP is the programming language that WordPress and Give are built on. The version that is currently used for your site is no longer supported. Newer versions of PHP are both faster and more secure. In fact, your version of PHP no longer receives security updates, which is why we\'re sending you this notice.', 'give').'</p>';
638
+			$notice_desc .= '<p>'.__('Hosts have the ability to update your PHP version, but sometimes they don\'t dare to do that because they\'re afraid they\'ll break your site.', 'give').'</p>';
639
+			$notice_desc .= '<p><strong>'.__('To which version should I update?', 'give').'</strong></p>';
640
+			$notice_desc .= '<p>'.__('You should update your PHP version to either 5.6 or to 7.0 or 7.1. On a normal WordPress site, switching to PHP 5.6 should never cause issues. We would however actually recommend you switch to PHP7. There are some plugins that are not ready for PHP7 though, so do some testing first. PHP7 is much faster than PHP 5.6. It\'s also the only PHP version still in active development and therefore the better option for your site in the long run.', 'give').'</p>';
641
+			$notice_desc .= '<p><strong>'.__('Can\'t update? Ask your host!', 'give').'</strong></p>';
642
+			$notice_desc .= '<p>'.sprintf(__('If you cannot upgrade your PHP version yourself, you can send an email to your host. If they don\'t want to upgrade your PHP version, we would suggest you switch hosts. Have a look at one of the recommended %1$sWordPress hosting partners%2$s.', 'give'), sprintf('<a href="%1$s" target="_blank">', esc_url('https://wordpress.org/hosting/')), '</a>').'</p>';
643 643
 
644 644
 			echo sprintf(
645 645
 				'<div class="notice notice-error">%1$s</div>',
646
-				wp_kses_post( $notice_desc )
646
+				wp_kses_post($notice_desc)
647 647
 			);
648 648
 		}
649 649
 
Please login to merge, or discard this patch.