Completed
Pull Request — master (#1832)
by Devin
04:50
created
includes/process-donation.php 1 patch
Spacing   +239 added lines, -239 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
 
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @since 1.0
32 32
 	 */
33
-	do_action( 'give_pre_process_donation' );
33
+	do_action('give_pre_process_donation');
34 34
 
35 35
 	// Validate the form $_POST data
36 36
 	$valid_data = give_donation_form_validate_fields();
@@ -45,26 +45,26 @@  discard block
 block discarded – undo
45 45
 	 * @param bool|array $valid_data Validate fields.
46 46
 	 * @param array $_POST Array of variables passed via the HTTP POST.
47 47
 	 */
48
-	do_action( 'give_checkout_error_checks', $valid_data, $_POST );
48
+	do_action('give_checkout_error_checks', $valid_data, $_POST);
49 49
 
50
-	$is_ajax = isset( $_POST['give_ajax'] );
50
+	$is_ajax = isset($_POST['give_ajax']);
51 51
 
52 52
 	// Process the login form
53
-	if ( isset( $_POST['give_login_submit'] ) ) {
53
+	if (isset($_POST['give_login_submit'])) {
54 54
 		give_process_form_login();
55 55
 	}
56 56
 
57 57
 	// Validate the user
58
-	$user = give_get_donation_form_user( $valid_data );
58
+	$user = give_get_donation_form_user($valid_data);
59 59
 
60
-	if ( false === $valid_data || give_get_errors() || ! $user ) {
61
-		if ( $is_ajax ) {
60
+	if (false === $valid_data || give_get_errors() || ! $user) {
61
+		if ($is_ajax) {
62 62
 			/**
63 63
 			 * Fires when AJAX sends back errors from the donation form.
64 64
 			 *
65 65
 			 * @since 1.0
66 66
 			 */
67
-			do_action( 'give_ajax_donation_errors' );
67
+			do_action('give_ajax_donation_errors');
68 68
 			give_die();
69 69
 		} else {
70 70
 			return false;
@@ -72,17 +72,17 @@  discard block
 block discarded – undo
72 72
 	}
73 73
 
74 74
 	// If AJAX send back success to proceed with form submission
75
-	if ( $is_ajax ) {
75
+	if ($is_ajax) {
76 76
 		echo 'success';
77 77
 		give_die();
78 78
 	}
79 79
 
80 80
 	// After AJAX: Setup session if not using php_sessions
81
-	if ( ! Give()->session->use_php_sessions() ) {
81
+	if ( ! Give()->session->use_php_sessions()) {
82 82
 		// Double-check that set_cookie is publicly accessible;
83 83
 		// we're using a slightly modified class-wp-sessions.php
84
-		$session_reflection = new ReflectionMethod( 'WP_Session', 'set_cookie' );
85
-		if ( $session_reflection->isPublic() ) {
84
+		$session_reflection = new ReflectionMethod('WP_Session', 'set_cookie');
85
+		if ($session_reflection->isPublic()) {
86 86
 			// Manually set the cookie.
87 87
 			Give()->session->init()->set_cookie();
88 88
 		}
@@ -97,18 +97,18 @@  discard block
 block discarded – undo
97 97
 		'address'    => $user['address'],
98 98
 	);
99 99
 
100
-	$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
100
+	$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
101 101
 
102
-	$price        = isset( $_POST['give-amount'] ) ? (float) apply_filters( 'give_donation_total', give_sanitize_amount( give_format_amount( $_POST['give-amount'] ) ) ) : '0.00';
103
-	$purchase_key = strtolower( md5( $user['user_email'] . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) );
102
+	$price        = isset($_POST['give-amount']) ? (float) apply_filters('give_donation_total', give_sanitize_amount(give_format_amount($_POST['give-amount']))) : '0.00';
103
+	$purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true)));
104 104
 
105 105
 	// Setup donation information
106 106
 	$donation_data = array(
107 107
 		'price'        => $price,
108 108
 		'purchase_key' => $purchase_key,
109 109
 		'user_email'   => $user['user_email'],
110
-		'date'         => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ),
111
-		'user_info'    => stripslashes_deep( $user_info ),
110
+		'date'         => date('Y-m-d H:i:s', current_time('timestamp')),
111
+		'user_info'    => stripslashes_deep($user_info),
112 112
 		'post_data'    => $_POST,
113 113
 		'gateway'      => $valid_data['gateway'],
114 114
 		'card_info'    => $valid_data['cc_info'],
@@ -128,10 +128,10 @@  discard block
 block discarded – undo
128 128
 	 * @param array $user_info Array containing basic user information.
129 129
 	 * @param bool|array $valid_data Validate fields.
130 130
 	 */
131
-	do_action( 'give_checkout_before_gateway', $_POST, $user_info, $valid_data );
131
+	do_action('give_checkout_before_gateway', $_POST, $user_info, $valid_data);
132 132
 
133 133
 	// Sanity check for price
134
-	if ( ! $donation_data['price'] ) {
134
+	if ( ! $donation_data['price']) {
135 135
 		// Revert to manual
136 136
 		$donation_data['gateway'] = 'manual';
137 137
 		$_POST['give-gateway']    = 'manual';
@@ -142,27 +142,27 @@  discard block
 block discarded – undo
142 142
 	 *
143 143
 	 * @since 1.7
144 144
 	 */
145
-	$donation_data = apply_filters( 'give_donation_data_before_gateway', $donation_data, $valid_data );
145
+	$donation_data = apply_filters('give_donation_data_before_gateway', $donation_data, $valid_data);
146 146
 
147 147
 	// Setup the data we're storing in the donation session
148 148
 	$session_data = $donation_data;
149 149
 
150 150
 	// Make sure credit card numbers are never stored in sessions
151
-	unset( $session_data['card_info']['card_number'] );
152
-	unset( $session_data['post_data']['card_number'] );
151
+	unset($session_data['card_info']['card_number']);
152
+	unset($session_data['post_data']['card_number']);
153 153
 
154 154
 	// Used for showing data to non logged-in users after donation, and for other plugins needing donation data.
155
-	give_set_purchase_session( $session_data );
155
+	give_set_purchase_session($session_data);
156 156
 
157 157
 	// Send info to the gateway for payment processing
158
-	give_send_to_gateway( $donation_data['gateway'], $donation_data );
158
+	give_send_to_gateway($donation_data['gateway'], $donation_data);
159 159
 	give_die();
160 160
 
161 161
 }
162 162
 
163
-add_action( 'give_purchase', 'give_process_donation_form' );
164
-add_action( 'wp_ajax_give_process_donation', 'give_process_donation_form' );
165
-add_action( 'wp_ajax_nopriv_give_process_donation', 'give_process_donation_form' );
163
+add_action('give_purchase', 'give_process_donation_form');
164
+add_action('wp_ajax_give_process_donation', 'give_process_donation_form');
165
+add_action('wp_ajax_nopriv_give_process_donation', 'give_process_donation_form');
166 166
 
167 167
 
168 168
 /**
@@ -175,29 +175,29 @@  discard block
 block discarded – undo
175 175
  *
176 176
  * @return void
177 177
  */
178
-function give_check_logged_in_user_for_existing_email( $valid_data, $post ) {
178
+function give_check_logged_in_user_for_existing_email($valid_data, $post) {
179 179
 
180 180
 	// Verify that the email address belongs to this customer.
181
-	if ( is_user_logged_in() ) {
181
+	if (is_user_logged_in()) {
182 182
 
183
-		$submitted_email    = $valid_data['logged_in_user']['user_email'];
184
-		$customer = new Give_Donor( get_current_user_id(), true );
183
+		$submitted_email = $valid_data['logged_in_user']['user_email'];
184
+		$customer = new Give_Donor(get_current_user_id(), true);
185 185
 
186 186
 		// If this email address is not registered with this customer, see if it belongs to any other customer
187 187
 		if (
188 188
 			$submitted_email !== $customer->email
189
-			&& ( is_array( $customer->emails ) && ! in_array( $submitted_email, $customer->emails ) )
189
+			&& (is_array($customer->emails) && ! in_array($submitted_email, $customer->emails))
190 190
 		) {
191
-			$found_customer = new Give_Donor( $submitted_email );
191
+			$found_customer = new Give_Donor($submitted_email);
192 192
 
193
-			if ( $found_customer->id > 0 ) {
194
-				give_set_error( 'give-customer-email-exists', sprintf( __( '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' ), $customer->email, $submitted_email ) );
193
+			if ($found_customer->id > 0) {
194
+				give_set_error('give-customer-email-exists', sprintf(__('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'), $customer->email, $submitted_email));
195 195
 			}
196 196
 		}
197 197
 	}
198 198
 }
199 199
 
200
-add_action( 'give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 2 );
200
+add_action('give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 2);
201 201
 
202 202
 /**
203 203
  * Process the checkout login form
@@ -208,37 +208,37 @@  discard block
 block discarded – undo
208 208
  */
209 209
 function give_process_form_login() {
210 210
 
211
-	$is_ajax = isset( $_POST['give_ajax'] );
211
+	$is_ajax = isset($_POST['give_ajax']);
212 212
 
213 213
 	$user_data = give_donation_form_validate_user_login();
214 214
 
215
-	if ( give_get_errors() || $user_data['user_id'] < 1 ) {
216
-		if ( $is_ajax ) {
215
+	if (give_get_errors() || $user_data['user_id'] < 1) {
216
+		if ($is_ajax) {
217 217
 			/**
218 218
 			 * Fires when AJAX sends back errors from the donation form.
219 219
 			 *
220 220
 			 * @since 1.0
221 221
 			 */
222
-			do_action( 'give_ajax_donation_errors' );
222
+			do_action('give_ajax_donation_errors');
223 223
 			give_die();
224 224
 		} else {
225
-			wp_redirect( $_SERVER['HTTP_REFERER'] );
225
+			wp_redirect($_SERVER['HTTP_REFERER']);
226 226
 			exit;
227 227
 		}
228 228
 	}
229 229
 
230
-	give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] );
230
+	give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']);
231 231
 
232
-	if ( $is_ajax ) {
232
+	if ($is_ajax) {
233 233
 		echo 'success';
234 234
 		give_die();
235 235
 	} else {
236
-		wp_redirect( $_SERVER['HTTP_REFERER'] );
236
+		wp_redirect($_SERVER['HTTP_REFERER']);
237 237
 	}
238 238
 }
239 239
 
240
-add_action( 'wp_ajax_give_process_donation_login', 'give_process_form_login' );
241
-add_action( 'wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login' );
240
+add_action('wp_ajax_give_process_donation_login', 'give_process_form_login');
241
+add_action('wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login');
242 242
 
243 243
 /**
244 244
  * Donation Form Validate Fields.
@@ -250,55 +250,55 @@  discard block
 block discarded – undo
250 250
 function give_donation_form_validate_fields() {
251 251
 
252 252
 	// Check if there is $_POST
253
-	if ( empty( $_POST ) ) {
253
+	if (empty($_POST)) {
254 254
 		return false;
255 255
 	}
256 256
 
257
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
257
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
258 258
 
259 259
 	// Start an array to collect valid data
260 260
 	$valid_data = array(
261 261
 		'gateway'          => give_donation_form_validate_gateway(), // Gateway fallback (amount is validated here)
262
-		'need_new_user'    => false,     // New user flag
263
-		'need_user_login'  => false,     // Login user flag
264
-		'logged_user_data' => array(),   // Logged user collected data
265
-		'new_user_data'    => array(),   // New user collected data
266
-		'login_user_data'  => array(),   // Login user collected data
267
-		'guest_user_data'  => array(),   // Guest user collected data
268
-		'cc_info'          => give_donation_form_validate_cc(),// Credit card info
262
+		'need_new_user'    => false, // New user flag
263
+		'need_user_login'  => false, // Login user flag
264
+		'logged_user_data' => array(), // Logged user collected data
265
+		'new_user_data'    => array(), // New user collected data
266
+		'login_user_data'  => array(), // Login user collected data
267
+		'guest_user_data'  => array(), // Guest user collected data
268
+		'cc_info'          => give_donation_form_validate_cc(), // Credit card info
269 269
 	);
270 270
 
271 271
 	// Validate Honeypot First
272
-	if ( ! empty( $_POST['give-honeypot'] ) ) {
273
-		give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) );
272
+	if ( ! empty($_POST['give-honeypot'])) {
273
+		give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give'));
274 274
 	}
275 275
 
276 276
 	// Validate agree to terms
277
-	if ( give_is_terms_enabled( $form_id ) ) {
277
+	if (give_is_terms_enabled($form_id)) {
278 278
 		give_donation_form_validate_agree_to_terms();
279 279
 	}
280 280
 
281 281
 	// Stop processing donor registration, if donor registration is optional and donor can do guest checkout.
282 282
 	// If registration form username field is empty that means donor do not want to registration instead want guest checkout.
283 283
 	if (
284
-		! give_logged_in_only( $form_id )
285
-		&& isset( $_POST['give-purchase-var'] )
284
+		! give_logged_in_only($form_id)
285
+		&& isset($_POST['give-purchase-var'])
286 286
 		&& $_POST['give-purchase-var'] == 'needs-to-register'
287
-		&& empty( $_POST['give_user_login'] )
287
+		&& empty($_POST['give_user_login'])
288 288
 	) {
289
-		unset( $_POST['give-purchase-var'] );
289
+		unset($_POST['give-purchase-var']);
290 290
 	}
291 291
 
292
-	if ( is_user_logged_in() ) {
292
+	if (is_user_logged_in()) {
293 293
 		// Collect logged in user data.
294 294
 		$valid_data['logged_in_user'] = give_donation_form_validate_logged_in_user();
295
-	} elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' ) {
295
+	} elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register') {
296 296
 		// Set new user registration as required.
297 297
 		$valid_data['need_new_user'] = true;
298 298
 		// Validate new user data.
299 299
 		$valid_data['new_user_data'] = give_donation_form_validate_new_user();
300 300
 		// Check if login validation is needed.
301
-	} elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) {
301
+	} elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') {
302 302
 		// Set user login as required.
303 303
 		$valid_data['need_user_login'] = true;
304 304
 		// Validate users login info.
@@ -323,41 +323,41 @@  discard block
 block discarded – undo
323 323
  */
324 324
 function give_donation_form_validate_gateway() {
325 325
 
326
-	$form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0;
327
-	$amount  = isset( $_REQUEST['give-amount'] ) ? give_sanitize_amount( $_REQUEST['give-amount'] ) : 0;
328
-	$gateway = give_get_default_gateway( $form_id );
326
+	$form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0;
327
+	$amount  = isset($_REQUEST['give-amount']) ? give_sanitize_amount($_REQUEST['give-amount']) : 0;
328
+	$gateway = give_get_default_gateway($form_id);
329 329
 
330 330
 	// Check if a gateway value is present.
331
-	if ( ! empty( $_REQUEST['give-gateway'] ) ) {
331
+	if ( ! empty($_REQUEST['give-gateway'])) {
332 332
 
333
-		$gateway = sanitize_text_field( $_REQUEST['give-gateway'] );
333
+		$gateway = sanitize_text_field($_REQUEST['give-gateway']);
334 334
 
335 335
 		// Is amount being donated in LIVE mode 0.00? If so, error:
336
-		if ( $amount == 0 && ! give_is_test_mode() ) {
336
+		if ($amount == 0 && ! give_is_test_mode()) {
337 337
 
338
-			give_set_error( 'invalid_donation_amount', __( 'Please insert a valid donation amount.', 'give' ) );
338
+			give_set_error('invalid_donation_amount', __('Please insert a valid donation amount.', 'give'));
339 339
 
340 340
 		} // End if().
341
-		elseif ( ! give_verify_minimum_price() ) {
341
+		elseif ( ! give_verify_minimum_price()) {
342 342
 			// translators: %s: minimum donation amount.
343 343
 			give_set_error(
344 344
 				'invalid_donation_minimum',
345 345
 				sprintf(
346 346
 					/* translators: %s: minimum donation amount */
347
-					__( 'This form has a minimum donation amount of %s.', 'give' ),
348
-					give_currency_filter( give_format_amount( give_get_form_minimum_price( $form_id ) ) )
347
+					__('This form has a minimum donation amount of %s.', 'give'),
348
+					give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id)))
349 349
 				)
350 350
 			);
351 351
 
352 352
 		} //Is this test mode zero donation? Let it through but set to manual gateway.
353
-		elseif ( $amount == 0 && give_is_test_mode() ) {
353
+		elseif ($amount == 0 && give_is_test_mode()) {
354 354
 
355 355
 			$gateway = 'manual';
356 356
 
357 357
 		} //Check if this gateway is active.
358
-		elseif ( ! give_is_gateway_active( $gateway ) ) {
358
+		elseif ( ! give_is_gateway_active($gateway)) {
359 359
 
360
-			give_set_error( 'invalid_gateway', __( 'The selected payment gateway is not enabled.', 'give' ) );
360
+			give_set_error('invalid_gateway', __('The selected payment gateway is not enabled.', 'give'));
361 361
 
362 362
 		}
363 363
 	}
@@ -375,21 +375,21 @@  discard block
 block discarded – undo
375 375
  */
376 376
 function give_verify_minimum_price() {
377 377
 
378
-	$amount          = give_sanitize_amount( $_REQUEST['give-amount'] );
379
-	$form_id         = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0;
380
-	$price_id        = isset( $_REQUEST['give-price-id'] ) ? $_REQUEST['give-price-id'] : null;
381
-	$variable_prices = give_has_variable_prices( $form_id );
378
+	$amount          = give_sanitize_amount($_REQUEST['give-amount']);
379
+	$form_id         = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0;
380
+	$price_id        = isset($_REQUEST['give-price-id']) ? $_REQUEST['give-price-id'] : null;
381
+	$variable_prices = give_has_variable_prices($form_id);
382 382
 
383
-	if ( $variable_prices && in_array( $price_id, give_get_variable_price_ids( $form_id ) ) ) {
383
+	if ($variable_prices && in_array($price_id, give_get_variable_price_ids($form_id))) {
384 384
 
385
-		$price_level_amount = give_get_price_option_amount( $form_id, $price_id );
385
+		$price_level_amount = give_get_price_option_amount($form_id, $price_id);
386 386
 
387
-		if ( $price_level_amount == $amount ) {
387
+		if ($price_level_amount == $amount) {
388 388
 			return true;
389 389
 		}
390 390
 	}
391 391
 
392
-	if ( give_get_form_minimum_price( $form_id ) > $amount ) {
392
+	if (give_get_form_minimum_price($form_id) > $amount) {
393 393
 		return false;
394 394
 	}
395 395
 
@@ -405,9 +405,9 @@  discard block
 block discarded – undo
405 405
  */
406 406
 function give_donation_form_validate_agree_to_terms() {
407 407
 	// Validate agree to terms.
408
-	if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) {
408
+	if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) {
409 409
 		// User did not agree.
410
-		give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', __( 'You must agree to the terms and conditions.', 'give' ) ) );
410
+		give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', __('You must agree to the terms and conditions.', 'give')));
411 411
 	}
412 412
 }
413 413
 
@@ -421,43 +421,43 @@  discard block
 block discarded – undo
421 421
  *
422 422
  * @return      array
423 423
  */
424
-function give_get_required_fields( $form_id ) {
424
+function give_get_required_fields($form_id) {
425 425
 
426
-	$payment_mode = give_get_chosen_gateway( $form_id );
426
+	$payment_mode = give_get_chosen_gateway($form_id);
427 427
 
428 428
 	$required_fields = array(
429 429
 		'give_email' => array(
430 430
 			'error_id'      => 'invalid_email',
431
-			'error_message' => __( 'Please enter a valid email address.', 'give' ),
431
+			'error_message' => __('Please enter a valid email address.', 'give'),
432 432
 		),
433 433
 		'give_first' => array(
434 434
 			'error_id'      => 'invalid_first_name',
435
-			'error_message' => __( 'Please enter your first name.', 'give' ),
435
+			'error_message' => __('Please enter your first name.', 'give'),
436 436
 		),
437 437
 	);
438 438
 
439
-	$require_address = give_require_billing_address( $payment_mode );
439
+	$require_address = give_require_billing_address($payment_mode);
440 440
 
441
-	if ( $require_address ) {
442
-		$required_fields['card_address']    = array(
441
+	if ($require_address) {
442
+		$required_fields['card_address'] = array(
443 443
 			'error_id'      => 'invalid_card_address',
444
-			'error_message' => __( 'Please enter your primary billing address.', 'give' ),
444
+			'error_message' => __('Please enter your primary billing address.', 'give'),
445 445
 		);
446
-		$required_fields['card_zip']        = array(
446
+		$required_fields['card_zip'] = array(
447 447
 			'error_id'      => 'invalid_zip_code',
448
-			'error_message' => __( 'Please enter your zip / postal code.', 'give' ),
448
+			'error_message' => __('Please enter your zip / postal code.', 'give'),
449 449
 		);
450
-		$required_fields['card_city']       = array(
450
+		$required_fields['card_city'] = array(
451 451
 			'error_id'      => 'invalid_city',
452
-			'error_message' => __( 'Please enter your billing city.', 'give' ),
452
+			'error_message' => __('Please enter your billing city.', 'give'),
453 453
 		);
454 454
 		$required_fields['billing_country'] = array(
455 455
 			'error_id'      => 'invalid_country',
456
-			'error_message' => __( 'Please select your billing country.', 'give' ),
456
+			'error_message' => __('Please select your billing country.', 'give'),
457 457
 		);
458
-		$required_fields['card_state']      = array(
458
+		$required_fields['card_state'] = array(
459 459
 			'error_id'      => 'invalid_state',
460
-			'error_message' => __( 'Please enter billing state / province.', 'give' ),
460
+			'error_message' => __('Please enter billing state / province.', 'give'),
461 461
 		);
462 462
 	}
463 463
 
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
 	 *
467 467
 	 * @since 1.7
468 468
 	 */
469
-	$required_fields = apply_filters( 'give_donation_form_required_fields', $required_fields, $form_id );
469
+	$required_fields = apply_filters('give_donation_form_required_fields', $required_fields, $form_id);
470 470
 
471 471
 	return $required_fields;
472 472
 
@@ -481,16 +481,16 @@  discard block
 block discarded – undo
481 481
  *
482 482
  * @return bool
483 483
  */
484
-function give_require_billing_address( $payment_mode ) {
484
+function give_require_billing_address($payment_mode) {
485 485
 
486 486
 	$return = false;
487 487
 
488
-	if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) {
488
+	if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) {
489 489
 		$return = true;
490 490
 	}
491 491
 
492 492
 	// Let payment gateways and other extensions determine if address fields should be required.
493
-	return apply_filters( 'give_require_billing_address', $return );
493
+	return apply_filters('give_require_billing_address', $return);
494 494
 
495 495
 }
496 496
 
@@ -504,42 +504,42 @@  discard block
 block discarded – undo
504 504
 function give_donation_form_validate_logged_in_user() {
505 505
 	global $user_ID;
506 506
 
507
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
507
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
508 508
 
509 509
 	// Start empty array to collect valid user data.
510 510
 	$valid_user_data = array(
511 511
 		// Assume there will be errors.
512
-		'user_id' => - 1,
512
+		'user_id' => -1,
513 513
 	);
514 514
 
515 515
 	// Verify there is a user_ID.
516
-	if ( $user_ID > 0 ) {
516
+	if ($user_ID > 0) {
517 517
 		// Get the logged in user data.
518
-		$user_data = get_userdata( $user_ID );
518
+		$user_data = get_userdata($user_ID);
519 519
 
520 520
 		// Loop through required fields and show error messages.
521
-		foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) {
522
-			if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
523
-				give_set_error( $value['error_id'], $value['error_message'] );
521
+		foreach (give_get_required_fields($form_id) as $field_name => $value) {
522
+			if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) {
523
+				give_set_error($value['error_id'], $value['error_message']);
524 524
 			}
525 525
 		}
526 526
 
527 527
 		// Verify data.
528
-		if ( $user_data ) {
528
+		if ($user_data) {
529 529
 			// Collected logged in user data.
530 530
 			$valid_user_data = array(
531 531
 				'user_id'    => $user_ID,
532
-				'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email,
533
-				'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name,
534
-				'user_last'  => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name,
532
+				'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email,
533
+				'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name,
534
+				'user_last'  => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name,
535 535
 			);
536 536
 
537
-			if ( ! is_email( $valid_user_data['user_email'] ) ) {
538
-				give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
537
+			if ( ! is_email($valid_user_data['user_email'])) {
538
+				give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
539 539
 			}
540 540
 		} else {
541 541
 			// Set invalid user error.
542
-			give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) );
542
+			give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give'));
543 543
 		}
544 544
 	}
545 545
 
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
 	// Default user data.
559 559
 	$default_user_data = array(
560 560
 		'give-form-id'           => '',
561
-		'user_id'                => - 1, // Assume there will be errors.
561
+		'user_id'                => -1, // Assume there will be errors.
562 562
 		'user_first'             => '',
563 563
 		'user_last'              => '',
564 564
 		'give_user_login'        => false,
@@ -568,14 +568,14 @@  discard block
 block discarded – undo
568 568
 	);
569 569
 
570 570
 	// Get user data.
571
-	$user_data            = wp_parse_args( array_map( 'trim', give_clean( $_POST ) ), $default_user_data );
571
+	$user_data            = wp_parse_args(array_map('trim', give_clean($_POST)), $default_user_data);
572 572
 	$registering_new_user = false;
573
-	$form_id              = absint( $user_data['give-form-id'] );
573
+	$form_id              = absint($user_data['give-form-id']);
574 574
 
575 575
 	// Start an empty array to collect valid user data.
576 576
 	$valid_user_data = array(
577 577
 		// Assume there will be errors.
578
-		'user_id'    => - 1,
578
+		'user_id'    => -1,
579 579
 
580 580
 		// Get first name.
581 581
 		'user_first' => $user_data['give_first'],
@@ -585,25 +585,25 @@  discard block
 block discarded – undo
585 585
 	);
586 586
 
587 587
 	// Loop through required fields and show error messages.
588
-	foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) {
589
-		if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
590
-			give_set_error( $value['error_id'], $value['error_message'] );
588
+	foreach (give_get_required_fields($form_id) as $field_name => $value) {
589
+		if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) {
590
+			give_set_error($value['error_id'], $value['error_message']);
591 591
 		}
592 592
 	}
593 593
 
594 594
 	// Check if we have an username to register.
595
-	if ( give_validate_username( $user_data['give_user_login'] ) ) {
595
+	if (give_validate_username($user_data['give_user_login'])) {
596 596
 		$registering_new_user          = true;
597 597
 		$valid_user_data['user_login'] = $user_data['give_user_login'];
598 598
 	}
599 599
 
600 600
 	// Check if we have an email to verify.
601
-	if ( give_validate_user_email( $user_data['give_email'], $registering_new_user ) ) {
601
+	if (give_validate_user_email($user_data['give_email'], $registering_new_user)) {
602 602
 		$valid_user_data['user_email'] = $user_data['give_email'];
603 603
 	}
604 604
 
605 605
 	// Check password.
606
-	if ( give_validate_user_password( $user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user ) ) {
606
+	if (give_validate_user_password($user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user)) {
607 607
 		// All is good to go.
608 608
 		$valid_user_data['user_pass'] = $user_data['give_user_pass'];
609 609
 	}
@@ -623,36 +623,36 @@  discard block
 block discarded – undo
623 623
 	// Start an array to collect valid user data.
624 624
 	$valid_user_data = array(
625 625
 		// Assume there will be errors.
626
-		'user_id' => - 1,
626
+		'user_id' => -1,
627 627
 	);
628 628
 
629 629
 	// Username.
630
-	if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) {
631
-		give_set_error( 'must_log_in', __( 'You must register or login to complete your donation.', 'give' ) );
630
+	if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') {
631
+		give_set_error('must_log_in', __('You must register or login to complete your donation.', 'give'));
632 632
 
633 633
 		return $valid_user_data;
634 634
 	}
635 635
 
636 636
 	// Get the user by login.
637
-	$user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) );
637
+	$user_data = get_user_by('login', strip_tags($_POST['give_user_login']));
638 638
 
639 639
 	// Check if user exists.
640
-	if ( $user_data ) {
640
+	if ($user_data) {
641 641
 		// Get password.
642
-		$user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false;
642
+		$user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false;
643 643
 
644 644
 		// Check user_pass.
645
-		if ( $user_pass ) {
645
+		if ($user_pass) {
646 646
 			// Check if password is valid.
647
-			if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) {
647
+			if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) {
648 648
 				// Incorrect password.
649 649
 				give_set_error(
650 650
 					'password_incorrect',
651 651
 					sprintf(
652 652
 						'%1$s <a href="%2$s">%3$s</a>',
653
-						__( 'The password you entered is incorrect.', 'give' ),
654
-						wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ),
655
-						__( 'Reset Password', 'give' )
653
+						__('The password you entered is incorrect.', 'give'),
654
+						wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"),
655
+						__('Reset Password', 'give')
656 656
 					)
657 657
 				);
658 658
 				// All is correct.
@@ -669,11 +669,11 @@  discard block
 block discarded – undo
669 669
 			}
670 670
 		} else {
671 671
 			// Empty password.
672
-			give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) );
672
+			give_set_error('password_empty', __('Enter a password.', 'give'));
673 673
 		}
674 674
 	} else {
675 675
 		// No username.
676
-		give_set_error( 'username_incorrect', __( 'The username you entered does not exist.', 'give' ) );
676
+		give_set_error('username_incorrect', __('The username you entered does not exist.', 'give'));
677 677
 	}// End if().
678 678
 
679 679
 	return $valid_user_data;
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
  */
689 689
 function give_donation_form_validate_guest_user() {
690 690
 
691
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
691
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
692 692
 
693 693
 	// Start an array to collect valid user data.
694 694
 	$valid_user_data = array(
@@ -697,38 +697,38 @@  discard block
 block discarded – undo
697 697
 	);
698 698
 
699 699
 	// Show error message if user must be logged in.
700
-	if ( give_logged_in_only( $form_id ) ) {
701
-		give_set_error( 'logged_in_only', __( 'You must be logged in to donate.', 'give' ) );
700
+	if (give_logged_in_only($form_id)) {
701
+		give_set_error('logged_in_only', __('You must be logged in to donate.', 'give'));
702 702
 	}
703 703
 
704 704
 	// Get the guest email.
705
-	$guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false;
705
+	$guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false;
706 706
 
707 707
 	// Check email.
708
-	if ( $guest_email && strlen( $guest_email ) > 0 ) {
708
+	if ($guest_email && strlen($guest_email) > 0) {
709 709
 		// Validate email.
710
-		if ( ! is_email( $guest_email ) ) {
710
+		if ( ! is_email($guest_email)) {
711 711
 			// Invalid email.
712
-			give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) );
712
+			give_set_error('email_invalid', __('Invalid email.', 'give'));
713 713
 		} else {
714 714
 			// All is good to go.
715 715
 			$valid_user_data['user_email'] = $guest_email;
716 716
 
717 717
 			// Get user_id from donor if exist.
718
-			$donor = new Give_Donor( $guest_email );
719
-			if ( $donor->id && $donor->user_id ) {
718
+			$donor = new Give_Donor($guest_email);
719
+			if ($donor->id && $donor->user_id) {
720 720
 				$valid_user_data['user_id'] = $donor->user_id;
721 721
 			}
722 722
 		}
723 723
 	} else {
724 724
 		// No email.
725
-		give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) );
725
+		give_set_error('email_empty', __('Enter an email.', 'give'));
726 726
 	}
727 727
 
728 728
 	// Loop through required fields and show error messages.
729
-	foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) {
730
-		if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
731
-			give_set_error( $value['error_id'], $value['error_message'] );
729
+	foreach (give_get_required_fields($form_id) as $field_name => $value) {
730
+		if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) {
731
+			give_set_error($value['error_id'], $value['error_message']);
732 732
 		}
733 733
 	}
734 734
 
@@ -744,36 +744,36 @@  discard block
 block discarded – undo
744 744
  * @since   1.0
745 745
  * @return  integer
746 746
  */
747
-function give_register_and_login_new_user( $user_data = array() ) {
747
+function give_register_and_login_new_user($user_data = array()) {
748 748
 	// Verify the array.
749
-	if ( empty( $user_data ) ) {
750
-		return - 1;
749
+	if (empty($user_data)) {
750
+		return -1;
751 751
 	}
752 752
 
753
-	if ( give_get_errors() ) {
754
-		return - 1;
753
+	if (give_get_errors()) {
754
+		return -1;
755 755
 	}
756 756
 
757
-	$user_args = apply_filters( 'give_insert_user_args', array(
758
-		'user_login'      => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '',
759
-		'user_pass'       => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '',
760
-		'user_email'      => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '',
761
-		'first_name'      => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '',
762
-		'last_name'       => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '',
763
-		'user_registered' => date( 'Y-m-d H:i:s' ),
764
-		'role'            => get_option( 'default_role' ),
765
-	), $user_data );
757
+	$user_args = apply_filters('give_insert_user_args', array(
758
+		'user_login'      => isset($user_data['user_login']) ? $user_data['user_login'] : '',
759
+		'user_pass'       => isset($user_data['user_pass']) ? $user_data['user_pass'] : '',
760
+		'user_email'      => isset($user_data['user_email']) ? $user_data['user_email'] : '',
761
+		'first_name'      => isset($user_data['user_first']) ? $user_data['user_first'] : '',
762
+		'last_name'       => isset($user_data['user_last']) ? $user_data['user_last'] : '',
763
+		'user_registered' => date('Y-m-d H:i:s'),
764
+		'role'            => get_option('default_role'),
765
+	), $user_data);
766 766
 
767 767
 	// Insert new user.
768
-	$user_id = wp_insert_user( $user_args );
768
+	$user_id = wp_insert_user($user_args);
769 769
 
770 770
 	// Validate inserted user.
771
-	if ( is_wp_error( $user_id ) ) {
772
-		return - 1;
771
+	if (is_wp_error($user_id)) {
772
+		return -1;
773 773
 	}
774 774
 
775 775
 	// Allow themes and plugins to filter the user data.
776
-	$user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args );
776
+	$user_data = apply_filters('give_insert_user_data', $user_data, $user_args);
777 777
 
778 778
 	/**
779 779
 	 * Fires after inserting user.
@@ -783,10 +783,10 @@  discard block
 block discarded – undo
783 783
 	 * @param int $user_id User id.
784 784
 	 * @param array $user_data Array containing user data.
785 785
 	 */
786
-	do_action( 'give_insert_user', $user_id, $user_data );
786
+	do_action('give_insert_user', $user_id, $user_data);
787 787
 
788 788
 	// Login new user.
789
-	give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] );
789
+	give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']);
790 790
 
791 791
 	// Return user id.
792 792
 	return $user_id;
@@ -801,27 +801,27 @@  discard block
 block discarded – undo
801 801
  * @since   1.0
802 802
  * @return  array|bool
803 803
  */
804
-function give_get_donation_form_user( $valid_data = array() ) {
804
+function give_get_donation_form_user($valid_data = array()) {
805 805
 
806 806
 	// Initialize user.
807 807
 	$user    = false;
808
-	$is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
808
+	$is_ajax = defined('DOING_AJAX') && DOING_AJAX;
809 809
 
810
-	if ( $is_ajax ) {
810
+	if ($is_ajax) {
811 811
 		// Do not create or login the user during the ajax submission (check for errors only).
812 812
 		return true;
813
-	} elseif ( is_user_logged_in() ) {
813
+	} elseif (is_user_logged_in()) {
814 814
 		// Set the valid user as the logged in collected data.
815 815
 		$user = $valid_data['logged_in_user'];
816
-	} elseif ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) {
816
+	} elseif ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) {
817 817
 		// New user registration.
818
-		if ( $valid_data['need_new_user'] === true ) {
818
+		if ($valid_data['need_new_user'] === true) {
819 819
 			// Set user.
820 820
 			$user = $valid_data['new_user_data'];
821 821
 			// Register and login new user.
822
-			$user['user_id'] = give_register_and_login_new_user( $user );
822
+			$user['user_id'] = give_register_and_login_new_user($user);
823 823
 			// User login
824
-		} elseif ( $valid_data['need_user_login'] === true && ! $is_ajax ) {
824
+		} elseif ($valid_data['need_user_login'] === true && ! $is_ajax) {
825 825
 
826 826
 			/**
827 827
 			 * The login form is now processed in the give_process_donation_login() function.
@@ -833,48 +833,48 @@  discard block
 block discarded – undo
833 833
 			// Set user.
834 834
 			$user = $valid_data['login_user_data'];
835 835
 			// Login user.
836
-			give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] );
836
+			give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']);
837 837
 		}
838 838
 	}
839 839
 
840 840
 	// Check guest checkout.
841
-	if ( false === $user && false === give_logged_in_only( $_POST['give-form-id'] ) ) {
841
+	if (false === $user && false === give_logged_in_only($_POST['give-form-id'])) {
842 842
 		// Set user
843 843
 		$user = $valid_data['guest_user_data'];
844 844
 	}
845 845
 
846 846
 	// Verify we have an user.
847
-	if ( false === $user || empty( $user ) ) {
847
+	if (false === $user || empty($user)) {
848 848
 		// Return false.
849 849
 		return false;
850 850
 	}
851 851
 
852 852
 	// Get user first name.
853
-	if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) {
854
-		$user['user_first'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : '';
853
+	if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) {
854
+		$user['user_first'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : '';
855 855
 	}
856 856
 
857 857
 	// Get user last name.
858
-	if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) {
859
-		$user['user_last'] = isset( $_POST['give_last'] ) ? strip_tags( trim( $_POST['give_last'] ) ) : '';
858
+	if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) {
859
+		$user['user_last'] = isset($_POST['give_last']) ? strip_tags(trim($_POST['give_last'])) : '';
860 860
 	}
861 861
 
862 862
 	// Get the user's billing address details.
863 863
 	$user['address']            = array();
864
-	$user['address']['line1']   = ! empty( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : false;
865
-	$user['address']['line2']   = ! empty( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : false;
866
-	$user['address']['city']    = ! empty( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : false;
867
-	$user['address']['state']   = ! empty( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : false;
868
-	$user['address']['country'] = ! empty( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : false;
869
-	$user['address']['zip']     = ! empty( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : false;
870
-
871
-	if ( empty( $user['address']['country'] ) ) {
864
+	$user['address']['line1']   = ! empty($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : false;
865
+	$user['address']['line2']   = ! empty($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : false;
866
+	$user['address']['city']    = ! empty($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : false;
867
+	$user['address']['state']   = ! empty($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : false;
868
+	$user['address']['country'] = ! empty($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : false;
869
+	$user['address']['zip']     = ! empty($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : false;
870
+
871
+	if (empty($user['address']['country'])) {
872 872
 		$user['address'] = false;
873 873
 	} // End if().
874 874
 
875
-	if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $user['address'] ) ) {
875
+	if ( ! empty($user['user_id']) && $user['user_id'] > 0 && ! empty($user['address'])) {
876 876
 		// Store the address in the user's meta so the donation form can be pre-populated with it on return donation.
877
-		update_user_meta( $user['user_id'], '_give_user_address', $user['address'] );
877
+		update_user_meta($user['user_id'], '_give_user_address', $user['address']);
878 878
 	}
879 879
 
880 880
 	// Return valid user.
@@ -893,16 +893,16 @@  discard block
 block discarded – undo
893 893
 	$card_data = give_get_donation_cc_info();
894 894
 
895 895
 	// Validate the card zip.
896
-	if ( ! empty( $card_data['card_zip'] ) ) {
897
-		if ( ! give_donation_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) {
898
-			give_set_error( 'invalid_cc_zip', __( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) );
896
+	if ( ! empty($card_data['card_zip'])) {
897
+		if ( ! give_donation_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) {
898
+			give_set_error('invalid_cc_zip', __('The zip / postal code you entered for your billing address is invalid.', 'give'));
899 899
 		}
900 900
 	}
901 901
 
902 902
 	// Ensure no spaces.
903
-	if ( ! empty( $card_data['card_number'] ) ) {
904
-		$card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); // no "+" signs
905
-		$card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces
903
+	if ( ! empty($card_data['card_number'])) {
904
+		$card_data['card_number'] = str_replace('+', '', $card_data['card_number']); // no "+" signs
905
+		$card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces
906 906
 	}
907 907
 
908 908
 	// This should validate card numbers at some point too.
@@ -919,17 +919,17 @@  discard block
 block discarded – undo
919 919
 function give_get_donation_cc_info() {
920 920
 
921 921
 	$cc_info                   = array();
922
-	$cc_info['card_name']      = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : '';
923
-	$cc_info['card_number']    = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : '';
924
-	$cc_info['card_cvc']       = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : '';
925
-	$cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : '';
926
-	$cc_info['card_exp_year']  = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : '';
927
-	$cc_info['card_address']   = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : '';
928
-	$cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : '';
929
-	$cc_info['card_city']      = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : '';
930
-	$cc_info['card_state']     = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : '';
931
-	$cc_info['card_country']   = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : '';
932
-	$cc_info['card_zip']       = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : '';
922
+	$cc_info['card_name']      = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : '';
923
+	$cc_info['card_number']    = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : '';
924
+	$cc_info['card_cvc']       = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : '';
925
+	$cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : '';
926
+	$cc_info['card_exp_year']  = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : '';
927
+	$cc_info['card_address']   = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : '';
928
+	$cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : '';
929
+	$cc_info['card_city']      = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : '';
930
+	$cc_info['card_state']     = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : '';
931
+	$cc_info['card_country']   = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : '';
932
+	$cc_info['card_zip']       = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : '';
933 933
 
934 934
 	// Return cc info.
935 935
 	return $cc_info;
@@ -945,14 +945,14 @@  discard block
 block discarded – undo
945 945
  *
946 946
  * @return bool|mixed
947 947
  */
948
-function give_donation_form_validate_cc_zip( $zip = 0, $country_code = '' ) {
948
+function give_donation_form_validate_cc_zip($zip = 0, $country_code = '') {
949 949
 	$ret = false;
950 950
 
951
-	if ( empty( $zip ) || empty( $country_code ) ) {
951
+	if (empty($zip) || empty($country_code)) {
952 952
 		return $ret;
953 953
 	}
954 954
 
955
-	$country_code = strtoupper( $country_code );
955
+	$country_code = strtoupper($country_code);
956 956
 
957 957
 	$zip_regex = array(
958 958
 		'AD' => 'AD\d{3}',
@@ -1112,11 +1112,11 @@  discard block
 block discarded – undo
1112 1112
 		'ZM' => '\d{5}',
1113 1113
 	);
1114 1114
 
1115
-	if ( ! isset( $zip_regex[ $country_code ] ) || preg_match( '/' . $zip_regex[ $country_code ] . '/i', $zip ) ) {
1115
+	if ( ! isset($zip_regex[$country_code]) || preg_match('/'.$zip_regex[$country_code].'/i', $zip)) {
1116 1116
 		$ret = true;
1117 1117
 	}
1118 1118
 
1119
-	return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code );
1119
+	return apply_filters('give_is_zip_valid', $ret, $zip, $country_code);
1120 1120
 }
1121 1121
 
1122 1122
 
@@ -1130,36 +1130,36 @@  discard block
 block discarded – undo
1130 1130
  *
1131 1131
  * @return bool
1132 1132
  */
1133
-function give_validate_multi_donation_form_level( $valid_data, $data ) {
1133
+function give_validate_multi_donation_form_level($valid_data, $data) {
1134 1134
 	/* @var Give_Donate_Form $form */
1135
-	$form = new Give_Donate_Form( $data['give-form-id'] );
1135
+	$form = new Give_Donate_Form($data['give-form-id']);
1136 1136
 
1137 1137
 	$donation_level_matched = false;
1138 1138
 
1139
-	if ( $form->is_multi_type_donation_form() ) {
1139
+	if ($form->is_multi_type_donation_form()) {
1140 1140
 
1141 1141
 		// Bailout.
1142
-		if ( ! ( $variable_prices = $form->get_prices() ) ) {
1142
+		if ( ! ($variable_prices = $form->get_prices())) {
1143 1143
 			return false;
1144 1144
 		}
1145 1145
 
1146 1146
 		// Sanitize donation amount.
1147
-		$data['give-amount'] = give_sanitize_amount( $data['give-amount'] );
1147
+		$data['give-amount'] = give_sanitize_amount($data['give-amount']);
1148 1148
 
1149 1149
 		// Get number of decimals.
1150 1150
 		$default_decimals = give_get_price_decimals();
1151 1151
 
1152
-		if ( $data['give-amount'] === give_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ), $default_decimals ) ) {
1152
+		if ($data['give-amount'] === give_sanitize_amount(give_get_price_option_amount($data['give-form-id'], $data['give-price-id']), $default_decimals)) {
1153 1153
 			return true;
1154 1154
 		}
1155 1155
 
1156 1156
 		// Find correct donation level from all donation levels.
1157
-		foreach ( $variable_prices as $variable_price ) {
1157
+		foreach ($variable_prices as $variable_price) {
1158 1158
 			// Sanitize level amount.
1159
-			$variable_price['_give_amount'] = give_sanitize_amount( $variable_price['_give_amount'], $default_decimals );
1159
+			$variable_price['_give_amount'] = give_sanitize_amount($variable_price['_give_amount'], $default_decimals);
1160 1160
 
1161 1161
 			// Set first match donation level ID.
1162
-			if ( $data['give-amount'] === $variable_price['_give_amount'] ) {
1162
+			if ($data['give-amount'] === $variable_price['_give_amount']) {
1163 1163
 				$_POST['give-price-id'] = $variable_price['_give_id']['level_id'];
1164 1164
 				$donation_level_matched = true;
1165 1165
 				break;
@@ -1170,19 +1170,19 @@  discard block
 block discarded – undo
1170 1170
 		// If yes then set price id to custom if amount is greater then custom minimum amount (if any).
1171 1171
 		if (
1172 1172
 			! $donation_level_matched
1173
-			&& ( give_is_setting_enabled( give_get_meta( $data['give-form-id'], '_give_custom_amount', true ) ) )
1173
+			&& (give_is_setting_enabled(give_get_meta($data['give-form-id'], '_give_custom_amount', true)))
1174 1174
 		) {
1175 1175
 			// Sanitize custom minimum amount.
1176
-			$custom_minimum_amount = give_sanitize_amount( give_get_meta( $data['give-form-id'], '_give_custom_amount_minimum', true ), $default_decimals );
1176
+			$custom_minimum_amount = give_sanitize_amount(give_get_meta($data['give-form-id'], '_give_custom_amount_minimum', true), $default_decimals);
1177 1177
 
1178
-			if ( $data['give-amount'] >= $custom_minimum_amount ) {
1178
+			if ($data['give-amount'] >= $custom_minimum_amount) {
1179 1179
 				$_POST['give-price-id'] = 'custom';
1180 1180
 				$donation_level_matched = true;
1181 1181
 			}
1182 1182
 		}
1183 1183
 	}// End if().
1184 1184
 
1185
-	return ( $donation_level_matched ? true : false );
1185
+	return ($donation_level_matched ? true : false);
1186 1186
 }
1187 1187
 
1188
-add_action( 'give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2 );
1188
+add_action('give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2);
Please login to merge, or discard this patch.
includes/class-give-cache.php 1 patch
Spacing   +51 added lines, -51 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
 
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	 * @return static
44 44
 	 */
45 45
 	public static function get_instance() {
46
-		if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Give_Cache ) ) {
46
+		if ( ! isset(self::$instance) && ! (self::$instance instanceof Give_Cache)) {
47 47
 			self::$instance = new Give_Cache();
48 48
 		}
49 49
 
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	 */
59 59
 	public function setup_hooks() {
60 60
 		// weekly delete all expired cache.
61
-		add_action( 'give_weekly_scheduled_events', array( $this, 'delete_all_expired' ) );
61
+		add_action('give_weekly_scheduled_events', array($this, 'delete_all_expired'));
62 62
 	}
63 63
 
64 64
 	/**
@@ -72,12 +72,12 @@  discard block
 block discarded – undo
72 72
 	 * @return string
73 73
 	 */
74 74
 
75
-	public static function get_key( $action, $query_args = null ) {
75
+	public static function get_key($action, $query_args = null) {
76 76
 		$cache_key = "give_cache_{$action}";
77 77
 
78 78
 		// Bailout.
79
-		if ( ! empty( $query_args ) ) {
80
-			$cache_key = "{$cache_key}_" . substr( md5( serialize( $query_args ) ), 0, 15 );
79
+		if ( ! empty($query_args)) {
80
+			$cache_key = "{$cache_key}_".substr(md5(serialize($query_args)), 0, 15);
81 81
 		}
82 82
 
83 83
 		return $cache_key;
@@ -95,26 +95,26 @@  discard block
 block discarded – undo
95 95
 	 * @return mixed
96 96
 	 */
97 97
 
98
-	public static function get( $cache_key, $custom_key = false, $query_args = array() ) {
99
-		if ( ! self::is_valid_cache_key( $cache_key ) ) {
100
-			if ( ! $custom_key ) {
101
-				return new WP_Error( 'give_invalid_cache_key', __( 'Cache key format should be give_cache_*', 'give' ) );
98
+	public static function get($cache_key, $custom_key = false, $query_args = array()) {
99
+		if ( ! self::is_valid_cache_key($cache_key)) {
100
+			if ( ! $custom_key) {
101
+				return new WP_Error('give_invalid_cache_key', __('Cache key format should be give_cache_*', 'give'));
102 102
 			}
103 103
 
104
-			$cache_key = self::get_key( $cache_key, $query_args );
104
+			$cache_key = self::get_key($cache_key, $query_args);
105 105
 		}
106 106
 
107
-		$option = get_option( $cache_key );
107
+		$option = get_option($cache_key);
108 108
 
109 109
 		// Backward compatibility (<1.8.7).
110
-		if ( ! is_array( $option ) || empty( $option ) || ! array_key_exists( 'expiration', $option ) ) {
110
+		if ( ! is_array($option) || empty($option) || ! array_key_exists('expiration', $option)) {
111 111
 			return $option;
112 112
 		}
113 113
 
114 114
 		// Get current time.
115
-		$current_time = current_time( 'timestamp', 1 );
115
+		$current_time = current_time('timestamp', 1);
116 116
 
117
-		if ( empty( $option['expiration'] ) || ( $current_time < $option['expiration'] ) ) {
117
+		if (empty($option['expiration']) || ($current_time < $option['expiration'])) {
118 118
 			$option = $option['data'];
119 119
 		} else {
120 120
 			$option = false;
@@ -137,23 +137,23 @@  discard block
 block discarded – undo
137 137
 	 * @return mixed
138 138
 	 */
139 139
 
140
-	public static function set( $cache_key, $data, $expiration = null, $custom_key = false, $query_args = array() ) {
141
-		if ( ! self::is_valid_cache_key( $cache_key ) ) {
142
-			if ( ! $custom_key ) {
143
-				return new WP_Error( 'give_invalid_cache_key', __( 'Cache key format should be give_cache_*', 'give' ) );
140
+	public static function set($cache_key, $data, $expiration = null, $custom_key = false, $query_args = array()) {
141
+		if ( ! self::is_valid_cache_key($cache_key)) {
142
+			if ( ! $custom_key) {
143
+				return new WP_Error('give_invalid_cache_key', __('Cache key format should be give_cache_*', 'give'));
144 144
 			}
145 145
 
146
-			$cache_key = self::get_key( $cache_key, $query_args );
146
+			$cache_key = self::get_key($cache_key, $query_args);
147 147
 		}
148 148
 
149 149
 		$option_value = array(
150 150
 			'data'       => $data,
151
-			'expiration' => ! is_null( $expiration )
152
-				? ( $expiration + current_time( 'timestamp', 1 ) )
151
+			'expiration' => ! is_null($expiration)
152
+				? ($expiration + current_time('timestamp', 1))
153 153
 				: null,
154 154
 		);
155 155
 
156
-		$result = update_option( $cache_key, $option_value, 'no' );
156
+		$result = update_option($cache_key, $option_value, 'no');
157 157
 
158 158
 		return $result;
159 159
 	}
@@ -168,27 +168,27 @@  discard block
 block discarded – undo
168 168
 	 * @return bool|WP_Error
169 169
 	 */
170 170
 
171
-	public static function delete( $cache_keys ) {
171
+	public static function delete($cache_keys) {
172 172
 		$result = true;
173 173
 		$invalid_keys = array();
174 174
 
175
-		if ( ! empty( $cache_keys ) ) {
176
-			$cache_keys = is_array( $cache_keys ) ? $cache_keys : array( $cache_keys );
175
+		if ( ! empty($cache_keys)) {
176
+			$cache_keys = is_array($cache_keys) ? $cache_keys : array($cache_keys);
177 177
 
178
-			foreach ( $cache_keys as $cache_key ) {
179
-				if ( ! self::is_valid_cache_key( $cache_key ) ) {
178
+			foreach ($cache_keys as $cache_key) {
179
+				if ( ! self::is_valid_cache_key($cache_key)) {
180 180
 					$invalid_keys[] = $cache_key;
181 181
 					$result = false;
182 182
 				}
183 183
 
184
-				delete_option( $cache_key );
184
+				delete_option($cache_key);
185 185
 			}
186 186
 		}
187 187
 
188
-		if( ! $result ) {
188
+		if ( ! $result) {
189 189
 			$result = new WP_Error(
190 190
 				'give_invalid_cache_key',
191
-					__( 'Cache key format should be give_cache_*', 'give' ),
191
+					__('Cache key format should be give_cache_*', 'give'),
192 192
 					$invalid_keys
193 193
 			);
194 194
 		}
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 	 *
208 208
 	 * @return bool
209 209
 	 */
210
-	public static function delete_all_expired( $force = false ) {
210
+	public static function delete_all_expired($force = false) {
211 211
 		global $wpdb;
212 212
 		$options = $wpdb->get_results(
213 213
 			$wpdb->prepare(
@@ -221,30 +221,30 @@  discard block
 block discarded – undo
221 221
 		);
222 222
 
223 223
 		// Bailout.
224
-		if ( empty( $options ) ) {
224
+		if (empty($options)) {
225 225
 			return false;
226 226
 		}
227 227
 
228
-		$current_time = current_time( 'timestamp', 1 );
228
+		$current_time = current_time('timestamp', 1);
229 229
 
230 230
 		// Delete log cache.
231
-		foreach ( $options as $option ) {
232
-			$option['option_value'] = maybe_unserialize( $option['option_value'] );
231
+		foreach ($options as $option) {
232
+			$option['option_value'] = maybe_unserialize($option['option_value']);
233 233
 
234 234
 			if (
235 235
 				(
236
-					! self::is_valid_cache_key( $option['option_name'] )
237
-					|| ! is_array( $option['option_value'] ) // Backward compatibility (<1.8.7).
238
-					|| ! array_key_exists( 'expiration', $option['option_value'] ) // Backward compatibility (<1.8.7).
239
-					|| empty( $option['option_value']['expiration'] )
240
-					|| ( $current_time < $option['option_value']['expiration'] )
236
+					! self::is_valid_cache_key($option['option_name'])
237
+					|| ! is_array($option['option_value']) // Backward compatibility (<1.8.7).
238
+					|| ! array_key_exists('expiration', $option['option_value']) // Backward compatibility (<1.8.7).
239
+					|| empty($option['option_value']['expiration'])
240
+					|| ($current_time < $option['option_value']['expiration'])
241 241
 				)
242 242
 				&& ! $force
243 243
 			) {
244 244
 				continue;
245 245
 			}
246 246
 
247
-			self::delete( $option['option_name'] );
247
+			self::delete($option['option_name']);
248 248
 		}
249 249
 	}
250 250
 
@@ -260,16 +260,16 @@  discard block
 block discarded – undo
260 260
 	 *
261 261
 	 * @return array
262 262
 	 */
263
-	public static function get_options_like( $option_name, $fields = false ) {
263
+	public static function get_options_like($option_name, $fields = false) {
264 264
 		global $wpdb;
265 265
 
266
-		if ( empty( $option_name ) ) {
266
+		if (empty($option_name)) {
267 267
 			return array();
268 268
 		}
269 269
 
270 270
 		$field_names = $fields ? 'option_name, option_value' : 'option_name';
271 271
 
272
-		if ( $fields ) {
272
+		if ($fields) {
273 273
 			$options = $wpdb->get_results(
274 274
 				$wpdb->prepare(
275 275
 					"SELECT {$field_names }
@@ -293,10 +293,10 @@  discard block
 block discarded – undo
293 293
 			);
294 294
 		}
295 295
 
296
-		if ( ! empty( $options ) && $fields ) {
297
-			foreach ( $options as $index => $option ) {
298
-				$option['option_value'] = maybe_unserialize( $option['option_value'] );
299
-				$options[ $index ]      = $option;
296
+		if ( ! empty($options) && $fields) {
297
+			foreach ($options as $index => $option) {
298
+				$option['option_value'] = maybe_unserialize($option['option_value']);
299
+				$options[$index]      = $option;
300 300
 			}
301 301
 		}
302 302
 
@@ -313,8 +313,8 @@  discard block
 block discarded – undo
313 313
 	 *
314 314
 	 * @return bool|int
315 315
 	 */
316
-	public static function is_valid_cache_key( $cache_key ) {
317
-		return ( false !== strpos( $cache_key, 'give_cache_' ) );
316
+	public static function is_valid_cache_key($cache_key) {
317
+		return (false !== strpos($cache_key, 'give_cache_'));
318 318
 	}
319 319
 }
320 320
 
Please login to merge, or discard this patch.
includes/class-give-db.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -98,11 +98,11 @@  discard block
 block discarded – undo
98 98
 	 *
99 99
 	 * @return object
100 100
 	 */
101
-	public function get( $row_id ) {
101
+	public function get($row_id) {
102 102
 		/* @var WPDB $wpdb */
103 103
 		global $wpdb;
104 104
 
105
-		return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) );
105
+		return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id));
106 106
 	}
107 107
 
108 108
 	/**
@@ -116,12 +116,12 @@  discard block
 block discarded – undo
116 116
      *
117 117
      * @return object
118 118
 	 */
119
-	public function get_by( $column, $row_id ) {
119
+	public function get_by($column, $row_id) {
120 120
         /* @var WPDB $wpdb */
121 121
         global $wpdb;
122 122
 
123
-		$column = esc_sql( $column );
124
-		return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id ) );
123
+		$column = esc_sql($column);
124
+		return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id));
125 125
 	}
126 126
 
127 127
 	/**
@@ -135,12 +135,12 @@  discard block
 block discarded – undo
135 135
      *
136 136
 	 * @return string      Column value.
137 137
 	 */
138
-	public function get_column( $column, $row_id ) {
138
+	public function get_column($column, $row_id) {
139 139
         /* @var WPDB $wpdb */
140 140
         global $wpdb;
141 141
 
142
-		$column = esc_sql( $column );
143
-		return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) );
142
+		$column = esc_sql($column);
143
+		return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id));
144 144
 	}
145 145
 
146 146
 	/**
@@ -155,13 +155,13 @@  discard block
 block discarded – undo
155 155
      *
156 156
 	 * @return string
157 157
 	 */
158
-	public function get_column_by( $column, $column_where, $column_value ) {
158
+	public function get_column_by($column, $column_where, $column_value) {
159 159
         /* @var WPDB $wpdb */
160 160
         global $wpdb;
161 161
 
162
-		$column_where = esc_sql( $column_where );
163
-		$column       = esc_sql( $column );
164
-		return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value ) );
162
+		$column_where = esc_sql($column_where);
163
+		$column       = esc_sql($column);
164
+		return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value));
165 165
 	}
166 166
 
167 167
 	/**
@@ -175,12 +175,12 @@  discard block
 block discarded – undo
175 175
      *
176 176
 	 * @return int
177 177
 	 */
178
-	public function insert( $data, $type = '' ) {
178
+	public function insert($data, $type = '') {
179 179
         /* @var WPDB $wpdb */
180 180
         global $wpdb;
181 181
 
182 182
 		// Set default values.
183
-		$data = wp_parse_args( $data, $this->get_column_defaults() );
183
+		$data = wp_parse_args($data, $this->get_column_defaults());
184 184
 
185 185
 		/**
186 186
 		 * Fires before inserting data to the database.
@@ -189,22 +189,22 @@  discard block
 block discarded – undo
189 189
 		 *
190 190
 		 * @param array $data
191 191
 		 */
192
-		do_action( "give_pre_insert_{$type}", $data );
192
+		do_action("give_pre_insert_{$type}", $data);
193 193
 
194 194
 		// Initialise column format array
195 195
 		$column_formats = $this->get_columns();
196 196
 
197 197
 		// Force fields to lower case
198
-		$data = array_change_key_case( $data );
198
+		$data = array_change_key_case($data);
199 199
 
200 200
 		// White list columns
201
-		$data = array_intersect_key( $data, $column_formats );
201
+		$data = array_intersect_key($data, $column_formats);
202 202
 
203 203
 		// Reorder $column_formats to match the order of columns given in $data
204
-		$data_keys      = array_keys( $data );
205
-		$column_formats = array_merge( array_flip( $data_keys ), $column_formats );
204
+		$data_keys      = array_keys($data);
205
+		$column_formats = array_merge(array_flip($data_keys), $column_formats);
206 206
 
207
-		$wpdb->insert( $this->table_name, $data, $column_formats );
207
+		$wpdb->insert($this->table_name, $data, $column_formats);
208 208
 
209 209
 		/**
210 210
 		 * Fires after inserting data to the database.
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 		 * @param int   $insert_id
215 215
 		 * @param array $data
216 216
 		 */
217
-		do_action( "give_post_insert_{$type}", $wpdb->insert_id, $data );
217
+		do_action("give_post_insert_{$type}", $wpdb->insert_id, $data);
218 218
 
219 219
 		return $wpdb->insert_id;
220 220
 	}
@@ -231,18 +231,18 @@  discard block
 block discarded – undo
231 231
      *
232 232
 	 * @return bool
233 233
 	 */
234
-	public function update( $row_id, $data = array(), $where = '' ) {
234
+	public function update($row_id, $data = array(), $where = '') {
235 235
         /* @var WPDB $wpdb */
236 236
         global $wpdb;
237 237
 
238 238
 		// Row ID must be positive integer
239
-		$row_id = absint( $row_id );
239
+		$row_id = absint($row_id);
240 240
 
241
-		if ( empty( $row_id ) ) {
241
+		if (empty($row_id)) {
242 242
 			return false;
243 243
 		}
244 244
 
245
-		if ( empty( $where ) ) {
245
+		if (empty($where)) {
246 246
 			$where = $this->primary_key;
247 247
 		}
248 248
 
@@ -250,16 +250,16 @@  discard block
 block discarded – undo
250 250
 		$column_formats = $this->get_columns();
251 251
 
252 252
 		// Force fields to lower case
253
-		$data = array_change_key_case( $data );
253
+		$data = array_change_key_case($data);
254 254
 
255 255
 		// White list columns
256
-		$data = array_intersect_key( $data, $column_formats );
256
+		$data = array_intersect_key($data, $column_formats);
257 257
 
258 258
 		// Reorder $column_formats to match the order of columns given in $data
259
-		$data_keys      = array_keys( $data );
260
-		$column_formats = array_merge( array_flip( $data_keys ), $column_formats );
259
+		$data_keys      = array_keys($data);
260
+		$column_formats = array_merge(array_flip($data_keys), $column_formats);
261 261
 
262
-		if ( false === $wpdb->update( $this->table_name, $data, array( $where => $row_id ), $column_formats ) ) {
262
+		if (false === $wpdb->update($this->table_name, $data, array($where => $row_id), $column_formats)) {
263 263
 			return false;
264 264
 		}
265 265
 
@@ -276,18 +276,18 @@  discard block
 block discarded – undo
276 276
      *
277 277
 	 * @return bool
278 278
 	 */
279
-	public function delete( $row_id = 0 ) {
279
+	public function delete($row_id = 0) {
280 280
         /* @var WPDB $wpdb */
281 281
         global $wpdb;
282 282
 
283 283
 		// Row ID must be positive integer
284
-		$row_id = absint( $row_id );
284
+		$row_id = absint($row_id);
285 285
 
286
-		if ( empty( $row_id ) ) {
286
+		if (empty($row_id)) {
287 287
 			return false;
288 288
 		}
289 289
 
290
-		if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id ) ) ) {
290
+		if (false === $wpdb->query($wpdb->prepare("DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id))) {
291 291
 			return false;
292 292
 		}
293 293
 
@@ -304,13 +304,13 @@  discard block
 block discarded – undo
304 304
      *
305 305
 	 * @return bool          If the table name exists.
306 306
 	 */
307
-	public function table_exists( $table ) {
307
+	public function table_exists($table) {
308 308
         /* @var WPDB $wpdb */
309 309
 		global $wpdb;
310 310
 
311
-		$table = sanitize_text_field( $table );
311
+		$table = sanitize_text_field($table);
312 312
 
313
-		return $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table ) ) === $table;
313
+		return $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE '%s'", $table)) === $table;
314 314
 	}
315 315
 
316 316
 	/**
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 	 * @return bool Returns if the customers table was installed and upgrade routine run.
323 323
 	 */
324 324
 	public function installed() {
325
-		return $this->table_exists( $this->table_name );
325
+		return $this->table_exists($this->table_name);
326 326
 	}
327 327
 
328 328
 	/**
@@ -332,8 +332,8 @@  discard block
 block discarded – undo
332 332
 	 * @access public
333 333
 	 */
334 334
 	public function register_table() {
335
-		$current_version = get_option( $this->table_name . '_db_version' );
336
-		if ( ! $current_version || version_compare( $current_version, $this->version, '<' ) ) {
335
+		$current_version = get_option($this->table_name.'_db_version');
336
+		if ( ! $current_version || version_compare($current_version, $this->version, '<')) {
337 337
 			$this->create_table();
338 338
 		}
339 339
 	}
@@ -344,5 +344,5 @@  discard block
 block discarded – undo
344 344
 	 * @since  1.8.9
345 345
 	 * @access public
346 346
 	 */
347
-	public function create_table(){}
347
+	public function create_table() {}
348 348
 }
Please login to merge, or discard this patch.
includes/install.php 1 patch
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -26,15 +26,15 @@  discard block
 block discarded – undo
26 26
  * @global     $wpdb
27 27
  * @return void
28 28
  */
29
-function give_install( $network_wide = false ) {
29
+function give_install($network_wide = false) {
30 30
 
31 31
 	global $wpdb;
32 32
 
33
-	if ( is_multisite() && $network_wide ) {
33
+	if (is_multisite() && $network_wide) {
34 34
 
35
-		foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs LIMIT 100" ) as $blog_id ) {
35
+		foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs LIMIT 100") as $blog_id) {
36 36
 
37
-			switch_to_blog( $blog_id );
37
+			switch_to_blog($blog_id);
38 38
 			give_run_install();
39 39
 			restore_current_blog();
40 40
 
@@ -62,24 +62,24 @@  discard block
 block discarded – undo
62 62
 	give_setup_post_types();
63 63
 
64 64
 	// Clear the permalinks.
65
-	flush_rewrite_rules( false );
65
+	flush_rewrite_rules(false);
66 66
 
67 67
 	// Add Upgraded From Option.
68
-	$current_version = get_option( 'give_version' );
69
-	if ( $current_version ) {
70
-		update_option( 'give_version_upgraded_from', $current_version );
68
+	$current_version = get_option('give_version');
69
+	if ($current_version) {
70
+		update_option('give_version_upgraded_from', $current_version);
71 71
 	}
72 72
 
73 73
 	// Setup some default options.
74 74
 	$options = array();
75 75
 
76 76
 	// Checks if the Success Page option exists AND that the page exists.
77
-	if ( ! get_post( give_get_option( 'success_page' ) ) ) {
77
+	if ( ! get_post(give_get_option('success_page'))) {
78 78
 
79 79
 		// Donation Confirmation (Success) Page
80 80
 		$success = wp_insert_post(
81 81
 			array(
82
-				'post_title'     => esc_html__( 'Donation Confirmation', 'give' ),
82
+				'post_title'     => esc_html__('Donation Confirmation', 'give'),
83 83
 				'post_content'   => '[give_receipt]',
84 84
 				'post_status'    => 'publish',
85 85
 				'post_author'    => 1,
@@ -93,13 +93,13 @@  discard block
 block discarded – undo
93 93
 	}
94 94
 
95 95
 	// Checks if the Failure Page option exists AND that the page exists.
96
-	if ( ! get_post( give_get_option( 'failure_page' ) ) ) {
96
+	if ( ! get_post(give_get_option('failure_page'))) {
97 97
 
98 98
 		// Failed Donation Page
99 99
 		$failed = wp_insert_post(
100 100
 			array(
101
-				'post_title'     => esc_html__( 'Donation Failed', 'give' ),
102
-				'post_content'   => esc_html__( 'We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give' ),
101
+				'post_title'     => esc_html__('Donation Failed', 'give'),
102
+				'post_content'   => esc_html__('We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give'),
103 103
 				'post_status'    => 'publish',
104 104
 				'post_author'    => 1,
105 105
 				'post_type'      => 'page',
@@ -111,11 +111,11 @@  discard block
 block discarded – undo
111 111
 	}
112 112
 
113 113
 	// Checks if the History Page option exists AND that the page exists.
114
-	if ( ! get_post( give_get_option( 'history_page' ) ) ) {
114
+	if ( ! get_post(give_get_option('history_page'))) {
115 115
 		// Donation History Page
116 116
 		$history = wp_insert_post(
117 117
 			array(
118
-				'post_title'     => esc_html__( 'Donation History', 'give' ),
118
+				'post_title'     => esc_html__('Donation History', 'give'),
119 119
 				'post_content'   => '[donation_history]',
120 120
 				'post_status'    => 'publish',
121 121
 				'post_author'    => 1,
@@ -128,22 +128,22 @@  discard block
 block discarded – undo
128 128
 	}
129 129
 
130 130
 	//Fresh Install? Setup Test Mode, Base Country (US), Test Gateway, Currency.
131
-	if ( empty( $current_version ) ) {
132
-		$options = array_merge( $options, give_get_default_settings() );
131
+	if (empty($current_version)) {
132
+		$options = array_merge($options, give_get_default_settings());
133 133
 	}
134 134
 
135 135
 	// Populate the default values.
136
-	update_option( 'give_settings', array_merge( $give_options, $options ) );
136
+	update_option('give_settings', array_merge($give_options, $options));
137 137
 
138 138
 	/**
139 139
 	 * Run plugin upgrades.
140 140
 	 *
141 141
 	 * @since 1.8
142 142
 	 */
143
-	do_action( 'give_upgrades' );
143
+	do_action('give_upgrades');
144 144
 
145
-	if ( GIVE_VERSION !== get_option( 'give_version' ) ) {
146
-		update_option( 'give_version', GIVE_VERSION );
145
+	if (GIVE_VERSION !== get_option('give_version')) {
146
+		update_option('give_version', GIVE_VERSION);
147 147
 	}
148 148
 
149 149
 	// Create Give roles.
@@ -152,18 +152,18 @@  discard block
 block discarded – undo
152 152
 	$roles->add_caps();
153 153
 
154 154
 	$api = new Give_API();
155
-	update_option( 'give_default_api_version', 'v' . $api->get_version() );
155
+	update_option('give_default_api_version', 'v'.$api->get_version());
156 156
 
157 157
 	// Check for PHP Session support, and enable if available.
158 158
 	$give_sessions = new Give_Session();
159 159
 	$give_sessions->use_php_sessions();
160 160
 
161 161
 	// Add a temporary option to note that Give pages have been created.
162
-	Give_Cache::set( '_give_installed', $options, 30, true );
162
+	Give_Cache::set('_give_installed', $options, 30, true);
163 163
 
164
-	if ( ! $current_version ) {
164
+	if ( ! $current_version) {
165 165
 
166
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php';
166
+		require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php';
167 167
 
168 168
 		// When new upgrade routines are added, mark them as complete on fresh install.
169 169
 		$upgrade_routines = array(
@@ -175,18 +175,18 @@  discard block
 block discarded – undo
175 175
 			'v189_upgrades_levels_post_meta'
176 176
 		);
177 177
 
178
-		foreach ( $upgrade_routines as $upgrade ) {
179
-			give_set_upgrade_complete( $upgrade );
178
+		foreach ($upgrade_routines as $upgrade) {
179
+			give_set_upgrade_complete($upgrade);
180 180
 		}
181 181
 	}
182 182
 
183 183
 	// Bail if activating from network, or bulk.
184
-	if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
184
+	if (is_network_admin() || isset($_GET['activate-multi'])) {
185 185
 		return;
186 186
 	}
187 187
 
188 188
 	// Add the transient to redirect.
189
-	Give_Cache::set( '_give_activation_redirect', true, 30, true );
189
+	Give_Cache::set('_give_activation_redirect', true, 30, true);
190 190
 
191 191
 	// Set 'Donation Form' meta box enabled by default.
192 192
 	give_nav_donation_metabox_enabled();
@@ -206,11 +206,11 @@  discard block
 block discarded – undo
206 206
  * @param  int $site_id The Site ID.
207 207
  * @param  array $meta Blog Meta.
208 208
  */
209
-function give_on_create_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
209
+function give_on_create_blog($blog_id, $user_id, $domain, $path, $site_id, $meta) {
210 210
 
211
-	if ( is_plugin_active_for_network( GIVE_PLUGIN_BASENAME ) ) {
211
+	if (is_plugin_active_for_network(GIVE_PLUGIN_BASENAME)) {
212 212
 
213
-		switch_to_blog( $blog_id );
213
+		switch_to_blog($blog_id);
214 214
 		give_install();
215 215
 		restore_current_blog();
216 216
 
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 
219 219
 }
220 220
 
221
-add_action( 'wpmu_new_blog', 'give_on_create_blog', 10, 6 );
221
+add_action('wpmu_new_blog', 'give_on_create_blog', 10, 6);
222 222
 
223 223
 
224 224
 /**
@@ -231,13 +231,13 @@  discard block
 block discarded – undo
231 231
  *
232 232
  * @return array          The tables to drop.
233 233
  */
234
-function give_wpmu_drop_tables( $tables, $blog_id ) {
234
+function give_wpmu_drop_tables($tables, $blog_id) {
235 235
 
236
-	switch_to_blog( $blog_id );
236
+	switch_to_blog($blog_id);
237 237
 	$donors_db     = new Give_DB_Donors();
238 238
 	$donor_meta_db = new Give_DB_Donor_Meta();
239 239
 
240
-	if ( $donors_db->installed() ) {
240
+	if ($donors_db->installed()) {
241 241
 		$tables[] = $donors_db->table_name;
242 242
 		$tables[] = $donor_meta_db->table_name;
243 243
 	}
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 
248 248
 }
249 249
 
250
-add_filter( 'wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2 );
250
+add_filter('wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2);
251 251
 
252 252
 /**
253 253
  * Post-installation
@@ -259,16 +259,16 @@  discard block
 block discarded – undo
259 259
  */
260 260
 function give_after_install() {
261 261
 
262
-	if ( ! is_admin() ) {
262
+	if ( ! is_admin()) {
263 263
 		return;
264 264
 	}
265 265
 
266
-	$give_options     = Give_Cache::get( '_give_installed', true );
267
-	$give_table_check = get_option( '_give_table_check', false );
266
+	$give_options     = Give_Cache::get('_give_installed', true);
267
+	$give_table_check = get_option('_give_table_check', false);
268 268
 
269
-	if ( false === $give_table_check || current_time( 'timestamp' ) > $give_table_check ) {
269
+	if (false === $give_table_check || current_time('timestamp') > $give_table_check) {
270 270
 
271
-		if ( ! @Give()->donor_meta->installed() ) {
271
+		if ( ! @Give()->donor_meta->installed()) {
272 272
 
273 273
 			// Create the donor meta database.
274 274
 			// (this ensures it creates it on multisite instances where it is network activated).
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 
277 277
 		}
278 278
 
279
-		if ( ! @Give()->donors->installed() ) {
279
+		if ( ! @Give()->donors->installed()) {
280 280
 			// Create the donor database.
281 281
 			// (this ensures it creates it on multisite instances where it is network activated).
282 282
 			@Give()->donors->create_table();
@@ -288,22 +288,22 @@  discard block
 block discarded – undo
288 288
 			 *
289 289
 			 * @param array $give_options Give plugin options.
290 290
 			 */
291
-			do_action( 'give_after_install', $give_options );
291
+			do_action('give_after_install', $give_options);
292 292
 		}
293 293
 
294
-		update_option( '_give_table_check', ( current_time( 'timestamp' ) + WEEK_IN_SECONDS ) );
294
+		update_option('_give_table_check', (current_time('timestamp') + WEEK_IN_SECONDS));
295 295
 
296 296
 	}
297 297
 
298 298
 	// Delete the transient
299
-	if ( false !== $give_options ) {
300
-		Give_Cache::delete( Give_Cache::get_key( '_give_installed' ) );
299
+	if (false !== $give_options) {
300
+		Give_Cache::delete(Give_Cache::get_key('_give_installed'));
301 301
 	}
302 302
 
303 303
 
304 304
 }
305 305
 
306
-add_action( 'admin_init', 'give_after_install' );
306
+add_action('admin_init', 'give_after_install');
307 307
 
308 308
 
309 309
 /**
@@ -318,11 +318,11 @@  discard block
 block discarded – undo
318 318
 
319 319
 	global $wp_roles;
320 320
 
321
-	if ( ! is_object( $wp_roles ) ) {
321
+	if ( ! is_object($wp_roles)) {
322 322
 		return;
323 323
 	}
324 324
 
325
-	if ( ! array_key_exists( 'give_manager', $wp_roles->roles ) ) {
325
+	if ( ! array_key_exists('give_manager', $wp_roles->roles)) {
326 326
 
327 327
 		// Create Give plugin roles
328 328
 		$roles = new Give_Roles();
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 
334 334
 }
335 335
 
336
-add_action( 'admin_init', 'give_install_roles_on_network' );
336
+add_action('admin_init', 'give_install_roles_on_network');
337 337
 
338 338
 /**
339 339
  * Default core setting values.
@@ -369,14 +369,14 @@  discard block
 block discarded – undo
369 369
 		'uninstall_on_delete'                         => 'disabled',
370 370
 		'the_content_filter'                          => 'enabled',
371 371
 		'scripts_footer'                              => 'disabled',
372
-		'agree_to_terms_label'                        => __( 'Agree to Terms?', 'give' ),
372
+		'agree_to_terms_label'                        => __('Agree to Terms?', 'give'),
373 373
 		'agreement_text'                              => give_get_default_agreement_text(),
374 374
 
375 375
 		// Paypal IPN verification.
376 376
 		'paypal_verification'                         => 'enabled',
377 377
 
378 378
 		// Default is manual gateway.
379
-		'gateways'                                    => array( 'manual' => 1, 'offline' => 1 ),
379
+		'gateways'                                    => array('manual' => 1, 'offline' => 1),
380 380
 		'default_gateway'                             => 'manual',
381 381
 
382 382
 		// Offline gateway setup.
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
  */
402 402
 function give_get_default_agreement_text() {
403 403
 
404
-	$org_name = get_bloginfo( 'name' );
404
+	$org_name = get_bloginfo('name');
405 405
 
406 406
 	$agreement = sprintf(
407 407
 		'<p>Acceptance of any contribution, gift or grant is at the discretion of the %1$s. The  %1$s will not accept any gift unless it can be used or expended consistently with the purpose and mission of the  %1$s.</p>
@@ -415,5 +415,5 @@  discard block
 block discarded – undo
415 415
 		$org_name
416 416
 	);
417 417
 
418
-	return apply_filters( 'give_get_default_agreement_text', $agreement, $org_name );
418
+	return apply_filters('give_get_default_agreement_text', $agreement, $org_name);
419 419
 }
Please login to merge, or discard this patch.
includes/shortcodes.php 1 patch
Spacing   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -26,15 +26,15 @@  discard block
 block discarded – undo
26 26
 function give_donation_history() {
27 27
 
28 28
 	// If payment_key query arg exists, return receipt instead of donation history.
29
-	if ( isset( $_GET['payment_key'] ) ) {
29
+	if (isset($_GET['payment_key'])) {
30 30
 		ob_start();
31
-		echo give_receipt_shortcode( array() );
32
-		echo '<a href="' . esc_url( give_get_history_page_uri() ) . '">&laquo; ' . __( 'Return to All Donations', 'give' ) . '</a>';
31
+		echo give_receipt_shortcode(array());
32
+		echo '<a href="'.esc_url(give_get_history_page_uri()).'">&laquo; '.__('Return to All Donations', 'give').'</a>';
33 33
 
34 34
 		return ob_get_clean();
35 35
 	}
36 36
 
37
-	$email_access = give_get_option( 'email_access' );
37
+	$email_access = give_get_option('email_access');
38 38
 
39 39
 	/**
40 40
 	 * Determine access
@@ -44,30 +44,30 @@  discard block
 block discarded – undo
44 44
 	 */
45 45
 	if (
46 46
 		is_user_logged_in() || false !== Give()->session->get_session_expiration()
47
-		|| ( give_is_setting_enabled( $email_access ) && Give()->email_access->token_exists )
47
+		|| (give_is_setting_enabled($email_access) && Give()->email_access->token_exists)
48 48
 	) {
49 49
 		ob_start();
50
-		give_get_template_part( 'history', 'donations' );
50
+		give_get_template_part('history', 'donations');
51 51
 
52 52
 		return ob_get_clean();
53 53
 
54
-	} elseif ( give_is_setting_enabled( $email_access ) ) {
54
+	} elseif (give_is_setting_enabled($email_access)) {
55 55
 		// Is Email-based access enabled?
56 56
 		ob_start();
57
-		give_get_template_part( 'email', 'login-form' );
57
+		give_get_template_part('email', 'login-form');
58 58
 
59 59
 		return ob_get_clean();
60 60
 
61 61
 	} else {
62 62
 
63
-		$output = apply_filters( 'give_donation_history_nonuser_message', Give()->notices->print_frontend_notice( __( 'You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give' ), false ) );
64
-		$output .= do_shortcode( '[give_login]' );
63
+		$output = apply_filters('give_donation_history_nonuser_message', Give()->notices->print_frontend_notice(__('You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give'), false));
64
+		$output .= do_shortcode('[give_login]');
65 65
 
66 66
 		return $output;
67 67
 	}
68 68
 }
69 69
 
70
-add_shortcode( 'donation_history', 'give_donation_history' );
70
+add_shortcode('donation_history', 'give_donation_history');
71 71
 
72 72
 /**
73 73
  * Donation Form Shortcode
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
  *
81 81
  * @return string
82 82
  */
83
-function give_form_shortcode( $atts ) {
84
-	$atts = shortcode_atts( array(
83
+function give_form_shortcode($atts) {
84
+	$atts = shortcode_atts(array(
85 85
 		'id'                    => '',
86 86
 		'show_title'            => true,
87 87
 		'show_goal'             => true,
@@ -89,21 +89,21 @@  discard block
 block discarded – undo
89 89
 		'float_labels'          => '',
90 90
 		'display_style'         => '',
91 91
 		'continue_button_title' => '',
92
-	), $atts, 'give_form' );
92
+	), $atts, 'give_form');
93 93
 
94 94
 	// Convert string to bool.
95
-	$atts['show_title'] = filter_var( $atts['show_title'], FILTER_VALIDATE_BOOLEAN );
96
-	$atts['show_goal']  = filter_var( $atts['show_goal'], FILTER_VALIDATE_BOOLEAN );
95
+	$atts['show_title'] = filter_var($atts['show_title'], FILTER_VALIDATE_BOOLEAN);
96
+	$atts['show_goal']  = filter_var($atts['show_goal'], FILTER_VALIDATE_BOOLEAN);
97 97
 
98 98
 	//get the Give Form
99 99
 	ob_start();
100
-	give_get_donation_form( $atts );
100
+	give_get_donation_form($atts);
101 101
 	$final_output = ob_get_clean();
102 102
 
103
-	return apply_filters( 'give_donate_form', $final_output, $atts );
103
+	return apply_filters('give_donate_form', $final_output, $atts);
104 104
 }
105 105
 
106
-add_shortcode( 'give_form', 'give_form_shortcode' );
106
+add_shortcode('give_form', 'give_form_shortcode');
107 107
 
108 108
 /**
109 109
  * Donation Form Goal Shortcode.
@@ -116,37 +116,37 @@  discard block
 block discarded – undo
116 116
  *
117 117
  * @return string
118 118
  */
119
-function give_goal_shortcode( $atts ) {
120
-	$atts = shortcode_atts( array(
119
+function give_goal_shortcode($atts) {
120
+	$atts = shortcode_atts(array(
121 121
 		'id'        => '',
122 122
 		'show_text' => true,
123 123
 		'show_bar'  => true,
124
-	), $atts, 'give_goal' );
124
+	), $atts, 'give_goal');
125 125
 
126 126
 
127 127
 	//get the Give Form.
128 128
 	ob_start();
129 129
 
130 130
 	//Sanity check 1: ensure there is an ID Provided.
131
-	if ( empty( $atts['id'] ) ) {
132
-		Give()->notices->print_frontend_notice( __( 'The shortcode is missing Donation Form ID attribute.', 'give' ), true );
131
+	if (empty($atts['id'])) {
132
+		Give()->notices->print_frontend_notice(__('The shortcode is missing Donation Form ID attribute.', 'give'), true);
133 133
 	}
134 134
 
135 135
 	//Sanity check 2: Check the form even has Goals enabled.
136
-	if ( ! give_is_setting_enabled( give_get_meta( $atts['id'], '_give_goal_option', true ) ) ) {
136
+	if ( ! give_is_setting_enabled(give_get_meta($atts['id'], '_give_goal_option', true))) {
137 137
 
138
-		Give()->notices->print_frontend_notice( __( 'The form does not have Goals enabled.', 'give' ), true );
138
+		Give()->notices->print_frontend_notice(__('The form does not have Goals enabled.', 'give'), true);
139 139
 	} else {
140 140
 		//Passed all sanity checks: output Goal.
141
-		give_show_goal_progress( $atts['id'], $atts );
141
+		give_show_goal_progress($atts['id'], $atts);
142 142
 	}
143 143
 
144 144
 	$final_output = ob_get_clean();
145 145
 
146
-	return apply_filters( 'give_goal_shortcode_output', $final_output, $atts );
146
+	return apply_filters('give_goal_shortcode_output', $final_output, $atts);
147 147
 }
148 148
 
149
-add_shortcode( 'give_goal', 'give_goal_shortcode' );
149
+add_shortcode('give_goal', 'give_goal_shortcode');
150 150
 
151 151
 
152 152
 /**
@@ -163,22 +163,22 @@  discard block
 block discarded – undo
163 163
  *
164 164
  * @return string
165 165
  */
166
-function give_login_form_shortcode( $atts ) {
167
-	$atts = shortcode_atts( array(
166
+function give_login_form_shortcode($atts) {
167
+	$atts = shortcode_atts(array(
168 168
 		// Add backward compatibility for redirect attribute.
169 169
 		'redirect' => '',
170 170
 
171 171
 		'login-redirect'  => '',
172 172
 		'logout-redirect' => '',
173
-	), $atts, 'give_login' );
173
+	), $atts, 'give_login');
174 174
 
175 175
 	// Check login-redirect attribute first, if it empty or not found then check for redirect attribute and add value of this to login-redirect attribute.
176
-	$atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect'] ) ? $atts['redirect'] : '' );
176
+	$atts['login-redirect'] = ! empty($atts['login-redirect']) ? $atts['login-redirect'] : ( ! empty($atts['redirect']) ? $atts['redirect'] : '');
177 177
 
178
-	return give_login_form( $atts['login-redirect'], $atts['logout-redirect'] );
178
+	return give_login_form($atts['login-redirect'], $atts['logout-redirect']);
179 179
 }
180 180
 
181
-add_shortcode( 'give_login', 'give_login_form_shortcode' );
181
+add_shortcode('give_login', 'give_login_form_shortcode');
182 182
 
183 183
 /**
184 184
  * Register Shortcode.
@@ -193,15 +193,15 @@  discard block
 block discarded – undo
193 193
  *
194 194
  * @return string
195 195
  */
196
-function give_register_form_shortcode( $atts ) {
197
-	$atts = shortcode_atts( array(
196
+function give_register_form_shortcode($atts) {
197
+	$atts = shortcode_atts(array(
198 198
 		'redirect' => '',
199
-	), $atts, 'give_register' );
199
+	), $atts, 'give_register');
200 200
 
201
-	return give_register_form( $atts['redirect'] );
201
+	return give_register_form($atts['redirect']);
202 202
 }
203 203
 
204
-add_shortcode( 'give_register', 'give_register_form_shortcode' );
204
+add_shortcode('give_register', 'give_register_form_shortcode');
205 205
 
206 206
 /**
207 207
  * Receipt Shortcode.
@@ -214,12 +214,12 @@  discard block
 block discarded – undo
214 214
  *
215 215
  * @return string
216 216
  */
217
-function give_receipt_shortcode( $atts ) {
217
+function give_receipt_shortcode($atts) {
218 218
 
219 219
 	global $give_receipt_args, $payment;
220 220
 
221
-	$give_receipt_args = shortcode_atts( array(
222
-		'error'          => __( 'You are missing the payment key to view this donation receipt.', 'give' ),
221
+	$give_receipt_args = shortcode_atts(array(
222
+		'error'          => __('You are missing the payment key to view this donation receipt.', 'give'),
223 223
 		'price'          => true,
224 224
 		'donor'          => true,
225 225
 		'date'           => true,
@@ -228,50 +228,50 @@  discard block
 block discarded – undo
228 228
 		'payment_id'     => true,
229 229
 		'payment_status' => false,
230 230
 		'status_notice'  => true,
231
-	), $atts, 'give_receipt' );
231
+	), $atts, 'give_receipt');
232 232
 
233 233
 	//set $session var
234 234
 	$session = give_get_purchase_session();
235 235
 
236 236
 	//set payment key var
237
-	if ( isset( $_GET['payment_key'] ) ) {
238
-		$payment_key = urldecode( $_GET['payment_key'] );
239
-	} elseif ( $session ) {
237
+	if (isset($_GET['payment_key'])) {
238
+		$payment_key = urldecode($_GET['payment_key']);
239
+	} elseif ($session) {
240 240
 		$payment_key = $session['purchase_key'];
241
-	} elseif ( $give_receipt_args['payment_key'] ) {
241
+	} elseif ($give_receipt_args['payment_key']) {
242 242
 		$payment_key = $give_receipt_args['payment_key'];
243 243
 	}
244 244
 
245
-	$email_access = give_get_option( 'email_access' );
245
+	$email_access = give_get_option('email_access');
246 246
 
247 247
 	// No payment_key found & Email Access is Turned on:
248
-	if ( ! isset( $payment_key ) && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) {
248
+	if ( ! isset($payment_key) && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) {
249 249
 
250 250
 		ob_start();
251 251
 
252
-		give_get_template_part( 'email-login-form' );
252
+		give_get_template_part('email-login-form');
253 253
 
254 254
 		return ob_get_clean();
255 255
 
256
-	} elseif ( ! isset( $payment_key ) ) {
256
+	} elseif ( ! isset($payment_key)) {
257 257
 
258
-		return Give()->notices->print_frontend_notice( $give_receipt_args['error'], false, 'error' );
258
+		return Give()->notices->print_frontend_notice($give_receipt_args['error'], false, 'error');
259 259
 
260 260
 	}
261 261
 
262
-	$payment_id    = give_get_purchase_id_by_key( $payment_key );
263
-	$user_can_view = give_can_view_receipt( $payment_key );
262
+	$payment_id    = give_get_purchase_id_by_key($payment_key);
263
+	$user_can_view = give_can_view_receipt($payment_key);
264 264
 
265 265
 	// Key was provided, but user is logged out. Offer them the ability to login and view the receipt.
266
-	if ( ! $user_can_view && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) {
266
+	if ( ! $user_can_view && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) {
267 267
 
268 268
 		ob_start();
269 269
 
270
-		give_get_template_part( 'email-login-form' );
270
+		give_get_template_part('email-login-form');
271 271
 
272 272
 		return ob_get_clean();
273 273
 
274
-	} elseif ( ! $user_can_view ) {
274
+	} elseif ( ! $user_can_view) {
275 275
 
276 276
 		global $give_login_redirect;
277 277
 
@@ -279,9 +279,9 @@  discard block
 block discarded – undo
279 279
 
280 280
 		ob_start();
281 281
 
282
-		Give()->notices->print_frontend_notice( apply_filters( 'give_must_be_logged_in_error_message', __( 'You must be logged in to view this donation receipt.', 'give' ) ) );
282
+		Give()->notices->print_frontend_notice(apply_filters('give_must_be_logged_in_error_message', __('You must be logged in to view this donation receipt.', 'give')));
283 283
 
284
-		give_get_template_part( 'shortcode', 'login' );
284
+		give_get_template_part('shortcode', 'login');
285 285
 
286 286
 		$login_form = ob_get_clean();
287 287
 
@@ -296,20 +296,20 @@  discard block
 block discarded – undo
296 296
 	 * or if user is logged in and the user can view sensitive shop data.
297 297
 	 *
298 298
 	 */
299
-	if ( ! apply_filters( 'give_user_can_view_receipt', $user_can_view, $give_receipt_args ) ) {
300
-		return Give()->notices->print_frontend_notice( $give_receipt_args['error'], false, 'error' );
299
+	if ( ! apply_filters('give_user_can_view_receipt', $user_can_view, $give_receipt_args)) {
300
+		return Give()->notices->print_frontend_notice($give_receipt_args['error'], false, 'error');
301 301
 	}
302 302
 
303 303
 	ob_start();
304 304
 
305
-	give_get_template_part( 'shortcode', 'receipt' );
305
+	give_get_template_part('shortcode', 'receipt');
306 306
 
307 307
 	$display = ob_get_clean();
308 308
 
309 309
 	return $display;
310 310
 }
311 311
 
312
-add_shortcode( 'give_receipt', 'give_receipt_shortcode' );
312
+add_shortcode('give_receipt', 'give_receipt_shortcode');
313 313
 
314 314
 /**
315 315
  * Profile Editor Shortcode.
@@ -328,18 +328,18 @@  discard block
 block discarded – undo
328 328
  *
329 329
  * @return string Output generated from the profile editor
330 330
  */
331
-function give_profile_editor_shortcode( $atts ) {
331
+function give_profile_editor_shortcode($atts) {
332 332
 
333 333
 	ob_start();
334 334
 
335
-	give_get_template_part( 'shortcode', 'profile-editor' );
335
+	give_get_template_part('shortcode', 'profile-editor');
336 336
 
337 337
 	$display = ob_get_clean();
338 338
 
339 339
 	return $display;
340 340
 }
341 341
 
342
-add_shortcode( 'give_profile_editor', 'give_profile_editor_shortcode' );
342
+add_shortcode('give_profile_editor', 'give_profile_editor_shortcode');
343 343
 
344 344
 /**
345 345
  * Process Profile Updater Form.
@@ -352,30 +352,30 @@  discard block
 block discarded – undo
352 352
  *
353 353
  * @return bool
354 354
  */
355
-function give_process_profile_editor_updates( $data ) {
355
+function give_process_profile_editor_updates($data) {
356 356
 	// Profile field change request
357
-	if ( empty( $_POST['give_profile_editor_submit'] ) && ! is_user_logged_in() ) {
357
+	if (empty($_POST['give_profile_editor_submit']) && ! is_user_logged_in()) {
358 358
 		return false;
359 359
 	}
360 360
 
361 361
 	// Nonce security
362
-	if ( ! wp_verify_nonce( $data['give_profile_editor_nonce'], 'give-profile-editor-nonce' ) ) {
362
+	if ( ! wp_verify_nonce($data['give_profile_editor_nonce'], 'give-profile-editor-nonce')) {
363 363
 		return false;
364 364
 	}
365 365
 
366 366
 	$user_id       = get_current_user_id();
367
-	$old_user_data = get_userdata( $user_id );
368
-
369
-	$display_name = isset( $data['give_display_name'] ) ? sanitize_text_field( $data['give_display_name'] ) : $old_user_data->display_name;
370
-	$first_name   = isset( $data['give_first_name'] ) ? sanitize_text_field( $data['give_first_name'] ) : $old_user_data->first_name;
371
-	$last_name    = isset( $data['give_last_name'] ) ? sanitize_text_field( $data['give_last_name'] ) : $old_user_data->last_name;
372
-	$email        = isset( $data['give_email'] ) ? sanitize_email( $data['give_email'] ) : $old_user_data->user_email;
373
-	$line1        = ( isset( $data['give_address_line1'] ) ? sanitize_text_field( $data['give_address_line1'] ) : '' );
374
-	$line2        = ( isset( $data['give_address_line2'] ) ? sanitize_text_field( $data['give_address_line2'] ) : '' );
375
-	$city         = ( isset( $data['give_address_city'] ) ? sanitize_text_field( $data['give_address_city'] ) : '' );
376
-	$state        = ( isset( $data['give_address_state'] ) ? sanitize_text_field( $data['give_address_state'] ) : '' );
377
-	$zip          = ( isset( $data['give_address_zip'] ) ? sanitize_text_field( $data['give_address_zip'] ) : '' );
378
-	$country      = ( isset( $data['give_address_country'] ) ? sanitize_text_field( $data['give_address_country'] ) : '' );
367
+	$old_user_data = get_userdata($user_id);
368
+
369
+	$display_name = isset($data['give_display_name']) ? sanitize_text_field($data['give_display_name']) : $old_user_data->display_name;
370
+	$first_name   = isset($data['give_first_name']) ? sanitize_text_field($data['give_first_name']) : $old_user_data->first_name;
371
+	$last_name    = isset($data['give_last_name']) ? sanitize_text_field($data['give_last_name']) : $old_user_data->last_name;
372
+	$email        = isset($data['give_email']) ? sanitize_email($data['give_email']) : $old_user_data->user_email;
373
+	$line1        = (isset($data['give_address_line1']) ? sanitize_text_field($data['give_address_line1']) : '');
374
+	$line2        = (isset($data['give_address_line2']) ? sanitize_text_field($data['give_address_line2']) : '');
375
+	$city         = (isset($data['give_address_city']) ? sanitize_text_field($data['give_address_city']) : '');
376
+	$state        = (isset($data['give_address_state']) ? sanitize_text_field($data['give_address_state']) : '');
377
+	$zip          = (isset($data['give_address_zip']) ? sanitize_text_field($data['give_address_zip']) : '');
378
+	$country      = (isset($data['give_address_country']) ? sanitize_text_field($data['give_address_country']) : '');
379 379
 
380 380
 	$userdata = array(
381 381
 		'ID'           => $user_id,
@@ -403,40 +403,40 @@  discard block
 block discarded – undo
403 403
 	 * @param int $user_id The ID of the user.
404 404
 	 * @param array $userdata User info, including ID, first name, last name, display name and email.
405 405
 	 */
406
-	do_action( 'give_pre_update_user_profile', $user_id, $userdata );
406
+	do_action('give_pre_update_user_profile', $user_id, $userdata);
407 407
 
408 408
 	// Make sure to validate passwords for existing Donors
409
-	give_validate_user_password( $data['give_new_user_pass1'], $data['give_new_user_pass2'] );
409
+	give_validate_user_password($data['give_new_user_pass1'], $data['give_new_user_pass2']);
410 410
 
411
-	if ( empty( $email ) ) {
411
+	if (empty($email)) {
412 412
 		// Make sure email should not be empty.
413
-		give_set_error( 'email_empty', __( 'The email you entered is empty.', 'give' ) );
413
+		give_set_error('email_empty', __('The email you entered is empty.', 'give'));
414 414
 
415
-	} else if ( ! is_email( $email ) ) {
415
+	} else if ( ! is_email($email)) {
416 416
 		// Make sure email should be valid.
417
-		give_set_error( 'email_not_valid', __( 'The email you entered is not valid. Please use another', 'give' ) );
417
+		give_set_error('email_not_valid', __('The email you entered is not valid. Please use another', 'give'));
418 418
 
419
-	} else if ( $email != $old_user_data->user_email ) {
419
+	} else if ($email != $old_user_data->user_email) {
420 420
 		// Make sure the new email doesn't belong to another user
421
-		if ( email_exists( $email ) ) {
422
-			give_set_error( 'email_exists', __( 'The email you entered belongs to another user. Please use another.', 'give' ) );
421
+		if (email_exists($email)) {
422
+			give_set_error('email_exists', __('The email you entered belongs to another user. Please use another.', 'give'));
423 423
 		}
424 424
 	}
425 425
 
426 426
 	// Check for errors
427 427
 	$errors = give_get_errors();
428 428
 
429
-	if ( $errors ) {
429
+	if ($errors) {
430 430
 		// Send back to the profile editor if there are errors
431
-		wp_redirect( $data['give_redirect'] );
431
+		wp_redirect($data['give_redirect']);
432 432
 		give_die();
433 433
 	}
434 434
 
435 435
 	// Update the user
436
-	$meta    = update_user_meta( $user_id, '_give_user_address', $address );
437
-	$updated = wp_update_user( $userdata );
436
+	$meta    = update_user_meta($user_id, '_give_user_address', $address);
437
+	$updated = wp_update_user($userdata);
438 438
 
439
-	if ( $updated ) {
439
+	if ($updated) {
440 440
 
441 441
 		/**
442 442
 		 * Fires after updating user profile.
@@ -446,12 +446,12 @@  discard block
 block discarded – undo
446 446
 		 * @param int $user_id The ID of the user.
447 447
 		 * @param array $userdata User info, including ID, first name, last name, display name and email.
448 448
 		 */
449
-		do_action( 'give_user_profile_updated', $user_id, $userdata );
450
-		wp_redirect( add_query_arg( 'updated', 'true', $data['give_redirect'] ) );
449
+		do_action('give_user_profile_updated', $user_id, $userdata);
450
+		wp_redirect(add_query_arg('updated', 'true', $data['give_redirect']));
451 451
 		give_die();
452 452
 	}
453 453
 
454 454
 	return false;
455 455
 }
456 456
 
457
-add_action( 'give_edit_user_profile', 'give_process_profile_editor_updates' );
457
+add_action('give_edit_user_profile', 'give_process_profile_editor_updates');
Please login to merge, or discard this patch.
includes/user-functions.php 1 patch
Spacing   +143 added lines, -143 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly.
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -30,54 +30,54 @@  discard block
 block discarded – undo
30 30
  *
31 31
  * @return bool|array List of all user donations.
32 32
  */
33
-function give_get_users_donations( $user = 0, $number = 20, $pagination = false, $status = 'complete' ) {
33
+function give_get_users_donations($user = 0, $number = 20, $pagination = false, $status = 'complete') {
34 34
 
35
-	if ( empty( $user ) ) {
35
+	if (empty($user)) {
36 36
 		$user = get_current_user_id();
37 37
 	}
38 38
 
39
-	if ( 0 === $user && ! Give()->email_access->token_exists ) {
39
+	if (0 === $user && ! Give()->email_access->token_exists) {
40 40
 		return false;
41 41
 	}
42 42
 
43 43
 	$status = $status === 'complete' ? 'publish' : $status;
44 44
 	$paged = 1;
45 45
 
46
-	if ( $pagination ) {
47
-		if ( get_query_var( 'paged' ) ) {
48
-			$paged = get_query_var( 'paged' );
49
-		} elseif ( get_query_var( 'page' ) ) {
50
-			$paged = get_query_var( 'page' );
46
+	if ($pagination) {
47
+		if (get_query_var('paged')) {
48
+			$paged = get_query_var('paged');
49
+		} elseif (get_query_var('page')) {
50
+			$paged = get_query_var('page');
51 51
 		}
52 52
 	}
53 53
 
54
-	$args = apply_filters( 'give_get_users_donations_args', array(
54
+	$args = apply_filters('give_get_users_donations_args', array(
55 55
 		'user'    => $user,
56 56
 		'number'  => $number,
57 57
 		'status'  => $status,
58 58
 		'orderby' => 'date',
59
-	) );
59
+	));
60 60
 
61
-	if ( $pagination ) {
61
+	if ($pagination) {
62 62
 		$args['page'] = $paged;
63 63
 	} else {
64 64
 		$args['nopaging'] = true;
65 65
 	}
66 66
 
67
-	$by_user_id = is_numeric( $user ) ? true : false;
68
-	$donor   = new Give_Donor( $user, $by_user_id );
67
+	$by_user_id = is_numeric($user) ? true : false;
68
+	$donor = new Give_Donor($user, $by_user_id);
69 69
 
70
-	if ( ! empty( $donor->payment_ids ) ) {
70
+	if ( ! empty($donor->payment_ids)) {
71 71
 
72
-		unset( $args['user'] );
73
-		$args['post__in'] = array_map( 'absint', explode( ',', $donor->payment_ids ) );
72
+		unset($args['user']);
73
+		$args['post__in'] = array_map('absint', explode(',', $donor->payment_ids));
74 74
 
75 75
 	}
76 76
 
77
-	$donations = give_get_payments( apply_filters( 'give_get_users_donations_args', $args ) );
77
+	$donations = give_get_payments(apply_filters('give_get_users_donations_args', $args));
78 78
 
79 79
 	// No donations
80
-	if ( ! $donations ) {
80
+	if ( ! $donations) {
81 81
 		return false;
82 82
 	}
83 83
 
@@ -96,65 +96,65 @@  discard block
 block discarded – undo
96 96
  *
97 97
  * @return bool|object List of unique forms donated by user
98 98
  */
99
-function give_get_users_completed_donations( $user = 0, $status = 'complete' ) {
100
-	if ( empty( $user ) ) {
99
+function give_get_users_completed_donations($user = 0, $status = 'complete') {
100
+	if (empty($user)) {
101 101
 		$user = get_current_user_id();
102 102
 	}
103 103
 
104
-	if ( empty( $user ) ) {
104
+	if (empty($user)) {
105 105
 		return false;
106 106
 	}
107 107
 
108
-	$by_user_id = is_numeric( $user ) ? true : false;
108
+	$by_user_id = is_numeric($user) ? true : false;
109 109
 
110
-	$donor = new Give_Donor( $user, $by_user_id );
110
+	$donor = new Give_Donor($user, $by_user_id);
111 111
 
112
-	if ( empty( $donor->payment_ids ) ) {
112
+	if (empty($donor->payment_ids)) {
113 113
 		return false;
114 114
 	}
115 115
 
116 116
 	// Get all the items donated.
117
-	$payment_ids    = array_reverse( explode( ',', $donor->payment_ids ) );
118
-	$limit_payments = apply_filters( 'give_users_completed_donations_payments', 50 );
119
-	if ( ! empty( $limit_payments ) ) {
120
-		$payment_ids = array_slice( $payment_ids, 0, $limit_payments );
117
+	$payment_ids    = array_reverse(explode(',', $donor->payment_ids));
118
+	$limit_payments = apply_filters('give_users_completed_donations_payments', 50);
119
+	if ( ! empty($limit_payments)) {
120
+		$payment_ids = array_slice($payment_ids, 0, $limit_payments);
121 121
 	}
122 122
 	$donation_data = array();
123
-	foreach ( $payment_ids as $payment_id ) {
124
-		$donation_data[] = give_get_payment_meta( $payment_id );
123
+	foreach ($payment_ids as $payment_id) {
124
+		$donation_data[] = give_get_payment_meta($payment_id);
125 125
 	}
126 126
 
127
-	if ( empty( $donation_data ) ) {
127
+	if (empty($donation_data)) {
128 128
 		return false;
129 129
 	}
130 130
 
131 131
 	// Grab only the post ids "form_id" of the forms donated on this order
132 132
 	$completed_donations_ids = array();
133
-	foreach ( $donation_data as $donation_meta ) {
134
-		$completed_donations_ids[] = isset( $donation_meta['form_id'] ) ? $donation_meta['form_id'] : '';
133
+	foreach ($donation_data as $donation_meta) {
134
+		$completed_donations_ids[] = isset($donation_meta['form_id']) ? $donation_meta['form_id'] : '';
135 135
 	}
136 136
 
137
-	if ( empty( $completed_donations_ids ) ) {
137
+	if (empty($completed_donations_ids)) {
138 138
 		return false;
139 139
 	}
140 140
 
141 141
 	// Only include each donation once
142
-	$form_ids = array_unique( $completed_donations_ids );
142
+	$form_ids = array_unique($completed_donations_ids);
143 143
 
144 144
 	// Make sure we still have some products and a first item
145
-	if ( empty( $form_ids ) || ! isset( $form_ids[0] ) ) {
145
+	if (empty($form_ids) || ! isset($form_ids[0])) {
146 146
 		return false;
147 147
 	}
148 148
 
149
-	$post_type = get_post_type( $form_ids[0] );
149
+	$post_type = get_post_type($form_ids[0]);
150 150
 
151
-	$args = apply_filters( 'give_get_users_completed_donations_args', array(
151
+	$args = apply_filters('give_get_users_completed_donations_args', array(
152 152
 		'include'        => $form_ids,
153 153
 		'post_type'      => $post_type,
154
-		'posts_per_page' => - 1,
155
-	) );
154
+		'posts_per_page' => -1,
155
+	));
156 156
 
157
-	return apply_filters( 'give_users_completed_donations_list', get_posts( $args ) );
157
+	return apply_filters('give_users_completed_donations_list', get_posts($args));
158 158
 }
159 159
 
160 160
 
@@ -170,12 +170,12 @@  discard block
 block discarded – undo
170 170
  *
171 171
  * @return      bool True if has donated, false other wise.
172 172
  */
173
-function give_has_donations( $user_id = null ) {
174
-	if ( empty( $user_id ) ) {
173
+function give_has_donations($user_id = null) {
174
+	if (empty($user_id)) {
175 175
 		$user_id = get_current_user_id();
176 176
 	}
177 177
 
178
-	if ( give_get_users_donations( $user_id, 1 ) ) {
178
+	if (give_get_users_donations($user_id, 1)) {
179 179
 		return true; // User has at least one donation.
180 180
 	}
181 181
 
@@ -196,23 +196,23 @@  discard block
 block discarded – undo
196 196
  *
197 197
  * @return      array
198 198
  */
199
-function give_get_donation_stats_by_user( $user = '' ) {
199
+function give_get_donation_stats_by_user($user = '') {
200 200
 
201 201
 	$field = '';
202 202
 
203
-	if ( is_email( $user ) ) {
203
+	if (is_email($user)) {
204 204
 		$field = 'email';
205
-	} elseif ( is_numeric( $user ) ) {
205
+	} elseif (is_numeric($user)) {
206 206
 		$field = 'user_id';
207 207
 	}
208 208
 
209
-	$stats    = array();
210
-	$donor = Give()->donors->get_donor_by( $field, $user );
209
+	$stats = array();
210
+	$donor = Give()->donors->get_donor_by($field, $user);
211 211
 
212
-	if ( $donor ) {
213
-		$donor = new Give_Donor( $donor->id );
214
-		$stats['purchases']   = absint( $donor->purchase_count );
215
-		$stats['total_spent'] = give_sanitize_amount( $donor->purchase_value );
212
+	if ($donor) {
213
+		$donor = new Give_Donor($donor->id);
214
+		$stats['purchases']   = absint($donor->purchase_count);
215
+		$stats['total_spent'] = give_sanitize_amount($donor->purchase_value);
216 216
 	}
217 217
 
218 218
 	/**
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 	 *
221 221
 	 * @since 1.7
222 222
 	 */
223
-	$stats = (array) apply_filters( 'give_donation_stats_by_user', $stats, $user );
223
+	$stats = (array) apply_filters('give_donation_stats_by_user', $stats, $user);
224 224
 
225 225
 	return $stats;
226 226
 }
@@ -238,21 +238,21 @@  discard block
 block discarded – undo
238 238
  *
239 239
  * @return      int The total number of donations.
240 240
  */
241
-function give_count_donations_of_donor( $user = null ) {
241
+function give_count_donations_of_donor($user = null) {
242 242
 
243 243
 	// Logged in?
244
-	if ( empty( $user ) ) {
244
+	if (empty($user)) {
245 245
 		$user = get_current_user_id();
246 246
 	}
247 247
 
248 248
 	// Email access?
249
-	if ( empty( $user ) && Give()->email_access->token_email ) {
249
+	if (empty($user) && Give()->email_access->token_email) {
250 250
 		$user = Give()->email_access->token_email;
251 251
 	}
252 252
 
253
-	$stats = ! empty( $user ) ? give_get_donation_stats_by_user( $user ) : false;
253
+	$stats = ! empty($user) ? give_get_donation_stats_by_user($user) : false;
254 254
 
255
-	return isset( $stats['purchases'] ) ? $stats['purchases'] : 0;
255
+	return isset($stats['purchases']) ? $stats['purchases'] : 0;
256 256
 }
257 257
 
258 258
 /**
@@ -265,9 +265,9 @@  discard block
 block discarded – undo
265 265
  *
266 266
  * @return      float The total amount the user has spent
267 267
  */
268
-function give_donation_total_of_user( $user = null ) {
268
+function give_donation_total_of_user($user = null) {
269 269
 
270
-	$stats = give_get_donation_stats_by_user( $user );
270
+	$stats = give_get_donation_stats_by_user($user);
271 271
 
272 272
 	return $stats['total_spent'];
273 273
 }
@@ -283,40 +283,40 @@  discard block
 block discarded – undo
283 283
  *
284 284
  * @return bool
285 285
  */
286
-function give_validate_username( $username, $form_id = 0 ) {
286
+function give_validate_username($username, $form_id = 0) {
287 287
 	$valid = true;
288 288
 
289 289
 	// Validate username.
290
-	if ( ! empty( $username ) ) {
290
+	if ( ! empty($username)) {
291 291
 
292 292
 		// Sanitize username.
293
-		$sanitized_user_name = sanitize_user( $username, false );
293
+		$sanitized_user_name = sanitize_user($username, false);
294 294
 
295 295
 		// We have an user name, check if it already exists.
296
-		if ( username_exists( $username ) ) {
296
+		if (username_exists($username)) {
297 297
 			// Username already registered.
298
-			give_set_error( 'username_unavailable', __( 'Username already taken.', 'give' ) );
298
+			give_set_error('username_unavailable', __('Username already taken.', 'give'));
299 299
 			$valid = false;
300 300
 
301 301
 			// Check if it's valid.
302
-		} elseif ( $sanitized_user_name !== $username ) {
302
+		} elseif ($sanitized_user_name !== $username) {
303 303
 			// Invalid username.
304
-			if ( is_multisite() ) {
305
-				give_set_error( 'username_invalid', __( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ) );
304
+			if (is_multisite()) {
305
+				give_set_error('username_invalid', __('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give'));
306 306
 				$valid = false;
307 307
 			} else {
308
-				give_set_error( 'username_invalid', __( 'Invalid username.', 'give' ) );
308
+				give_set_error('username_invalid', __('Invalid username.', 'give'));
309 309
 				$valid = false;
310 310
 			}
311 311
 		}
312 312
 	} else {
313 313
 		// Username is empty.
314
-		give_set_error( 'username_empty', __( 'Enter a username.', 'give' ) );
314
+		give_set_error('username_empty', __('Enter a username.', 'give'));
315 315
 		$valid = false;
316 316
 
317 317
 		// Check if guest checkout is disable for form.
318
-		if ( $form_id && give_logged_in_only( $form_id ) ) {
319
-			give_set_error( 'registration_required', __( 'You must register or login to complete your donation.', 'give' ) );
318
+		if ($form_id && give_logged_in_only($form_id)) {
319
+			give_set_error('registration_required', __('You must register or login to complete your donation.', 'give'));
320 320
 			$valid = false;
321 321
 		}
322 322
 	}
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 	 * @param string $username
331 331
 	 * @param bool   $form_id
332 332
 	 */
333
-	$valid = (bool) apply_filters( 'give_validate_username', $valid, $username, $form_id );
333
+	$valid = (bool) apply_filters('give_validate_username', $valid, $username, $form_id);
334 334
 
335 335
 	return $valid;
336 336
 }
@@ -346,22 +346,22 @@  discard block
 block discarded – undo
346 346
  *
347 347
  * @return bool
348 348
  */
349
-function give_validate_user_email( $email, $registering_new_user = false ) {
349
+function give_validate_user_email($email, $registering_new_user = false) {
350 350
 	$valid = true;
351 351
 
352
-	if ( empty( $email ) ) {
352
+	if (empty($email)) {
353 353
 		// No email.
354
-		give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) );
354
+		give_set_error('email_empty', __('Enter an email.', 'give'));
355 355
 		$valid = false;
356 356
 
357
-	} elseif ( ! is_email( $email ) ) {
357
+	} elseif ( ! is_email($email)) {
358 358
 		// Validate email.
359
-		give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) );
359
+		give_set_error('email_invalid', __('Invalid email.', 'give'));
360 360
 		$valid = false;
361 361
 
362
-	} elseif ( $registering_new_user && ( give_donor_email_exists( $email ) || email_exists( $email ) ) ) {
362
+	} elseif ($registering_new_user && (give_donor_email_exists($email) || email_exists($email))) {
363 363
 		// Check if email exists.
364
-		give_set_error( 'email_used', __( 'The email address provided is already active for another user.', 'give' ) );
364
+		give_set_error('email_used', __('The email address provided is already active for another user.', 'give'));
365 365
 		$valid = false;
366 366
 	}
367 367
 
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 	 * @param string $email
375 375
 	 * @param bool   $registering_new_user
376 376
 	 */
377
-	$valid = (bool) apply_filters( 'give_validate_user_email', $valid, $email, $registering_new_user );
377
+	$valid = (bool) apply_filters('give_validate_user_email', $valid, $email, $registering_new_user);
378 378
 
379 379
 	return $valid;
380 380
 }
@@ -390,34 +390,34 @@  discard block
 block discarded – undo
390 390
  *
391 391
  * @return bool
392 392
  */
393
-function give_validate_user_password( $password = '', $confirm_password = '', $registering_new_user = false ) {
393
+function give_validate_user_password($password = '', $confirm_password = '', $registering_new_user = false) {
394 394
 	$valid = true;
395 395
 
396 396
 	// Passwords Validation For New Donors Only
397
-	if ( $registering_new_user ) {
397
+	if ($registering_new_user) {
398 398
 		// Password or confirmation missing.
399
-		if ( ! $password ) {
399
+		if ( ! $password) {
400 400
 			// The password is invalid.
401
-			give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) );
401
+			give_set_error('password_empty', __('Enter a password.', 'give'));
402 402
 			$valid = false;
403
-		} elseif ( ! $confirm_password ) {
403
+		} elseif ( ! $confirm_password) {
404 404
 			// Confirmation password is invalid.
405
-			give_set_error( 'confirmation_empty', __( 'Enter the password confirmation.', 'give' ) );
405
+			give_set_error('confirmation_empty', __('Enter the password confirmation.', 'give'));
406 406
 			$valid = false;
407 407
 		}
408 408
 	}
409 409
 	// Passwords Validation For New Donors as well as Existing Donors
410
-	if( $password || $confirm_password ) {
411
-		if ( strlen( $password ) < 6 || strlen( $confirm_password ) < 6 ) {
410
+	if ($password || $confirm_password) {
411
+		if (strlen($password) < 6 || strlen($confirm_password) < 6) {
412 412
 			// Seems Weak Password
413
-			give_set_error( 'password_weak', __( 'Passwords should have atleast 6 characters.', 'give' ) );
413
+			give_set_error('password_weak', __('Passwords should have atleast 6 characters.', 'give'));
414 414
 			$valid = false;
415 415
 		}
416
-		if ( $password && $confirm_password ) {
416
+		if ($password && $confirm_password) {
417 417
 			// Verify confirmation matches.
418
-			if ( $password != $confirm_password ) {
418
+			if ($password != $confirm_password) {
419 419
 				// Passwords do not match
420
-				give_set_error( 'password_mismatch', __( 'Passwords you entered do not match. Please try again.', 'give' ) );
420
+				give_set_error('password_mismatch', __('Passwords you entered do not match. Please try again.', 'give'));
421 421
 				$valid = false;
422 422
 			}
423 423
 		}
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 	 * @param string $confirm_password
434 434
 	 * @param bool   $registering_new_user
435 435
 	 */
436
-	$valid = (bool) apply_filters( 'give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user );
436
+	$valid = (bool) apply_filters('give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user);
437 437
 
438 438
 	return $valid;
439 439
 }
@@ -451,33 +451,33 @@  discard block
 block discarded – undo
451 451
  *
452 452
  * @return      void
453 453
  */
454
-function give_add_past_donations_to_new_user( $user_id ) {
454
+function give_add_past_donations_to_new_user($user_id) {
455 455
 
456
-	$email = get_the_author_meta( 'user_email', $user_id );
456
+	$email = get_the_author_meta('user_email', $user_id);
457 457
 
458
-	$payments = give_get_payments( array(
458
+	$payments = give_get_payments(array(
459 459
 		's' => $email,
460
-	) );
460
+	));
461 461
 
462
-	if ( $payments ) {
463
-		foreach ( $payments as $payment ) {
464
-			if ( intval( give_get_payment_user_id( $payment->ID ) ) > 0 ) {
462
+	if ($payments) {
463
+		foreach ($payments as $payment) {
464
+			if (intval(give_get_payment_user_id($payment->ID)) > 0) {
465 465
 				continue;
466 466
 			} // End if().
467 467
 
468
-			$meta                    = give_get_payment_meta( $payment->ID );
469
-			$meta['user_info']       = maybe_unserialize( $meta['user_info'] );
468
+			$meta                    = give_get_payment_meta($payment->ID);
469
+			$meta['user_info']       = maybe_unserialize($meta['user_info']);
470 470
 			$meta['user_info']['id'] = $user_id;
471 471
 
472 472
 			// Store the updated user ID in the payment meta.
473
-			give_update_payment_meta( $payment->ID, '_give_payment_meta', $meta );
474
-			give_update_payment_meta( $payment->ID, '_give_payment_user_id', $user_id );
473
+			give_update_payment_meta($payment->ID, '_give_payment_meta', $meta);
474
+			give_update_payment_meta($payment->ID, '_give_payment_user_id', $user_id);
475 475
 		}
476 476
 	}
477 477
 
478 478
 }
479 479
 
480
-add_action( 'user_register', 'give_add_past_donations_to_new_user' );
480
+add_action('user_register', 'give_add_past_donations_to_new_user');
481 481
 
482 482
 
483 483
 /**
@@ -503,34 +503,34 @@  discard block
 block discarded – undo
503 503
  *
504 504
  * @return        array The donor's address, if any
505 505
  */
506
-function give_get_donor_address( $user_id = 0 ) {
507
-	if ( empty( $user_id ) ) {
506
+function give_get_donor_address($user_id = 0) {
507
+	if (empty($user_id)) {
508 508
 		$user_id = get_current_user_id();
509 509
 	}
510 510
 
511
-	$address = get_user_meta( $user_id, '_give_user_address', true );
511
+	$address = get_user_meta($user_id, '_give_user_address', true);
512 512
 
513
-	if ( ! isset( $address['line1'] ) ) {
513
+	if ( ! isset($address['line1'])) {
514 514
 		$address['line1'] = '';
515 515
 	}
516 516
 
517
-	if ( ! isset( $address['line2'] ) ) {
517
+	if ( ! isset($address['line2'])) {
518 518
 		$address['line2'] = '';
519 519
 	}
520 520
 
521
-	if ( ! isset( $address['city'] ) ) {
521
+	if ( ! isset($address['city'])) {
522 522
 		$address['city'] = '';
523 523
 	}
524 524
 
525
-	if ( ! isset( $address['zip'] ) ) {
525
+	if ( ! isset($address['zip'])) {
526 526
 		$address['zip'] = '';
527 527
 	}
528 528
 
529
-	if ( ! isset( $address['country'] ) ) {
529
+	if ( ! isset($address['country'])) {
530 530
 		$address['country'] = '';
531 531
 	}
532 532
 
533
-	if ( ! isset( $address['state'] ) ) {
533
+	if ( ! isset($address['state'])) {
534 534
 		$address['state'] = '';
535 535
 	}
536 536
 
@@ -550,32 +550,32 @@  discard block
 block discarded – undo
550 550
  *
551 551
  * @return        void
552 552
  */
553
-function give_new_user_notification( $user_id = 0, $user_data = array() ) {
553
+function give_new_user_notification($user_id = 0, $user_data = array()) {
554 554
 
555
-	if ( empty( $user_id ) || empty( $user_data ) ) {
555
+	if (empty($user_id) || empty($user_data)) {
556 556
 		return;
557 557
 	}
558
-	$blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
558
+	$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
559 559
 
560 560
 
561 561
 	// New User Registration: Email sends to the site admin.
562 562
 	$emails = Give()->emails;
563
-	$emails->__set( 'heading', esc_html__( 'New User Registration', 'give' ) );
563
+	$emails->__set('heading', esc_html__('New User Registration', 'give'));
564 564
 
565 565
 	/* translators: %s: site name */
566
-	$message = sprintf( esc_attr__( 'A new user has registered on %s:', 'give' ), $blogname ) . "\r\n\r\n";
566
+	$message = sprintf(esc_attr__('A new user has registered on %s:', 'give'), $blogname)."\r\n\r\n";
567 567
 	/* translators: %s: user login */
568
-	$message .= '<strong>' . esc_attr__( 'Username:', 'give' ) . '</strong> ' . $user_data['user_login'] . "\r\n";
568
+	$message .= '<strong>'.esc_attr__('Username:', 'give').'</strong> '.$user_data['user_login']."\r\n";
569 569
 	/* translators: %s: user email */
570
-	$message .= '<strong>' . esc_attr__( 'E-mail:', 'give' ) . '</strong> ' . $user_data['user_email']  . "\r\n\r\n";
570
+	$message .= '<strong>'.esc_attr__('E-mail:', 'give').'</strong> '.$user_data['user_email']."\r\n\r\n";
571 571
 
572
-	$message .= '<a href="' . admin_url('user-edit.php?user_id=' . $user_id) . '" target="_blank"> ' . esc_attr__( 'Click here to view &raquo;', 'give' ) . '</a>' . "\r\n";
572
+	$message .= '<a href="'.admin_url('user-edit.php?user_id='.$user_id).'" target="_blank"> '.esc_attr__('Click here to view &raquo;', 'give').'</a>'."\r\n";
573 573
 
574 574
 	$emails->send(
575
-		get_option( 'admin_email' ),
575
+		get_option('admin_email'),
576 576
 		sprintf(
577 577
 			/* translators: %s: site name */
578
-			esc_attr__( '[%s] New User Registration', 'give' ),
578
+			esc_attr__('[%s] New User Registration', 'give'),
579 579
 			$blogname
580 580
 		),
581 581
 		$message
@@ -583,22 +583,22 @@  discard block
 block discarded – undo
583 583
 
584 584
 
585 585
 	// Account Information: Email sends to donor who registered.
586
-	$emails->__set( 'heading', esc_html__( 'Account Information', 'give' ) );
586
+	$emails->__set('heading', esc_html__('Account Information', 'give'));
587 587
 
588
-	$message = sprintf( esc_attr__( 'The following email contains your account information for %s:', 'give' ), $blogname ) . "\r\n\r\n";
588
+	$message = sprintf(esc_attr__('The following email contains your account information for %s:', 'give'), $blogname)."\r\n\r\n";
589 589
 
590 590
 	/* translators: %s: user login */
591
-	$message .=  '<strong>' . esc_attr__( 'Username:', 'give' ) . '</strong> ' .  $user_data['user_login'] . "\r\n";
591
+	$message .= '<strong>'.esc_attr__('Username:', 'give').'</strong> '.$user_data['user_login']."\r\n";
592 592
 	/* translators: %s: password */
593
-	$message .=  '<strong>' . esc_attr__( 'Password:', 'give' ) . '</strong> ' . esc_attr__( '[Password entered during donation]', 'give' ) . "\r\n\r\n";
593
+	$message .= '<strong>'.esc_attr__('Password:', 'give').'</strong> '.esc_attr__('[Password entered during donation]', 'give')."\r\n\r\n";
594 594
 
595
-	$message .= '<a href="' . wp_login_url() . '" target="_blank"> ' . esc_attr__( 'Click here to login &raquo;', 'give' ) . '</a>' . "\r\n";
595
+	$message .= '<a href="'.wp_login_url().'" target="_blank"> '.esc_attr__('Click here to login &raquo;', 'give').'</a>'."\r\n";
596 596
 
597 597
 	$emails->send(
598 598
 		$user_data['user_email'],
599 599
 		sprintf(
600 600
 			/* translators: %s: site name */
601
-			esc_attr__( '[%s] Your username and password', 'give' ),
601
+			esc_attr__('[%s] Your username and password', 'give'),
602 602
 			$blogname
603 603
 		),
604 604
 		$message
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
 
607 607
 }
608 608
 
609
-add_action( 'give_insert_user', 'give_new_user_notification', 10, 2 );
609
+add_action('give_insert_user', 'give_new_user_notification', 10, 2);
610 610
 
611 611
 
612 612
 /**
@@ -622,34 +622,34 @@  discard block
 block discarded – undo
622 622
  *
623 623
  * @return      string
624 624
  */
625
-function give_get_donor_name_by( $id = 0, $from = 'donation' ) {
625
+function give_get_donor_name_by($id = 0, $from = 'donation') {
626 626
 
627 627
 	// ID shouldn't be empty
628
-	if ( empty( $id ) ) {
628
+	if (empty($id)) {
629 629
 		return;
630 630
 	}
631 631
 
632 632
 	$name = '';
633 633
 
634
-	switch ( $from ) {
634
+	switch ($from) {
635 635
 
636 636
 		case 'donation':
637 637
 
638
-			$user_info = give_get_payment_meta_user_info( $id );
639
-			$name = $user_info['first_name'] . ' ' . $user_info['last_name'];
638
+			$user_info = give_get_payment_meta_user_info($id);
639
+			$name = $user_info['first_name'].' '.$user_info['last_name'];
640 640
 
641 641
 		break;
642 642
 
643 643
 		case 'donor':
644 644
 
645
-			$donor = new Give_Donor( $id );
645
+			$donor = new Give_Donor($id);
646 646
 			$name = $donor->name;
647 647
 
648 648
 		break;
649 649
 
650 650
 	}
651 651
 
652
-	return trim( $name );
652
+	return trim($name);
653 653
 
654 654
 }
655 655
 
@@ -661,8 +661,8 @@  discard block
 block discarded – undo
661 661
  * @param  string   $email Donor Email.
662 662
  * @return boolean  The user's ID on success, and false on failure.
663 663
  */
664
-function give_donor_email_exists( $email ) {
665
-	if ( Give()->donors->get_donor_by( 'email', $email ) ) {
664
+function give_donor_email_exists($email) {
665
+	if (Give()->donors->get_donor_by('email', $email)) {
666 666
 		return true;
667 667
 	}
668 668
 	return false;
Please login to merge, or discard this patch.
includes/template-functions.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -45,22 +45,22 @@  discard block
 block discarded – undo
45 45
  * @param string $default_path  Default path. Default is empty.
46 46
  */
47 47
 function give_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
48
-    if ( ! empty( $args ) && is_array( $args ) ) {
49
-        extract( $args );
50
-    }
48
+	if ( ! empty( $args ) && is_array( $args ) ) {
49
+		extract( $args );
50
+	}
51 51
 
52
-    $template_names = array( $template_name . '.php' );
52
+	$template_names = array( $template_name . '.php' );
53 53
 
54
-    $located = give_locate_template( $template_names, $template_path, $default_path );
54
+	$located = give_locate_template( $template_names, $template_path, $default_path );
55 55
 
56
-    if ( ! file_exists( $located ) ) {
56
+	if ( ! file_exists( $located ) ) {
57 57
 		/* translators: %s: the template */
58
-        Give()->notices->print_frontend_notice( sprintf( __( 'The %s template was not found.', 'give' ), $located ), true );
59
-        return;
60
-    }
58
+		Give()->notices->print_frontend_notice( sprintf( __( 'The %s template was not found.', 'give' ), $located ), true );
59
+		return;
60
+	}
61 61
 
62
-    // Allow 3rd party plugin filter template file from their plugin.
63
-    $located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path );
62
+	// Allow 3rd party plugin filter template file from their plugin.
63
+	$located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path );
64 64
 
65 65
 	/**
66 66
 	 * Fires in give template, before the file is included.
@@ -74,9 +74,9 @@  discard block
 block discarded – undo
74 74
 	 * @param string $located       Template file filter by 3rd party plugin.
75 75
 	 * @param array  $args          Passed arguments.
76 76
 	 */
77
-    do_action( 'give_before_template_part', $template_name, $template_path, $located, $args );
77
+	do_action( 'give_before_template_part', $template_name, $template_path, $located, $args );
78 78
 
79
-    include( $located );
79
+	include( $located );
80 80
 
81 81
 	/**
82 82
 	 * Fires in give template, after the file is included.
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	 * @param string $located       Template file filter by 3rd party plugin.
91 91
 	 * @param array  $args          Passed arguments.
92 92
 	 */
93
-    do_action( 'give_after_template_part', $template_name, $template_path, $located, $args );
93
+	do_action( 'give_after_template_part', $template_name, $template_path, $located, $args );
94 94
 }
95 95
 
96 96
 /**
Please login to merge, or discard this patch.
Spacing   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
  * @return string
22 22
  */
23 23
 function give_get_templates_dir() {
24
-	return GIVE_PLUGIN_DIR . 'templates';
24
+	return GIVE_PLUGIN_DIR.'templates';
25 25
 }
26 26
 
27 27
 /**
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
  * @return string
32 32
  */
33 33
 function give_get_templates_url() {
34
-	return GIVE_PLUGIN_URL . 'templates';
34
+	return GIVE_PLUGIN_URL.'templates';
35 35
 }
36 36
 
37 37
 /**
@@ -44,23 +44,23 @@  discard block
 block discarded – undo
44 44
  * @param string $template_path Template file path. Default is empty.
45 45
  * @param string $default_path  Default path. Default is empty.
46 46
  */
47
-function give_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
48
-    if ( ! empty( $args ) && is_array( $args ) ) {
49
-        extract( $args );
47
+function give_get_template($template_name, $args = array(), $template_path = '', $default_path = '') {
48
+    if ( ! empty($args) && is_array($args)) {
49
+        extract($args);
50 50
     }
51 51
 
52
-    $template_names = array( $template_name . '.php' );
52
+    $template_names = array($template_name.'.php');
53 53
 
54
-    $located = give_locate_template( $template_names, $template_path, $default_path );
54
+    $located = give_locate_template($template_names, $template_path, $default_path);
55 55
 
56
-    if ( ! file_exists( $located ) ) {
56
+    if ( ! file_exists($located)) {
57 57
 		/* translators: %s: the template */
58
-        Give()->notices->print_frontend_notice( sprintf( __( 'The %s template was not found.', 'give' ), $located ), true );
58
+        Give()->notices->print_frontend_notice(sprintf(__('The %s template was not found.', 'give'), $located), true);
59 59
         return;
60 60
     }
61 61
 
62 62
     // Allow 3rd party plugin filter template file from their plugin.
63
-    $located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path );
63
+    $located = apply_filters('give_get_template', $located, $template_name, $args, $template_path, $default_path);
64 64
 
65 65
 	/**
66 66
 	 * Fires in give template, before the file is included.
@@ -74,9 +74,9 @@  discard block
 block discarded – undo
74 74
 	 * @param string $located       Template file filter by 3rd party plugin.
75 75
 	 * @param array  $args          Passed arguments.
76 76
 	 */
77
-    do_action( 'give_before_template_part', $template_name, $template_path, $located, $args );
77
+    do_action('give_before_template_part', $template_name, $template_path, $located, $args);
78 78
 
79
-    include( $located );
79
+    include($located);
80 80
 
81 81
 	/**
82 82
 	 * Fires in give template, after the file is included.
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	 * @param string $located       Template file filter by 3rd party plugin.
91 91
 	 * @param array  $args          Passed arguments.
92 92
 	 */
93
-    do_action( 'give_after_template_part', $template_name, $template_path, $located, $args );
93
+    do_action('give_after_template_part', $template_name, $template_path, $located, $args);
94 94
 }
95 95
 
96 96
 /**
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
  *
107 107
  * @return string 
108 108
  */
109
-function give_get_template_part( $slug, $name = null, $load = true ) {
109
+function give_get_template_part($slug, $name = null, $load = true) {
110 110
 
111 111
 	/**
112 112
 	 * Fires in give template part, before the template part is retrieved.
@@ -118,20 +118,20 @@  discard block
 block discarded – undo
118 118
 	 * @param string $slug Template part file slug {slug}.php.
119 119
 	 * @param string $name Template part file name {slug}-{name}.php.
120 120
 	 */
121
-	do_action( "get_template_part_{$slug}", $slug, $name );
121
+	do_action("get_template_part_{$slug}", $slug, $name);
122 122
 
123 123
 	// Setup possible parts
124 124
 	$templates = array();
125
-	if ( isset( $name ) ) {
126
-		$templates[] = $slug . '-' . $name . '.php';
125
+	if (isset($name)) {
126
+		$templates[] = $slug.'-'.$name.'.php';
127 127
 	}
128
-	$templates[] = $slug . '.php';
128
+	$templates[] = $slug.'.php';
129 129
 
130 130
 	// Allow template parts to be filtered
131
-	$templates = apply_filters( 'give_get_template_part', $templates, $slug, $name );
131
+	$templates = apply_filters('give_get_template_part', $templates, $slug, $name);
132 132
 
133 133
 	// Return the part that is found
134
-	return give_locate_template( $templates, $load, false );
134
+	return give_locate_template($templates, $load, false);
135 135
 }
136 136
 
137 137
 /**
@@ -152,37 +152,37 @@  discard block
 block discarded – undo
152 152
  *
153 153
  * @return string The template filename if one is located.
154 154
  */
155
-function give_locate_template( $template_names, $load = false, $require_once = true ) {
155
+function give_locate_template($template_names, $load = false, $require_once = true) {
156 156
 	// No file found yet
157 157
 	$located = false;
158 158
 
159 159
 	// Try to find a template file
160
-	foreach ( (array) $template_names as $template_name ) {
160
+	foreach ((array) $template_names as $template_name) {
161 161
 
162 162
 		// Continue if template is empty
163
-		if ( empty( $template_name ) ) {
163
+		if (empty($template_name)) {
164 164
 			continue;
165 165
 		}
166 166
 
167 167
 		// Trim off any slashes from the template name
168
-		$template_name = ltrim( $template_name, '/' );
168
+		$template_name = ltrim($template_name, '/');
169 169
 
170 170
 		// try locating this template file by looping through the template paths
171
-		foreach ( give_get_theme_template_paths() as $template_path ) {
171
+		foreach (give_get_theme_template_paths() as $template_path) {
172 172
 
173
-			if ( file_exists( $template_path . $template_name ) ) {
174
-				$located = $template_path . $template_name;
173
+			if (file_exists($template_path.$template_name)) {
174
+				$located = $template_path.$template_name;
175 175
 				break;
176 176
 			}
177 177
 		}
178 178
 
179
-		if ( $located ) {
179
+		if ($located) {
180 180
 			break;
181 181
 		}
182 182
 	}
183 183
 
184
-	if ( ( true == $load ) && ! empty( $located ) ) {
185
-		load_template( $located, $require_once );
184
+	if ((true == $load) && ! empty($located)) {
185
+		load_template($located, $require_once);
186 186
 	}
187 187
 
188 188
 	return $located;
@@ -199,17 +199,17 @@  discard block
 block discarded – undo
199 199
 	$template_dir = give_get_theme_template_dir_name();
200 200
 
201 201
 	$file_paths = array(
202
-		1   => trailingslashit( get_stylesheet_directory() ) . $template_dir,
203
-		10  => trailingslashit( get_template_directory() ) . $template_dir,
202
+		1   => trailingslashit(get_stylesheet_directory()).$template_dir,
203
+		10  => trailingslashit(get_template_directory()).$template_dir,
204 204
 		100 => give_get_templates_dir()
205 205
 	);
206 206
 
207
-	$file_paths = apply_filters( 'give_template_paths', $file_paths );
207
+	$file_paths = apply_filters('give_template_paths', $file_paths);
208 208
 
209 209
 	// sort the file paths based on priority
210
-	ksort( $file_paths, SORT_NUMERIC );
210
+	ksort($file_paths, SORT_NUMERIC);
211 211
 
212
-	return array_map( 'trailingslashit', $file_paths );
212
+	return array_map('trailingslashit', $file_paths);
213 213
 }
214 214
 
215 215
 /**
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
  * @return string
222 222
  */
223 223
 function give_get_theme_template_dir_name() {
224
-	return trailingslashit( apply_filters( 'give_templates_dir', 'give' ) );
224
+	return trailingslashit(apply_filters('give_templates_dir', 'give'));
225 225
 }
226 226
 
227 227
 /**
@@ -231,10 +231,10 @@  discard block
 block discarded – undo
231 231
  * @return void
232 232
  */
233 233
 function give_version_in_header() {
234
-	echo '<meta name="generator" content="Give v' . GIVE_VERSION . '" />' . "\n";
234
+	echo '<meta name="generator" content="Give v'.GIVE_VERSION.'" />'."\n";
235 235
 }
236 236
 
237
-add_action( 'wp_head', 'give_version_in_header' );
237
+add_action('wp_head', 'give_version_in_header');
238 238
 
239 239
 /**
240 240
  * Determines if we're currently on the Donations History page.
@@ -244,9 +244,9 @@  discard block
 block discarded – undo
244 244
  */
245 245
 function give_is_donation_history_page() {
246 246
 
247
-	$ret = is_page( give_get_option( 'history_page' ) );
247
+	$ret = is_page(give_get_option('history_page'));
248 248
 
249
-	return apply_filters( 'give_is_donation_history_page', $ret );
249
+	return apply_filters('give_is_donation_history_page', $ret);
250 250
 }
251 251
 
252 252
 /**
@@ -258,25 +258,25 @@  discard block
 block discarded – undo
258 258
  *
259 259
  * @return array Modified array of classes
260 260
  */
261
-function give_add_body_classes( $class ) {
261
+function give_add_body_classes($class) {
262 262
 	$classes = (array) $class;
263 263
 
264
-	if ( give_is_success_page() ) {
264
+	if (give_is_success_page()) {
265 265
 		$classes[] = 'give-success';
266 266
 		$classes[] = 'give-page';
267 267
 	}
268 268
 
269
-	if ( give_is_failed_transaction_page() ) {
269
+	if (give_is_failed_transaction_page()) {
270 270
 		$classes[] = 'give-failed-transaction';
271 271
 		$classes[] = 'give-page';
272 272
 	}
273 273
 
274
-	if ( give_is_donation_history_page() ) {
274
+	if (give_is_donation_history_page()) {
275 275
 		$classes[] = 'give-donation-history';
276 276
 		$classes[] = 'give-page';
277 277
 	}
278 278
 
279
-	if ( give_is_test_mode() ) {
279
+	if (give_is_test_mode()) {
280 280
 		$classes[] = 'give-test-mode';
281 281
 		$classes[] = 'give-page';
282 282
 	}
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 	//Theme-specific Classes used to prevent conflicts via CSS
285 285
 	$current_theme = wp_get_theme();
286 286
 
287
-	switch ( $current_theme->template ) {
287
+	switch ($current_theme->template) {
288 288
 
289 289
 		case 'Divi':
290 290
 			$classes[] = 'give-divi';
@@ -298,10 +298,10 @@  discard block
 block discarded – undo
298 298
 
299 299
 	}
300 300
 
301
-	return array_unique( $classes );
301
+	return array_unique($classes);
302 302
 }
303 303
 
304
-add_filter( 'body_class', 'give_add_body_classes' );
304
+add_filter('body_class', 'give_add_body_classes');
305 305
 
306 306
 
307 307
 /**
@@ -317,22 +317,22 @@  discard block
 block discarded – undo
317 317
  *
318 318
  * @return array
319 319
  */
320
-function give_add_post_class( $classes, $class = '', $post_id = '' ) {
321
-	if ( ! $post_id || 'give_forms' !== get_post_type( $post_id ) ) {
320
+function give_add_post_class($classes, $class = '', $post_id = '') {
321
+	if ( ! $post_id || 'give_forms' !== get_post_type($post_id)) {
322 322
 		return $classes;
323 323
 	}
324 324
 
325 325
 	//@TODO: Add classes for custom taxonomy and form configurations (multi vs single donations, etc).
326 326
 
327
-	if ( false !== ( $key = array_search( 'hentry', $classes ) ) ) {
328
-		unset( $classes[ $key ] );
327
+	if (false !== ($key = array_search('hentry', $classes))) {
328
+		unset($classes[$key]);
329 329
 	}
330 330
 
331 331
 	return $classes;
332 332
 }
333 333
 
334 334
 
335
-add_filter( 'post_class', 'give_add_post_class', 20, 3 );
335
+add_filter('post_class', 'give_add_post_class', 20, 3);
336 336
 
337 337
 /**
338 338
  * Get the placeholder image URL for forms etc
@@ -342,74 +342,74 @@  discard block
 block discarded – undo
342 342
  */
343 343
 function give_get_placeholder_img_src() {
344 344
 
345
-	$placeholder_url = '//placehold.it/600x600&text=' . urlencode( esc_attr__( 'Give Placeholder Image', 'give' ) );
345
+	$placeholder_url = '//placehold.it/600x600&text='.urlencode(esc_attr__('Give Placeholder Image', 'give'));
346 346
 
347
-	return apply_filters( 'give_placeholder_img_src', $placeholder_url );
347
+	return apply_filters('give_placeholder_img_src', $placeholder_url);
348 348
 }
349 349
 
350 350
 
351 351
 /**
352 352
  * Global
353 353
  */
354
-if ( ! function_exists( 'give_output_content_wrapper' ) ) {
354
+if ( ! function_exists('give_output_content_wrapper')) {
355 355
 
356 356
 	/**
357 357
 	 * Output the start of the page wrapper.
358 358
 	 */
359 359
 	function give_output_content_wrapper() {
360
-		give_get_template_part( 'global/wrapper-start' );
360
+		give_get_template_part('global/wrapper-start');
361 361
 	}
362 362
 }
363
-if ( ! function_exists( 'give_output_content_wrapper_end' ) ) {
363
+if ( ! function_exists('give_output_content_wrapper_end')) {
364 364
 
365 365
 	/**
366 366
 	 * Output the end of the page wrapper.
367 367
 	 */
368 368
 	function give_output_content_wrapper_end() {
369
-		give_get_template_part( 'global/wrapper-end' );
369
+		give_get_template_part('global/wrapper-end');
370 370
 	}
371 371
 }
372 372
 
373 373
 /**
374 374
  * Single Give Form
375 375
  */
376
-if ( ! function_exists( 'give_left_sidebar_pre_wrap' ) ) {
376
+if ( ! function_exists('give_left_sidebar_pre_wrap')) {
377 377
 	function give_left_sidebar_pre_wrap() {
378
-		echo apply_filters( 'give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">' );
378
+		echo apply_filters('give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">');
379 379
 	}
380 380
 }
381 381
 
382
-if ( ! function_exists( 'give_left_sidebar_post_wrap' ) ) {
382
+if ( ! function_exists('give_left_sidebar_post_wrap')) {
383 383
 	function give_left_sidebar_post_wrap() {
384
-		echo apply_filters( 'give_left_sidebar_post_wrap', '</div>' );
384
+		echo apply_filters('give_left_sidebar_post_wrap', '</div>');
385 385
 	}
386 386
 }
387 387
 
388
-if ( ! function_exists( 'give_get_forms_sidebar' ) ) {
388
+if ( ! function_exists('give_get_forms_sidebar')) {
389 389
 	function give_get_forms_sidebar() {
390
-		give_get_template_part( 'single-give-form/sidebar' );
390
+		give_get_template_part('single-give-form/sidebar');
391 391
 	}
392 392
 }
393 393
 
394
-if ( ! function_exists( 'give_show_form_images' ) ) {
394
+if ( ! function_exists('give_show_form_images')) {
395 395
 
396 396
 	/**
397 397
 	 * Output the donation form featured image.
398 398
 	 */
399 399
 	function give_show_form_images() {
400
-		if ( give_is_setting_enabled( give_get_option( 'form_featured_img' ) ) ) {
401
-			give_get_template_part( 'single-give-form/featured-image' );
400
+		if (give_is_setting_enabled(give_get_option('form_featured_img'))) {
401
+			give_get_template_part('single-give-form/featured-image');
402 402
 		}
403 403
 	}
404 404
 }
405 405
 
406
-if ( ! function_exists( 'give_template_single_title' ) ) {
406
+if ( ! function_exists('give_template_single_title')) {
407 407
 
408 408
 	/**
409 409
 	 * Output the form title.
410 410
 	 */
411 411
 	function give_template_single_title() {
412
-		give_get_template_part( 'single-give-form/title' );
412
+		give_get_template_part('single-give-form/title');
413 413
 	}
414 414
 }
415 415
 
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
  * Conditional Functions
418 418
  */
419 419
 
420
-if ( ! function_exists( 'is_give_form' ) ) {
420
+if ( ! function_exists('is_give_form')) {
421 421
 
422 422
 	/**
423 423
 	 * is_give_form
@@ -429,11 +429,11 @@  discard block
 block discarded – undo
429 429
 	 * @return bool
430 430
 	 */
431 431
 	function is_give_form() {
432
-		return is_singular( array( 'give_form' ) );
432
+		return is_singular(array('give_form'));
433 433
 	}
434 434
 }
435 435
 
436
-if ( ! function_exists( 'is_give_category' ) ) {
436
+if ( ! function_exists('is_give_category')) {
437 437
 
438 438
 	/**
439 439
 	 * is_give_category
@@ -448,12 +448,12 @@  discard block
 block discarded – undo
448 448
 	 *
449 449
 	 * @return bool
450 450
 	 */
451
-	function is_give_category( $term = '' ) {
452
-		return is_tax( 'give_forms_category', $term );
451
+	function is_give_category($term = '') {
452
+		return is_tax('give_forms_category', $term);
453 453
 	}
454 454
 }
455 455
 
456
-if ( ! function_exists( 'is_give_tag' ) ) {
456
+if ( ! function_exists('is_give_tag')) {
457 457
 
458 458
 	/**
459 459
 	 * is_give_tag
@@ -468,12 +468,12 @@  discard block
 block discarded – undo
468 468
 	 *
469 469
 	 * @return bool
470 470
 	 */
471
-	function is_give_tag( $term = '' ) {
472
-		return is_tax( 'give_forms_tag', $term );
471
+	function is_give_tag($term = '') {
472
+		return is_tax('give_forms_tag', $term);
473 473
 	}
474 474
 }
475 475
 
476
-if ( ! function_exists( 'is_give_taxonomy' ) ) {
476
+if ( ! function_exists('is_give_taxonomy')) {
477 477
 
478 478
 	/**
479 479
 	 * is_give_taxonomy
@@ -485,6 +485,6 @@  discard block
 block discarded – undo
485 485
 	 * @return bool
486 486
 	 */
487 487
 	function is_give_taxonomy() {
488
-		return is_tax( get_object_taxonomies( 'give_form' ) );
488
+		return is_tax(get_object_taxonomies('give_form'));
489 489
 	}
490 490
 }
Please login to merge, or discard this patch.
includes/error-tracking.php 1 patch
Spacing   +16 added lines, -16 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
 
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  * @return mixed array if errors are present, false if none found
26 26
  */
27 27
 function give_get_errors() {
28
-	return Give()->session->get( 'give_errors' );
28
+	return Give()->session->get('give_errors');
29 29
 }
30 30
 
31 31
 /**
@@ -41,13 +41,13 @@  discard block
 block discarded – undo
41 41
  *
42 42
  * @return void
43 43
  */
44
-function give_set_error( $error_id, $error_message ) {
44
+function give_set_error($error_id, $error_message) {
45 45
 	$errors = give_get_errors();
46
-	if ( ! $errors ) {
46
+	if ( ! $errors) {
47 47
 		$errors = array();
48 48
 	}
49
-	$errors[ $error_id ] = $error_message;
50
-	Give()->session->set( 'give_errors', $errors );
49
+	$errors[$error_id] = $error_message;
50
+	Give()->session->set('give_errors', $errors);
51 51
 }
52 52
 
53 53
 /**
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
  * @return void
59 59
  */
60 60
 function give_clear_errors() {
61
-	Give()->session->set( 'give_errors', null );
61
+	Give()->session->set('give_errors', null);
62 62
 }
63 63
 
64 64
 /**
@@ -71,11 +71,11 @@  discard block
 block discarded – undo
71 71
  *
72 72
  * @return void
73 73
  */
74
-function give_unset_error( $error_id ) {
74
+function give_unset_error($error_id) {
75 75
 	$errors = give_get_errors();
76
-	if ( $errors ) {
77
-		unset( $errors[ $error_id ] );
78
-		Give()->session->set( 'give_errors', $errors );
76
+	if ($errors) {
77
+		unset($errors[$error_id]);
78
+		Give()->session->set('give_errors', $errors);
79 79
 	}
80 80
 }
81 81
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
  * @return string
87 87
  */
88 88
 function _give_die_handler() {
89
-	if ( defined( 'GIVE_UNIT_TESTS' ) ) {
89
+	if (defined('GIVE_UNIT_TESTS')) {
90 90
 		return '_give_die_handler';
91 91
 	} else {
92 92
 		die();
@@ -106,8 +106,8 @@  discard block
 block discarded – undo
106 106
  *
107 107
  * @return void
108 108
  */
109
-function give_die( $message = '', $title = '', $status = 400 ) {
110
-	add_filter( 'wp_die_ajax_handler', '_give_die_handler', 10, 3 );
111
-	add_filter( 'wp_die_handler', '_give_die_handler', 10, 3 );
112
-	wp_die( $message, $title, array( 'response' => $status ) );
109
+function give_die($message = '', $title = '', $status = 400) {
110
+	add_filter('wp_die_ajax_handler', '_give_die_handler', 10, 3);
111
+	add_filter('wp_die_handler', '_give_die_handler', 10, 3);
112
+	wp_die($message, $title, array('response' => $status));
113 113
 }
Please login to merge, or discard this patch.
includes/emails/class-give-email-tags.php 1 patch
Spacing   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  */
24 24
 
25 25
 // Exit if accessed directly.
26
-if ( ! defined( 'ABSPATH' ) ) {
26
+if ( ! defined('ABSPATH')) {
27 27
 	exit;
28 28
 }
29 29
 
@@ -55,9 +55,9 @@  discard block
 block discarded – undo
55 55
 	 * @param string   $description Email tag description text
56 56
 	 * @param callable $func        Hook to run when email tag is found
57 57
 	 */
58
-	public function add( $tag, $description, $func ) {
59
-		if ( is_callable( $func ) ) {
60
-			$this->tags[ $tag ] = array(
58
+	public function add($tag, $description, $func) {
59
+		if (is_callable($func)) {
60
+			$this->tags[$tag] = array(
61 61
 				'tag'         => $tag,
62 62
 				'description' => $description,
63 63
 				'func'        => $func
@@ -72,8 +72,8 @@  discard block
 block discarded – undo
72 72
 	 *
73 73
 	 * @param string $tag Email tag to remove hook from
74 74
 	 */
75
-	public function remove( $tag ) {
76
-		unset( $this->tags[ $tag ] );
75
+	public function remove($tag) {
76
+		unset($this->tags[$tag]);
77 77
 	}
78 78
 
79 79
 	/**
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
 	 *
86 86
 	 * @return bool
87 87
 	 */
88
-	public function email_tag_exists( $tag ) {
89
-		return array_key_exists( $tag, $this->tags );
88
+	public function email_tag_exists($tag) {
89
+		return array_key_exists($tag, $this->tags);
90 90
 	}
91 91
 
92 92
 	/**
@@ -110,16 +110,16 @@  discard block
 block discarded – undo
110 110
 	 *
111 111
 	 * @return string Content with email tags filtered out.
112 112
 	 */
113
-	public function do_tags( $content, $payment_id ) {
113
+	public function do_tags($content, $payment_id) {
114 114
 
115 115
 		// Check if there is at least one tag added.
116
-		if ( empty( $this->tags ) || ! is_array( $this->tags ) ) {
116
+		if (empty($this->tags) || ! is_array($this->tags)) {
117 117
 			return $content;
118 118
 		}
119 119
 
120 120
 		$this->payment_id = $payment_id;
121 121
 
122
-		$new_content = preg_replace_callback( "/{([A-z0-9\-\_]+)}/s", array( $this, 'do_tag' ), $content );
122
+		$new_content = preg_replace_callback("/{([A-z0-9\-\_]+)}/s", array($this, 'do_tag'), $content);
123 123
 
124 124
 		$this->payment_id = null;
125 125
 
@@ -135,17 +135,17 @@  discard block
 block discarded – undo
135 135
 	 *
136 136
 	 * @return mixed
137 137
 	 */
138
-	public function do_tag( $m ) {
138
+	public function do_tag($m) {
139 139
 
140 140
 		// Get tag
141 141
 		$tag = $m[1];
142 142
 
143 143
 		// Return tag if tag not set
144
-		if ( ! $this->email_tag_exists( $tag ) ) {
144
+		if ( ! $this->email_tag_exists($tag)) {
145 145
 			return $m[0];
146 146
 		}
147 147
 
148
-		return call_user_func( $this->tags[ $tag ]['func'], $this->payment_id, $tag );
148
+		return call_user_func($this->tags[$tag]['func'], $this->payment_id, $tag);
149 149
 	}
150 150
 
151 151
 }
@@ -159,8 +159,8 @@  discard block
 block discarded – undo
159 159
  * @param string   $description Description of the email tag added
160 160
  * @param callable $func        Hook to run when email tag is found
161 161
  */
162
-function give_add_email_tag( $tag, $description, $func ) {
163
-	Give()->email_tags->add( $tag, $description, $func );
162
+function give_add_email_tag($tag, $description, $func) {
163
+	Give()->email_tags->add($tag, $description, $func);
164 164
 }
165 165
 
166 166
 /**
@@ -170,8 +170,8 @@  discard block
 block discarded – undo
170 170
  *
171 171
  * @param string $tag Email tag to remove hook from
172 172
  */
173
-function give_remove_email_tag( $tag ) {
174
-	Give()->email_tags->remove( $tag );
173
+function give_remove_email_tag($tag) {
174
+	Give()->email_tags->remove($tag);
175 175
 }
176 176
 
177 177
 /**
@@ -183,8 +183,8 @@  discard block
 block discarded – undo
183 183
  *
184 184
  * @return bool
185 185
  */
186
-function give_email_tag_exists( $tag ) {
187
-	return Give()->email_tags->email_tag_exists( $tag );
186
+function give_email_tag_exists($tag) {
187
+	return Give()->email_tags->email_tag_exists($tag);
188 188
 }
189 189
 
190 190
 /**
@@ -211,9 +211,9 @@  discard block
 block discarded – undo
211 211
 	$email_tags = give_get_email_tags();
212 212
 
213 213
 	ob_start();
214
-	if ( count( $email_tags ) > 0 ) : ?>
214
+	if (count($email_tags) > 0) : ?>
215 215
 		<div class="give-email-tags-wrap">
216
-			<?php foreach ( $email_tags as $email_tag ) : ?>
216
+			<?php foreach ($email_tags as $email_tag) : ?>
217 217
 				<span class="give_<?php echo $email_tag['tag']; ?>_tag">
218 218
 					<code>{<?php echo $email_tag['tag']; ?>}</code> - <?php echo $email_tag['description']; ?>
219 219
 				</span>
@@ -235,12 +235,12 @@  discard block
 block discarded – undo
235 235
  *
236 236
  * @return string Content with email tags filtered out.
237 237
  */
238
-function give_do_email_tags( $content, $payment_id ) {
238
+function give_do_email_tags($content, $payment_id) {
239 239
 
240 240
 	// Replace all tags
241
-	$content = Give()->email_tags->do_tags( $content, $payment_id );
241
+	$content = Give()->email_tags->do_tags($content, $payment_id);
242 242
 
243
-	$content = apply_filters( 'give_email_template_tags', $content, give_get_payment_meta( $payment_id ), $payment_id );
243
+	$content = apply_filters('give_email_template_tags', $content, give_get_payment_meta($payment_id), $payment_id);
244 244
 
245 245
 	// Return content
246 246
 	return $content;
@@ -259,10 +259,10 @@  discard block
 block discarded – undo
259 259
 	 *
260 260
 	 * @since 1.0
261 261
 	 */
262
-	do_action( 'give_add_email_tags' );
262
+	do_action('give_add_email_tags');
263 263
 }
264 264
 
265
-add_action( 'give_init', 'give_load_email_tags' );
265
+add_action('give_init', 'give_load_email_tags');
266 266
 
267 267
 /**
268 268
  * Add default Give email template tags.
@@ -275,97 +275,97 @@  discard block
 block discarded – undo
275 275
 	$email_tags = array(
276 276
 		array(
277 277
 			'tag'         => 'donation',
278
-			'description' => esc_html__( 'The donation form name, and the donation level (if applicable).', 'give' ),
278
+			'description' => esc_html__('The donation form name, and the donation level (if applicable).', 'give'),
279 279
 			'function'    => 'give_email_tag_donation'
280 280
 		),
281 281
 		array(
282 282
 			'tag'         => 'form_title',
283
-			'description' => esc_html__( 'The donation form name.', 'give' ),
283
+			'description' => esc_html__('The donation form name.', 'give'),
284 284
 			'function'    => 'give_email_tag_form_title'
285 285
 		),
286 286
 		array(
287 287
 			'tag'         => 'amount',
288
-			'description' => esc_html__( 'The total donation amount with currency sign.', 'give' ),
288
+			'description' => esc_html__('The total donation amount with currency sign.', 'give'),
289 289
 			'function'    => 'give_email_tag_amount'
290 290
 		),
291 291
 		array(
292 292
 			'tag'         => 'price',
293
-			'description' => esc_html__( 'The total donation amount with currency sign.', 'give' ),
293
+			'description' => esc_html__('The total donation amount with currency sign.', 'give'),
294 294
 			'function'    => 'give_email_tag_price'
295 295
 		),
296 296
 		array(
297 297
 			'tag'         => 'name',
298
-			'description' => esc_html__( 'The donor\'s first name.', 'give' ),
298
+			'description' => esc_html__('The donor\'s first name.', 'give'),
299 299
 			'function'    => 'give_email_tag_first_name'
300 300
 		),
301 301
 		array(
302 302
 			'tag'         => 'fullname',
303
-			'description' => esc_html__( 'The donor\'s full name, first and last.', 'give' ),
303
+			'description' => esc_html__('The donor\'s full name, first and last.', 'give'),
304 304
 			'function'    => 'give_email_tag_fullname'
305 305
 		),
306 306
 		array(
307 307
 			'tag'         => 'username',
308
-			'description' => esc_html__( 'The donor\'s user name on the site, if they registered an account.', 'give' ),
308
+			'description' => esc_html__('The donor\'s user name on the site, if they registered an account.', 'give'),
309 309
 			'function'    => 'give_email_tag_username'
310 310
 		),
311 311
 		array(
312 312
 			'tag'         => 'user_email',
313
-			'description' => esc_html__( 'The donor\'s email address.', 'give' ),
313
+			'description' => esc_html__('The donor\'s email address.', 'give'),
314 314
 			'function'    => 'give_email_tag_user_email'
315 315
 		),
316 316
 		array(
317 317
 			'tag'         => 'billing_address',
318
-			'description' => esc_html__( 'The donor\'s billing address.', 'give' ),
318
+			'description' => esc_html__('The donor\'s billing address.', 'give'),
319 319
 			'function'    => 'give_email_tag_billing_address'
320 320
 		),
321 321
 		array(
322 322
 			'tag'         => 'date',
323
-			'description' => esc_html__( 'The date of the donation.', 'give' ),
323
+			'description' => esc_html__('The date of the donation.', 'give'),
324 324
 			'function'    => 'give_email_tag_date'
325 325
 		),
326 326
 		array(
327 327
 			'tag'         => 'payment_id',
328
-			'description' => esc_html__( 'The unique ID number for this donation.', 'give' ),
328
+			'description' => esc_html__('The unique ID number for this donation.', 'give'),
329 329
 			'function'    => 'give_email_tag_payment_id'
330 330
 		),
331 331
 		array(
332 332
 			'tag'         => 'receipt_id',
333
-			'description' => esc_html__( 'The unique ID number for this donation receipt.', 'give' ),
333
+			'description' => esc_html__('The unique ID number for this donation receipt.', 'give'),
334 334
 			'function'    => 'give_email_tag_receipt_id'
335 335
 		),
336 336
 		array(
337 337
 			'tag'         => 'payment_method',
338
-			'description' => esc_html__( 'The method of payment used for this donation.', 'give' ),
338
+			'description' => esc_html__('The method of payment used for this donation.', 'give'),
339 339
 			'function'    => 'give_email_tag_payment_method'
340 340
 		),
341 341
 		array(
342 342
 			'tag'         => 'sitename',
343
-			'description' => esc_html__( 'The name of your site.', 'give' ),
343
+			'description' => esc_html__('The name of your site.', 'give'),
344 344
 			'function'    => 'give_email_tag_sitename'
345 345
 		),
346 346
 		array(
347 347
 			'tag'         => 'receipt_link',
348
-			'description' => esc_html__( 'The donation receipt direct link, to view the receipt on the website.', 'give' ),
348
+			'description' => esc_html__('The donation receipt direct link, to view the receipt on the website.', 'give'),
349 349
 			'function'    => 'give_email_tag_receipt_link'
350 350
 		),
351 351
 		array(
352 352
 			'tag'         => 'receipt_link_url',
353
-			'description' => esc_html__( 'The donation receipt direct URL, to view the receipt on the website.', 'give' ),
353
+			'description' => esc_html__('The donation receipt direct URL, to view the receipt on the website.', 'give'),
354 354
 			'function'    => 'give_email_tag_receipt_link_url'
355 355
 		),
356 356
 	);
357 357
 
358 358
 	// Apply give_email_tags filter
359
-	$email_tags = apply_filters( 'give_email_tags', $email_tags );
359
+	$email_tags = apply_filters('give_email_tags', $email_tags);
360 360
 
361 361
 	// Add email tags
362
-	foreach ( $email_tags as $email_tag ) {
363
-		give_add_email_tag( $email_tag['tag'], $email_tag['description'], $email_tag['function'] );
362
+	foreach ($email_tags as $email_tag) {
363
+		give_add_email_tag($email_tag['tag'], $email_tag['description'], $email_tag['function']);
364 364
 	}
365 365
 
366 366
 }
367 367
 
368
-add_action( 'give_add_email_tags', 'give_setup_email_tags' );
368
+add_action('give_add_email_tags', 'give_setup_email_tags');
369 369
 
370 370
 
371 371
 /**
@@ -377,15 +377,15 @@  discard block
 block discarded – undo
377 377
  *
378 378
  * @return string name
379 379
  */
380
-function give_email_tag_first_name( $payment_id ) {
381
-	$payment   = new Give_Payment( $payment_id );
380
+function give_email_tag_first_name($payment_id) {
381
+	$payment   = new Give_Payment($payment_id);
382 382
 	$user_info = $payment->user_info;
383 383
 
384
-	if ( empty( $user_info ) ) {
384
+	if (empty($user_info)) {
385 385
 		return '';
386 386
 	}
387 387
 
388
-	$email_name = give_get_email_names( $user_info );
388
+	$email_name = give_get_email_names($user_info);
389 389
 
390 390
 	return $email_name['name'];
391 391
 }
@@ -399,15 +399,15 @@  discard block
 block discarded – undo
399 399
  *
400 400
  * @return string fullname
401 401
  */
402
-function give_email_tag_fullname( $payment_id ) {
403
-	$payment   = new Give_Payment( $payment_id );
402
+function give_email_tag_fullname($payment_id) {
403
+	$payment   = new Give_Payment($payment_id);
404 404
 	$user_info = $payment->user_info;
405 405
 
406
-	if ( empty( $user_info ) ) {
406
+	if (empty($user_info)) {
407 407
 		return '';
408 408
 	}
409 409
 
410
-	$email_name = give_get_email_names( $user_info );
410
+	$email_name = give_get_email_names($user_info);
411 411
 
412 412
 	return $email_name['fullname'];
413 413
 }
@@ -421,15 +421,15 @@  discard block
 block discarded – undo
421 421
  *
422 422
  * @return string username.
423 423
  */
424
-function give_email_tag_username( $payment_id ) {
425
-	$payment   = new Give_Payment( $payment_id );
424
+function give_email_tag_username($payment_id) {
425
+	$payment   = new Give_Payment($payment_id);
426 426
 	$user_info = $payment->user_info;
427 427
 
428
-	if ( empty( $user_info ) ) {
428
+	if (empty($user_info)) {
429 429
 		return '';
430 430
 	}
431 431
 
432
-	$email_name = give_get_email_names( $user_info );
432
+	$email_name = give_get_email_names($user_info);
433 433
 
434 434
 	return $email_name['username'];
435 435
 }
@@ -443,8 +443,8 @@  discard block
 block discarded – undo
443 443
  *
444 444
  * @return string user_email
445 445
  */
446
-function give_email_tag_user_email( $payment_id ) {
447
-	$payment = new Give_Payment( $payment_id );
446
+function give_email_tag_user_email($payment_id) {
447
+	$payment = new Give_Payment($payment_id);
448 448
 
449 449
 	return $payment->email;
450 450
 }
@@ -458,9 +458,9 @@  discard block
 block discarded – undo
458 458
  *
459 459
  * @return string billing_address
460 460
  */
461
-function give_email_tag_billing_address( $payment_id ) {
462
-	$user_info    = give_get_payment_meta_user_info( $payment_id );
463
-	$user_address = ! empty( $user_info['address'] ) ? $user_info['address'] : array(
461
+function give_email_tag_billing_address($payment_id) {
462
+	$user_info    = give_get_payment_meta_user_info($payment_id);
463
+	$user_address = ! empty($user_info['address']) ? $user_info['address'] : array(
464 464
 		'line1'   => '',
465 465
 		'line2'   => '',
466 466
 		'city'    => '',
@@ -469,11 +469,11 @@  discard block
 block discarded – undo
469 469
 		'zip'     => ''
470 470
 	);
471 471
 
472
-	$return = $user_address['line1'] . "\n";
473
-	if ( ! empty( $user_address['line2'] ) ) {
474
-		$return .= $user_address['line2'] . "\n";
472
+	$return = $user_address['line1']."\n";
473
+	if ( ! empty($user_address['line2'])) {
474
+		$return .= $user_address['line2']."\n";
475 475
 	}
476
-	$return .= $user_address['city'] . ' ' . $user_address['zip'] . ' ' . $user_address['state'] . "\n";
476
+	$return .= $user_address['city'].' '.$user_address['zip'].' '.$user_address['state']."\n";
477 477
 	$return .= $user_address['country'];
478 478
 
479 479
 	return $return;
@@ -488,10 +488,10 @@  discard block
 block discarded – undo
488 488
  *
489 489
  * @return string date
490 490
  */
491
-function give_email_tag_date( $payment_id ) {
492
-	$payment = new Give_Payment( $payment_id );
491
+function give_email_tag_date($payment_id) {
492
+	$payment = new Give_Payment($payment_id);
493 493
 
494
-	return date_i18n( give_date_format(), strtotime( $payment->date ) );
494
+	return date_i18n(give_date_format(), strtotime($payment->date));
495 495
 }
496 496
 
497 497
 /**
@@ -503,11 +503,11 @@  discard block
 block discarded – undo
503 503
  *
504 504
  * @return string amount
505 505
  */
506
-function give_email_tag_amount( $payment_id ) {
507
-	$payment     = new Give_Payment( $payment_id );
508
-	$give_amount = give_currency_filter( give_format_amount( $payment->total ), $payment->currency );
506
+function give_email_tag_amount($payment_id) {
507
+	$payment     = new Give_Payment($payment_id);
508
+	$give_amount = give_currency_filter(give_format_amount($payment->total), $payment->currency);
509 509
 
510
-	return html_entity_decode( $give_amount, ENT_COMPAT, 'UTF-8' );
510
+	return html_entity_decode($give_amount, ENT_COMPAT, 'UTF-8');
511 511
 }
512 512
 
513 513
 /**
@@ -519,8 +519,8 @@  discard block
 block discarded – undo
519 519
  *
520 520
  * @return string price
521 521
  */
522
-function give_email_tag_price( $payment_id ) {
523
-	return give_email_tag_amount( $payment_id );
522
+function give_email_tag_price($payment_id) {
523
+	return give_email_tag_amount($payment_id);
524 524
 }
525 525
 
526 526
 /**
@@ -532,8 +532,8 @@  discard block
 block discarded – undo
532 532
  *
533 533
  * @return int payment_id
534 534
  */
535
-function give_email_tag_payment_id( $payment_id ) {
536
-	$payment = new Give_Payment( $payment_id );
535
+function give_email_tag_payment_id($payment_id) {
536
+	$payment = new Give_Payment($payment_id);
537 537
 
538 538
 	return $payment->number;
539 539
 }
@@ -547,8 +547,8 @@  discard block
 block discarded – undo
547 547
  *
548 548
  * @return string receipt_id
549 549
  */
550
-function give_email_tag_receipt_id( $payment_id ) {
551
-	$payment = new Give_Payment( $payment_id );
550
+function give_email_tag_receipt_id($payment_id) {
551
+	$payment = new Give_Payment($payment_id);
552 552
 
553 553
 	return $payment->key;
554 554
 }
@@ -562,14 +562,14 @@  discard block
 block discarded – undo
562 562
  *
563 563
  * @return string $form_title
564 564
  */
565
-function give_email_tag_donation( $payment_id ) {
566
-	$payment      = new Give_Payment( $payment_id );
565
+function give_email_tag_donation($payment_id) {
566
+	$payment      = new Give_Payment($payment_id);
567 567
 	$payment_meta = $payment->payment_meta;
568
-	$level_title  = give_has_variable_prices( $payment->form_id );
568
+	$level_title  = give_has_variable_prices($payment->form_id);
569 569
 	$separator    = $level_title ? '-' : '';
570
-	$form_title   = strip_tags( give_get_payment_form_title( $payment_meta, false, $separator ) );
570
+	$form_title   = strip_tags(give_get_payment_form_title($payment_meta, false, $separator));
571 571
 
572
-	return ! empty( $form_title ) ? $form_title : '';
572
+	return ! empty($form_title) ? $form_title : '';
573 573
 
574 574
 }
575 575
 
@@ -582,11 +582,11 @@  discard block
 block discarded – undo
582 582
  *
583 583
  * @return string $form_title
584 584
  */
585
-function give_email_tag_form_title( $payment_id ) {
586
-	$payment      = new Give_Payment( $payment_id );
585
+function give_email_tag_form_title($payment_id) {
586
+	$payment      = new Give_Payment($payment_id);
587 587
 	$payment_meta = $payment->payment_meta;
588 588
 
589
-	return isset( $payment_meta['form_title'] ) ? strip_tags( $payment_meta['form_title'] ) : '';
589
+	return isset($payment_meta['form_title']) ? strip_tags($payment_meta['form_title']) : '';
590 590
 
591 591
 }
592 592
 
@@ -599,10 +599,10 @@  discard block
 block discarded – undo
599 599
  *
600 600
  * @return string gateway
601 601
  */
602
-function give_email_tag_payment_method( $payment_id ) {
603
-	$payment = new Give_Payment( $payment_id );
602
+function give_email_tag_payment_method($payment_id) {
603
+	$payment = new Give_Payment($payment_id);
604 604
 
605
-	return give_get_gateway_checkout_label( $payment->gateway );
605
+	return give_get_gateway_checkout_label($payment->gateway);
606 606
 }
607 607
 
608 608
 /**
@@ -614,8 +614,8 @@  discard block
 block discarded – undo
614 614
  *
615 615
  * @return string sitename
616 616
  */
617
-function give_email_tag_sitename( $payment_id ) {
618
-	return wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES );
617
+function give_email_tag_sitename($payment_id) {
618
+	return wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
619 619
 }
620 620
 
621 621
 /**
@@ -627,19 +627,19 @@  discard block
 block discarded – undo
627 627
  *
628 628
  * @return string receipt_link
629 629
  */
630
-function give_email_tag_receipt_link( $payment_id ) {
630
+function give_email_tag_receipt_link($payment_id) {
631 631
 
632
-	$receipt_url = esc_url( add_query_arg( array(
633
-		'payment_key' => give_get_payment_key( $payment_id ),
632
+	$receipt_url = esc_url(add_query_arg(array(
633
+		'payment_key' => give_get_payment_key($payment_id),
634 634
 		'give_action' => 'view_receipt'
635
-	), home_url() ) );
636
-	$formatted   = sprintf(
635
+	), home_url()));
636
+	$formatted = sprintf(
637 637
 		'<a href="%1$s">%2$s</a>',
638 638
 		$receipt_url,
639
-		esc_html__( 'View it in your browser', 'give' )
639
+		esc_html__('View it in your browser', 'give')
640 640
 	);
641 641
 
642
-	if ( give_get_option( 'email_template' ) !== 'none' ) {
642
+	if (give_get_option('email_template') !== 'none') {
643 643
 		return $formatted;
644 644
 	} else {
645 645
 		return $receipt_url;
@@ -658,12 +658,12 @@  discard block
 block discarded – undo
658 658
  *
659 659
  * @return string receipt_url
660 660
  */
661
-function give_email_tag_receipt_link_url( $payment_id ) {
661
+function give_email_tag_receipt_link_url($payment_id) {
662 662
 
663
-	$receipt_url = esc_url( add_query_arg( array(
664
-		'payment_key' => give_get_payment_key( $payment_id ),
663
+	$receipt_url = esc_url(add_query_arg(array(
664
+		'payment_key' => give_get_payment_key($payment_id),
665 665
 		'give_action' => 'view_receipt'
666
-	), home_url() ) );
666
+	), home_url()));
667 667
 
668 668
 	return $receipt_url;
669 669
 
Please login to merge, or discard this patch.