Completed
Push — master ( b9ae17...4096fc )
by Devin
07:53
created
includes/process-donation.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  *
25 25
  * @throws ReflectionException Exception Handling.
26 26
  *
27
- * @return mixed
27
+ * @return false|null
28 28
  */
29 29
 function give_process_donation_form() {
30 30
 
@@ -1319,7 +1319,7 @@  discard block
 block discarded – undo
1319 1319
  *
1320 1320
  * @param array $valid_data List of Valid Data.
1321 1321
  *
1322
- * @return bool
1322
+ * @return boolean|null
1323 1323
  */
1324 1324
 function give_validate_donation_amount( $valid_data ) {
1325 1325
 
Please login to merge, or discard this patch.
Spacing   +296 added lines, -297 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
 
@@ -29,20 +29,20 @@  discard block
 block discarded – undo
29 29
 function give_process_donation_form() {
30 30
 
31 31
 	// Sanitize Posted Data.
32
-	$post_data  = give_clean( $_POST ); // WPCS: input var ok, CSRF ok.
32
+	$post_data = give_clean($_POST); // WPCS: input var ok, CSRF ok.
33 33
 
34 34
 	// Check whether the form submitted via AJAX or not.
35
-	$is_ajax = isset( $post_data['give_ajax'] );
35
+	$is_ajax = isset($post_data['give_ajax']);
36 36
 
37 37
 	// Verify donation form nonce.
38
-	if ( ! give_verify_donation_form_nonce( $post_data['give-form-hash'], $post_data['give-form-id'] ) ) {
39
-		if ( $is_ajax ) {
38
+	if ( ! give_verify_donation_form_nonce($post_data['give-form-hash'], $post_data['give-form-id'])) {
39
+		if ($is_ajax) {
40 40
 			/**
41 41
 			 * Fires when AJAX sends back errors from the donation form.
42 42
 			 *
43 43
 			 * @since 1.0
44 44
 			 */
45
-			do_action( 'give_ajax_donation_errors' );
45
+			do_action('give_ajax_donation_errors');
46 46
 			give_die();
47 47
 		} else {
48 48
 			give_send_back_to_checkout();
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 * @since 1.0
56 56
 	 */
57
-	do_action( 'give_pre_process_donation' );
57
+	do_action('give_pre_process_donation');
58 58
 
59 59
 	// Validate the form $_POST data.
60 60
 	$valid_data = give_donation_form_validate_fields();
@@ -70,24 +70,24 @@  discard block
 block discarded – undo
70 70
 	 * @param array $deprecated Deprecated Since 2.0.2. Use $_POST instead.
71 71
 	 */
72 72
 	$deprecated = $post_data;
73
-	do_action( 'give_checkout_error_checks', $valid_data, $deprecated );
73
+	do_action('give_checkout_error_checks', $valid_data, $deprecated);
74 74
 
75 75
 	// Process the login form.
76
-	if ( isset( $post_data['give_login_submit'] ) ) {
76
+	if (isset($post_data['give_login_submit'])) {
77 77
 		give_process_form_login();
78 78
 	}
79 79
 
80 80
 	// Validate the user.
81
-	$user = give_get_donation_form_user( $valid_data );
81
+	$user = give_get_donation_form_user($valid_data);
82 82
 
83
-	if ( false === $valid_data || give_get_errors() || ! $user ) {
84
-		if ( $is_ajax ) {
83
+	if (false === $valid_data || give_get_errors() || ! $user) {
84
+		if ($is_ajax) {
85 85
 			/**
86 86
 			 * Fires when AJAX sends back errors from the donation form.
87 87
 			 *
88 88
 			 * @since 1.0
89 89
 			 */
90
-			do_action( 'give_ajax_donation_errors' );
90
+			do_action('give_ajax_donation_errors');
91 91
 			give_die();
92 92
 		} else {
93 93
 			return false;
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	}
96 96
 
97 97
 	// If AJAX send back success to proceed with form submission.
98
-	if ( $is_ajax ) {
98
+	if ($is_ajax) {
99 99
 		echo 'success';
100 100
 		give_die();
101 101
 	}
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	 *
106 106
 	 * @since 2.2.0
107 107
 	 */
108
-	do_action( 'give_process_donation_after_validation' );
108
+	do_action('give_process_donation_after_validation');
109 109
 
110 110
 	// Setup user information.
111 111
 	$user_info = array(
@@ -117,23 +117,22 @@  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 122
 	// Donation form ID.
123
-	$form_id = isset( $post_data['give-form-id'] ) ? absint( $post_data['give-form-id'] ) : 0;
123
+	$form_id = isset($post_data['give-form-id']) ? absint($post_data['give-form-id']) : 0;
124 124
 
125
-	$price = isset( $post_data['give-amount'] ) ?
126
-		(float) apply_filters( 'give_donation_total', give_maybe_sanitize_amount( $post_data['give-amount'], array( 'currency' => give_get_currency( $form_id ) ) ) ) :
127
-		'0.00';
128
-	$purchase_key = strtolower( md5( $user['user_email'] . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) );
125
+	$price = isset($post_data['give-amount']) ?
126
+		(float) apply_filters('give_donation_total', give_maybe_sanitize_amount($post_data['give-amount'], array('currency' => give_get_currency($form_id)))) : '0.00';
127
+	$purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true)));
129 128
 
130 129
 	// Setup donation information.
131 130
 	$donation_data = array(
132 131
 		'price'         => $price,
133 132
 		'purchase_key'  => $purchase_key,
134 133
 		'user_email'    => $user['user_email'],
135
-		'date'          => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ),
136
-		'user_info'     => stripslashes_deep( $user_info ),
134
+		'date'          => date('Y-m-d H:i:s', current_time('timestamp')),
135
+		'user_info'     => stripslashes_deep($user_info),
137 136
 		'post_data'     => $post_data,
138 137
 		'gateway'       => $valid_data['gateway'],
139 138
 		'card_info'     => $valid_data['cc_info'],
@@ -153,10 +152,10 @@  discard block
 block discarded – undo
153 152
 	 * @param array      $user_info  Array containing basic user information.
154 153
 	 * @param bool|array $valid_data Validate fields.
155 154
 	 */
156
-	do_action( 'give_checkout_before_gateway', $post_data, $user_info, $valid_data );
155
+	do_action('give_checkout_before_gateway', $post_data, $user_info, $valid_data);
157 156
 
158 157
 	// Sanity check for price.
159
-	if ( ! $donation_data['price'] ) {
158
+	if ( ! $donation_data['price']) {
160 159
 		// Revert to manual.
161 160
 		$donation_data['gateway'] = 'manual';
162 161
 		$_POST['give-gateway']    = 'manual';
@@ -167,26 +166,26 @@  discard block
 block discarded – undo
167 166
 	 *
168 167
 	 * @since 1.7
169 168
 	 */
170
-	$donation_data = apply_filters( 'give_donation_data_before_gateway', $donation_data, $valid_data );
169
+	$donation_data = apply_filters('give_donation_data_before_gateway', $donation_data, $valid_data);
171 170
 
172 171
 	// Setup the data we're storing in the donation session.
173 172
 	$session_data = $donation_data;
174 173
 
175 174
 	// Make sure credit card numbers are never stored in sessions.
176
-	unset( $session_data['card_info']['card_number'] );
177
-	unset( $session_data['post_data']['card_number'] );
175
+	unset($session_data['card_info']['card_number']);
176
+	unset($session_data['post_data']['card_number']);
178 177
 
179 178
 	// Used for showing data to non logged-in users after donation, and for other plugins needing donation data.
180
-	give_set_purchase_session( $session_data );
179
+	give_set_purchase_session($session_data);
181 180
 
182 181
 	// Send info to the gateway for payment processing.
183
-	give_send_to_gateway( $donation_data['gateway'], $donation_data );
182
+	give_send_to_gateway($donation_data['gateway'], $donation_data);
184 183
 	give_die();
185 184
 }
186 185
 
187
-add_action( 'give_purchase', 'give_process_donation_form' );
188
-add_action( 'wp_ajax_give_process_donation', 'give_process_donation_form' );
189
-add_action( 'wp_ajax_nopriv_give_process_donation', 'give_process_donation_form' );
186
+add_action('give_purchase', 'give_process_donation_form');
187
+add_action('wp_ajax_give_process_donation', 'give_process_donation_form');
188
+add_action('wp_ajax_nopriv_give_process_donation', 'give_process_donation_form');
190 189
 
191 190
 /**
192 191
  * Verify that when a logged in user makes a donation that the email address used doesn't belong to a different customer.
@@ -197,27 +196,27 @@  discard block
 block discarded – undo
197 196
  *
198 197
  * @return void
199 198
  */
200
-function give_check_logged_in_user_for_existing_email( $valid_data ) {
199
+function give_check_logged_in_user_for_existing_email($valid_data) {
201 200
 
202 201
 	// Verify that the email address belongs to this customer.
203
-	if ( is_user_logged_in() ) {
202
+	if (is_user_logged_in()) {
204 203
 
205 204
 		$submitted_email = $valid_data['logged_in_user']['user_email'];
206
-		$donor           = new Give_Donor( get_current_user_id(), true );
205
+		$donor           = new Give_Donor(get_current_user_id(), true);
207 206
 
208 207
 		// If this email address is not registered with this customer, see if it belongs to any other customer.
209 208
 		if (
210 209
 			$submitted_email !== $donor->email
211
-			&& ( is_array( $donor->emails ) && ! in_array( $submitted_email, $donor->emails, true ) )
210
+			&& (is_array($donor->emails) && ! in_array($submitted_email, $donor->emails, true))
212 211
 		) {
213
-			$found_donor = new Give_Donor( $submitted_email );
212
+			$found_donor = new Give_Donor($submitted_email);
214 213
 
215
-			if ( $found_donor->id > 0 ) {
214
+			if ($found_donor->id > 0) {
216 215
 				give_set_error(
217 216
 					'give-customer-email-exists',
218 217
 					sprintf(
219 218
 						/* translators: 1. Donor Email, 2. Submitted Email */
220
-						__( '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' ),
219
+						__('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'),
221 220
 						$donor->email,
222 221
 						$submitted_email
223 222
 					)
@@ -227,7 +226,7 @@  discard block
 block discarded – undo
227 226
 	}
228 227
 }
229 228
 
230
-add_action( 'give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 1 );
229
+add_action('give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 1);
231 230
 
232 231
 /**
233 232
  * Process the checkout login form
@@ -239,49 +238,49 @@  discard block
 block discarded – undo
239 238
  */
240 239
 function give_process_form_login() {
241 240
 
242
-	$is_ajax   = ! empty( $_POST['give_ajax'] ) ? give_clean( $_POST['give_ajax'] ) : 0; // WPCS: input var ok, sanitization ok, CSRF ok.
241
+	$is_ajax   = ! empty($_POST['give_ajax']) ? give_clean($_POST['give_ajax']) : 0; // WPCS: input var ok, sanitization ok, CSRF ok.
243 242
 	$referrer  = wp_get_referer();
244 243
 	$user_data = give_donation_form_validate_user_login();
245 244
 
246
-	if ( give_get_errors() || $user_data['user_id'] < 1 ) {
247
-		if ( $is_ajax ) {
245
+	if (give_get_errors() || $user_data['user_id'] < 1) {
246
+		if ($is_ajax) {
248 247
 			/**
249 248
 			 * Fires when AJAX sends back errors from the donation form.
250 249
 			 *
251 250
 			 * @since 1.0
252 251
 			 */
253 252
 			ob_start();
254
-			do_action( 'give_ajax_donation_errors' );
253
+			do_action('give_ajax_donation_errors');
255 254
 			$message = ob_get_contents();
256 255
 			ob_end_clean();
257
-			wp_send_json_error( $message );
256
+			wp_send_json_error($message);
258 257
 		} else {
259
-			wp_safe_redirect( $referrer );
258
+			wp_safe_redirect($referrer);
260 259
 			exit;
261 260
 		}
262 261
 	}
263 262
 
264
-	give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] );
263
+	give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']);
265 264
 
266
-	if ( $is_ajax ) {
265
+	if ($is_ajax) {
267 266
 		$message = Give()->notices->print_frontend_notice(
268 267
 			sprintf(
269 268
 				/* translators: %s: user first name */
270
-				esc_html__( 'Welcome %s! You have successfully logged into your account.', 'give' ),
271
-				( ! empty( $user_data['user_first'] ) ) ? $user_data['user_first'] : $user_data['user_login']
269
+				esc_html__('Welcome %s! You have successfully logged into your account.', 'give'),
270
+				( ! empty($user_data['user_first'])) ? $user_data['user_first'] : $user_data['user_login']
272 271
 			),
273 272
 			false,
274 273
 			'success'
275 274
 		);
276 275
 
277
-		wp_send_json_success( $message );
276
+		wp_send_json_success($message);
278 277
 	} else {
279
-		wp_safe_redirect( $referrer );
278
+		wp_safe_redirect($referrer);
280 279
 	}
281 280
 }
282 281
 
283
-add_action( 'wp_ajax_give_process_donation_login', 'give_process_form_login' );
284
-add_action( 'wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login' );
282
+add_action('wp_ajax_give_process_donation_login', 'give_process_form_login');
283
+add_action('wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login');
285 284
 
286 285
 /**
287 286
  * Donation Form Validate Fields.
@@ -293,49 +292,49 @@  discard block
 block discarded – undo
293 292
  */
294 293
 function give_donation_form_validate_fields() {
295 294
 
296
-	$post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok.
295
+	$post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok.
297 296
 
298 297
 	// Validate Honeypot First.
299
-	if ( ! empty( $post_data['give-honeypot'] ) ) {
300
-		give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) );
298
+	if ( ! empty($post_data['give-honeypot'])) {
299
+		give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give'));
301 300
 	}
302 301
 
303 302
 	// Check spam detect.
304 303
 	if (
305
-		isset( $post_data['action'] ) &&
306
-		give_is_setting_enabled( give_get_option( 'akismet_spam_protection' ) ) &&
304
+		isset($post_data['action']) &&
305
+		give_is_setting_enabled(give_get_option('akismet_spam_protection')) &&
307 306
 		give_is_spam_donation()
308 307
 	) {
309
-		give_set_error( 'spam_donation', __( 'This donation has been flagged as spam. Please try again.', 'give' ) );
308
+		give_set_error('spam_donation', __('This donation has been flagged as spam. Please try again.', 'give'));
310 309
 	}
311 310
 
312 311
 	// Start an array to collect valid data.
313 312
 	$valid_data = array(
314 313
 		'gateway'          => give_donation_form_validate_gateway(), // Gateway fallback (amount is validated here).
315
-		'need_new_user'    => false,     // New user flag.
316
-		'need_user_login'  => false,     // Login user flag.
317
-		'logged_user_data' => array(),   // Logged user collected data.
318
-		'new_user_data'    => array(),   // New user collected data.
319
-		'login_user_data'  => array(),   // Login user collected data.
320
-		'guest_user_data'  => array(),   // Guest user collected data.
314
+		'need_new_user'    => false, // New user flag.
315
+		'need_user_login'  => false, // Login user flag.
316
+		'logged_user_data' => array(), // Logged user collected data.
317
+		'new_user_data'    => array(), // New user collected data.
318
+		'login_user_data'  => array(), // Login user collected data.
319
+		'guest_user_data'  => array(), // Guest user collected data.
321 320
 		'cc_info'          => give_donation_form_validate_cc(), // Credit card info.
322 321
 	);
323 322
 
324
-	$form_id = intval( $post_data['give-form-id'] );
323
+	$form_id = intval($post_data['give-form-id']);
325 324
 
326 325
 	// Validate agree to terms.
327
-	if ( give_is_terms_enabled( $form_id ) ) {
326
+	if (give_is_terms_enabled($form_id)) {
328 327
 		give_donation_form_validate_agree_to_terms();
329 328
 	}
330 329
 
331
-	if ( is_user_logged_in() ) {
330
+	if (is_user_logged_in()) {
332 331
 
333 332
 		// Collect logged in user data.
334 333
 		$valid_data['logged_in_user'] = give_donation_form_validate_logged_in_user();
335 334
 	} elseif (
336
-		isset( $post_data['give-purchase-var'] ) &&
335
+		isset($post_data['give-purchase-var']) &&
337 336
 		'needs-to-register' === $post_data['give-purchase-var'] &&
338
-		! empty( $post_data['give_create_account'] )
337
+		! empty($post_data['give_create_account'])
339 338
 	) {
340 339
 
341 340
 		// Set new user registration as required.
@@ -344,7 +343,7 @@  discard block
 block discarded – undo
344 343
 		// Validate new user data.
345 344
 		$valid_data['new_user_data'] = give_donation_form_validate_new_user();
346 345
 	} elseif (
347
-		isset( $post_data['give-purchase-var'] ) &&
346
+		isset($post_data['give-purchase-var']) &&
348 347
 		'needs-to-login' === $post_data['give-purchase-var']
349 348
 	) {
350 349
 
@@ -373,14 +372,14 @@  discard block
 block discarded – undo
373 372
 function give_is_spam_donation() {
374 373
 	$spam = false;
375 374
 
376
-	$user_agent = (string) isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : '';
375
+	$user_agent = (string) isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
377 376
 
378
-	if ( strlen( $user_agent ) < 2 ) {
377
+	if (strlen($user_agent) < 2) {
379 378
 		$spam = true;
380 379
 	}
381 380
 
382 381
 	// Allow developer to customized Akismet spam detect API call and it's response.
383
-	return apply_filters( 'give_spam', $spam );
382
+	return apply_filters('give_spam', $spam);
384 383
 }
385 384
 
386 385
 /**
@@ -395,33 +394,33 @@  discard block
 block discarded – undo
395 394
  */
396 395
 function give_donation_form_validate_gateway() {
397 396
 
398
-	$post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok.
399
-	$form_id   = ! empty( $post_data['give-form-id'] ) ? $post_data['give-form-id'] : 0;
400
-	$amount    = ! empty( $post_data['give-amount'] ) ? give_maybe_sanitize_amount( $post_data['give-amount'] ) : 0;
401
-	$gateway   = ! empty( $post_data['give-gateway'] ) ? $post_data['give-gateway'] : 0;
397
+	$post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok.
398
+	$form_id   = ! empty($post_data['give-form-id']) ? $post_data['give-form-id'] : 0;
399
+	$amount    = ! empty($post_data['give-amount']) ? give_maybe_sanitize_amount($post_data['give-amount']) : 0;
400
+	$gateway   = ! empty($post_data['give-gateway']) ? $post_data['give-gateway'] : 0;
402 401
 
403 402
 	// Bailout, if payment gateway is not submitted with donation form data.
404
-	if ( empty( $gateway ) ) {
403
+	if (empty($gateway)) {
405 404
 
406
-		give_set_error( 'empty_gateway', __( 'The donation form will process with a valid payment gateway.', 'give' ) );
405
+		give_set_error('empty_gateway', __('The donation form will process with a valid payment gateway.', 'give'));
407 406
 
408
-	} elseif ( ! give_is_gateway_active( $gateway ) ) {
407
+	} elseif ( ! give_is_gateway_active($gateway)) {
409 408
 
410
-		give_set_error( 'invalid_gateway', __( 'The selected payment gateway is not enabled.', 'give' ) );
409
+		give_set_error('invalid_gateway', __('The selected payment gateway is not enabled.', 'give'));
411 410
 
412
-	} elseif ( empty( $amount ) ) {
411
+	} elseif (empty($amount)) {
413 412
 
414
-		give_set_error( 'invalid_donation_amount', __( 'Please insert a valid donation amount.', 'give' ) );
413
+		give_set_error('invalid_donation_amount', __('Please insert a valid donation amount.', 'give'));
415 414
 
416
-	} elseif ( ! give_verify_minimum_price( 'minimum' ) ) {
415
+	} elseif ( ! give_verify_minimum_price('minimum')) {
417 416
 
418 417
 		give_set_error(
419 418
 			'invalid_donation_minimum',
420 419
 			sprintf(
421 420
 				/* translators: %s: minimum donation amount */
422
-				__( 'This form has a minimum donation amount of %s.', 'give' ),
421
+				__('This form has a minimum donation amount of %s.', 'give'),
423 422
 				give_currency_filter(
424
-					give_format_amount( give_get_form_minimum_price( $form_id ),
423
+					give_format_amount(give_get_form_minimum_price($form_id),
425 424
 						array(
426 425
 							'sanitize' => false,
427 426
 						)
@@ -429,15 +428,15 @@  discard block
 block discarded – undo
429 428
 				)
430 429
 			)
431 430
 		);
432
-	} elseif ( ! give_verify_minimum_price( 'maximum' ) ) {
431
+	} elseif ( ! give_verify_minimum_price('maximum')) {
433 432
 
434 433
 		give_set_error(
435 434
 			'invalid_donation_maximum',
436 435
 			sprintf(
437 436
 				/* translators: %s: Maximum donation amount */
438
-				__( 'This form has a maximum donation amount of %s.', 'give' ),
437
+				__('This form has a maximum donation amount of %s.', 'give'),
439 438
 				give_currency_filter(
440
-					give_format_amount( give_get_form_maximum_price( $form_id ),
439
+					give_format_amount(give_get_form_maximum_price($form_id),
441 440
 						array(
442 441
 							'sanitize' => false,
443 442
 						)
@@ -463,33 +462,33 @@  discard block
 block discarded – undo
463 462
  *
464 463
  * @return bool
465 464
  */
466
-function give_verify_minimum_price( $amount_range = 'minimum' ) {
465
+function give_verify_minimum_price($amount_range = 'minimum') {
467 466
 
468
-	$post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok.
469
-	$form_id   = ! empty( $post_data['give-form-id'] ) ? $post_data['give-form-id'] : 0;
470
-	$amount    = ! empty( $post_data['give-amount'] ) ? give_maybe_sanitize_amount( $post_data['give-amount'], array( 'currency' => give_get_currency( $form_id ) ) ) : 0;
471
-	$price_id  = isset( $post_data['give-price-id'] ) ? absint( $post_data['give-price-id'] ) : '';
467
+	$post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok.
468
+	$form_id   = ! empty($post_data['give-form-id']) ? $post_data['give-form-id'] : 0;
469
+	$amount    = ! empty($post_data['give-amount']) ? give_maybe_sanitize_amount($post_data['give-amount'], array('currency' => give_get_currency($form_id))) : 0;
470
+	$price_id  = isset($post_data['give-price-id']) ? absint($post_data['give-price-id']) : '';
472 471
 
473
-	$variable_prices = give_has_variable_prices( $form_id );
474
-	$price_ids       = array_map( 'absint', give_get_variable_price_ids( $form_id ) );
472
+	$variable_prices = give_has_variable_prices($form_id);
473
+	$price_ids       = array_map('absint', give_get_variable_price_ids($form_id));
475 474
 	$verified_stat   = false;
476 475
 
477
-	if ( $variable_prices && in_array( $price_id, $price_ids, true ) ) {
476
+	if ($variable_prices && in_array($price_id, $price_ids, true)) {
478 477
 
479
-		$price_level_amount = give_get_price_option_amount( $form_id, $price_id );
478
+		$price_level_amount = give_get_price_option_amount($form_id, $price_id);
480 479
 
481
-		if ( $price_level_amount == $amount ) {
480
+		if ($price_level_amount == $amount) {
482 481
 			$verified_stat = true;
483 482
 		}
484 483
 	}
485 484
 
486
-	if ( ! $verified_stat ) {
487
-		switch ( $amount_range ) {
485
+	if ( ! $verified_stat) {
486
+		switch ($amount_range) {
488 487
 			case 'minimum' :
489
-				$verified_stat = ( give_get_form_minimum_price( $form_id ) > $amount ) ? false : true;
488
+				$verified_stat = (give_get_form_minimum_price($form_id) > $amount) ? false : true;
490 489
 				break;
491 490
 			case 'maximum' :
492
-				$verified_stat = ( give_get_form_maximum_price( $form_id ) < $amount ) ? false : true;
491
+				$verified_stat = (give_get_form_maximum_price($form_id) < $amount) ? false : true;
493 492
 				break;
494 493
 		}
495 494
 	}
@@ -503,7 +502,7 @@  discard block
 block discarded – undo
503 502
 	 * @param string  $amount_range  Type of the amount.
504 503
 	 * @param integer $form_id       Give Donation Form ID.
505 504
 	 */
506
-	return apply_filters( 'give_verify_minimum_maximum_price', $verified_stat, $amount_range, $form_id );
505
+	return apply_filters('give_verify_minimum_maximum_price', $verified_stat, $amount_range, $form_id);
507 506
 }
508 507
 
509 508
 /**
@@ -516,13 +515,13 @@  discard block
 block discarded – undo
516 515
  */
517 516
 function give_donation_form_validate_agree_to_terms() {
518 517
 
519
-	$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.
518
+	$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.
520 519
 
521 520
 	// Proceed only, if donor agreed to terms.
522
-	if ( ! $agree_to_terms ) {
521
+	if ( ! $agree_to_terms) {
523 522
 
524 523
 		// User did not agree.
525
-		give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', __( 'You must agree to the terms and conditions.', 'give' ) ) );
524
+		give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', __('You must agree to the terms and conditions.', 'give')));
526 525
 	}
527 526
 }
528 527
 
@@ -536,92 +535,92 @@  discard block
 block discarded – undo
536 535
  *
537 536
  * @return array
538 537
  */
539
-function give_get_required_fields( $form_id ) {
538
+function give_get_required_fields($form_id) {
540 539
 
541
-	$payment_mode = give_get_chosen_gateway( $form_id );
540
+	$payment_mode = give_get_chosen_gateway($form_id);
542 541
 
543 542
 	$required_fields = array(
544 543
 		'give_email' => array(
545 544
 			'error_id'      => 'invalid_email',
546
-			'error_message' => __( 'Please enter a valid email address.', 'give' ),
545
+			'error_message' => __('Please enter a valid email address.', 'give'),
547 546
 		),
548 547
 		'give_first' => array(
549 548
 			'error_id'      => 'invalid_first_name',
550
-			'error_message' => __( 'Please enter your first name.', 'give' ),
549
+			'error_message' => __('Please enter your first name.', 'give'),
551 550
 		),
552 551
 	);
553 552
 
554
-	$name_title_prefix = give_is_name_title_prefix_required( $form_id );
555
-	if ( $name_title_prefix ) {
553
+	$name_title_prefix = give_is_name_title_prefix_required($form_id);
554
+	if ($name_title_prefix) {
556 555
 		$required_fields['give_title'] = array(
557 556
 			'error_id'      => 'invalid_title',
558
-			'error_message' => __( 'Please enter your title.', 'give' ),
557
+			'error_message' => __('Please enter your title.', 'give'),
559 558
 		);
560 559
 	}
561 560
 
562
-	$require_address = give_require_billing_address( $payment_mode );
561
+	$require_address = give_require_billing_address($payment_mode);
563 562
 
564
-	if ( $require_address ) {
565
-		$required_fields['card_address']    = array(
563
+	if ($require_address) {
564
+		$required_fields['card_address'] = array(
566 565
 			'error_id'      => 'invalid_card_address',
567
-			'error_message' => __( 'Please enter your primary billing address.', 'give' ),
566
+			'error_message' => __('Please enter your primary billing address.', 'give'),
568 567
 		);
569
-		$required_fields['card_zip']        = array(
568
+		$required_fields['card_zip'] = array(
570 569
 			'error_id'      => 'invalid_zip_code',
571
-			'error_message' => __( 'Please enter your zip / postal code.', 'give' ),
570
+			'error_message' => __('Please enter your zip / postal code.', 'give'),
572 571
 		);
573
-		$required_fields['card_city']       = array(
572
+		$required_fields['card_city'] = array(
574 573
 			'error_id'      => 'invalid_city',
575
-			'error_message' => __( 'Please enter your billing city.', 'give' ),
574
+			'error_message' => __('Please enter your billing city.', 'give'),
576 575
 		);
577 576
 		$required_fields['billing_country'] = array(
578 577
 			'error_id'      => 'invalid_country',
579
-			'error_message' => __( 'Please select your billing country.', 'give' ),
578
+			'error_message' => __('Please select your billing country.', 'give'),
580 579
 		);
581 580
 
582 581
 
583 582
 		$required_fields['card_state'] = array(
584 583
 			'error_id'      => 'invalid_state',
585
-			'error_message' => __( 'Please enter billing state / province / County.', 'give' ),
584
+			'error_message' => __('Please enter billing state / province / County.', 'give'),
586 585
 		);
587 586
 
588
-		$country = ! empty( $_POST['billing_country'] ) ? give_clean( $_POST['billing_country'] ) : 0; // WPCS: input var ok, sanitization ok, CSRF ok.
587
+		$country = ! empty($_POST['billing_country']) ? give_clean($_POST['billing_country']) : 0; // WPCS: input var ok, sanitization ok, CSRF ok.
589 588
 
590 589
 		// Check if billing country already exists.
591
-		if ( $country ) {
590
+		if ($country) {
592 591
 
593 592
 			// Get the country list that does not required any states init.
594 593
 			$states_country = give_states_not_required_country_list();
595 594
 
596 595
 			// Check if states is empty or not.
597
-			if ( array_key_exists( $country, $states_country ) ) {
596
+			if (array_key_exists($country, $states_country)) {
598 597
 				// If states is empty remove the required fields of state in billing cart.
599
-				unset( $required_fields['card_state'] );
598
+				unset($required_fields['card_state']);
600 599
 			}
601 600
 		}
602 601
 	} // End if().
603 602
 
604
-	if ( give_is_company_field_enabled( $form_id ) ) {
605
-		$form_option    = give_get_meta( $form_id, '_give_company_field', true );
606
-		$global_setting = give_get_option( 'company_field' );
603
+	if (give_is_company_field_enabled($form_id)) {
604
+		$form_option    = give_get_meta($form_id, '_give_company_field', true);
605
+		$global_setting = give_get_option('company_field');
607 606
 
608 607
 		$is_company_field_required = false;
609 608
 
610
-		if ( ! empty( $form_option ) && give_is_setting_enabled( $form_option, array( 'required' ) ) ) {
609
+		if ( ! empty($form_option) && give_is_setting_enabled($form_option, array('required'))) {
611 610
 			$is_company_field_required = true;
612 611
 
613
-		} elseif ( 'global' === $form_option && give_is_setting_enabled( $global_setting, array( 'required' ) ) ) {
612
+		} elseif ('global' === $form_option && give_is_setting_enabled($global_setting, array('required'))) {
614 613
 			$is_company_field_required = true;
615 614
 
616
-		} elseif ( empty( $form_option ) && give_is_setting_enabled( $global_setting, array( 'required' ) ) ) {
615
+		} elseif (empty($form_option) && give_is_setting_enabled($global_setting, array('required'))) {
617 616
 			$is_company_field_required = true;
618 617
 
619 618
 		}
620 619
 
621
-		if ( $is_company_field_required ) {
620
+		if ($is_company_field_required) {
622 621
 			$required_fields['give_company_name'] = array(
623 622
 				'error_id'      => 'invalid_company',
624
-				'error_message' => __( 'Please enter Company Name.', 'give' ),
623
+				'error_message' => __('Please enter Company Name.', 'give'),
625 624
 			);
626 625
 		}
627 626
 	}
@@ -631,7 +630,7 @@  discard block
 block discarded – undo
631 630
 	 *
632 631
 	 * @since 1.7
633 632
 	 */
634
-	$required_fields = apply_filters( 'give_donation_form_required_fields', $required_fields, $form_id );
633
+	$required_fields = apply_filters('give_donation_form_required_fields', $required_fields, $form_id);
635 634
 
636 635
 	return $required_fields;
637 636
 
@@ -646,17 +645,17 @@  discard block
 block discarded – undo
646 645
  *
647 646
  * @return bool
648 647
  */
649
-function give_require_billing_address( $payment_mode ) {
648
+function give_require_billing_address($payment_mode) {
650 649
 
651 650
 	$return          = false;
652
-	$billing_country = ! empty( $_POST['billing_country'] ) ? give_clean( $_POST['billing_country'] ) : 0; // WPCS: input var ok, sanitization ok, CSRF ok.
651
+	$billing_country = ! empty($_POST['billing_country']) ? give_clean($_POST['billing_country']) : 0; // WPCS: input var ok, sanitization ok, CSRF ok.
653 652
 
654
-	if ( $billing_country || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) {
653
+	if ($billing_country || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) {
655 654
 		$return = true;
656 655
 	}
657 656
 
658 657
 	// Let payment gateways and other extensions determine if address fields should be required.
659
-	return apply_filters( 'give_require_billing_address', $return );
658
+	return apply_filters('give_require_billing_address', $return);
660 659
 
661 660
 }
662 661
 
@@ -670,47 +669,47 @@  discard block
 block discarded – undo
670 669
  */
671 670
 function give_donation_form_validate_logged_in_user() {
672 671
 
673
-	$post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok.
672
+	$post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok.
674 673
 	$user_id   = get_current_user_id();
675
-	$form_id   = ! empty( $post_data['give-form-id'] ) ? $post_data['give-form-id'] : 0;
674
+	$form_id   = ! empty($post_data['give-form-id']) ? $post_data['give-form-id'] : 0;
676 675
 
677 676
 	// Start empty array to collect valid user data.
678 677
 	$valid_user_data = array(
679 678
 
680 679
 		// Assume there will be errors.
681
-		'user_id' => - 1,
680
+		'user_id' => -1,
682 681
 	);
683 682
 
684 683
 	// Proceed on;y, if valid $user_id found.
685
-	if ( $user_id > 0 ) {
684
+	if ($user_id > 0) {
686 685
 
687 686
 		// Get the logged in user data.
688
-		$user_data = get_userdata( $user_id );
687
+		$user_data = get_userdata($user_id);
689 688
 
690 689
 		// Validate Required Form Fields.
691
-		give_validate_required_form_fields( $form_id );
690
+		give_validate_required_form_fields($form_id);
692 691
 
693 692
 		// Verify data.
694
-		if ( is_object( $user_data ) && $user_data->ID > 0 ) {
693
+		if (is_object($user_data) && $user_data->ID > 0) {
695 694
 
696 695
 			// Collected logged in user data.
697 696
 			$valid_user_data = array(
698 697
 				'user_id'    => $user_id,
699
-				'user_email' => ! empty( $post_data['give_email'] ) ? sanitize_email( $post_data['give_email'] ) : $user_data->user_email,
700
-				'user_first' => ! empty( $post_data['give_first'] ) ? $post_data['give_first'] : $user_data->first_name,
701
-				'user_last'  => ! empty( $post_data['give_last'] ) ? $post_data['give_last'] : $user_data->last_name,
698
+				'user_email' => ! empty($post_data['give_email']) ? sanitize_email($post_data['give_email']) : $user_data->user_email,
699
+				'user_first' => ! empty($post_data['give_first']) ? $post_data['give_first'] : $user_data->first_name,
700
+				'user_last'  => ! empty($post_data['give_last']) ? $post_data['give_last'] : $user_data->last_name,
702 701
 			);
703 702
 
704 703
 			// Validate essential form fields.
705
-			give_donation_form_validate_name_fields( $post_data );
704
+			give_donation_form_validate_name_fields($post_data);
706 705
 
707
-			if ( ! is_email( $valid_user_data['user_email'] ) ) {
708
-				give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
706
+			if ( ! is_email($valid_user_data['user_email'])) {
707
+				give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
709 708
 			}
710 709
 		} else {
711 710
 
712 711
 			// Set invalid user information error.
713
-			give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) );
712
+			give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give'));
714 713
 		}
715 714
 	}
716 715
 
@@ -731,7 +730,7 @@  discard block
 block discarded – undo
731 730
 	$auto_generated_password = wp_generate_password();
732 731
 	$default_user_data       = array(
733 732
 		'give-form-id'           => '',
734
-		'user_id'                => - 1, // Assume there will be errors.
733
+		'user_id'                => -1, // Assume there will be errors.
735 734
 		'user_first'             => '',
736 735
 		'user_last'              => '',
737 736
 		'give_user_login'        => false,
@@ -741,26 +740,26 @@  discard block
 block discarded – undo
741 740
 	);
742 741
 
743 742
 	// Get data.
744
-	$post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok.
745
-	$user_data = wp_parse_args( $post_data, $default_user_data );
743
+	$post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok.
744
+	$user_data = wp_parse_args($post_data, $default_user_data);
746 745
 
747
-	$form_id = absint( $user_data['give-form-id'] );
748
-	$nonce   = ! empty( $post_data['give-form-user-register-hash'] ) ? $post_data['give-form-user-register-hash'] : '';
746
+	$form_id = absint($user_data['give-form-id']);
747
+	$nonce   = ! empty($post_data['give-form-user-register-hash']) ? $post_data['give-form-user-register-hash'] : '';
749 748
 
750 749
 	// Validate user creation nonce.
751
-	if ( ! wp_verify_nonce( $nonce, "give_form_create_user_nonce_{$form_id}" ) ) {
752
-		give_set_error( 'invalid_nonce', __( 'Nonce verification has failed.', 'give' ) );
750
+	if ( ! wp_verify_nonce($nonce, "give_form_create_user_nonce_{$form_id}")) {
751
+		give_set_error('invalid_nonce', __('Nonce verification has failed.', 'give'));
753 752
 	}
754 753
 
755 754
 	$registering_new_user = false;
756 755
 
757
-	give_donation_form_validate_name_fields( $user_data );
756
+	give_donation_form_validate_name_fields($user_data);
758 757
 
759 758
 	// Start an empty array to collect valid user data.
760 759
 	$valid_user_data = array(
761 760
 
762 761
 		// Assume there will be errors.
763
-		'user_id'    => - 1,
762
+		'user_id'    => -1,
764 763
 
765 764
 		// Get first name.
766 765
 		'user_first' => $user_data['give_first'],
@@ -773,13 +772,13 @@  discard block
 block discarded – undo
773 772
 	);
774 773
 
775 774
 	// Validate Required Form Fields.
776
-	give_validate_required_form_fields( $form_id );
775
+	give_validate_required_form_fields($form_id);
777 776
 
778 777
 	// Set Email as Username.
779 778
 	$valid_user_data['user_login'] = $user_data['give_email'];
780 779
 
781 780
 	// Check if we have an email to verify.
782
-	if ( give_validate_user_email( $user_data['give_email'], $registering_new_user ) ) {
781
+	if (give_validate_user_email($user_data['give_email'], $registering_new_user)) {
783 782
 		$valid_user_data['user_email'] = $user_data['give_email'];
784 783
 	}
785 784
 
@@ -796,47 +795,47 @@  discard block
 block discarded – undo
796 795
  */
797 796
 function give_donation_form_validate_user_login() {
798 797
 
799
-	$post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok.
798
+	$post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok.
800 799
 
801 800
 	// Start an array to collect valid user data.
802 801
 	$valid_user_data = array(
803 802
 
804 803
 		// Assume there will be errors.
805
-		'user_id' => - 1,
804
+		'user_id' => -1,
806 805
 	);
807 806
 
808 807
 	// Bailout, if Username is empty.
809
-	if ( empty( $post_data['give_user_login'] ) ) {
810
-		give_set_error( 'must_log_in', __( 'You must register or login to complete your donation.', 'give' ) );
808
+	if (empty($post_data['give_user_login'])) {
809
+		give_set_error('must_log_in', __('You must register or login to complete your donation.', 'give'));
811 810
 
812 811
 		return $valid_user_data;
813 812
 	}
814 813
 
815 814
 	// Get the user by login.
816
-	$user_data = get_user_by( 'login', strip_tags( $post_data['give_user_login'] ) );
815
+	$user_data = get_user_by('login', strip_tags($post_data['give_user_login']));
817 816
 
818 817
 	// Check if user exists.
819
-	if ( $user_data ) {
818
+	if ($user_data) {
820 819
 
821 820
 		// Get password.
822
-		$user_pass = ! empty( $post_data['give_user_pass'] ) ? $post_data['give_user_pass'] : false;
821
+		$user_pass = ! empty($post_data['give_user_pass']) ? $post_data['give_user_pass'] : false;
823 822
 
824 823
 		// Check user_pass.
825
-		if ( $user_pass ) {
824
+		if ($user_pass) {
826 825
 
827 826
 			// Check if password is valid.
828
-			if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) {
827
+			if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) {
829 828
 
830
-				$current_page_url = site_url() . '/' . get_page_uri();
829
+				$current_page_url = site_url().'/'.get_page_uri();
831 830
 
832 831
 				// Incorrect password.
833 832
 				give_set_error(
834 833
 					'password_incorrect',
835 834
 					sprintf(
836 835
 						'%1$s <a href="%2$s">%3$s</a>',
837
-						__( 'The password you entered is incorrect.', 'give' ),
838
-						wp_lostpassword_url( $current_page_url ),
839
-						__( 'Reset Password', 'give' )
836
+						__('The password you entered is incorrect.', 'give'),
837
+						wp_lostpassword_url($current_page_url),
838
+						__('Reset Password', 'give')
840 839
 					)
841 840
 				);
842 841
 
@@ -854,11 +853,11 @@  discard block
 block discarded – undo
854 853
 			}
855 854
 		} else {
856 855
 			// Empty password.
857
-			give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) );
856
+			give_set_error('password_empty', __('Enter a password.', 'give'));
858 857
 		}
859 858
 	} else {
860 859
 		// No username.
861
-		give_set_error( 'username_incorrect', __( 'The username you entered does not exist.', 'give' ) );
860
+		give_set_error('username_incorrect', __('The username you entered does not exist.', 'give'));
862 861
 	} // End if().
863 862
 
864 863
 	return $valid_user_data;
@@ -874,8 +873,8 @@  discard block
 block discarded – undo
874 873
  */
875 874
 function give_donation_form_validate_guest_user() {
876 875
 
877
-	$post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok.
878
-	$form_id   = ! empty( $post_data['give-form-id'] ) ? $post_data['give-form-id'] : 0;
876
+	$post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok.
877
+	$form_id   = ! empty($post_data['give-form-id']) ? $post_data['give-form-id'] : 0;
879 878
 
880 879
 	// Start an array to collect valid user data.
881 880
 	$valid_user_data = array(
@@ -884,22 +883,22 @@  discard block
 block discarded – undo
884 883
 	);
885 884
 
886 885
 	// Validate name fields.
887
-	give_donation_form_validate_name_fields( $post_data );
886
+	give_donation_form_validate_name_fields($post_data);
888 887
 
889 888
 	// Validate Required Form Fields.
890
-	give_validate_required_form_fields( $form_id );
889
+	give_validate_required_form_fields($form_id);
891 890
 
892 891
 	// Get the guest email.
893
-	$guest_email = ! empty( $post_data['give_email'] ) ? $post_data['give_email'] : false;
892
+	$guest_email = ! empty($post_data['give_email']) ? $post_data['give_email'] : false;
894 893
 
895 894
 	// Check email.
896
-	if ( $guest_email && strlen( $guest_email ) > 0 ) {
895
+	if ($guest_email && strlen($guest_email) > 0) {
897 896
 
898 897
 		// Validate email.
899
-		if ( ! is_email( $guest_email ) ) {
898
+		if ( ! is_email($guest_email)) {
900 899
 
901 900
 			// Invalid email.
902
-			give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) );
901
+			give_set_error('email_invalid', __('Invalid email.', 'give'));
903 902
 
904 903
 		} else {
905 904
 
@@ -907,15 +906,15 @@  discard block
 block discarded – undo
907 906
 			$valid_user_data['user_email'] = $guest_email;
908 907
 
909 908
 			// Get user_id from donor if exist.
910
-			$donor = new Give_Donor( $guest_email );
909
+			$donor = new Give_Donor($guest_email);
911 910
 
912
-			if ( $donor->id && $donor->user_id ) {
911
+			if ($donor->id && $donor->user_id) {
913 912
 				$valid_user_data['user_id'] = $donor->user_id;
914 913
 			}
915 914
 		}
916 915
 	} else {
917 916
 		// No email.
918
-		give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) );
917
+		give_set_error('email_empty', __('Enter an email.', 'give'));
919 918
 	}
920 919
 
921 920
 	return $valid_user_data;
@@ -931,36 +930,36 @@  discard block
 block discarded – undo
931 930
  *
932 931
  * @return  integer
933 932
  */
934
-function give_register_and_login_new_user( $user_data = array() ) {
933
+function give_register_and_login_new_user($user_data = array()) {
935 934
 	// Verify the array.
936
-	if ( empty( $user_data ) ) {
937
-		return - 1;
935
+	if (empty($user_data)) {
936
+		return -1;
938 937
 	}
939 938
 
940
-	if ( give_get_errors() ) {
941
-		return - 1;
939
+	if (give_get_errors()) {
940
+		return -1;
942 941
 	}
943 942
 
944
-	$user_args = apply_filters( 'give_insert_user_args', array(
945
-		'user_login'      => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '',
946
-		'user_pass'       => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '',
947
-		'user_email'      => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '',
948
-		'first_name'      => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '',
949
-		'last_name'       => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '',
950
-		'user_registered' => date( 'Y-m-d H:i:s' ),
951
-		'role'            => give_get_option( 'donor_default_user_role', 'give_donor' ),
952
-	), $user_data );
943
+	$user_args = apply_filters('give_insert_user_args', array(
944
+		'user_login'      => isset($user_data['user_login']) ? $user_data['user_login'] : '',
945
+		'user_pass'       => isset($user_data['user_pass']) ? $user_data['user_pass'] : '',
946
+		'user_email'      => isset($user_data['user_email']) ? $user_data['user_email'] : '',
947
+		'first_name'      => isset($user_data['user_first']) ? $user_data['user_first'] : '',
948
+		'last_name'       => isset($user_data['user_last']) ? $user_data['user_last'] : '',
949
+		'user_registered' => date('Y-m-d H:i:s'),
950
+		'role'            => give_get_option('donor_default_user_role', 'give_donor'),
951
+	), $user_data);
953 952
 
954 953
 	// Insert new user.
955
-	$user_id = wp_insert_user( $user_args );
954
+	$user_id = wp_insert_user($user_args);
956 955
 
957 956
 	// Validate inserted user.
958
-	if ( is_wp_error( $user_id ) ) {
959
-		return - 1;
957
+	if (is_wp_error($user_id)) {
958
+		return -1;
960 959
 	}
961 960
 
962 961
 	// Allow themes and plugins to filter the user data.
963
-	$user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args );
962
+	$user_data = apply_filters('give_insert_user_data', $user_data, $user_args);
964 963
 
965 964
 	/**
966 965
 	 * Fires after inserting user.
@@ -970,7 +969,7 @@  discard block
 block discarded – undo
970 969
 	 * @param int $user_id User id.
971 970
 	 * @param array $user_data Array containing user data.
972 971
 	 */
973
-	do_action( 'give_insert_user', $user_id, $user_data );
972
+	do_action('give_insert_user', $user_id, $user_data);
974 973
 
975 974
 	/**
976 975
 	 * Filter allow user to alter if user when to login or not when user is register for the first time.
@@ -979,9 +978,9 @@  discard block
 block discarded – undo
979 978
 	 *
980 979
 	 * return bool True if login with registration and False if only want to register.
981 980
 	 */
982
-	if ( true === (bool) apply_filters( 'give_log_user_in_on_register', true ) ) {
981
+	if (true === (bool) apply_filters('give_log_user_in_on_register', true)) {
983 982
 		// Login new user.
984
-		give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] );
983
+		give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']);
985 984
 	}
986 985
 
987 986
 	// Return user id.
@@ -998,33 +997,33 @@  discard block
 block discarded – undo
998 997
  *
999 998
  * @return  array|bool
1000 999
  */
1001
-function give_get_donation_form_user( $valid_data = array() ) {
1000
+function give_get_donation_form_user($valid_data = array()) {
1002 1001
 
1003 1002
 	// Initialize user.
1004 1003
 	$user      = false;
1005
-	$is_ajax   = defined( 'DOING_AJAX' ) && DOING_AJAX;
1006
-	$post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok.
1004
+	$is_ajax   = defined('DOING_AJAX') && DOING_AJAX;
1005
+	$post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok.
1007 1006
 
1008
-	if ( $is_ajax ) {
1007
+	if ($is_ajax) {
1009 1008
 
1010 1009
 		// Do not create or login the user during the ajax submission (check for errors only).
1011 1010
 		return true;
1012
-	} elseif ( is_user_logged_in() ) {
1011
+	} elseif (is_user_logged_in()) {
1013 1012
 
1014 1013
 		// Set the valid user as the logged in collected data.
1015 1014
 		$user = $valid_data['logged_in_user'];
1016
-	} elseif ( true === $valid_data['need_new_user'] || true === $valid_data['need_user_login'] ) {
1015
+	} elseif (true === $valid_data['need_new_user'] || true === $valid_data['need_user_login']) {
1017 1016
 
1018 1017
 		// New user registration.
1019
-		if ( true === $valid_data['need_new_user'] ) {
1018
+		if (true === $valid_data['need_new_user']) {
1020 1019
 
1021 1020
 			// Set user.
1022 1021
 			$user = $valid_data['new_user_data'];
1023 1022
 
1024 1023
 			// Register and login new user.
1025
-			$user['user_id'] = give_register_and_login_new_user( $user );
1024
+			$user['user_id'] = give_register_and_login_new_user($user);
1026 1025
 
1027
-		} elseif ( true === $valid_data['need_user_login'] && ! $is_ajax ) {
1026
+		} elseif (true === $valid_data['need_user_login'] && ! $is_ajax) {
1028 1027
 
1029 1028
 			/**
1030 1029
 			 * The login form is now processed in the give_process_donation_login() function.
@@ -1036,47 +1035,47 @@  discard block
 block discarded – undo
1036 1035
 			$user = $valid_data['login_user_data'];
1037 1036
 
1038 1037
 			// Login user.
1039
-			give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] );
1038
+			give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']);
1040 1039
 		}
1041 1040
 	} // End if().
1042 1041
 
1043 1042
 	// Check guest checkout.
1044
-	if ( false === $user && false === give_logged_in_only( $post_data['give-form-id'] ) ) {
1043
+	if (false === $user && false === give_logged_in_only($post_data['give-form-id'])) {
1045 1044
 
1046 1045
 		// Set user.
1047 1046
 		$user = $valid_data['guest_user_data'];
1048 1047
 	}
1049 1048
 
1050 1049
 	// Verify we have an user.
1051
-	if ( false === $user || empty( $user ) ) {
1050
+	if (false === $user || empty($user)) {
1052 1051
 		return false;
1053 1052
 	}
1054 1053
 
1055 1054
 	// Get user first name.
1056
-	if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) {
1057
-		$user['user_first'] = isset( $post_data['give_first'] ) ? strip_tags( trim( $post_data['give_first'] ) ) : '';
1055
+	if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) {
1056
+		$user['user_first'] = isset($post_data['give_first']) ? strip_tags(trim($post_data['give_first'])) : '';
1058 1057
 	}
1059 1058
 
1060 1059
 	// Get user last name.
1061
-	if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) {
1062
-		$user['user_last'] = isset( $post_data['give_last'] ) ? strip_tags( trim( $post_data['give_last'] ) ) : '';
1060
+	if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) {
1061
+		$user['user_last'] = isset($post_data['give_last']) ? strip_tags(trim($post_data['give_last'])) : '';
1063 1062
 	}
1064 1063
 
1065 1064
 	// Add Title Prefix to user information.
1066
-	if ( empty( $user['user_title'] ) || strlen( trim( $user['user_title'] ) ) < 1 ) {
1067
-		$user['user_title'] = ! empty( $post_data['give_title'] ) ? strip_tags( trim( $post_data['give_title'] ) ) : '';
1065
+	if (empty($user['user_title']) || strlen(trim($user['user_title'])) < 1) {
1066
+		$user['user_title'] = ! empty($post_data['give_title']) ? strip_tags(trim($post_data['give_title'])) : '';
1068 1067
 	}
1069 1068
 
1070 1069
 	// Get the user's billing address details.
1071 1070
 	$user['address']            = array();
1072
-	$user['address']['line1']   = ! empty( $post_data['card_address'] ) ? $post_data['card_address'] : false;
1073
-	$user['address']['line2']   = ! empty( $post_data['card_address_2'] ) ? $post_data['card_address_2'] : false;
1074
-	$user['address']['city']    = ! empty( $post_data['card_city'] ) ? $post_data['card_city'] : false;
1075
-	$user['address']['state']   = ! empty( $post_data['card_state'] ) ? $post_data['card_state'] : false;
1076
-	$user['address']['zip']     = ! empty( $post_data['card_zip'] ) ? $post_data['card_zip'] : false;
1077
-	$user['address']['country'] = ! empty( $post_data['billing_country'] ) ? $post_data['billing_country'] : false;
1078
-
1079
-	if ( empty( $user['address']['country'] ) ) {
1071
+	$user['address']['line1']   = ! empty($post_data['card_address']) ? $post_data['card_address'] : false;
1072
+	$user['address']['line2']   = ! empty($post_data['card_address_2']) ? $post_data['card_address_2'] : false;
1073
+	$user['address']['city']    = ! empty($post_data['card_city']) ? $post_data['card_city'] : false;
1074
+	$user['address']['state']   = ! empty($post_data['card_state']) ? $post_data['card_state'] : false;
1075
+	$user['address']['zip']     = ! empty($post_data['card_zip']) ? $post_data['card_zip'] : false;
1076
+	$user['address']['country'] = ! empty($post_data['billing_country']) ? $post_data['billing_country'] : false;
1077
+
1078
+	if (empty($user['address']['country'])) {
1080 1079
 		$user['address'] = false;
1081 1080
 	} // End if().
1082 1081
 
@@ -1097,16 +1096,16 @@  discard block
 block discarded – undo
1097 1096
 	$card_data = give_get_donation_cc_info();
1098 1097
 
1099 1098
 	// Validate the card zip.
1100
-	if ( ! empty( $card_data['card_zip'] ) ) {
1101
-		if ( ! give_donation_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) {
1102
-			give_set_error( 'invalid_cc_zip', __( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) );
1099
+	if ( ! empty($card_data['card_zip'])) {
1100
+		if ( ! give_donation_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) {
1101
+			give_set_error('invalid_cc_zip', __('The zip / postal code you entered for your billing address is invalid.', 'give'));
1103 1102
 		}
1104 1103
 	}
1105 1104
 
1106 1105
 	// Ensure no spaces.
1107
-	if ( ! empty( $card_data['card_number'] ) ) {
1108
-		$card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); // no "+" signs.
1109
-		$card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces.
1106
+	if ( ! empty($card_data['card_number'])) {
1107
+		$card_data['card_number'] = str_replace('+', '', $card_data['card_number']); // no "+" signs.
1108
+		$card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces.
1110 1109
 	}
1111 1110
 
1112 1111
 	// This should validate card numbers at some point too.
@@ -1124,20 +1123,20 @@  discard block
 block discarded – undo
1124 1123
 function give_get_donation_cc_info() {
1125 1124
 
1126 1125
 	// Sanitize the values submitted with donation form.
1127
-	$post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok.
1126
+	$post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok.
1128 1127
 
1129 1128
 	$cc_info                   = array();
1130
-	$cc_info['card_name']      = ! empty( $post_data['card_name'] ) ? $post_data['card_name'] : '';
1131
-	$cc_info['card_number']    = ! empty( $post_data['card_number'] ) ? $post_data['card_number'] : '';
1132
-	$cc_info['card_cvc']       = ! empty( $post_data['card_cvc'] ) ? $post_data['card_cvc'] : '';
1133
-	$cc_info['card_exp_month'] = ! empty( $post_data['card_exp_month'] ) ? $post_data['card_exp_month'] : '';
1134
-	$cc_info['card_exp_year']  = ! empty( $post_data['card_exp_year'] ) ? $post_data['card_exp_year'] : '';
1135
-	$cc_info['card_address']   = ! empty( $post_data['card_address'] ) ? $post_data['card_address'] : '';
1136
-	$cc_info['card_address_2'] = ! empty( $post_data['card_address_2'] ) ? $post_data['card_address_2'] : '';
1137
-	$cc_info['card_city']      = ! empty( $post_data['card_city'] ) ? $post_data['card_city'] : '';
1138
-	$cc_info['card_state']     = ! empty( $post_data['card_state'] ) ? $post_data['card_state'] : '';
1139
-	$cc_info['card_country']   = ! empty( $post_data['billing_country'] ) ? $post_data['billing_country'] : '';
1140
-	$cc_info['card_zip']       = ! empty( $post_data['card_zip'] ) ? $post_data['card_zip'] : '';
1129
+	$cc_info['card_name']      = ! empty($post_data['card_name']) ? $post_data['card_name'] : '';
1130
+	$cc_info['card_number']    = ! empty($post_data['card_number']) ? $post_data['card_number'] : '';
1131
+	$cc_info['card_cvc']       = ! empty($post_data['card_cvc']) ? $post_data['card_cvc'] : '';
1132
+	$cc_info['card_exp_month'] = ! empty($post_data['card_exp_month']) ? $post_data['card_exp_month'] : '';
1133
+	$cc_info['card_exp_year']  = ! empty($post_data['card_exp_year']) ? $post_data['card_exp_year'] : '';
1134
+	$cc_info['card_address']   = ! empty($post_data['card_address']) ? $post_data['card_address'] : '';
1135
+	$cc_info['card_address_2'] = ! empty($post_data['card_address_2']) ? $post_data['card_address_2'] : '';
1136
+	$cc_info['card_city']      = ! empty($post_data['card_city']) ? $post_data['card_city'] : '';
1137
+	$cc_info['card_state']     = ! empty($post_data['card_state']) ? $post_data['card_state'] : '';
1138
+	$cc_info['card_country']   = ! empty($post_data['billing_country']) ? $post_data['billing_country'] : '';
1139
+	$cc_info['card_zip']       = ! empty($post_data['card_zip']) ? $post_data['card_zip'] : '';
1141 1140
 
1142 1141
 	// Return cc info.
1143 1142
 	return $cc_info;
@@ -1153,14 +1152,14 @@  discard block
 block discarded – undo
1153 1152
  *
1154 1153
  * @return bool|mixed
1155 1154
  */
1156
-function give_donation_form_validate_cc_zip( $zip = 0, $country_code = '' ) {
1155
+function give_donation_form_validate_cc_zip($zip = 0, $country_code = '') {
1157 1156
 	$ret = false;
1158 1157
 
1159
-	if ( empty( $zip ) || empty( $country_code ) ) {
1158
+	if (empty($zip) || empty($country_code)) {
1160 1159
 		return $ret;
1161 1160
 	}
1162 1161
 
1163
-	$country_code = strtoupper( $country_code );
1162
+	$country_code = strtoupper($country_code);
1164 1163
 
1165 1164
 	$zip_regex = array(
1166 1165
 		'AD' => 'AD\d{3}',
@@ -1320,11 +1319,11 @@  discard block
 block discarded – undo
1320 1319
 		'ZM' => '\d{5}',
1321 1320
 	);
1322 1321
 
1323
-	if ( ! isset( $zip_regex[ $country_code ] ) || preg_match( '/' . $zip_regex[ $country_code ] . '/i', $zip ) ) {
1322
+	if ( ! isset($zip_regex[$country_code]) || preg_match('/'.$zip_regex[$country_code].'/i', $zip)) {
1324 1323
 		$ret = true;
1325 1324
 	}
1326 1325
 
1327
-	return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code );
1326
+	return apply_filters('give_is_zip_valid', $ret, $zip, $country_code);
1328 1327
 }
1329 1328
 
1330 1329
 /**
@@ -1336,60 +1335,60 @@  discard block
 block discarded – undo
1336 1335
  *
1337 1336
  * @return bool
1338 1337
  */
1339
-function give_validate_donation_amount( $valid_data ) {
1338
+function give_validate_donation_amount($valid_data) {
1340 1339
 
1341
-	$post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok.
1340
+	$post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok.
1342 1341
 
1343 1342
 	/* @var Give_Donate_Form $form */
1344
-	$form = new Give_Donate_Form( $post_data['give-form-id'] );
1343
+	$form = new Give_Donate_Form($post_data['give-form-id']);
1345 1344
 
1346 1345
 	// Get the form currency.
1347
-	$form_currency = give_get_currency( $post_data['give-form-id'] );
1346
+	$form_currency = give_get_currency($post_data['give-form-id']);
1348 1347
 
1349 1348
 	$donation_level_matched = false;
1350 1349
 
1351
-	if ( $form->is_set_type_donation_form() ) {
1350
+	if ($form->is_set_type_donation_form()) {
1352 1351
 
1353 1352
 		// Sanitize donation amount.
1354
-		$post_data['give-amount'] = give_maybe_sanitize_amount( $post_data['give-amount'], array( 'currency' => $form_currency ) );
1353
+		$post_data['give-amount'] = give_maybe_sanitize_amount($post_data['give-amount'], array('currency' => $form_currency));
1355 1354
 
1356 1355
 		// Backward compatibility.
1357
-		if ( $form->is_custom_price( $post_data['give-amount'] ) ) {
1356
+		if ($form->is_custom_price($post_data['give-amount'])) {
1358 1357
 			$post_data['give-price-id'] = 'custom';
1359 1358
 		}
1360 1359
 
1361 1360
 		$donation_level_matched = true;
1362 1361
 
1363
-	} elseif ( $form->is_multi_type_donation_form() ) {
1362
+	} elseif ($form->is_multi_type_donation_form()) {
1364 1363
 
1365 1364
 		$variable_prices = $form->get_prices();
1366 1365
 
1367 1366
 		// Bailout.
1368
-		if ( ! $variable_prices ) {
1367
+		if ( ! $variable_prices) {
1369 1368
 			return false;
1370 1369
 		}
1371 1370
 
1372 1371
 		// Sanitize donation amount.
1373
-		$post_data['give-amount']     = give_maybe_sanitize_amount( $post_data['give-amount'], array( 'currency' => $form_currency ) );
1374
-		$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 ) );
1372
+		$post_data['give-amount']     = give_maybe_sanitize_amount($post_data['give-amount'], array('currency' => $form_currency));
1373
+		$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));
1375 1374
 		$new_price_id                 = '';
1376 1375
 
1377
-		if ( $post_data['give-amount'] === $variable_price_option_amount ) {
1376
+		if ($post_data['give-amount'] === $variable_price_option_amount) {
1378 1377
 			return true;
1379 1378
 		}
1380 1379
 
1381
-		if ( $form->is_custom_price( $post_data['give-amount'] ) ) {
1380
+		if ($form->is_custom_price($post_data['give-amount'])) {
1382 1381
 			$new_price_id = 'custom';
1383 1382
 		} else {
1384 1383
 
1385 1384
 			// Find correct donation level from all donation levels.
1386
-			foreach ( $variable_prices as $variable_price ) {
1385
+			foreach ($variable_prices as $variable_price) {
1387 1386
 
1388 1387
 				// Sanitize level amount.
1389
-				$variable_price['_give_amount'] = give_maybe_sanitize_amount( $variable_price['_give_amount'] );
1388
+				$variable_price['_give_amount'] = give_maybe_sanitize_amount($variable_price['_give_amount']);
1390 1389
 
1391 1390
 				// Set first match donation level ID.
1392
-				if ( $post_data['give-amount'] === $variable_price['_give_amount'] ) {
1391
+				if ($post_data['give-amount'] === $variable_price['_give_amount']) {
1393 1392
 					$new_price_id = $variable_price['_give_id']['level_id'];
1394 1393
 					break;
1395 1394
 				}
@@ -1398,26 +1397,26 @@  discard block
 block discarded – undo
1398 1397
 
1399 1398
 		// If donation amount is not find in donation levels then check if form has custom donation feature enable or not.
1400 1399
 		// If yes then set price id to custom if amount is greater then custom minimum amount (if any).
1401
-		if ( $post_data['give-price-id'] === $new_price_id ) {
1400
+		if ($post_data['give-price-id'] === $new_price_id) {
1402 1401
 			$donation_level_matched = true;
1403 1402
 		}
1404 1403
 	} // End if().
1405 1404
 
1406
-	if ( ! $donation_level_matched ) {
1405
+	if ( ! $donation_level_matched) {
1407 1406
 		give_set_error(
1408 1407
 			'invalid_donation_amount',
1409 1408
 			sprintf(
1410 1409
 			/* translators: %s: invalid donation amount */
1411
-				__( 'Donation amount %s is invalid.', 'give' ),
1410
+				__('Donation amount %s is invalid.', 'give'),
1412 1411
 				give_currency_filter(
1413
-					give_format_amount( $post_data['give-amount'], array( 'sanitize' => false, ) )
1412
+					give_format_amount($post_data['give-amount'], array('sanitize' => false,))
1414 1413
 				)
1415 1414
 			)
1416 1415
 		);
1417 1416
 	}
1418 1417
 }
1419 1418
 
1420
-add_action( 'give_checkout_error_checks', 'give_validate_donation_amount', 10, 1 );
1419
+add_action('give_checkout_error_checks', 'give_validate_donation_amount', 10, 1);
1421 1420
 
1422 1421
 /**
1423 1422
  * Validate Required Form Fields.
@@ -1426,20 +1425,20 @@  discard block
 block discarded – undo
1426 1425
  *
1427 1426
  * @since 2.0
1428 1427
  */
1429
-function give_validate_required_form_fields( $form_id ) {
1428
+function give_validate_required_form_fields($form_id) {
1430 1429
 
1431 1430
 	// Sanitize values submitted with donation form.
1432
-	$post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok.
1431
+	$post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok.
1433 1432
 
1434 1433
 	// Loop through required fields and show error messages.
1435
-	foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) {
1434
+	foreach (give_get_required_fields($form_id) as $field_name => $value) {
1436 1435
 
1437 1436
 		// Clean Up Data of the input fields.
1438
-		$field_value = $post_data[ $field_name ];
1437
+		$field_value = $post_data[$field_name];
1439 1438
 
1440 1439
 		// Check whether the required field is empty, then show the error message.
1441
-		if ( in_array( $value, give_get_required_fields( $form_id ), true ) && empty( $field_value ) ) {
1442
-			give_set_error( $value['error_id'], $value['error_message'] );
1440
+		if (in_array($value, give_get_required_fields($form_id), true) && empty($field_value)) {
1441
+			give_set_error($value['error_id'], $value['error_message']);
1443 1442
 		}
1444 1443
 	}
1445 1444
 }
@@ -1453,12 +1452,12 @@  discard block
 block discarded – undo
1453 1452
  *
1454 1453
  * @return void
1455 1454
  */
1456
-function give_donation_form_validate_name_fields( $post_data ) {
1455
+function give_donation_form_validate_name_fields($post_data) {
1457 1456
 
1458
-	$is_alpha_first_name = ( ! is_email( $post_data['give_first'] ) && ! preg_match( '~[0-9]~', $post_data['give_first'] ) );
1459
-	$is_alpha_last_name  = ( ! is_email( $post_data['give_last'] ) && ! preg_match( '~[0-9]~', $post_data['give_last'] ) );
1457
+	$is_alpha_first_name = ( ! is_email($post_data['give_first']) && ! preg_match('~[0-9]~', $post_data['give_first']));
1458
+	$is_alpha_last_name  = ( ! is_email($post_data['give_last']) && ! preg_match('~[0-9]~', $post_data['give_last']));
1460 1459
 
1461
-	if ( ! $is_alpha_first_name || ( ! empty( $post_data['give_last'] ) && ! $is_alpha_last_name ) ) {
1462
-		give_set_error( 'invalid_name', esc_html__( 'The First Name and Last Name fields cannot contain an email address or numbers.', 'give' ) );
1460
+	if ( ! $is_alpha_first_name || ( ! empty($post_data['give_last']) && ! $is_alpha_last_name)) {
1461
+		give_set_error('invalid_name', esc_html__('The First Name and Last Name fields cannot contain an email address or numbers.', 'give'));
1463 1462
 	}
1464 1463
 }
Please login to merge, or discard this patch.
includes/class-give-readme-parser.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @license     https://opensource.org/licenses/gpl-license GNU Public License
9 9
  * @since       2.1.4
10 10
  */
11
-class Give_Readme_Parser{
11
+class Give_Readme_Parser {
12 12
 	/**
13 13
 	 * Readme file url
14 14
 	 *
@@ -32,9 +32,9 @@  discard block
 block discarded – undo
32 32
 	 *
33 33
 	 * @param string $file_url
34 34
 	 */
35
-	function __construct( $file_url ) {
35
+	function __construct($file_url) {
36 36
 		$this->file_url     = $file_url;
37
-		$this->file_content = wp_remote_retrieve_body( wp_remote_get( $this->file_url ) );
37
+		$this->file_content = wp_remote_retrieve_body(wp_remote_get($this->file_url));
38 38
 	}
39 39
 
40 40
 	/**
@@ -47,11 +47,11 @@  discard block
 block discarded – undo
47 47
 	 */
48 48
 	public function requires_at_least() {
49 49
 		// Regex to extract Give core minimum version from the readme.txt file.
50
-		preg_match('|Requires Give:(.*)|i', $this->file_content, $_requires_at_least );
50
+		preg_match('|Requires Give:(.*)|i', $this->file_content, $_requires_at_least);
51 51
 
52
-		if( is_array( $_requires_at_least ) && 1 < count( $_requires_at_least ) ) {
53
-			$_requires_at_least = trim( $_requires_at_least[1] );
54
-		}else{
52
+		if (is_array($_requires_at_least) && 1 < count($_requires_at_least)) {
53
+			$_requires_at_least = trim($_requires_at_least[1]);
54
+		} else {
55 55
 			$_requires_at_least = null;
56 56
 		}
57 57
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@
 block discarded – undo
51 51
 
52 52
 		if( is_array( $_requires_at_least ) && 1 < count( $_requires_at_least ) ) {
53 53
 			$_requires_at_least = trim( $_requires_at_least[1] );
54
-		}else{
54
+		} else{
55 55
 			$_requires_at_least = null;
56 56
 		}
57 57
 
Please login to merge, or discard this patch.
includes/emails/template.php 1 patch
Spacing   +55 added lines, -55 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
 
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
  *
43 43
  * @return string $message Fully formatted message
44 44
  */
45
-function give_email_template_tags( $message, $payment_data, $payment_id, $admin_notice = false ) {
46
-	return give_do_email_tags( $message, $payment_id );
45
+function give_email_template_tags($message, $payment_data, $payment_id, $admin_notice = false) {
46
+	return give_do_email_tags($message, $payment_id);
47 47
 }
48 48
 
49 49
 /**
@@ -57,45 +57,45 @@  discard block
 block discarded – undo
57 57
  *
58 58
  * @return string $message Fully formatted message
59 59
  */
60
-function give_email_preview_template_tags( $message ) {
60
+function give_email_preview_template_tags($message) {
61 61
 
62
-	$price = give_currency_filter( give_format_amount( 10.50, array( 'sanitize' => false ) ) );
62
+	$price = give_currency_filter(give_format_amount(10.50, array('sanitize' => false)));
63 63
 
64 64
 	$gateway = 'PayPal';
65 65
 
66
-	$receipt_id = strtolower( md5( uniqid() ) );
66
+	$receipt_id = strtolower(md5(uniqid()));
67 67
 
68
-	$payment_id = rand( 1, 100 );
69
-	$receipt_link_url = esc_url( add_query_arg( array( 'payment_key' => $receipt_id ), give_get_history_page_uri() ) );
68
+	$payment_id = rand(1, 100);
69
+	$receipt_link_url = esc_url(add_query_arg(array('payment_key' => $receipt_id), give_get_history_page_uri()));
70 70
 
71 71
 	$receipt_link     = sprintf(
72 72
 		'<a href="%1$s">%2$s</a>',
73 73
 		$receipt_link_url,
74
-		esc_html__( 'View the receipt in your browser &raquo;', 'give' )
74
+		esc_html__('View the receipt in your browser &raquo;', 'give')
75 75
 	);
76 76
 
77 77
 	// Set user.
78 78
 	$user = wp_get_current_user();
79 79
 
80
-	$message = str_replace( '{name}', $user->display_name, $message );
81
-	$message = str_replace( '{fullname}', $user->display_name, $message );
82
-	$message = str_replace( '{username}', $user->user_login, $message );
83
-	$message = str_replace( '{user_email}', $user->user_email, $message );
84
-	$message = str_replace( '{billing_address}', "123 Test Street, Unit 222\nSomewhere Town, CA, 92101", $message );
85
-	$message = str_replace( '{date}', date( give_date_format(), current_time( 'timestamp' ) ), $message );
86
-	$message = str_replace( '{amount}', $price, $message );
87
-	$message = str_replace( '{price}', $price, $message );
88
-	$message = str_replace( '{donation}', esc_html__( 'Sample Donation Form Title', 'give' ), $message );
89
-	$message = str_replace( '{form_title}', esc_html__( 'Sample Donation Form Title - Sample Donation Level', 'give' ), $message );
90
-	$message = str_replace( '{receipt_id}', $receipt_id, $message );
91
-	$message = str_replace( '{payment_method}', $gateway, $message );
92
-	$message = str_replace( '{sitename}', get_bloginfo( 'name' ), $message );
93
-	$message = str_replace( '{payment_id}', $payment_id, $message );
94
-	$message = str_replace( '{receipt_link}', $receipt_link, $message );
95
-	$message = str_replace( '{receipt_link_url}', $receipt_link_url, $message );
96
-	$message = str_replace( '{pdf_receipt}', '<a href="#">Download Receipt</a>', $message );
97
-
98
-	return wpautop( apply_filters( 'give_email_preview_template_tags', $message ) );
80
+	$message = str_replace('{name}', $user->display_name, $message);
81
+	$message = str_replace('{fullname}', $user->display_name, $message);
82
+	$message = str_replace('{username}', $user->user_login, $message);
83
+	$message = str_replace('{user_email}', $user->user_email, $message);
84
+	$message = str_replace('{billing_address}', "123 Test Street, Unit 222\nSomewhere Town, CA, 92101", $message);
85
+	$message = str_replace('{date}', date(give_date_format(), current_time('timestamp')), $message);
86
+	$message = str_replace('{amount}', $price, $message);
87
+	$message = str_replace('{price}', $price, $message);
88
+	$message = str_replace('{donation}', esc_html__('Sample Donation Form Title', 'give'), $message);
89
+	$message = str_replace('{form_title}', esc_html__('Sample Donation Form Title - Sample Donation Level', 'give'), $message);
90
+	$message = str_replace('{receipt_id}', $receipt_id, $message);
91
+	$message = str_replace('{payment_method}', $gateway, $message);
92
+	$message = str_replace('{sitename}', get_bloginfo('name'), $message);
93
+	$message = str_replace('{payment_id}', $payment_id, $message);
94
+	$message = str_replace('{receipt_link}', $receipt_link, $message);
95
+	$message = str_replace('{receipt_link_url}', $receipt_link_url, $message);
96
+	$message = str_replace('{pdf_receipt}', '<a href="#">Download Receipt</a>', $message);
97
+
98
+	return wpautop(apply_filters('give_email_preview_template_tags', $message));
99 99
 }
100 100
 
101 101
 
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
  *
112 112
  * @return array
113 113
  */
114
-function give_email_preview_buttons_callback( $field ) {
115
-	$field_id = str_replace( '_preview_buttons', '', $field['id'] );
114
+function give_email_preview_buttons_callback($field) {
115
+	$field_id = str_replace('_preview_buttons', '', $field['id']);
116 116
 
117 117
 	ob_start();
118 118
 
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 		'<a href="%1$s" class="button-secondary" target="_blank">%2$s</a>',
121 121
 		wp_nonce_url(
122 122
 			add_query_arg(
123
-				array( 'give_action' => 'preview_email', 'email_type' => $field_id ),
123
+				array('give_action' => 'preview_email', 'email_type' => $field_id),
124 124
 				home_url()
125 125
 			), 'give-preview-email'
126 126
 		),
@@ -130,13 +130,13 @@  discard block
 block discarded – undo
130 130
 	echo sprintf(
131 131
 		' <a href="%1$s" aria-label="%2$s" class="button-secondary">%3$s</a>',
132 132
 		wp_nonce_url(
133
-				add_query_arg( array(
133
+				add_query_arg(array(
134 134
 			'give_action'  => 'send_preview_email',
135 135
 			'email_type' => $field_id,
136 136
 			'give-messages[]' => 'sent-test-email',
137
-		) ), 'give-send-preview-email' ),
138
-		esc_attr__( 'Send Test Email.', 'give' ),
139
-		esc_html__( 'Send Test Email', 'give' )
137
+		)), 'give-send-preview-email' ),
138
+		esc_attr__('Send Test Email.', 'give'),
139
+		esc_html__('Send Test Email', 'give')
140 140
 	);
141 141
 
142 142
 	echo ob_get_clean();
@@ -155,34 +155,34 @@  discard block
 block discarded – undo
155 155
 
156 156
 	//Payment receipt switcher
157 157
 	$payment_count = give_count_payments()->publish;
158
-	$payment_id    = give_check_variable( give_clean( $_GET ), 'isset', 0, 'preview_id' );
158
+	$payment_id    = give_check_variable(give_clean($_GET), 'isset', 0, 'preview_id');
159 159
 
160
-	if ( $payment_count <= 0 ) {
160
+	if ($payment_count <= 0) {
161 161
 		return false;
162 162
 	}
163 163
 
164 164
 	//Get payments.
165
-	$donations = new Give_Payments_Query( array(
165
+	$donations = new Give_Payments_Query(array(
166 166
 		'number' => 100,
167 167
 		'output' => '',
168 168
 		'fields' => 'ids'
169
-	) );
169
+	));
170 170
 	$donations = $donations->get_payments();
171
-	$options  = array();
171
+	$options = array();
172 172
 
173 173
 	// Default option.
174
-	$options[0] = esc_html__( 'No donations found.', 'give' );
174
+	$options[0] = esc_html__('No donations found.', 'give');
175 175
 
176 176
 	//Provide nice human readable options.
177
-	if ( $donations ) {
178
-		$options[0] = esc_html__( '- Select a donation -', 'give' );
179
-		foreach ( $donations as $donation_id ) {
177
+	if ($donations) {
178
+		$options[0] = esc_html__('- Select a donation -', 'give');
179
+		foreach ($donations as $donation_id) {
180 180
 
181
-			$options[ $donation_id ] = sprintf(
181
+			$options[$donation_id] = sprintf(
182 182
 				'#%1$s - %2$s - %3$s',
183 183
 				$donation_id,
184
-				give_get_donation_donor_email( $donation_id ),
185
-				get_the_title( $donation_id )
184
+				give_get_donation_donor_email($donation_id),
185
+				get_the_title($donation_id)
186 186
 			);
187 187
 		}
188 188
 	}
@@ -191,27 +191,27 @@  discard block
 block discarded – undo
191 191
 	$transaction_header = '<div style="margin:0;padding:10px 0;width:100%;background-color:#FFF;border-bottom:1px solid #eee; text-align:center;">';
192 192
 
193 193
 	// Remove payment id query param if set from request url.
194
-	$request_url_data = wp_parse_url( $_SERVER['REQUEST_URI'] );
194
+	$request_url_data = wp_parse_url($_SERVER['REQUEST_URI']);
195 195
 	$query            = $request_url_data['query'];
196
-	$query            = remove_query_arg( array( 'preview_id' ), $query );
196
+	$query            = remove_query_arg(array('preview_id'), $query);
197 197
 
198
-	$request_url = home_url( '/?' . str_replace( '', '', $query ) );
198
+	$request_url = home_url('/?'.str_replace('', '', $query));
199 199
 
200 200
 	$transaction_header .= '<script>
201 201
 				 function change_preview(){
202 202
 				  var transactions = document.getElementById("give_preview_email_payment_id");
203 203
 			        var selected_trans = transactions.options[transactions.selectedIndex];
204 204
 				        if (selected_trans){
205
-				            var url_string = "' . $request_url . '&preview_id=" + selected_trans.value;
205
+				            var url_string = "' . $request_url.'&preview_id=" + selected_trans.value;
206 206
 				                window.location = url_string;
207 207
 				        }
208 208
 				    }
209 209
 			    </script>';
210 210
 
211
-	$transaction_header .= '<label for="give_preview_email_payment_id" style="font-size:12px;color:#333;margin:0 4px 0 0;">' . esc_html__( 'Preview email with a donation:', 'give' ) . '</label>';
211
+	$transaction_header .= '<label for="give_preview_email_payment_id" style="font-size:12px;color:#333;margin:0 4px 0 0;">'.esc_html__('Preview email with a donation:', 'give').'</label>';
212 212
 
213 213
 	//The select field with 100 latest transactions
214
-	$transaction_header .= Give()->html->select( array(
214
+	$transaction_header .= Give()->html->select(array(
215 215
 		'name'             => 'preview_email_payment_id',
216 216
 		'selected'         => $payment_id,
217 217
 		'id'               => 'give_preview_email_payment_id',
@@ -221,11 +221,11 @@  discard block
 block discarded – undo
221 221
 		'select_atts'      => 'onchange="change_preview()"',
222 222
 		'show_option_all'  => false,
223 223
 		'show_option_none' => false,
224
-	) );
224
+	));
225 225
 
226 226
 	//Closing tag
227 227
 	$transaction_header .= '</div>';
228 228
 
229
-	return apply_filters( 'give_preview_email_receipt_header', $transaction_header );
229
+	return apply_filters('give_preview_email_receipt_header', $transaction_header);
230 230
 
231 231
 }
Please login to merge, or discard this patch.
includes/admin/shortcodes/shortcode-give-totals.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  */
10 10
 
11 11
 // Exit if accessed directly.
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit;
14 14
 }
15 15
 
@@ -23,10 +23,10 @@  discard block
 block discarded – undo
23 23
 	 */
24 24
 	public function __construct() {
25 25
 
26
-		$this->shortcode['title'] = __( 'Give Totals', 'give' );
27
-		$this->shortcode['label'] = __( 'Give Totals', 'give' );
26
+		$this->shortcode['title'] = __('Give Totals', 'give');
27
+		$this->shortcode['label'] = __('Give Totals', 'give');
28 28
 
29
-		parent::__construct( 'give_totals' );
29
+		parent::__construct('give_totals');
30 30
 	}
31 31
 
32 32
 	/**
@@ -39,69 +39,69 @@  discard block
 block discarded – undo
39 39
 
40 40
 		$category_options = array();
41 41
 		$category_lists   = array();
42
-		$categories       = get_terms( 'give_forms_category', apply_filters( 'give_forms_category_dropdown', array() ) );
43
-		if ( give_is_setting_enabled( give_get_option( 'categories' ) ) && ! is_wp_error( $categories ) ) {
44
-			foreach ( $categories as $category ) {
45
-				$category_options[ absint( $category->term_id ) ] = esc_html( $category->name );
42
+		$categories       = get_terms('give_forms_category', apply_filters('give_forms_category_dropdown', array()));
43
+		if (give_is_setting_enabled(give_get_option('categories')) && ! is_wp_error($categories)) {
44
+			foreach ($categories as $category) {
45
+				$category_options[absint($category->term_id)] = esc_html($category->name);
46 46
 			}
47 47
 
48 48
 			$category_lists['type']    = 'listbox';
49 49
 			$category_lists['name']    = 'cats';
50
-			$category_lists['label']   = __( 'Select a Donation Form Category:', 'give' );
51
-			$category_lists['tooltip'] = __( 'Select a Donation Form Category', 'give' );
50
+			$category_lists['label']   = __('Select a Donation Form Category:', 'give');
51
+			$category_lists['tooltip'] = __('Select a Donation Form Category', 'give');
52 52
 			$category_lists['options'] = $category_options;
53 53
 		}
54 54
 
55 55
 		$tag_options = array();
56 56
 		$tag_lists   = array();
57
-		$tags        = get_terms( 'give_forms_tag', apply_filters( 'give_forms_tag_dropdown', array() ) );
58
-		if ( give_is_setting_enabled( give_get_option( 'tags' ) ) && ! is_wp_error( $tags ) ) {
59
-			$tags = get_terms( 'give_forms_tag', apply_filters( 'give_forms_tag_dropdown', array() ) );
60
-			foreach ( $tags as $tag ) {
61
-				$tag_options[ absint( $tag->term_id ) ] = esc_html( $tag->name );
57
+		$tags        = get_terms('give_forms_tag', apply_filters('give_forms_tag_dropdown', array()));
58
+		if (give_is_setting_enabled(give_get_option('tags')) && ! is_wp_error($tags)) {
59
+			$tags = get_terms('give_forms_tag', apply_filters('give_forms_tag_dropdown', array()));
60
+			foreach ($tags as $tag) {
61
+				$tag_options[absint($tag->term_id)] = esc_html($tag->name);
62 62
 			}
63 63
 
64 64
 			$tag_lists['type']    = 'listbox';
65 65
 			$tag_lists['name']    = 'tags';
66
-			$tag_lists['label']   = __( 'Select a Donation Form Tag:', 'give' );
67
-			$tag_lists['tooltip'] = __( 'Select a Donation Form Tag', 'give' );
66
+			$tag_lists['label']   = __('Select a Donation Form Tag:', 'give');
67
+			$tag_lists['tooltip'] = __('Select a Donation Form Tag', 'give');
68 68
 			$tag_lists['options'] = $tag_options;
69 69
 		}
70 70
 
71 71
 		return array(
72 72
 			array(
73 73
 				'type' => 'container',
74
-				'html' => sprintf( '<p class="give-totals-shortcode-container-message">%s</p>',
75
-					__( 'This shortcode shows the total amount raised towards a custom goal for one or several forms regardless of whether they have goals enabled or not.', 'give' )
74
+				'html' => sprintf('<p class="give-totals-shortcode-container-message">%s</p>',
75
+					__('This shortcode shows the total amount raised towards a custom goal for one or several forms regardless of whether they have goals enabled or not.', 'give')
76 76
 				),
77 77
 			),
78 78
 			array(
79 79
 				'type' => 'container',
80
-				'html' => sprintf( '<p class="strong margin-top">%s</p>', __( 'Shortcode Configuration', 'give' ) ),
80
+				'html' => sprintf('<p class="strong margin-top">%s</p>', __('Shortcode Configuration', 'give')),
81 81
 			),
82 82
 			array(
83 83
 				'type'    => 'textbox',
84 84
 				'name'    => 'ids',
85
-				'label'   => __( 'Donation Form IDs:', 'give' ),
86
-				'tooltip' => __( 'Enter the IDs separated by commas for the donation forms you would like to combine within the totals.', 'give' ),
85
+				'label'   => __('Donation Form IDs:', 'give'),
86
+				'tooltip' => __('Enter the IDs separated by commas for the donation forms you would like to combine within the totals.', 'give'),
87 87
 			),
88 88
 			$category_lists,
89 89
 			$tag_lists,
90 90
 			array(
91 91
 				'type'     => 'textbox',
92 92
 				'name'     => 'total_goal',
93
-				'label'    => __( 'Total Goal:', 'give' ),
94
-				'tooltip'  => __( 'Enter the total goal amount that you would like to display.', 'give' ),
93
+				'label'    => __('Total Goal:', 'give'),
94
+				'tooltip'  => __('Enter the total goal amount that you would like to display.', 'give'),
95 95
 				'required' => array(
96
-					'alert' => esc_html__( 'Please enter a valid total goal amount.', 'give' ),
96
+					'alert' => esc_html__('Please enter a valid total goal amount.', 'give'),
97 97
 				),
98 98
 			),
99 99
 			array(
100 100
 				'type'      => 'textbox',
101 101
 				'name'      => 'message',
102
-				'label'     => __( 'Message:', 'give' ),
103
-				'tooltip'   => __( 'Enter a message to display encouraging donors to support the goal.', 'give' ),
104
-				'value'     => apply_filters( 'give_totals_message', __( 'Hey! We\'ve raised {total} of the {total_goal} we are trying to raise for this campaign!', 'give' ) ),
102
+				'label'     => __('Message:', 'give'),
103
+				'tooltip'   => __('Enter a message to display encouraging donors to support the goal.', 'give'),
104
+				'value'     => apply_filters('give_totals_message', __('Hey! We\'ve raised {total} of the {total_goal} we are trying to raise for this campaign!', 'give')),
105 105
 				'multiline' => true,
106 106
 				'minWidth'  => 300,
107 107
 				'minHeight' => 60,
@@ -109,24 +109,24 @@  discard block
 block discarded – undo
109 109
 			array(
110 110
 				'type'    => 'textbox',
111 111
 				'name'    => 'link',
112
-				'label'   => __( 'Link:', 'give' ),
113
-				'tooltip' => __( 'Enter a link to the main campaign donation form.', 'give' ),
112
+				'label'   => __('Link:', 'give'),
113
+				'tooltip' => __('Enter a link to the main campaign donation form.', 'give'),
114 114
 			),
115 115
 			array(
116 116
 				'type'    => 'textbox',
117 117
 				'name'    => 'link_text',
118
-				'label'   => __( 'Link Text:', 'give' ),
119
-				'tooltip' => __( 'Enter hyperlink text for the link to the main campaign donation form.', 'give' ),
120
-				'value'   => __( 'Donate!', 'give' ),
118
+				'label'   => __('Link Text:', 'give'),
119
+				'tooltip' => __('Enter hyperlink text for the link to the main campaign donation form.', 'give'),
120
+				'value'   => __('Donate!', 'give'),
121 121
 			),
122 122
 			array(
123 123
 				'type'    => 'listbox',
124 124
 				'name'    => 'progress_bar',
125
-				'label'   => __( 'Show Progress Bar:', 'give' ),
126
-				'tooltip' => __( 'Select whether you would like to show a goal progress bar.', 'give' ),
125
+				'label'   => __('Show Progress Bar:', 'give'),
126
+				'tooltip' => __('Select whether you would like to show a goal progress bar.', 'give'),
127 127
 				'options' => array(
128
-					'true'  => __( 'Show', 'give' ),
129
-					'false' => __( 'Hide', 'give' ),
128
+					'true'  => __('Show', 'give'),
129
+					'false' => __('Hide', 'give'),
130 130
 				),
131 131
 				'value'   => 'true',
132 132
 			),
Please login to merge, or discard this patch.
includes/admin/forms/dashboard-columns.php 1 patch
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -27,34 +27,34 @@  discard block
 block discarded – undo
27 27
  * @return array $form_columns Updated array of forms columns
28 28
  *  Post Type List Table
29 29
  */
30
-function give_form_columns( $give_form_columns ) {
30
+function give_form_columns($give_form_columns) {
31 31
 
32 32
 	// Standard columns
33 33
 	$give_form_columns = array(
34 34
 		'cb'            => '<input type="checkbox"/>',
35
-		'title'         => __( 'Name', 'give' ),
36
-		'form_category' => __( 'Categories', 'give' ),
37
-		'form_tag'      => __( 'Tags', 'give' ),
38
-		'price'         => __( 'Amount', 'give' ),
39
-		'goal'          => __( 'Goal', 'give' ),
40
-		'donations'     => __( 'Donations', 'give' ),
41
-		'earnings'      => __( 'Income', 'give' ),
42
-		'shortcode'     => __( 'Shortcode', 'give' ),
43
-		'date'          => __( 'Date', 'give' ),
35
+		'title'         => __('Name', 'give'),
36
+		'form_category' => __('Categories', 'give'),
37
+		'form_tag'      => __('Tags', 'give'),
38
+		'price'         => __('Amount', 'give'),
39
+		'goal'          => __('Goal', 'give'),
40
+		'donations'     => __('Donations', 'give'),
41
+		'earnings'      => __('Income', 'give'),
42
+		'shortcode'     => __('Shortcode', 'give'),
43
+		'date'          => __('Date', 'give'),
44 44
 	);
45 45
 
46 46
 	// Does the user want categories / tags?
47
-	if ( ! give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ) ) {
48
-		unset( $give_form_columns['form_category'] );
47
+	if ( ! give_is_setting_enabled(give_get_option('categories', 'disabled'))) {
48
+		unset($give_form_columns['form_category']);
49 49
 	}
50
-	if ( ! give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) ) ) {
51
-		unset( $give_form_columns['form_tag'] );
50
+	if ( ! give_is_setting_enabled(give_get_option('tags', 'disabled'))) {
51
+		unset($give_form_columns['form_tag']);
52 52
 	}
53 53
 
54
-	return apply_filters( 'give_forms_columns', $give_form_columns );
54
+	return apply_filters('give_forms_columns', $give_form_columns);
55 55
 }
56 56
 
57
-add_filter( 'manage_edit-give_forms_columns', 'give_form_columns' );
57
+add_filter('manage_edit-give_forms_columns', 'give_form_columns');
58 58
 
59 59
 /**
60 60
  * Render Give Form Columns
@@ -66,70 +66,70 @@  discard block
 block discarded – undo
66 66
  *
67 67
  * @return void
68 68
  */
69
-function give_render_form_columns( $column_name, $post_id ) {
70
-	if ( get_post_type( $post_id ) == 'give_forms' ) {
69
+function give_render_form_columns($column_name, $post_id) {
70
+	if (get_post_type($post_id) == 'give_forms') {
71 71
 
72
-		switch ( $column_name ) {
72
+		switch ($column_name) {
73 73
 			case 'form_category':
74
-				echo get_the_term_list( $post_id, 'give_forms_category', '', ', ', '' );
74
+				echo get_the_term_list($post_id, 'give_forms_category', '', ', ', '');
75 75
 				break;
76 76
 			case 'form_tag':
77
-				echo get_the_term_list( $post_id, 'give_forms_tag', '', ', ', '' );
77
+				echo get_the_term_list($post_id, 'give_forms_tag', '', ', ', '');
78 78
 				break;
79 79
 			case 'price':
80
-				if ( give_has_variable_prices( $post_id ) ) {
81
-					echo give_price_range( $post_id );
80
+				if (give_has_variable_prices($post_id)) {
81
+					echo give_price_range($post_id);
82 82
 				} else {
83
-					echo give_price( $post_id, false );
84
-					printf( '<input type="hidden" class="formprice-%1$s" value="%2$s" />', esc_attr( $post_id ), esc_attr( give_get_form_price( $post_id ) ) );
83
+					echo give_price($post_id, false);
84
+					printf('<input type="hidden" class="formprice-%1$s" value="%2$s" />', esc_attr($post_id), esc_attr(give_get_form_price($post_id)));
85 85
 				}
86 86
 				break;
87 87
 			case 'goal':
88
-				if ( give_is_setting_enabled( give_get_meta( $post_id, '_give_goal_option', true ) ) ) {
88
+				if (give_is_setting_enabled(give_get_meta($post_id, '_give_goal_option', true))) {
89 89
 
90
-					echo give_admin_form_goal_stats( $post_id );
90
+					echo give_admin_form_goal_stats($post_id);
91 91
 
92 92
 				} else {
93
-					_e( 'No Goal Set', 'give' );
93
+					_e('No Goal Set', 'give');
94 94
 				}
95 95
 
96 96
 				printf(
97 97
 					'<input type="hidden" class="formgoal-%1$s" value="%2$s" />',
98
-					esc_attr( $post_id ),
99
-					give_get_form_goal( $post_id )
98
+					esc_attr($post_id),
99
+					give_get_form_goal($post_id)
100 100
 				);
101 101
 
102 102
 				break;
103 103
 			case 'donations':
104
-				if ( current_user_can( 'view_give_form_stats', $post_id ) ) {
104
+				if (current_user_can('view_give_form_stats', $post_id)) {
105 105
 					printf(
106 106
 						'<a href="%1$s">%2$s</a>',
107
-						esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&form_id=' . $post_id ) ),
108
-						give_get_form_sales_stats( $post_id )
107
+						esc_url(admin_url('edit.php?post_type=give_forms&page=give-payment-history&form_id='.$post_id)),
108
+						give_get_form_sales_stats($post_id)
109 109
 					);
110 110
 				} else {
111 111
 					echo '-';
112 112
 				}
113 113
 				break;
114 114
 			case 'earnings':
115
-				if ( current_user_can( 'view_give_form_stats', $post_id ) ) {
115
+				if (current_user_can('view_give_form_stats', $post_id)) {
116 116
 					printf(
117 117
 						'<a href="%1$s">%2$s</a>',
118
-						esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-reports&tab=forms&form-id=' . $post_id ) ),
119
-						give_currency_filter( give_format_amount( give_get_form_earnings_stats( $post_id ), array( 'sanitize' => false ) ) )
118
+						esc_url(admin_url('edit.php?post_type=give_forms&page=give-reports&tab=forms&form-id='.$post_id)),
119
+						give_currency_filter(give_format_amount(give_get_form_earnings_stats($post_id), array('sanitize' => false)))
120 120
 					);
121 121
 				} else {
122 122
 					echo '-';
123 123
 				}
124 124
 				break;
125 125
 			case 'shortcode':
126
-				printf( '<input onclick="this.setSelectionRange(0, this.value.length)" type="text" class="shortcode-input" readonly="" value="[give_form id=&#34;%s&#34;]"', absint( $post_id ) );
126
+				printf('<input onclick="this.setSelectionRange(0, this.value.length)" type="text" class="shortcode-input" readonly="" value="[give_form id=&#34;%s&#34;]"', absint($post_id));
127 127
 				break;
128 128
 		}// End switch().
129 129
 	}// End if().
130 130
 }
131 131
 
132
-add_action( 'manage_posts_custom_column', 'give_render_form_columns', 10, 2 );
132
+add_action('manage_posts_custom_column', 'give_render_form_columns', 10, 2);
133 133
 
134 134
 /**
135 135
  * Registers the sortable columns in the list table
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
  *
141 141
  * @return array $columns Array of sortable columns
142 142
  */
143
-function give_sortable_form_columns( $columns ) {
143
+function give_sortable_form_columns($columns) {
144 144
 	$columns['price']     = 'amount';
145 145
 	$columns['sales']     = 'sales';
146 146
 	$columns['earnings']  = 'earnings';
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 	return $columns;
151 151
 }
152 152
 
153
-add_filter( 'manage_edit-give_forms_sortable_columns', 'give_sortable_form_columns' );
153
+add_filter('manage_edit-give_forms_sortable_columns', 'give_sortable_form_columns');
154 154
 
155 155
 /**
156 156
  * Sorts Columns in the Forms List Table
@@ -161,13 +161,13 @@  discard block
 block discarded – undo
161 161
  *
162 162
  * @return array $vars Array of all the sort variables.
163 163
  */
164
-function give_sort_forms( $vars ) {
164
+function give_sort_forms($vars) {
165 165
 	// Check if we're viewing the "give_forms" post type.
166
-	if ( ! isset( $vars['post_type'] ) || ! isset( $vars['orderby'] ) || 'give_forms' !== $vars['post_type'] ) {
166
+	if ( ! isset($vars['post_type']) || ! isset($vars['orderby']) || 'give_forms' !== $vars['post_type']) {
167 167
 		return $vars;
168 168
 	}
169 169
 
170
-	switch ( $vars['orderby'] ) {
170
+	switch ($vars['orderby']) {
171 171
 		// Check if 'orderby' is set to "sales".
172 172
 		case 'sales':
173 173
 			$vars = array_merge(
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 
193 193
 		// Check if "orderby" is set to "price/amount".
194 194
 		case 'amount':
195
-			$multi_level_meta_key = ( 'asc' === $vars['order'] ) ? '_give_levels_minimum_amount' : '_give_levels_maximum_amount';
195
+			$multi_level_meta_key = ('asc' === $vars['order']) ? '_give_levels_minimum_amount' : '_give_levels_maximum_amount';
196 196
 
197 197
 			$vars['orderby']    = 'meta_value_num';
198 198
 			$vars['meta_query'] = array(
@@ -244,17 +244,17 @@  discard block
 block discarded – undo
244 244
  *
245 245
  * @return array       Array of all sort variables.
246 246
  */
247
-function give_filter_forms( $vars ) {
248
-	if ( isset( $vars['post_type'] ) && 'give_forms' == $vars['post_type'] ) {
247
+function give_filter_forms($vars) {
248
+	if (isset($vars['post_type']) && 'give_forms' == $vars['post_type']) {
249 249
 
250 250
 		// If an author ID was passed, use it
251
-		if ( isset( $_REQUEST['author'] ) && ! current_user_can( 'view_give_reports' ) ) {
251
+		if (isset($_REQUEST['author']) && ! current_user_can('view_give_reports')) {
252 252
 
253 253
 			$author_id = $_REQUEST['author'];
254
-			if ( (int) $author_id !== get_current_user_id() ) {
255
-				wp_die( esc_html__( 'You do not have permission to view this data.', 'give' ), esc_html__( 'Error', 'give' ), array(
254
+			if ((int) $author_id !== get_current_user_id()) {
255
+				wp_die(esc_html__('You do not have permission to view this data.', 'give'), esc_html__('Error', 'give'), array(
256 256
 					'response' => 403,
257
-				) );
257
+				));
258 258
 			}
259 259
 			$vars = array_merge(
260 260
 				$vars,
@@ -278,11 +278,11 @@  discard block
 block discarded – undo
278 278
  * @return void
279 279
  */
280 280
 function give_forms_load() {
281
-	add_filter( 'request', 'give_sort_forms' );
282
-	add_filter( 'request', 'give_filter_forms' );
281
+	add_filter('request', 'give_sort_forms');
282
+	add_filter('request', 'give_filter_forms');
283 283
 }
284 284
 
285
-add_action( 'load-edit.php', 'give_forms_load', 9999 );
285
+add_action('load-edit.php', 'give_forms_load', 9999);
286 286
 
287 287
 /**
288 288
  * Remove Forms Month Filter
@@ -296,17 +296,17 @@  discard block
 block discarded – undo
296 296
  * @global      $typenow The post type we are viewing.
297 297
  * @return array Empty array disables the dropdown.
298 298
  */
299
-function give_remove_month_filter( $dates ) {
299
+function give_remove_month_filter($dates) {
300 300
 	global $typenow;
301 301
 
302
-	if ( $typenow == 'give_forms' ) {
302
+	if ($typenow == 'give_forms') {
303 303
 		$dates = array();
304 304
 	}
305 305
 
306 306
 	return $dates;
307 307
 }
308 308
 
309
-add_filter( 'months_dropdown_results', 'give_remove_month_filter', 99 );
309
+add_filter('months_dropdown_results', 'give_remove_month_filter', 99);
310 310
 
311 311
 /**
312 312
  * Updates price when saving post
@@ -318,33 +318,33 @@  discard block
 block discarded – undo
318 318
  *
319 319
  * @return int|null
320 320
  */
321
-function give_price_save_quick_edit( $post_id ) {
322
-	if ( ! isset( $_POST['post_type'] ) || 'give_forms' !== $_POST['post_type'] ) {
321
+function give_price_save_quick_edit($post_id) {
322
+	if ( ! isset($_POST['post_type']) || 'give_forms' !== $_POST['post_type']) {
323 323
 		return;
324 324
 	}
325
-	if ( ! current_user_can( 'edit_post', $post_id ) ) {
325
+	if ( ! current_user_can('edit_post', $post_id)) {
326 326
 		return $post_id;
327 327
 	}
328
-	if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
328
+	if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
329 329
 		return $post_id;
330 330
 	}
331 331
 
332
-	if ( isset( $_REQUEST['_give_regprice'] ) ) {
333
-		give_update_meta( $post_id, '_give_set_price', give_sanitize_amount_for_db( strip_tags( stripslashes( $_REQUEST['_give_regprice'] ) ) ) );
332
+	if (isset($_REQUEST['_give_regprice'])) {
333
+		give_update_meta($post_id, '_give_set_price', give_sanitize_amount_for_db(strip_tags(stripslashes($_REQUEST['_give_regprice']))));
334 334
 	}
335 335
 
336 336
 	// Override the Donation minimum amount.
337 337
 	if (
338
-		isset( $_REQUEST['_give_custom_amount'], $_REQUEST['_give_set_price'], $_REQUEST['_give_price_option'], $_REQUEST['_give_custom_amount_range'] )
338
+		isset($_REQUEST['_give_custom_amount'], $_REQUEST['_give_set_price'], $_REQUEST['_give_price_option'], $_REQUEST['_give_custom_amount_range'])
339 339
 		&& 'set' === $_REQUEST['_give_price_option']
340
-		&& give_is_setting_enabled( $_REQUEST['_give_custom_amount'] )
341
-		&& give_maybe_sanitize_amount( $_REQUEST['_give_set_price'] ) < give_maybe_sanitize_amount( $_REQUEST['_give_custom_amount_range']['minimum'] )
340
+		&& give_is_setting_enabled($_REQUEST['_give_custom_amount'])
341
+		&& give_maybe_sanitize_amount($_REQUEST['_give_set_price']) < give_maybe_sanitize_amount($_REQUEST['_give_custom_amount_range']['minimum'])
342 342
 	) {
343
-		give_update_meta( $post_id, '_give_custom_amount_range_minimum', give_sanitize_amount_for_db( $_REQUEST['_give_set_price'] ) );
343
+		give_update_meta($post_id, '_give_custom_amount_range_minimum', give_sanitize_amount_for_db($_REQUEST['_give_set_price']));
344 344
 	}
345 345
 }
346 346
 
347
-add_action( 'save_post', 'give_price_save_quick_edit' );
347
+add_action('save_post', 'give_price_save_quick_edit');
348 348
 
349 349
 /**
350 350
  * Process bulk edit actions via AJAX
@@ -354,18 +354,18 @@  discard block
 block discarded – undo
354 354
  */
355 355
 function give_save_bulk_edit() {
356 356
 
357
-	$post_ids = ( isset( $_POST['post_ids'] ) && ! empty( $_POST['post_ids'] ) ) ? $_POST['post_ids'] : array();
357
+	$post_ids = (isset($_POST['post_ids']) && ! empty($_POST['post_ids'])) ? $_POST['post_ids'] : array();
358 358
 
359
-	if ( ! empty( $post_ids ) && is_array( $post_ids ) ) {
360
-		$price = isset( $_POST['price'] ) ? strip_tags( stripslashes( $_POST['price'] ) ) : 0;
361
-		foreach ( $post_ids as $post_id ) {
359
+	if ( ! empty($post_ids) && is_array($post_ids)) {
360
+		$price = isset($_POST['price']) ? strip_tags(stripslashes($_POST['price'])) : 0;
361
+		foreach ($post_ids as $post_id) {
362 362
 
363
-			if ( ! current_user_can( 'edit_post', $post_id ) ) {
363
+			if ( ! current_user_can('edit_post', $post_id)) {
364 364
 				continue;
365 365
 			}
366 366
 
367
-			if ( ! empty( $price ) ) {
368
-				give_update_meta( $post_id, '_give_set_price', give_sanitize_amount_for_db( $price ) );
367
+			if ( ! empty($price)) {
368
+				give_update_meta($post_id, '_give_set_price', give_sanitize_amount_for_db($price));
369 369
 			}
370 370
 		}
371 371
 	}
@@ -373,4 +373,4 @@  discard block
 block discarded – undo
373 373
 	die();
374 374
 }
375 375
 
376
-add_action( 'wp_ajax_give_save_bulk_edit', 'give_save_bulk_edit' );
376
+add_action('wp_ajax_give_save_bulk_edit', 'give_save_bulk_edit');
Please login to merge, or discard this patch.
includes/admin/abstract-admin-settings-page.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -9,11 +9,11 @@  discard block
 block discarded – undo
9 9
  * @since       1.8
10 10
  */
11 11
 
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit; // Exit if accessed directly
14 14
 }
15 15
 
16
-if ( ! class_exists( 'Give_Settings_Page' ) ) :
16
+if ( ! class_exists('Give_Settings_Page')) :
17 17
 
18 18
 	/**
19 19
 	 * Give_Settings_Page.
@@ -70,25 +70,25 @@  discard block
 block discarded – undo
70 70
 			// Get current setting page.
71 71
 			$this->current_setting_page = give_get_current_setting_page();
72 72
 
73
-			add_filter( "give_default_setting_tab_section_{$this->id}", array( $this, 'set_default_setting_tab' ), 10 );
74
-			add_filter( "{$this->current_setting_page}_tabs_array", array( $this, 'add_settings_page' ), 20 );
75
-			add_action( "{$this->current_setting_page}_settings_{$this->id}_page", array( $this, 'output' ) );
73
+			add_filter("give_default_setting_tab_section_{$this->id}", array($this, 'set_default_setting_tab'), 10);
74
+			add_filter("{$this->current_setting_page}_tabs_array", array($this, 'add_settings_page'), 20);
75
+			add_action("{$this->current_setting_page}_settings_{$this->id}_page", array($this, 'output'));
76 76
 
77 77
 			// Output section only if exist.
78 78
 			$sections = $this->get_sections();
79
-			if ( ! empty( $sections ) ) {
80
-				add_action( "{$this->current_setting_page}_sections_{$this->id}_page", array(
79
+			if ( ! empty($sections)) {
80
+				add_action("{$this->current_setting_page}_sections_{$this->id}_page", array(
81 81
 					$this,
82 82
 					'output_sections',
83
-				) );
83
+				));
84 84
 			}
85 85
 
86 86
 			// Save hide button by default.
87 87
 			$GLOBALS['give_hide_save_button'] = true;
88 88
 
89 89
 			// Enable saving feature.
90
-			if ( $this->enable_save ) {
91
-				add_action( "{$this->current_setting_page}_save_{$this->id}", array( $this, 'save' ) );
90
+			if ($this->enable_save) {
91
+				add_action("{$this->current_setting_page}_save_{$this->id}", array($this, 'save'));
92 92
 			}
93 93
 		}
94 94
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 		 *
114 114
 		 * @return string
115 115
 		 */
116
-		function set_default_setting_tab( $setting_tab ) {
116
+		function set_default_setting_tab($setting_tab) {
117 117
 			return $this->default_tab;
118 118
 		}
119 119
 
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
 		 *
127 127
 		 * @return array
128 128
 		 */
129
-		public function add_settings_page( $pages ) {
130
-			$pages[ $this->id ] = $this->label;
129
+		public function add_settings_page($pages) {
130
+			$pages[$this->id] = $this->label;
131 131
 
132 132
 			return $pages;
133 133
 		}
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 			 *
147 147
 			 * @param  array $settings
148 148
 			 */
149
-			$settings = apply_filters( 'give_get_settings_' . $this->id, array() );
149
+			$settings = apply_filters('give_get_settings_'.$this->id, array());
150 150
 
151 151
 			// Output.
152 152
 			return $settings;
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 		 * @return array
160 160
 		 */
161 161
 		public function get_sections() {
162
-			return apply_filters( 'give_get_sections_' . $this->id, array() );
162
+			return apply_filters('give_get_sections_'.$this->id, array());
163 163
 		}
164 164
 
165 165
 		/**
@@ -176,40 +176,40 @@  discard block
 block discarded – undo
176 176
 			$sections = $this->get_sections();
177 177
 
178 178
 			// Bailout.
179
-			if ( empty( $sections ) ) {
179
+			if (empty($sections)) {
180 180
 				return;
181 181
 			}
182 182
 
183 183
 			// Show section settings only if setting section exist.
184
-			if ( $current_section && ! in_array( $current_section, array_keys( $sections ), true ) ) {
185
-				echo wp_kses_post( '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>' );
184
+			if ($current_section && ! in_array($current_section, array_keys($sections), true)) {
185
+				echo wp_kses_post('<div class="error"><p>'.__('Oops, this settings page does not exist.', 'give').'</p></div>');
186 186
 				$GLOBALS['give_hide_save_button'] = true;
187 187
 
188 188
 				return;
189 189
 			}
190 190
 
191
-			if ( is_null( $this->current_setting_page ) ) {
191
+			if (is_null($this->current_setting_page)) {
192 192
 				$this->current_setting_page = give_get_current_setting_page();
193 193
 			}
194 194
 
195 195
 			$section_list = array();
196
-			foreach ( $sections as $id => $label ) {
196
+			foreach ($sections as $id => $label) {
197 197
 				/**
198 198
 				 * Fire the filter to hide particular section on tab.
199 199
 				 *
200 200
 				 * @since 2.0
201 201
 				 */
202
-				if ( apply_filters( "give_hide_section_{$id}_on_{$this->id}_page", false, $sections, $this->id ) ) {
202
+				if (apply_filters("give_hide_section_{$id}_on_{$this->id}_page", false, $sections, $this->id)) {
203 203
 					continue;
204 204
 				}
205 205
 
206
-				$section_list[] = '<li><a href="' . admin_url( 'edit.php?post_type=give_forms&page=' . $this->current_setting_page . '&tab=' . $this->id . '&section=' . sanitize_title( $id ) ) . '" class="' . ( $current_section === $id ? 'current' : '' ) . '">' . $label . '</a>';
206
+				$section_list[] = '<li><a href="'.admin_url('edit.php?post_type=give_forms&page='.$this->current_setting_page.'&tab='.$this->id.'&section='.sanitize_title($id)).'" class="'.($current_section === $id ? 'current' : '').'">'.$label.'</a>';
207 207
 			}
208 208
 
209
-			echo wp_kses_post( sprintf(
209
+			echo wp_kses_post(sprintf(
210 210
 				'<ul class="give-subsubsub">%s</ul><br class="clear" /><hr>',
211
-				implode( ' | </li>', $section_list )
212
-			) );
211
+				implode(' | </li>', $section_list)
212
+			));
213 213
 		}
214 214
 
215 215
 		/**
@@ -221,13 +221,13 @@  discard block
 block discarded – undo
221 221
 		 * @return void
222 222
 		 */
223 223
 		public function output() {
224
-			if ( $this->enable_save ) {
224
+			if ($this->enable_save) {
225 225
 				$GLOBALS['give_hide_save_button'] = false;
226 226
 			}
227 227
 
228 228
 			$settings = $this->get_settings();
229 229
 
230
-			Give_Admin_Settings::output_fields( $settings, 'give_settings' );
230
+			Give_Admin_Settings::output_fields($settings, 'give_settings');
231 231
 		}
232 232
 
233 233
 		/**
@@ -245,8 +245,8 @@  discard block
 block discarded – undo
245 245
 			 *
246 246
 			 * @since 2.1
247 247
 			 */
248
-			if ( apply_filters( "give_save_options_{$this->id}_{$current_section}", true ) ) {
249
-				Give_Admin_Settings::save_fields( $settings, 'give_settings' );
248
+			if (apply_filters("give_save_options_{$this->id}_{$current_section}", true)) {
249
+				Give_Admin_Settings::save_fields($settings, 'give_settings');
250 250
 			}
251 251
 
252 252
 			/**
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 			 *
255 255
 			 * @since 1.8
256 256
 			 */
257
-			do_action( 'give_update_options_' . $this->id . '_' . $current_section );
257
+			do_action('give_update_options_'.$this->id.'_'.$current_section);
258 258
 		}
259 259
 
260 260
 		/**
@@ -271,11 +271,11 @@  discard block
 block discarded – undo
271 271
 			$section         = $this->get_sections();
272 272
 			$current_section = give_get_current_setting_section();
273 273
 
274
-			if ( array_key_exists( $current_section, $section ) ) {
275
-				$heading[] = $section[ $current_section ];
274
+			if (array_key_exists($current_section, $section)) {
275
+				$heading[] = $section[$current_section];
276 276
 			}
277 277
 
278
-			return array_unique( $heading );
278
+			return array_unique($heading);
279 279
 		}
280 280
 
281 281
 		/**
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 		public function get_heading_html() {
290 290
 			return sprintf(
291 291
 				'<h1 class="wp-heading-inline">%s</h1><hr class="wp-header-end">',
292
-				implode( ' <span class="give-settings-heading-sep dashicons dashicons-arrow-right-alt2"></span> ', $this->get_heading() )
292
+				implode(' <span class="give-settings-heading-sep dashicons dashicons-arrow-right-alt2"></span> ', $this->get_heading())
293 293
 			);
294 294
 		}
295 295
 	}
Please login to merge, or discard this patch.
includes/admin/emails/filters.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -19,28 +19,28 @@  discard block
 block discarded – undo
19 19
  *
20 20
  * @return array
21 21
  */
22
-function give_email_notification_row_actions_callback( $row_actions, $email ) {
23
-	if( Give_Email_Notification_Util::is_email_preview( $email ) ) {
22
+function give_email_notification_row_actions_callback($row_actions, $email) {
23
+	if (Give_Email_Notification_Util::is_email_preview($email)) {
24 24
 		$preview_link = sprintf(
25 25
 			'<a href="%1$s" target="_blank">%2$s</a>',
26 26
 			wp_nonce_url(
27 27
 				add_query_arg(
28
-					array( 'give_action' => 'preview_email', 'email_type' => $email->config['id'] ),
28
+					array('give_action' => 'preview_email', 'email_type' => $email->config['id']),
29 29
 					home_url()
30 30
 				), 'give-preview-email'
31 31
 			),
32
-			__( 'Preview', 'give' )
32
+			__('Preview', 'give')
33 33
 		);
34 34
 
35 35
 		$send_preview_email_link = sprintf(
36 36
 			'<a href="%1$s">%2$s</a>',
37 37
 			wp_nonce_url(
38
-				add_query_arg( array(
38
+				add_query_arg(array(
39 39
 					'give_action'  => 'send_preview_email',
40 40
 					'email_type' => $email->config['id'],
41 41
 					'give-messages[]' => 'sent-test-email',
42
-				) ), 'give-send-preview-email' ),
43
-			__( 'Send test email', 'give' )
42
+				)), 'give-send-preview-email' ),
43
+			__('Send test email', 'give')
44 44
 		);
45 45
 
46 46
 		$row_actions['email_preview'] = $preview_link;
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 
50 50
 	return $row_actions;
51 51
 }
52
-add_filter( 'give_email_notification_row_actions', 'give_email_notification_row_actions_callback', 10, 2 );
52
+add_filter('give_email_notification_row_actions', 'give_email_notification_row_actions_callback', 10, 2);
53 53
 
54 54
 /**
55 55
  * This help to decode all email template tags.
@@ -61,12 +61,12 @@  discard block
 block discarded – undo
61 61
  *
62 62
  * @return string
63 63
  */
64
-function give_decode_email_tags( $message, $email_obj ) {
65
-	if ( ! empty( $email_obj->tag_args ) ) {
66
-		$message = give_do_email_tags( $message, $email_obj->tag_args );
64
+function give_decode_email_tags($message, $email_obj) {
65
+	if ( ! empty($email_obj->tag_args)) {
66
+		$message = give_do_email_tags($message, $email_obj->tag_args);
67 67
 	}
68 68
 
69 69
 	return $message;
70 70
 }
71 71
 
72
-add_filter( 'give_email_message', 'give_decode_email_tags', 10, 2 );
73 72
\ No newline at end of file
73
+add_filter('give_email_message', 'give_decode_email_tags', 10, 2);
74 74
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-give-roles.php 1 patch
Spacing   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
 	 * @access public
36 36
 	 */
37 37
 	public function __construct() {
38
-		add_filter( 'give_map_meta_cap', array( $this, 'meta_caps' ), 10, 4 );
39
-		add_filter( 'woocommerce_disable_admin_bar', array( $this, 'manage_admin_dashboard' ), 10, 1 );
40
-		add_filter( 'woocommerce_prevent_admin_access', array( $this, 'manage_admin_dashboard' ), 10 );
38
+		add_filter('give_map_meta_cap', array($this, 'meta_caps'), 10, 4);
39
+		add_filter('woocommerce_disable_admin_bar', array($this, 'manage_admin_dashboard'), 10, 1);
40
+		add_filter('woocommerce_prevent_admin_access', array($this, 'manage_admin_dashboard'), 10);
41 41
 	}
42 42
 
43 43
 	/**
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	 * @return void
52 52
 	 */
53 53
 	public function add_roles() {
54
-		add_role( 'give_manager', __( 'Give Manager', 'give' ), array(
54
+		add_role('give_manager', __('Give Manager', 'give'), array(
55 55
 			'read'                   => true,
56 56
 			'edit_posts'             => true,
57 57
 			'delete_posts'           => true,
@@ -80,25 +80,25 @@  discard block
 block discarded – undo
80 80
 			'publish_posts'          => true,
81 81
 			'read_private_pages'     => true,
82 82
 			'read_private_posts'     => true,
83
-		) );
83
+		));
84 84
 
85
-		add_role( 'give_accountant', __( 'Give Accountant', 'give' ), array(
85
+		add_role('give_accountant', __('Give Accountant', 'give'), array(
86 86
 			'read'         => true,
87 87
 			'edit_posts'   => false,
88 88
 			'delete_posts' => false,
89
-		) );
89
+		));
90 90
 
91
-		add_role( 'give_worker', __( 'Give Worker', 'give' ), array(
91
+		add_role('give_worker', __('Give Worker', 'give'), array(
92 92
 			'read'         => true,
93 93
 			'edit_posts'   => true,
94 94
 			'edit_pages'   => true,
95 95
 			'upload_files' => true,
96 96
 			'delete_posts' => false,
97
-		) );
97
+		));
98 98
 
99
-		add_role( 'give_donor', __( 'Give Donor', 'give' ), array(
99
+		add_role('give_donor', __('Give Donor', 'give'), array(
100 100
 			'read' => true,
101
-		) );
101
+		));
102 102
 
103 103
 	}
104 104
 
@@ -117,54 +117,54 @@  discard block
 block discarded – undo
117 117
 	public function add_caps() {
118 118
 		global $wp_roles;
119 119
 
120
-		if ( class_exists( 'WP_Roles' ) ) {
121
-			if ( ! isset( $wp_roles ) ) {
120
+		if (class_exists('WP_Roles')) {
121
+			if ( ! isset($wp_roles)) {
122 122
 				$wp_roles = new WP_Roles();
123 123
 			}
124 124
 		}
125 125
 
126
-		if ( is_object( $wp_roles ) ) {
127
-			$wp_roles->add_cap( 'give_manager', 'view_give_reports' );
128
-			$wp_roles->add_cap( 'give_manager', 'view_give_sensitive_data' );
129
-			$wp_roles->add_cap( 'give_manager', 'export_give_reports' );
130
-			$wp_roles->add_cap( 'give_manager', 'manage_give_settings' );
131
-			$wp_roles->add_cap( 'give_manager', 'view_give_payments' );
126
+		if (is_object($wp_roles)) {
127
+			$wp_roles->add_cap('give_manager', 'view_give_reports');
128
+			$wp_roles->add_cap('give_manager', 'view_give_sensitive_data');
129
+			$wp_roles->add_cap('give_manager', 'export_give_reports');
130
+			$wp_roles->add_cap('give_manager', 'manage_give_settings');
131
+			$wp_roles->add_cap('give_manager', 'view_give_payments');
132 132
 
133
-			$wp_roles->add_cap( 'administrator', 'view_give_reports' );
134
-			$wp_roles->add_cap( 'administrator', 'view_give_sensitive_data' );
135
-			$wp_roles->add_cap( 'administrator', 'export_give_reports' );
136
-			$wp_roles->add_cap( 'administrator', 'manage_give_settings' );
137
-			$wp_roles->add_cap( 'administrator', 'view_give_payments' );
133
+			$wp_roles->add_cap('administrator', 'view_give_reports');
134
+			$wp_roles->add_cap('administrator', 'view_give_sensitive_data');
135
+			$wp_roles->add_cap('administrator', 'export_give_reports');
136
+			$wp_roles->add_cap('administrator', 'manage_give_settings');
137
+			$wp_roles->add_cap('administrator', 'view_give_payments');
138 138
 
139 139
 			// Add the main post type capabilities.
140 140
 			$capabilities = $this->get_core_caps();
141
-			foreach ( $capabilities as $cap_group ) {
142
-				foreach ( $cap_group as $cap ) {
143
-					$wp_roles->add_cap( 'administrator', $cap );
144
-					$wp_roles->add_cap( 'give_manager', $cap );
141
+			foreach ($capabilities as $cap_group) {
142
+				foreach ($cap_group as $cap) {
143
+					$wp_roles->add_cap('administrator', $cap);
144
+					$wp_roles->add_cap('give_manager', $cap);
145 145
 				}
146 146
 			}
147 147
 
148 148
 			// Add Capabilities to Give Workers User Role.
149
-			$wp_roles->add_cap( 'give_worker', 'edit_give_payments' );
150
-			$wp_roles->add_cap( 'give_worker', 'delete_give_forms' );
151
-			$wp_roles->add_cap( 'give_worker', 'delete_others_give_forms' );
152
-			$wp_roles->add_cap( 'give_worker', 'delete_private_give_forms' );
153
-			$wp_roles->add_cap( 'give_worker', 'delete_published_give_forms' );
154
-			$wp_roles->add_cap( 'give_worker', 'edit_give_forms' );
155
-			$wp_roles->add_cap( 'give_worker', 'edit_others_give_forms' );
156
-			$wp_roles->add_cap( 'give_worker', 'edit_private_give_forms' );
157
-			$wp_roles->add_cap( 'give_worker', 'edit_published_give_forms' );
158
-			$wp_roles->add_cap( 'give_worker', 'publish_give_forms' );
159
-			$wp_roles->add_cap( 'give_worker', 'read_private_give_forms' );
149
+			$wp_roles->add_cap('give_worker', 'edit_give_payments');
150
+			$wp_roles->add_cap('give_worker', 'delete_give_forms');
151
+			$wp_roles->add_cap('give_worker', 'delete_others_give_forms');
152
+			$wp_roles->add_cap('give_worker', 'delete_private_give_forms');
153
+			$wp_roles->add_cap('give_worker', 'delete_published_give_forms');
154
+			$wp_roles->add_cap('give_worker', 'edit_give_forms');
155
+			$wp_roles->add_cap('give_worker', 'edit_others_give_forms');
156
+			$wp_roles->add_cap('give_worker', 'edit_private_give_forms');
157
+			$wp_roles->add_cap('give_worker', 'edit_published_give_forms');
158
+			$wp_roles->add_cap('give_worker', 'publish_give_forms');
159
+			$wp_roles->add_cap('give_worker', 'read_private_give_forms');
160 160
 
161 161
 			// Add Capabilities to Give Accountant User Role.
162
-			$wp_roles->add_cap( 'give_accountant', 'edit_give_forms' );
163
-			$wp_roles->add_cap( 'give_accountant', 'read_private_give_forms' );
164
-			$wp_roles->add_cap( 'give_accountant', 'view_give_reports' );
165
-			$wp_roles->add_cap( 'give_accountant', 'export_give_reports' );
166
-			$wp_roles->add_cap( 'give_accountant', 'edit_give_payments' );
167
-			$wp_roles->add_cap( 'give_accountant', 'view_give_payments' );
162
+			$wp_roles->add_cap('give_accountant', 'edit_give_forms');
163
+			$wp_roles->add_cap('give_accountant', 'read_private_give_forms');
164
+			$wp_roles->add_cap('give_accountant', 'view_give_reports');
165
+			$wp_roles->add_cap('give_accountant', 'export_give_reports');
166
+			$wp_roles->add_cap('give_accountant', 'edit_give_payments');
167
+			$wp_roles->add_cap('give_accountant', 'view_give_payments');
168 168
 
169 169
 		}
170 170
 	}
@@ -182,10 +182,10 @@  discard block
 block discarded – undo
182 182
 	public function get_core_caps() {
183 183
 		$capabilities = array();
184 184
 
185
-		$capability_types = array( 'give_form', 'give_payment' );
185
+		$capability_types = array('give_form', 'give_payment');
186 186
 
187
-		foreach ( $capability_types as $capability_type ) {
188
-			$capabilities[ $capability_type ] = array(
187
+		foreach ($capability_types as $capability_type) {
188
+			$capabilities[$capability_type] = array(
189 189
 				// Post type.
190 190
 				"edit_{$capability_type}",
191 191
 				"read_{$capability_type}",
@@ -231,22 +231,22 @@  discard block
 block discarded – undo
231 231
 	 *
232 232
 	 * @return array  $caps    Meta capabilities.
233 233
 	 */
234
-	public function meta_caps( $caps, $cap, $user_id, $args ) {
234
+	public function meta_caps($caps, $cap, $user_id, $args) {
235 235
 
236
-		switch ( $cap ) {
236
+		switch ($cap) {
237 237
 
238 238
 			case 'view_give_form_stats' :
239 239
 
240
-				if ( empty( $args[0] ) ) {
240
+				if (empty($args[0])) {
241 241
 					break;
242 242
 				}
243 243
 
244
-				$form = get_post( $args[0] );
245
-				if ( empty( $form ) ) {
244
+				$form = get_post($args[0]);
245
+				if (empty($form)) {
246 246
 					break;
247 247
 				}
248 248
 
249
-				if ( user_can( $user_id, 'view_give_reports' ) || $user_id == $form->post_author ) {
249
+				if (user_can($user_id, 'view_give_reports') || $user_id == $form->post_author) {
250 250
 					$caps = array();
251 251
 				}
252 252
 
@@ -273,57 +273,57 @@  discard block
 block discarded – undo
273 273
 
274 274
 		global $wp_roles;
275 275
 
276
-		if ( class_exists( 'WP_Roles' ) ) {
277
-			if ( ! isset( $wp_roles ) ) {
276
+		if (class_exists('WP_Roles')) {
277
+			if ( ! isset($wp_roles)) {
278 278
 				$wp_roles = new WP_Roles();
279 279
 			}
280 280
 		}
281 281
 
282
-		if ( is_object( $wp_roles ) ) {
282
+		if (is_object($wp_roles)) {
283 283
 			// Give Manager Capabilities.
284
-			$wp_roles->remove_cap( 'give_manager', 'view_give_reports' );
285
-			$wp_roles->remove_cap( 'give_manager', 'view_give_sensitive_data' );
286
-			$wp_roles->remove_cap( 'give_manager', 'export_give_reports' );
287
-			$wp_roles->remove_cap( 'give_manager', 'manage_give_settings' );
284
+			$wp_roles->remove_cap('give_manager', 'view_give_reports');
285
+			$wp_roles->remove_cap('give_manager', 'view_give_sensitive_data');
286
+			$wp_roles->remove_cap('give_manager', 'export_give_reports');
287
+			$wp_roles->remove_cap('give_manager', 'manage_give_settings');
288 288
 
289 289
 			// Site Administrator Capabilities.
290
-			$wp_roles->remove_cap( 'administrator', 'view_give_reports' );
291
-			$wp_roles->remove_cap( 'administrator', 'view_give_sensitive_data' );
292
-			$wp_roles->remove_cap( 'administrator', 'export_give_reports' );
293
-			$wp_roles->remove_cap( 'administrator', 'manage_give_settings' );
294
-			$wp_roles->remove_cap( 'administrator', 'view_give_payments' );
290
+			$wp_roles->remove_cap('administrator', 'view_give_reports');
291
+			$wp_roles->remove_cap('administrator', 'view_give_sensitive_data');
292
+			$wp_roles->remove_cap('administrator', 'export_give_reports');
293
+			$wp_roles->remove_cap('administrator', 'manage_give_settings');
294
+			$wp_roles->remove_cap('administrator', 'view_give_payments');
295 295
 
296 296
 			// Remove the Main Post Type Capabilities.
297 297
 			$capabilities = $this->get_core_caps();
298 298
 
299
-			foreach ( $capabilities as $cap_group ) {
300
-				foreach ( $cap_group as $cap ) {
301
-					$wp_roles->remove_cap( 'give_manager', $cap );
302
-					$wp_roles->remove_cap( 'administrator', $cap );
299
+			foreach ($capabilities as $cap_group) {
300
+				foreach ($cap_group as $cap) {
301
+					$wp_roles->remove_cap('give_manager', $cap);
302
+					$wp_roles->remove_cap('administrator', $cap);
303 303
 
304 304
 				}
305 305
 			}
306 306
 
307 307
 			// Remove capabilities from the Give Worker role.
308
-			$wp_roles->remove_cap( 'give_worker', 'edit_give_payments' );
309
-			$wp_roles->remove_cap( 'give_worker', 'delete_give_forms' );
310
-			$wp_roles->remove_cap( 'give_worker', 'delete_others_give_forms' );
311
-			$wp_roles->remove_cap( 'give_worker', 'delete_private_give_forms' );
312
-			$wp_roles->remove_cap( 'give_worker', 'delete_published_give_forms' );
313
-			$wp_roles->remove_cap( 'give_worker', 'edit_give_forms' );
314
-			$wp_roles->remove_cap( 'give_worker', 'edit_others_give_forms' );
315
-			$wp_roles->remove_cap( 'give_worker', 'edit_private_give_forms' );
316
-			$wp_roles->remove_cap( 'give_worker', 'edit_published_give_forms' );
317
-			$wp_roles->remove_cap( 'give_worker', 'publish_give_forms' );
318
-			$wp_roles->remove_cap( 'give_worker', 'read_private_give_forms' );
308
+			$wp_roles->remove_cap('give_worker', 'edit_give_payments');
309
+			$wp_roles->remove_cap('give_worker', 'delete_give_forms');
310
+			$wp_roles->remove_cap('give_worker', 'delete_others_give_forms');
311
+			$wp_roles->remove_cap('give_worker', 'delete_private_give_forms');
312
+			$wp_roles->remove_cap('give_worker', 'delete_published_give_forms');
313
+			$wp_roles->remove_cap('give_worker', 'edit_give_forms');
314
+			$wp_roles->remove_cap('give_worker', 'edit_others_give_forms');
315
+			$wp_roles->remove_cap('give_worker', 'edit_private_give_forms');
316
+			$wp_roles->remove_cap('give_worker', 'edit_published_give_forms');
317
+			$wp_roles->remove_cap('give_worker', 'publish_give_forms');
318
+			$wp_roles->remove_cap('give_worker', 'read_private_give_forms');
319 319
 
320 320
 			// Remove Capabilities from Give Accountant User Role.
321
-			$wp_roles->remove_cap( 'give_accountant', 'edit_give_forms' );
322
-			$wp_roles->remove_cap( 'give_accountant', 'read_private_give_forms' );
323
-			$wp_roles->remove_cap( 'give_accountant', 'view_give_reports' );
324
-			$wp_roles->remove_cap( 'give_accountant', 'export_give_reports' );
325
-			$wp_roles->remove_cap( 'give_accountant', 'edit_give_payments' );
326
-			$wp_roles->remove_cap( 'give_accountant', 'view_give_payments' );
321
+			$wp_roles->remove_cap('give_accountant', 'edit_give_forms');
322
+			$wp_roles->remove_cap('give_accountant', 'read_private_give_forms');
323
+			$wp_roles->remove_cap('give_accountant', 'view_give_reports');
324
+			$wp_roles->remove_cap('give_accountant', 'export_give_reports');
325
+			$wp_roles->remove_cap('give_accountant', 'edit_give_payments');
326
+			$wp_roles->remove_cap('give_accountant', 'view_give_payments');
327 327
 
328 328
 		}
329 329
 	}
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
 		$current_user = wp_get_current_user();
347 347
 
348 348
 		// If user with "Give Accountant" user role is logged-in .
349
-		if ( 0 !== $current_user->ID && in_array( 'give_accountant', (array) $current_user->roles, true ) ) {
349
+		if (0 !== $current_user->ID && in_array('give_accountant', (array) $current_user->roles, true)) {
350 350
 
351 351
 			// Return false, means no prevention.
352 352
 			return false;
Please login to merge, or discard this patch.
includes/emails/class-give-emails.php 1 patch
Spacing   +65 added lines, -65 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
 
@@ -102,12 +102,12 @@  discard block
 block discarded – undo
102 102
 	 */
103 103
 	public function __construct() {
104 104
 
105
-		if ( 'none' === $this->get_template() ) {
105
+		if ('none' === $this->get_template()) {
106 106
 			$this->html = false;
107 107
 		}
108 108
 
109
-		add_action( 'give_email_send_before', array( $this, 'send_before' ) );
110
-		add_action( 'give_email_send_after', array( $this, 'send_after' ) );
109
+		add_action('give_email_send_before', array($this, 'send_before'));
110
+		add_action('give_email_send_after', array($this, 'send_after'));
111 111
 
112 112
 	}
113 113
 
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 	 * @param $key
120 120
 	 * @param $value
121 121
 	 */
122
-	public function __set( $key, $value ) {
122
+	public function __set($key, $value) {
123 123
 		$this->$key = $value;
124 124
 	}
125 125
 
@@ -129,11 +129,11 @@  discard block
 block discarded – undo
129 129
 	 * @since 1.0
130 130
 	 */
131 131
 	public function get_from_name() {
132
-		if ( ! $this->from_name ) {
133
-			$this->from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) );
132
+		if ( ! $this->from_name) {
133
+			$this->from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES));
134 134
 		}
135 135
 
136
-		return apply_filters( 'give_email_from_name', wp_specialchars_decode( $this->from_name ), $this );
136
+		return apply_filters('give_email_from_name', wp_specialchars_decode($this->from_name), $this);
137 137
 	}
138 138
 
139 139
 	/**
@@ -142,11 +142,11 @@  discard block
 block discarded – undo
142 142
 	 * @since 1.0
143 143
 	 */
144 144
 	public function get_from_address() {
145
-		if ( ! $this->from_address ) {
146
-			$this->from_address = give_get_option( 'from_email', get_option( 'admin_email' ) );
145
+		if ( ! $this->from_address) {
146
+			$this->from_address = give_get_option('from_email', get_option('admin_email'));
147 147
 		}
148 148
 
149
-		return apply_filters( 'give_email_from_address', $this->from_address, $this );
149
+		return apply_filters('give_email_from_address', $this->from_address, $this);
150 150
 	}
151 151
 
152 152
 	/**
@@ -155,13 +155,13 @@  discard block
 block discarded – undo
155 155
 	 * @since 1.0
156 156
 	 */
157 157
 	public function get_content_type() {
158
-		if ( ! $this->content_type  ) {
158
+		if ( ! $this->content_type) {
159 159
 			$this->content_type = $this->html
160
-				? apply_filters( 'give_email_default_content_type', 'text/html', $this )
160
+				? apply_filters('give_email_default_content_type', 'text/html', $this)
161 161
 				: 'text/plain';
162 162
 		}
163 163
 
164
-		return apply_filters( 'give_email_content_type', $this->content_type, $this );
164
+		return apply_filters('give_email_content_type', $this->content_type, $this);
165 165
 	}
166 166
 
167 167
 	/**
@@ -170,13 +170,13 @@  discard block
 block discarded – undo
170 170
 	 * @since 1.0
171 171
 	 */
172 172
 	public function get_headers() {
173
-		if ( ! $this->headers ) {
173
+		if ( ! $this->headers) {
174 174
 			$this->headers = "From: {$this->get_from_name()} <{$this->get_from_address()}>\r\n";
175 175
 			$this->headers .= "Reply-To: {$this->get_from_address()}\r\n";
176 176
 			$this->headers .= "Content-Type: {$this->get_content_type()}; charset=utf-8\r\n";
177 177
 		}
178 178
 
179
-		return apply_filters( 'give_email_headers', $this->headers, $this );
179
+		return apply_filters('give_email_headers', $this->headers, $this);
180 180
 	}
181 181
 
182 182
 	/**
@@ -186,11 +186,11 @@  discard block
 block discarded – undo
186 186
 	 */
187 187
 	public function get_templates() {
188 188
 		$templates = array(
189
-			'default' => esc_html__( 'Default Template', 'give' ),
190
-			'none'    => esc_html__( 'No template, plain text only', 'give' )
189
+			'default' => esc_html__('Default Template', 'give'),
190
+			'none'    => esc_html__('No template, plain text only', 'give')
191 191
 		);
192 192
 
193
-		return apply_filters( 'give_email_templates', $templates );
193
+		return apply_filters('give_email_templates', $templates);
194 194
 	}
195 195
 
196 196
 	/**
@@ -199,11 +199,11 @@  discard block
 block discarded – undo
199 199
 	 * @since 1.0
200 200
 	 */
201 201
 	public function get_template() {
202
-		if ( ! $this->template ) {
203
-			$this->template = give_get_option( 'email_template', 'default' );
202
+		if ( ! $this->template) {
203
+			$this->template = give_get_option('email_template', 'default');
204 204
 		}
205 205
 
206
-		return apply_filters( 'give_email_template', $this->template );
206
+		return apply_filters('give_email_template', $this->template);
207 207
 	}
208 208
 
209 209
 	/**
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 	 * @since 1.0
213 213
 	 */
214 214
 	public function get_heading() {
215
-		return apply_filters( 'give_email_heading', $this->heading );
215
+		return apply_filters('give_email_heading', $this->heading);
216 216
 	}
217 217
 
218 218
 	/**
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 	 *
223 223
 	 * @return mixed
224 224
 	 */
225
-	public function parse_tags( $content ) {
225
+	public function parse_tags($content) {
226 226
 		return $content;
227 227
 	}
228 228
 
@@ -235,34 +235,34 @@  discard block
 block discarded – undo
235 235
 	 *
236 236
 	 * @return string
237 237
 	 */
238
-	public function build_email( $message ) {
238
+	public function build_email($message) {
239 239
 
240
-		if ( false === $this->html ) {
240
+		if (false === $this->html) {
241 241
 
242 242
 			// Added Replacement check to simply behaviour of anchor tags.
243 243
 			$pattern = '/<a.+?href\=(?:["|\'])(.+?)(?:["|\']).*?>(.+?)<\/a>/i';
244 244
 			$message = preg_replace_callback(
245 245
 				$pattern,
246
-				function ( $return ) {
247
-					if ( $return[1] !== $return[2] ) {
246
+				function($return) {
247
+					if ($return[1] !== $return[2]) {
248 248
 						return "{$return[2]} ( {$return[1]} )";
249 249
 					}
250 250
 
251
-					return trailingslashit( $return[1] );
251
+					return trailingslashit($return[1]);
252 252
 				},
253 253
 				$message
254 254
 			);
255 255
 
256
-			return apply_filters( 'give_email_message', wp_strip_all_tags( $message ), $this );
256
+			return apply_filters('give_email_message', wp_strip_all_tags($message), $this);
257 257
 		}
258 258
 
259
-		$message = $this->text_to_html( $message );
259
+		$message = $this->text_to_html($message);
260 260
 
261 261
 		$template = $this->get_template();
262 262
 
263 263
 		ob_start();
264 264
 
265
-		give_get_template_part( 'emails/header', $template, true );
265
+		give_get_template_part('emails/header', $template, true);
266 266
 
267 267
 		/**
268 268
 		 * Fires in the email head.
@@ -271,17 +271,17 @@  discard block
 block discarded – undo
271 271
 		 *
272 272
 		 * @param Give_Emails $this The email object.
273 273
 		 */
274
-		do_action( 'give_email_header', $this );
274
+		do_action('give_email_header', $this);
275 275
 
276
-		if ( has_action( 'give_email_template_' . $template ) ) {
276
+		if (has_action('give_email_template_'.$template)) {
277 277
 			/**
278 278
 			 * Fires in a specific email template.
279 279
 			 *
280 280
 			 * @since 1.0
281 281
 			 */
282
-			do_action( "give_email_template_{$template}" );
282
+			do_action("give_email_template_{$template}");
283 283
 		} else {
284
-			give_get_template_part( 'emails/body', $template, true );
284
+			give_get_template_part('emails/body', $template, true);
285 285
 		}
286 286
 
287 287
 		/**
@@ -291,9 +291,9 @@  discard block
 block discarded – undo
291 291
 		 *
292 292
 		 * @param Give_Emails $this The email object.
293 293
 		 */
294
-		do_action( 'give_email_body', $this );
294
+		do_action('give_email_body', $this);
295 295
 
296
-		give_get_template_part( 'emails/footer', $template, true );
296
+		give_get_template_part('emails/footer', $template, true);
297 297
 
298 298
 		/**
299 299
 		 * Fires in the email footer.
@@ -302,26 +302,26 @@  discard block
 block discarded – undo
302 302
 		 *
303 303
 		 * @param Give_Emails $this The email object.
304 304
 		 */
305
-		do_action( 'give_email_footer', $this );
305
+		do_action('give_email_footer', $this);
306 306
 
307 307
 		$body    = ob_get_clean();
308 308
 
309 309
 		// Email tag.
310
-		$message = str_replace( '{email}', $message, $body );
310
+		$message = str_replace('{email}', $message, $body);
311 311
 
312
-		$header_img = Give_Email_Notification_Util::get_email_logo( $this->form_id );
312
+		$header_img = Give_Email_Notification_Util::get_email_logo($this->form_id);
313 313
 
314
-		if ( ! empty( $header_img ) ) {
314
+		if ( ! empty($header_img)) {
315 315
 			$header_img = sprintf(
316 316
 				'<div id="template_header_image"><p style="margin-top:0;"><img style="max-width:450px;" src="%1$s" alt="%2$s" /></p></div>',
317
-				esc_url( $header_img ),
318
-				get_bloginfo( 'name' )
317
+				esc_url($header_img),
318
+				get_bloginfo('name')
319 319
 			);
320 320
 		}
321 321
 
322
-		$message  = str_replace( '{email_logo}', $header_img, $message );
322
+		$message = str_replace('{email_logo}', $header_img, $message);
323 323
 
324
-		return apply_filters( 'give_email_message', $message, $this );
324
+		return apply_filters('give_email_message', $message, $this);
325 325
 	}
326 326
 
327 327
 	/**
@@ -334,10 +334,10 @@  discard block
 block discarded – undo
334 334
 	 *
335 335
 	 * @return bool
336 336
 	 */
337
-	public function send( $to, $subject, $message, $attachments = '' ) {
337
+	public function send($to, $subject, $message, $attachments = '') {
338 338
 
339
-		if ( ! did_action( 'init' ) && ! did_action( 'admin_init' ) ) {
340
-			give_doing_it_wrong( __FUNCTION__, esc_html__( 'You cannot send email with Give_Emails until init/admin_init has been reached.', 'give' ), null );
339
+		if ( ! did_action('init') && ! did_action('admin_init')) {
340
+			give_doing_it_wrong(__FUNCTION__, esc_html__('You cannot send email with Give_Emails until init/admin_init has been reached.', 'give'), null);
341 341
 
342 342
 			return false;
343 343
 		}
@@ -349,16 +349,16 @@  discard block
 block discarded – undo
349 349
 		 *
350 350
 		 * @param Give_Emails $this The email object.
351 351
 		 */
352
-		do_action( 'give_email_send_before', $this );
352
+		do_action('give_email_send_before', $this);
353 353
 
354
-		$subject = $this->parse_tags( $subject );
355
-		$message = $this->parse_tags( $message );
354
+		$subject = $this->parse_tags($subject);
355
+		$message = $this->parse_tags($message);
356 356
 
357
-		$message = $this->build_email( $message );
357
+		$message = $this->build_email($message);
358 358
 
359
-		$attachments = apply_filters( 'give_email_attachments', $attachments, $this );
359
+		$attachments = apply_filters('give_email_attachments', $attachments, $this);
360 360
 
361
-		$sent = wp_mail( $to, $subject, $message, $this->get_headers(), $attachments );
361
+		$sent = wp_mail($to, $subject, $message, $this->get_headers(), $attachments);
362 362
 
363 363
 		/**
364 364
 		 * Fires after sending an email.
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
 		 *
368 368
 		 * @param Give_Emails $this The email object.
369 369
 		 */
370
-		do_action( 'give_email_send_after', $this );
370
+		do_action('give_email_send_after', $this);
371 371
 
372 372
 		return $sent;
373 373
 
@@ -379,9 +379,9 @@  discard block
 block discarded – undo
379 379
 	 * @since 1.0
380 380
 	 */
381 381
 	public function send_before() {
382
-		add_filter( 'wp_mail_from', array( $this, 'get_from_address' ) );
383
-		add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) );
384
-		add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) );
382
+		add_filter('wp_mail_from', array($this, 'get_from_address'));
383
+		add_filter('wp_mail_from_name', array($this, 'get_from_name'));
384
+		add_filter('wp_mail_content_type', array($this, 'get_content_type'));
385 385
 	}
386 386
 
387 387
 	/**
@@ -390,9 +390,9 @@  discard block
 block discarded – undo
390 390
 	 * @since 1.0
391 391
 	 */
392 392
 	public function send_after() {
393
-		remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ) );
394
-		remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) );
395
-		remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) );
393
+		remove_filter('wp_mail_from', array($this, 'get_from_address'));
394
+		remove_filter('wp_mail_from_name', array($this, 'get_from_name'));
395
+		remove_filter('wp_mail_content_type', array($this, 'get_content_type'));
396 396
 
397 397
 		// Reset email related params.
398 398
 		$this->heading = '';
@@ -406,10 +406,10 @@  discard block
 block discarded – undo
406 406
 	 *
407 407
 	 * @since 1.0
408 408
 	 */
409
-	public function text_to_html( $message ) {
409
+	public function text_to_html($message) {
410 410
 
411
-		if ( 'text/html' == $this->content_type || true === $this->html ) {
412
-			$message = wpautop( $message );
411
+		if ('text/html' == $this->content_type || true === $this->html) {
412
+			$message = wpautop($message);
413 413
 		}
414 414
 
415 415
 		return $message;
Please login to merge, or discard this patch.