Test Failed
Push — master ( 3f7048...88589f )
by Ravinder
04:53
created
includes/process-donation.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -288,8 +288,8 @@
 block discarded – undo
288 288
 
289 289
 	// Check spam detect.
290 290
 	if ( isset( $_POST['action'] )
291
-	     && give_is_setting_enabled( give_get_option( 'akismet_spam_protection' ) )
292
-	     && give_is_spam_donation()
291
+		 && give_is_setting_enabled( give_get_option( 'akismet_spam_protection' ) )
292
+		 && give_is_spam_donation()
293 293
 	) {
294 294
 		give_set_error( 'invalid_donation', __( 'This donation has been flagged as spam. Please try again.', 'give' ) );
295 295
 	}
Please login to merge, or discard this patch.
Spacing   +254 added lines, -255 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,21 +97,20 @@  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'] ) ?
103
-		(float) apply_filters( 'give_donation_total', give_maybe_sanitize_amount( $_POST['give-amount'] ) ) :
104
-		'0.00';
105
-	$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']) ?
103
+		(float) apply_filters('give_donation_total', give_maybe_sanitize_amount($_POST['give-amount'])) : '0.00';
104
+	$purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true)));
106 105
 
107 106
 	// Setup donation information.
108 107
 	$donation_data = array(
109 108
 		'price'         => $price,
110 109
 		'purchase_key'  => $purchase_key,
111 110
 		'user_email'    => $user['user_email'],
112
-		'date'          => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ),
113
-		'user_info'     => stripslashes_deep( $user_info ),
114
-		'post_data'     => give_clean( $_POST ),
111
+		'date'          => date('Y-m-d H:i:s', current_time('timestamp')),
112
+		'user_info'     => stripslashes_deep($user_info),
113
+		'post_data'     => give_clean($_POST),
115 114
 		'gateway'       => $valid_data['gateway'],
116 115
 		'card_info'     => $valid_data['cc_info'],
117 116
 	);
@@ -130,10 +129,10 @@  discard block
 block discarded – undo
130 129
 	 * @param array $user_info Array containing basic user information.
131 130
 	 * @param bool|array $valid_data Validate fields.
132 131
 	 */
133
-	do_action( 'give_checkout_before_gateway', give_clean( $_POST ), $user_info, $valid_data );
132
+	do_action('give_checkout_before_gateway', give_clean($_POST), $user_info, $valid_data);
134 133
 
135 134
 	// Sanity check for price.
136
-	if ( ! $donation_data['price'] ) {
135
+	if ( ! $donation_data['price']) {
137 136
 		// Revert to manual.
138 137
 		$donation_data['gateway'] = 'manual';
139 138
 		$_POST['give-gateway']    = 'manual';
@@ -144,27 +143,27 @@  discard block
 block discarded – undo
144 143
 	 *
145 144
 	 * @since 1.7
146 145
 	 */
147
-	$donation_data = apply_filters( 'give_donation_data_before_gateway', $donation_data, $valid_data );
146
+	$donation_data = apply_filters('give_donation_data_before_gateway', $donation_data, $valid_data);
148 147
 
149 148
 	// Setup the data we're storing in the donation session.
150 149
 	$session_data = $donation_data;
151 150
 
152 151
 	// Make sure credit card numbers are never stored in sessions.
153
-	unset( $session_data['card_info']['card_number'] );
154
-	unset( $session_data['post_data']['card_number'] );
152
+	unset($session_data['card_info']['card_number']);
153
+	unset($session_data['post_data']['card_number']);
155 154
 
156 155
 	// Used for showing data to non logged-in users after donation, and for other plugins needing donation data.
157
-	give_set_purchase_session( $session_data );
156
+	give_set_purchase_session($session_data);
158 157
 
159 158
 	// Send info to the gateway for payment processing.
160
-	give_send_to_gateway( $donation_data['gateway'], $donation_data );
159
+	give_send_to_gateway($donation_data['gateway'], $donation_data);
161 160
 	give_die();
162 161
 
163 162
 }
164 163
 
165
-add_action( 'give_purchase', 'give_process_donation_form' );
166
-add_action( 'wp_ajax_give_process_donation', 'give_process_donation_form' );
167
-add_action( 'wp_ajax_nopriv_give_process_donation', 'give_process_donation_form' );
164
+add_action('give_purchase', 'give_process_donation_form');
165
+add_action('wp_ajax_give_process_donation', 'give_process_donation_form');
166
+add_action('wp_ajax_nopriv_give_process_donation', 'give_process_donation_form');
168 167
 
169 168
 
170 169
 /**
@@ -177,29 +176,29 @@  discard block
 block discarded – undo
177 176
  *
178 177
  * @return void
179 178
  */
180
-function give_check_logged_in_user_for_existing_email( $valid_data, $post ) {
179
+function give_check_logged_in_user_for_existing_email($valid_data, $post) {
181 180
 
182 181
 	// Verify that the email address belongs to this customer.
183
-	if ( is_user_logged_in() ) {
182
+	if (is_user_logged_in()) {
184 183
 
185 184
 		$submitted_email = $valid_data['logged_in_user']['user_email'];
186
-		$donor           = new Give_Donor( get_current_user_id(), true );
185
+		$donor           = new Give_Donor(get_current_user_id(), true);
187 186
 
188 187
 		// If this email address is not registered with this customer, see if it belongs to any other customer.
189 188
 		if (
190 189
 			$submitted_email !== $donor->email
191
-			&& ( is_array( $donor->emails ) && ! in_array( $submitted_email, $donor->emails ) )
190
+			&& (is_array($donor->emails) && ! in_array($submitted_email, $donor->emails))
192 191
 		) {
193
-			$found_donor = new Give_Donor( $submitted_email );
192
+			$found_donor = new Give_Donor($submitted_email);
194 193
 
195
-			if ( $found_donor->id > 0 ) {
196
-				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' ), $donor->email, $submitted_email ) );
194
+			if ($found_donor->id > 0) {
195
+				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'), $donor->email, $submitted_email));
197 196
 			}
198 197
 		}
199 198
 	}
200 199
 }
201 200
 
202
-add_action( 'give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 2 );
201
+add_action('give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 2);
203 202
 
204 203
 /**
205 204
  * Process the checkout login form
@@ -209,49 +208,49 @@  discard block
 block discarded – undo
209 208
  * @return      void
210 209
  */
211 210
 function give_process_form_login() {
212
-	$is_ajax = isset( $_POST['give_ajax'] );
211
+	$is_ajax = isset($_POST['give_ajax']);
213 212
 
214 213
 	$user_data = give_donation_form_validate_user_login();
215 214
 
216
-	if ( give_get_errors() || $user_data['user_id'] < 1 ) {
217
-		if ( $is_ajax ) {
215
+	if (give_get_errors() || $user_data['user_id'] < 1) {
216
+		if ($is_ajax) {
218 217
 			/**
219 218
 			 * Fires when AJAX sends back errors from the donation form.
220 219
 			 *
221 220
 			 * @since 1.0
222 221
 			 */
223 222
 			ob_start();
224
-			do_action( 'give_ajax_donation_errors' );
223
+			do_action('give_ajax_donation_errors');
225 224
 			$message = ob_get_contents();
226 225
 			ob_end_clean();
227
-			wp_send_json_error( $message );
226
+			wp_send_json_error($message);
228 227
 		} else {
229
-			wp_redirect( $_SERVER['HTTP_REFERER'] );
228
+			wp_redirect($_SERVER['HTTP_REFERER']);
230 229
 			exit;
231 230
 		}
232 231
 	}
233 232
 
234
-	give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] );
233
+	give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']);
235 234
 
236
-	if ( $is_ajax ) {
235
+	if ($is_ajax) {
237 236
 		$message = Give()->notices->print_frontend_notice(
238 237
 			sprintf(
239 238
 			/* translators: %s: user first name */
240
-				esc_html__( 'Welcome %s! You have successfully logged into your account.', 'give' ),
241
-				( ! empty( $user_data['user_first'] ) ) ? $user_data['user_first'] : $user_data['user_login']
239
+				esc_html__('Welcome %s! You have successfully logged into your account.', 'give'),
240
+				( ! empty($user_data['user_first'])) ? $user_data['user_first'] : $user_data['user_login']
242 241
 			),
243 242
 			false,
244 243
 			'success'
245 244
 		);
246 245
 
247
-		wp_send_json_success( $message );
246
+		wp_send_json_success($message);
248 247
 	} else {
249
-		wp_redirect( $_SERVER['HTTP_REFERER'] );
248
+		wp_redirect($_SERVER['HTTP_REFERER']);
250 249
 	}
251 250
 }
252 251
 
253
-add_action( 'wp_ajax_give_process_donation_login', 'give_process_form_login' );
254
-add_action( 'wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login' );
252
+add_action('wp_ajax_give_process_donation_login', 'give_process_form_login');
253
+add_action('wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login');
255 254
 
256 255
 /**
257 256
  * Donation Form Validate Fields.
@@ -263,63 +262,63 @@  discard block
 block discarded – undo
263 262
 function give_donation_form_validate_fields() {
264 263
 
265 264
 	// Check if there is $_POST.
266
-	if ( empty( $_POST ) ) {
265
+	if (empty($_POST)) {
267 266
 		return false;
268 267
 	}
269 268
 
270
-	$form_id = ! empty( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
269
+	$form_id = ! empty($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
271 270
 
272 271
 	// Start an array to collect valid data.
273 272
 	$valid_data = array(
274 273
 		'gateway'          => give_donation_form_validate_gateway(), // Gateway fallback (amount is validated here).
275
-		'need_new_user'    => false,     // New user flag.
276
-		'need_user_login'  => false,     // Login user flag.
277
-		'logged_user_data' => array(),   // Logged user collected data.
278
-		'new_user_data'    => array(),   // New user collected data.
279
-		'login_user_data'  => array(),   // Login user collected data.
280
-		'guest_user_data'  => array(),   // Guest user collected data.
281
-		'cc_info'          => give_donation_form_validate_cc(),// Credit card info.
274
+		'need_new_user'    => false, // New user flag.
275
+		'need_user_login'  => false, // Login user flag.
276
+		'logged_user_data' => array(), // Logged user collected data.
277
+		'new_user_data'    => array(), // New user collected data.
278
+		'login_user_data'  => array(), // Login user collected data.
279
+		'guest_user_data'  => array(), // Guest user collected data.
280
+		'cc_info'          => give_donation_form_validate_cc(), // Credit card info.
282 281
 	);
283 282
 
284 283
 	// Validate Honeypot First.
285
-	if ( ! empty( $_POST['give-honeypot'] ) ) {
286
-		give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) );
284
+	if ( ! empty($_POST['give-honeypot'])) {
285
+		give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give'));
287 286
 	}
288 287
 
289 288
 	// Check spam detect.
290
-	if ( isset( $_POST['action'] )
291
-	     && give_is_setting_enabled( give_get_option( 'akismet_spam_protection' ) )
289
+	if (isset($_POST['action'])
290
+	     && give_is_setting_enabled(give_get_option('akismet_spam_protection'))
292 291
 	     && give_is_spam_donation()
293 292
 	) {
294
-		give_set_error( 'invalid_donation', __( 'This donation has been flagged as spam. Please try again.', 'give' ) );
293
+		give_set_error('invalid_donation', __('This donation has been flagged as spam. Please try again.', 'give'));
295 294
 	}
296 295
 
297 296
 	// Validate agree to terms.
298
-	if ( give_is_terms_enabled( $form_id ) ) {
297
+	if (give_is_terms_enabled($form_id)) {
299 298
 		give_donation_form_validate_agree_to_terms();
300 299
 	}
301 300
 
302 301
 	// Stop processing donor registration, if donor registration is optional and donor can do guest checkout.
303 302
 	// If registration form username field is empty that means donor does want to registration instead wants guest checkout.
304 303
 	if (
305
-		! give_logged_in_only( $form_id )
306
-		&& isset( $_POST['give-purchase-var'] )
304
+		! give_logged_in_only($form_id)
305
+		&& isset($_POST['give-purchase-var'])
307 306
 		&& $_POST['give-purchase-var'] == 'needs-to-register'
308
-		&& empty( $_POST['give_user_login'] )
307
+		&& empty($_POST['give_user_login'])
309 308
 	) {
310
-		unset( $_POST['give-purchase-var'] );
309
+		unset($_POST['give-purchase-var']);
311 310
 	}
312 311
 
313
-	if ( is_user_logged_in() ) {
312
+	if (is_user_logged_in()) {
314 313
 		// Collect logged in user data.
315 314
 		$valid_data['logged_in_user'] = give_donation_form_validate_logged_in_user();
316
-	} elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' ) {
315
+	} elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register') {
317 316
 		// Set new user registration as required.
318 317
 		$valid_data['need_new_user'] = true;
319 318
 		// Validate new user data.
320 319
 		$valid_data['new_user_data'] = give_donation_form_validate_new_user();
321 320
 		// Check if login validation is needed.
322
-	} elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) {
321
+	} elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') {
323 322
 		// Set user login as required.
324 323
 		$valid_data['need_user_login'] = true;
325 324
 		// Validate users login info.
@@ -343,14 +342,14 @@  discard block
 block discarded – undo
343 342
 function give_is_spam_donation() {
344 343
 	$spam = false;
345 344
 
346
-	$user_agent = (string) isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : '';
345
+	$user_agent = (string) isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
347 346
 
348
-	if ( strlen( $user_agent ) < 2 ) {
347
+	if (strlen($user_agent) < 2) {
349 348
 		$spam = true;
350 349
 	}
351 350
 
352 351
 	// Allow developer to customized Akismet spam detect API call and it's response.
353
-	return apply_filters( 'give_spam', $spam );
352
+	return apply_filters('give_spam', $spam);
354 353
 }
355 354
 
356 355
 /**
@@ -364,41 +363,41 @@  discard block
 block discarded – undo
364 363
  */
365 364
 function give_donation_form_validate_gateway() {
366 365
 
367
-	$form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0;
368
-	$amount  = isset( $_REQUEST['give-amount'] ) ? give_maybe_sanitize_amount( $_REQUEST['give-amount'] ) : 0;
369
-	$gateway = give_get_default_gateway( $form_id );
366
+	$form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0;
367
+	$amount  = isset($_REQUEST['give-amount']) ? give_maybe_sanitize_amount($_REQUEST['give-amount']) : 0;
368
+	$gateway = give_get_default_gateway($form_id);
370 369
 
371 370
 	// Check if a gateway value is present.
372
-	if ( ! empty( $_REQUEST['give-gateway'] ) ) {
371
+	if ( ! empty($_REQUEST['give-gateway'])) {
373 372
 
374
-		$gateway = sanitize_text_field( $_REQUEST['give-gateway'] );
373
+		$gateway = sanitize_text_field($_REQUEST['give-gateway']);
375 374
 
376 375
 		// Is amount being donated in LIVE mode 0.00? If so, error:
377
-		if ( $amount == 0 && ! give_is_test_mode() ) {
376
+		if ($amount == 0 && ! give_is_test_mode()) {
378 377
 
379
-			give_set_error( 'invalid_donation_amount', __( 'Please insert a valid donation amount.', 'give' ) );
378
+			give_set_error('invalid_donation_amount', __('Please insert a valid donation amount.', 'give'));
380 379
 
381 380
 		} // End if().
382
-		elseif ( ! give_verify_minimum_price() ) {
381
+		elseif ( ! give_verify_minimum_price()) {
383 382
 			// translators: %s: minimum donation amount.
384 383
 			give_set_error(
385 384
 				'invalid_donation_minimum',
386 385
 				sprintf(
387 386
 				/* translators: %s: minimum donation amount */
388
-					__( 'This form has a minimum donation amount of %s.', 'give' ),
389
-					give_currency_filter( give_format_amount( give_get_form_minimum_price( $form_id ), array( 'sanitize' => false ) ) )
387
+					__('This form has a minimum donation amount of %s.', 'give'),
388
+					give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id), array('sanitize' => false)))
390 389
 				)
391 390
 			);
392 391
 
393 392
 		} //Is this test mode zero donation? Let it through but set to manual gateway.
394
-		elseif ( $amount == 0 && give_is_test_mode() ) {
393
+		elseif ($amount == 0 && give_is_test_mode()) {
395 394
 
396 395
 			$gateway = 'manual';
397 396
 
398 397
 		} //Check if this gateway is active.
399
-		elseif ( ! give_is_gateway_active( $gateway ) ) {
398
+		elseif ( ! give_is_gateway_active($gateway)) {
400 399
 
401
-			give_set_error( 'invalid_gateway', __( 'The selected payment gateway is not enabled.', 'give' ) );
400
+			give_set_error('invalid_gateway', __('The selected payment gateway is not enabled.', 'give'));
402 401
 
403 402
 		}
404 403
 	}
@@ -416,21 +415,21 @@  discard block
 block discarded – undo
416 415
  */
417 416
 function give_verify_minimum_price() {
418 417
 
419
-	$amount          = give_maybe_sanitize_amount( $_REQUEST['give-amount'] );
420
-	$form_id         = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0;
421
-	$price_id        = isset( $_REQUEST['give-price-id'] ) ? $_REQUEST['give-price-id'] : null;
422
-	$variable_prices = give_has_variable_prices( $form_id );
418
+	$amount          = give_maybe_sanitize_amount($_REQUEST['give-amount']);
419
+	$form_id         = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0;
420
+	$price_id        = isset($_REQUEST['give-price-id']) ? $_REQUEST['give-price-id'] : null;
421
+	$variable_prices = give_has_variable_prices($form_id);
423 422
 
424
-	if ( $variable_prices && in_array( $price_id, give_get_variable_price_ids( $form_id ) ) ) {
423
+	if ($variable_prices && in_array($price_id, give_get_variable_price_ids($form_id))) {
425 424
 
426
-		$price_level_amount = give_get_price_option_amount( $form_id, $price_id );
425
+		$price_level_amount = give_get_price_option_amount($form_id, $price_id);
427 426
 
428
-		if ( $price_level_amount == $amount ) {
427
+		if ($price_level_amount == $amount) {
429 428
 			return true;
430 429
 		}
431 430
 	}
432 431
 
433
-	if ( give_get_form_minimum_price( $form_id ) > $amount ) {
432
+	if (give_get_form_minimum_price($form_id) > $amount) {
434 433
 		return false;
435 434
 	}
436 435
 
@@ -446,9 +445,9 @@  discard block
 block discarded – undo
446 445
  */
447 446
 function give_donation_form_validate_agree_to_terms() {
448 447
 	// Validate agree to terms.
449
-	if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) {
448
+	if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) {
450 449
 		// User did not agree.
451
-		give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', __( 'You must agree to the terms and conditions.', 'give' ) ) );
450
+		give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', __('You must agree to the terms and conditions.', 'give')));
452 451
 	}
453 452
 }
454 453
 
@@ -462,59 +461,59 @@  discard block
 block discarded – undo
462 461
  *
463 462
  * @return      array
464 463
  */
465
-function give_get_required_fields( $form_id ) {
464
+function give_get_required_fields($form_id) {
466 465
 
467
-	$payment_mode = give_get_chosen_gateway( $form_id );
466
+	$payment_mode = give_get_chosen_gateway($form_id);
468 467
 
469 468
 	$required_fields = array(
470 469
 		'give_email' => array(
471 470
 			'error_id'      => 'invalid_email',
472
-			'error_message' => __( 'Please enter a valid email address.', 'give' ),
471
+			'error_message' => __('Please enter a valid email address.', 'give'),
473 472
 		),
474 473
 		'give_first' => array(
475 474
 			'error_id'      => 'invalid_first_name',
476
-			'error_message' => __( 'Please enter your first name.', 'give' ),
475
+			'error_message' => __('Please enter your first name.', 'give'),
477 476
 		),
478 477
 	);
479 478
 
480
-	$require_address = give_require_billing_address( $payment_mode );
479
+	$require_address = give_require_billing_address($payment_mode);
481 480
 
482
-	if ( $require_address ) {
483
-		$required_fields['card_address']    = array(
481
+	if ($require_address) {
482
+		$required_fields['card_address'] = array(
484 483
 			'error_id'      => 'invalid_card_address',
485
-			'error_message' => __( 'Please enter your primary billing address.', 'give' ),
484
+			'error_message' => __('Please enter your primary billing address.', 'give'),
486 485
 		);
487
-		$required_fields['card_zip']        = array(
486
+		$required_fields['card_zip'] = array(
488 487
 			'error_id'      => 'invalid_zip_code',
489
-			'error_message' => __( 'Please enter your zip / postal code.', 'give' ),
488
+			'error_message' => __('Please enter your zip / postal code.', 'give'),
490 489
 		);
491
-		$required_fields['card_city']       = array(
490
+		$required_fields['card_city'] = array(
492 491
 			'error_id'      => 'invalid_city',
493
-			'error_message' => __( 'Please enter your billing city.', 'give' ),
492
+			'error_message' => __('Please enter your billing city.', 'give'),
494 493
 		);
495 494
 		$required_fields['billing_country'] = array(
496 495
 			'error_id'      => 'invalid_country',
497
-			'error_message' => __( 'Please select your billing country.', 'give' ),
496
+			'error_message' => __('Please select your billing country.', 'give'),
498 497
 		);
499 498
 
500 499
 
501 500
 		$required_fields['card_state'] = array(
502 501
 			'error_id'      => 'invalid_state',
503
-			'error_message' => __( 'Please enter billing state / province / County.', 'give' ),
502
+			'error_message' => __('Please enter billing state / province / County.', 'give'),
504 503
 		);
505 504
 
506 505
 		// Check if billing country alredy exists.
507
-		if ( ! empty( $_POST['billing_country'] ) ) {
506
+		if ( ! empty($_POST['billing_country'])) {
508 507
 			// Get the value from $_POST.
509
-			$country = sanitize_text_field( $_POST['billing_country'] );
508
+			$country = sanitize_text_field($_POST['billing_country']);
510 509
 
511 510
 			// Get the country list that does not required any states init.
512 511
 			$states_country = give_states_not_required_country_list();
513 512
 
514 513
 			// Check if states is empty or not.
515
-			if ( array_key_exists( $country, $states_country ) ) {
514
+			if (array_key_exists($country, $states_country)) {
516 515
 				// If states is empty remove the required feilds of state in billing cart.
517
-				unset( $required_fields['card_state'] );
516
+				unset($required_fields['card_state']);
518 517
 			}
519 518
 		}
520 519
 	}
@@ -524,7 +523,7 @@  discard block
 block discarded – undo
524 523
 	 *
525 524
 	 * @since 1.7
526 525
 	 */
527
-	$required_fields = apply_filters( 'give_donation_form_required_fields', $required_fields, $form_id );
526
+	$required_fields = apply_filters('give_donation_form_required_fields', $required_fields, $form_id);
528 527
 
529 528
 	return $required_fields;
530 529
 
@@ -539,16 +538,16 @@  discard block
 block discarded – undo
539 538
  *
540 539
  * @return bool
541 540
  */
542
-function give_require_billing_address( $payment_mode ) {
541
+function give_require_billing_address($payment_mode) {
543 542
 
544 543
 	$return = false;
545 544
 
546
-	if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) {
545
+	if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) {
547 546
 		$return = true;
548 547
 	}
549 548
 
550 549
 	// Let payment gateways and other extensions determine if address fields should be required.
551
-	return apply_filters( 'give_require_billing_address', $return );
550
+	return apply_filters('give_require_billing_address', $return);
552 551
 
553 552
 }
554 553
 
@@ -562,42 +561,42 @@  discard block
 block discarded – undo
562 561
 function give_donation_form_validate_logged_in_user() {
563 562
 	global $user_ID;
564 563
 
565
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
564
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
566 565
 
567 566
 	// Start empty array to collect valid user data.
568 567
 	$valid_user_data = array(
569 568
 		// Assume there will be errors.
570
-		'user_id' => - 1,
569
+		'user_id' => -1,
571 570
 	);
572 571
 
573 572
 	// Verify there is a user_ID.
574
-	if ( $user_ID > 0 ) {
573
+	if ($user_ID > 0) {
575 574
 		// Get the logged in user data.
576
-		$user_data = get_userdata( $user_ID );
575
+		$user_data = get_userdata($user_ID);
577 576
 
578 577
 		// Loop through required fields and show error messages.
579
-		foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) {
580
-			if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
581
-				give_set_error( $value['error_id'], $value['error_message'] );
578
+		foreach (give_get_required_fields($form_id) as $field_name => $value) {
579
+			if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) {
580
+				give_set_error($value['error_id'], $value['error_message']);
582 581
 			}
583 582
 		}
584 583
 
585 584
 		// Verify data.
586
-		if ( $user_data ) {
585
+		if ($user_data) {
587 586
 			// Collected logged in user data.
588 587
 			$valid_user_data = array(
589 588
 				'user_id'    => $user_ID,
590
-				'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email,
591
-				'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name,
592
-				'user_last'  => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name,
589
+				'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email,
590
+				'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name,
591
+				'user_last'  => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name,
593 592
 			);
594 593
 
595
-			if ( ! is_email( $valid_user_data['user_email'] ) ) {
596
-				give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
594
+			if ( ! is_email($valid_user_data['user_email'])) {
595
+				give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
597 596
 			}
598 597
 		} else {
599 598
 			// Set invalid user error.
600
-			give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) );
599
+			give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give'));
601 600
 		}
602 601
 	}
603 602
 
@@ -616,7 +615,7 @@  discard block
 block discarded – undo
616 615
 	// Default user data.
617 616
 	$default_user_data = array(
618 617
 		'give-form-id'           => '',
619
-		'user_id'                => - 1, // Assume there will be errors.
618
+		'user_id'                => -1, // Assume there will be errors.
620 619
 		'user_first'             => '',
621 620
 		'user_last'              => '',
622 621
 		'give_user_login'        => false,
@@ -626,14 +625,14 @@  discard block
 block discarded – undo
626 625
 	);
627 626
 
628 627
 	// Get user data.
629
-	$user_data            = wp_parse_args( give_clean( $_POST ), $default_user_data );
628
+	$user_data            = wp_parse_args(give_clean($_POST), $default_user_data);
630 629
 	$registering_new_user = false;
631
-	$form_id              = absint( $user_data['give-form-id'] );
630
+	$form_id              = absint($user_data['give-form-id']);
632 631
 
633 632
 	// Start an empty array to collect valid user data.
634 633
 	$valid_user_data = array(
635 634
 		// Assume there will be errors.
636
-		'user_id'    => - 1,
635
+		'user_id'    => -1,
637 636
 
638 637
 		// Get first name.
639 638
 		'user_first' => $user_data['give_first'],
@@ -643,25 +642,25 @@  discard block
 block discarded – undo
643 642
 	);
644 643
 
645 644
 	// Loop through required fields and show error messages.
646
-	foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) {
647
-		if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
648
-			give_set_error( $value['error_id'], $value['error_message'] );
645
+	foreach (give_get_required_fields($form_id) as $field_name => $value) {
646
+		if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) {
647
+			give_set_error($value['error_id'], $value['error_message']);
649 648
 		}
650 649
 	}
651 650
 
652 651
 	// Check if we have an username to register.
653
-	if ( give_validate_username( $user_data['give_user_login'] ) ) {
652
+	if (give_validate_username($user_data['give_user_login'])) {
654 653
 		$registering_new_user          = true;
655 654
 		$valid_user_data['user_login'] = $user_data['give_user_login'];
656 655
 	}
657 656
 
658 657
 	// Check if we have an email to verify.
659
-	if ( give_validate_user_email( $user_data['give_email'], $registering_new_user ) ) {
658
+	if (give_validate_user_email($user_data['give_email'], $registering_new_user)) {
660 659
 		$valid_user_data['user_email'] = $user_data['give_email'];
661 660
 	}
662 661
 
663 662
 	// Check password.
664
-	if ( give_validate_user_password( $user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user ) ) {
663
+	if (give_validate_user_password($user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user)) {
665 664
 		// All is good to go.
666 665
 		$valid_user_data['user_pass'] = $user_data['give_user_pass'];
667 666
 	}
@@ -681,36 +680,36 @@  discard block
 block discarded – undo
681 680
 	// Start an array to collect valid user data.
682 681
 	$valid_user_data = array(
683 682
 		// Assume there will be errors.
684
-		'user_id' => - 1,
683
+		'user_id' => -1,
685 684
 	);
686 685
 
687 686
 	// Username.
688
-	if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) {
689
-		give_set_error( 'must_log_in', __( 'You must register or login to complete your donation.', 'give' ) );
687
+	if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') {
688
+		give_set_error('must_log_in', __('You must register or login to complete your donation.', 'give'));
690 689
 
691 690
 		return $valid_user_data;
692 691
 	}
693 692
 
694 693
 	// Get the user by login.
695
-	$user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) );
694
+	$user_data = get_user_by('login', strip_tags($_POST['give_user_login']));
696 695
 
697 696
 	// Check if user exists.
698
-	if ( $user_data ) {
697
+	if ($user_data) {
699 698
 		// Get password.
700
-		$user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false;
699
+		$user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false;
701 700
 
702 701
 		// Check user_pass.
703
-		if ( $user_pass ) {
702
+		if ($user_pass) {
704 703
 			// Check if password is valid.
705
-			if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) {
704
+			if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) {
706 705
 				// Incorrect password.
707 706
 				give_set_error(
708 707
 					'password_incorrect',
709 708
 					sprintf(
710 709
 						'%1$s <a href="%2$s">%3$s</a>',
711
-						__( 'The password you entered is incorrect.', 'give' ),
712
-						wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ),
713
-						__( 'Reset Password', 'give' )
710
+						__('The password you entered is incorrect.', 'give'),
711
+						wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"),
712
+						__('Reset Password', 'give')
714 713
 					)
715 714
 				);
716 715
 				// All is correct.
@@ -728,11 +727,11 @@  discard block
 block discarded – undo
728 727
 			}
729 728
 		} else {
730 729
 			// Empty password.
731
-			give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) );
730
+			give_set_error('password_empty', __('Enter a password.', 'give'));
732 731
 		}
733 732
 	} else {
734 733
 		// No username.
735
-		give_set_error( 'username_incorrect', __( 'The username you entered does not exist.', 'give' ) );
734
+		give_set_error('username_incorrect', __('The username you entered does not exist.', 'give'));
736 735
 	}// End if().
737 736
 
738 737
 	return $valid_user_data;
@@ -747,7 +746,7 @@  discard block
 block discarded – undo
747 746
  */
748 747
 function give_donation_form_validate_guest_user() {
749 748
 
750
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
749
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
751 750
 
752 751
 	// Start an array to collect valid user data.
753 752
 	$valid_user_data = array(
@@ -756,38 +755,38 @@  discard block
 block discarded – undo
756 755
 	);
757 756
 
758 757
 	// Show error message if user must be logged in.
759
-	if ( give_logged_in_only( $form_id ) ) {
760
-		give_set_error( 'logged_in_only', __( 'You must be logged in to donate.', 'give' ) );
758
+	if (give_logged_in_only($form_id)) {
759
+		give_set_error('logged_in_only', __('You must be logged in to donate.', 'give'));
761 760
 	}
762 761
 
763 762
 	// Get the guest email.
764
-	$guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false;
763
+	$guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false;
765 764
 
766 765
 	// Check email.
767
-	if ( $guest_email && strlen( $guest_email ) > 0 ) {
766
+	if ($guest_email && strlen($guest_email) > 0) {
768 767
 		// Validate email.
769
-		if ( ! is_email( $guest_email ) ) {
768
+		if ( ! is_email($guest_email)) {
770 769
 			// Invalid email.
771
-			give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) );
770
+			give_set_error('email_invalid', __('Invalid email.', 'give'));
772 771
 		} else {
773 772
 			// All is good to go.
774 773
 			$valid_user_data['user_email'] = $guest_email;
775 774
 
776 775
 			// Get user_id from donor if exist.
777
-			$donor = new Give_Donor( $guest_email );
778
-			if ( $donor->id && $donor->user_id ) {
776
+			$donor = new Give_Donor($guest_email);
777
+			if ($donor->id && $donor->user_id) {
779 778
 				$valid_user_data['user_id'] = $donor->user_id;
780 779
 			}
781 780
 		}
782 781
 	} else {
783 782
 		// No email.
784
-		give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) );
783
+		give_set_error('email_empty', __('Enter an email.', 'give'));
785 784
 	}
786 785
 
787 786
 	// Loop through required fields and show error messages.
788
-	foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) {
789
-		if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
790
-			give_set_error( $value['error_id'], $value['error_message'] );
787
+	foreach (give_get_required_fields($form_id) as $field_name => $value) {
788
+		if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) {
789
+			give_set_error($value['error_id'], $value['error_message']);
791 790
 		}
792 791
 	}
793 792
 
@@ -803,36 +802,36 @@  discard block
 block discarded – undo
803 802
  * @since   1.0
804 803
  * @return  integer
805 804
  */
806
-function give_register_and_login_new_user( $user_data = array() ) {
805
+function give_register_and_login_new_user($user_data = array()) {
807 806
 	// Verify the array.
808
-	if ( empty( $user_data ) ) {
809
-		return - 1;
807
+	if (empty($user_data)) {
808
+		return -1;
810 809
 	}
811 810
 
812
-	if ( give_get_errors() ) {
813
-		return - 1;
811
+	if (give_get_errors()) {
812
+		return -1;
814 813
 	}
815 814
 
816
-	$user_args = apply_filters( 'give_insert_user_args', array(
817
-		'user_login'      => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '',
818
-		'user_pass'       => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '',
819
-		'user_email'      => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '',
820
-		'first_name'      => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '',
821
-		'last_name'       => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '',
822
-		'user_registered' => date( 'Y-m-d H:i:s' ),
823
-		'role'            => give_get_option( 'donor_default_user_role', 'give_donor' ),
824
-	), $user_data );
815
+	$user_args = apply_filters('give_insert_user_args', array(
816
+		'user_login'      => isset($user_data['user_login']) ? $user_data['user_login'] : '',
817
+		'user_pass'       => isset($user_data['user_pass']) ? $user_data['user_pass'] : '',
818
+		'user_email'      => isset($user_data['user_email']) ? $user_data['user_email'] : '',
819
+		'first_name'      => isset($user_data['user_first']) ? $user_data['user_first'] : '',
820
+		'last_name'       => isset($user_data['user_last']) ? $user_data['user_last'] : '',
821
+		'user_registered' => date('Y-m-d H:i:s'),
822
+		'role'            => give_get_option('donor_default_user_role', 'give_donor'),
823
+	), $user_data);
825 824
 
826 825
 	// Insert new user.
827
-	$user_id = wp_insert_user( $user_args );
826
+	$user_id = wp_insert_user($user_args);
828 827
 
829 828
 	// Validate inserted user.
830
-	if ( is_wp_error( $user_id ) ) {
831
-		return - 1;
829
+	if (is_wp_error($user_id)) {
830
+		return -1;
832 831
 	}
833 832
 
834 833
 	// Allow themes and plugins to filter the user data.
835
-	$user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args );
834
+	$user_data = apply_filters('give_insert_user_data', $user_data, $user_args);
836 835
 
837 836
 	/**
838 837
 	 * Fires after inserting user.
@@ -842,7 +841,7 @@  discard block
 block discarded – undo
842 841
 	 * @param int $user_id User id.
843 842
 	 * @param array $user_data Array containing user data.
844 843
 	 */
845
-	do_action( 'give_insert_user', $user_id, $user_data );
844
+	do_action('give_insert_user', $user_id, $user_data);
846 845
 
847 846
 	/**
848 847
 	 * Filter allow user to alter if user when to login or not when user is register for the first time.
@@ -851,9 +850,9 @@  discard block
 block discarded – undo
851 850
 	 *
852 851
 	 * return bool True if login with registration and False if only want to register.
853 852
 	 */
854
-	if ( true === (bool) apply_filters( 'give_log_user_in_on_register', true ) ) {
853
+	if (true === (bool) apply_filters('give_log_user_in_on_register', true)) {
855 854
 		// Login new user.
856
-		give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] );
855
+		give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']);
857 856
 	}
858 857
 
859 858
 	// Return user id.
@@ -869,27 +868,27 @@  discard block
 block discarded – undo
869 868
  * @since   1.0
870 869
  * @return  array|bool
871 870
  */
872
-function give_get_donation_form_user( $valid_data = array() ) {
871
+function give_get_donation_form_user($valid_data = array()) {
873 872
 
874 873
 	// Initialize user.
875 874
 	$user    = false;
876
-	$is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
875
+	$is_ajax = defined('DOING_AJAX') && DOING_AJAX;
877 876
 
878
-	if ( $is_ajax ) {
877
+	if ($is_ajax) {
879 878
 		// Do not create or login the user during the ajax submission (check for errors only).
880 879
 		return true;
881
-	} elseif ( is_user_logged_in() ) {
880
+	} elseif (is_user_logged_in()) {
882 881
 		// Set the valid user as the logged in collected data.
883 882
 		$user = $valid_data['logged_in_user'];
884
-	} elseif ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) {
883
+	} elseif ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) {
885 884
 		// New user registration.
886
-		if ( $valid_data['need_new_user'] === true ) {
885
+		if ($valid_data['need_new_user'] === true) {
887 886
 			// Set user.
888 887
 			$user = $valid_data['new_user_data'];
889 888
 			// Register and login new user.
890
-			$user['user_id'] = give_register_and_login_new_user( $user );
889
+			$user['user_id'] = give_register_and_login_new_user($user);
891 890
 			// User login
892
-		} elseif ( $valid_data['need_user_login'] === true && ! $is_ajax ) {
891
+		} elseif ($valid_data['need_user_login'] === true && ! $is_ajax) {
893 892
 
894 893
 			/**
895 894
 			 * The login form is now processed in the give_process_donation_login() function.
@@ -901,48 +900,48 @@  discard block
 block discarded – undo
901 900
 			// Set user.
902 901
 			$user = $valid_data['login_user_data'];
903 902
 			// Login user.
904
-			give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] );
903
+			give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']);
905 904
 		}
906 905
 	}
907 906
 
908 907
 	// Check guest checkout.
909
-	if ( false === $user && false === give_logged_in_only( $_POST['give-form-id'] ) ) {
908
+	if (false === $user && false === give_logged_in_only($_POST['give-form-id'])) {
910 909
 		// Set user
911 910
 		$user = $valid_data['guest_user_data'];
912 911
 	}
913 912
 
914 913
 	// Verify we have an user.
915
-	if ( false === $user || empty( $user ) ) {
914
+	if (false === $user || empty($user)) {
916 915
 		// Return false.
917 916
 		return false;
918 917
 	}
919 918
 
920 919
 	// Get user first name.
921
-	if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) {
922
-		$user['user_first'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : '';
920
+	if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) {
921
+		$user['user_first'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : '';
923 922
 	}
924 923
 
925 924
 	// Get user last name.
926
-	if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) {
927
-		$user['user_last'] = isset( $_POST['give_last'] ) ? strip_tags( trim( $_POST['give_last'] ) ) : '';
925
+	if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) {
926
+		$user['user_last'] = isset($_POST['give_last']) ? strip_tags(trim($_POST['give_last'])) : '';
928 927
 	}
929 928
 
930 929
 	// Get the user's billing address details.
931 930
 	$user['address']            = array();
932
-	$user['address']['line1']   = ! empty( $_POST['card_address'] ) ? give_clean( $_POST['card_address'] ) : false;
933
-	$user['address']['line2']   = ! empty( $_POST['card_address_2'] ) ? give_clean( $_POST['card_address_2'] ) : false;
934
-	$user['address']['city']    = ! empty( $_POST['card_city'] ) ? give_clean( $_POST['card_city'] ) : false;
935
-	$user['address']['state']   = ! empty( $_POST['card_state'] ) ? give_clean( $_POST['card_state'] ) : false;
936
-	$user['address']['zip']     = ! empty( $_POST['card_zip'] ) ? give_clean( $_POST['card_zip'] ) : false;
937
-	$user['address']['country'] = ! empty( $_POST['billing_country'] ) ? give_clean( $_POST['billing_country'] ) : false;
938
-
939
-	if ( empty( $user['address']['country'] ) ) {
931
+	$user['address']['line1']   = ! empty($_POST['card_address']) ? give_clean($_POST['card_address']) : false;
932
+	$user['address']['line2']   = ! empty($_POST['card_address_2']) ? give_clean($_POST['card_address_2']) : false;
933
+	$user['address']['city']    = ! empty($_POST['card_city']) ? give_clean($_POST['card_city']) : false;
934
+	$user['address']['state']   = ! empty($_POST['card_state']) ? give_clean($_POST['card_state']) : false;
935
+	$user['address']['zip']     = ! empty($_POST['card_zip']) ? give_clean($_POST['card_zip']) : false;
936
+	$user['address']['country'] = ! empty($_POST['billing_country']) ? give_clean($_POST['billing_country']) : false;
937
+
938
+	if (empty($user['address']['country'])) {
940 939
 		$user['address'] = false;
941 940
 	} // End if().
942 941
 
943
-	if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $user['address'] ) ) {
942
+	if ( ! empty($user['user_id']) && $user['user_id'] > 0 && ! empty($user['address'])) {
944 943
 		// Store the address in the user's meta so the donation form can be pre-populated with it on return donation.
945
-		update_user_meta( $user['user_id'], '_give_user_address', $user['address'] );
944
+		update_user_meta($user['user_id'], '_give_user_address', $user['address']);
946 945
 	}
947 946
 
948 947
 	// Return valid user.
@@ -961,16 +960,16 @@  discard block
 block discarded – undo
961 960
 	$card_data = give_get_donation_cc_info();
962 961
 
963 962
 	// Validate the card zip.
964
-	if ( ! empty( $card_data['card_zip'] ) ) {
965
-		if ( ! give_donation_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) {
966
-			give_set_error( 'invalid_cc_zip', __( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) );
963
+	if ( ! empty($card_data['card_zip'])) {
964
+		if ( ! give_donation_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) {
965
+			give_set_error('invalid_cc_zip', __('The zip / postal code you entered for your billing address is invalid.', 'give'));
967 966
 		}
968 967
 	}
969 968
 
970 969
 	// Ensure no spaces.
971
-	if ( ! empty( $card_data['card_number'] ) ) {
972
-		$card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); // no "+" signs
973
-		$card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces
970
+	if ( ! empty($card_data['card_number'])) {
971
+		$card_data['card_number'] = str_replace('+', '', $card_data['card_number']); // no "+" signs
972
+		$card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces
974 973
 	}
975 974
 
976 975
 	// This should validate card numbers at some point too.
@@ -987,17 +986,17 @@  discard block
 block discarded – undo
987 986
 function give_get_donation_cc_info() {
988 987
 
989 988
 	$cc_info                   = array();
990
-	$cc_info['card_name']      = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : '';
991
-	$cc_info['card_number']    = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : '';
992
-	$cc_info['card_cvc']       = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : '';
993
-	$cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : '';
994
-	$cc_info['card_exp_year']  = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : '';
995
-	$cc_info['card_address']   = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : '';
996
-	$cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : '';
997
-	$cc_info['card_city']      = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : '';
998
-	$cc_info['card_state']     = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : '';
999
-	$cc_info['card_country']   = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : '';
1000
-	$cc_info['card_zip']       = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : '';
989
+	$cc_info['card_name']      = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : '';
990
+	$cc_info['card_number']    = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : '';
991
+	$cc_info['card_cvc']       = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : '';
992
+	$cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : '';
993
+	$cc_info['card_exp_year']  = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : '';
994
+	$cc_info['card_address']   = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : '';
995
+	$cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : '';
996
+	$cc_info['card_city']      = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : '';
997
+	$cc_info['card_state']     = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : '';
998
+	$cc_info['card_country']   = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : '';
999
+	$cc_info['card_zip']       = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : '';
1001 1000
 
1002 1001
 	// Return cc info.
1003 1002
 	return $cc_info;
@@ -1013,14 +1012,14 @@  discard block
 block discarded – undo
1013 1012
  *
1014 1013
  * @return bool|mixed
1015 1014
  */
1016
-function give_donation_form_validate_cc_zip( $zip = 0, $country_code = '' ) {
1015
+function give_donation_form_validate_cc_zip($zip = 0, $country_code = '') {
1017 1016
 	$ret = false;
1018 1017
 
1019
-	if ( empty( $zip ) || empty( $country_code ) ) {
1018
+	if (empty($zip) || empty($country_code)) {
1020 1019
 		return $ret;
1021 1020
 	}
1022 1021
 
1023
-	$country_code = strtoupper( $country_code );
1022
+	$country_code = strtoupper($country_code);
1024 1023
 
1025 1024
 	$zip_regex = array(
1026 1025
 		'AD' => 'AD\d{3}',
@@ -1180,11 +1179,11 @@  discard block
 block discarded – undo
1180 1179
 		'ZM' => '\d{5}',
1181 1180
 	);
1182 1181
 
1183
-	if ( ! isset( $zip_regex[ $country_code ] ) || preg_match( '/' . $zip_regex[ $country_code ] . '/i', $zip ) ) {
1182
+	if ( ! isset($zip_regex[$country_code]) || preg_match('/'.$zip_regex[$country_code].'/i', $zip)) {
1184 1183
 		$ret = true;
1185 1184
 	}
1186 1185
 
1187
-	return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code );
1186
+	return apply_filters('give_is_zip_valid', $ret, $zip, $country_code);
1188 1187
 }
1189 1188
 
1190 1189
 
@@ -1198,33 +1197,33 @@  discard block
 block discarded – undo
1198 1197
  *
1199 1198
  * @return bool
1200 1199
  */
1201
-function give_validate_multi_donation_form_level( $valid_data, $data ) {
1200
+function give_validate_multi_donation_form_level($valid_data, $data) {
1202 1201
 	/* @var Give_Donate_Form $form */
1203
-	$form = new Give_Donate_Form( $data['give-form-id'] );
1202
+	$form = new Give_Donate_Form($data['give-form-id']);
1204 1203
 
1205 1204
 	$donation_level_matched = false;
1206 1205
 
1207
-	if ( $form->is_multi_type_donation_form() ) {
1206
+	if ($form->is_multi_type_donation_form()) {
1208 1207
 
1209 1208
 		// Bailout.
1210
-		if ( ! ( $variable_prices = $form->get_prices() ) ) {
1209
+		if ( ! ($variable_prices = $form->get_prices())) {
1211 1210
 			return false;
1212 1211
 		}
1213 1212
 
1214 1213
 		// Sanitize donation amount.
1215
-		$data['give-amount'] = give_maybe_sanitize_amount( $data['give-amount'] );
1214
+		$data['give-amount'] = give_maybe_sanitize_amount($data['give-amount']);
1216 1215
 
1217
-		if ( $data['give-amount'] === give_maybe_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ) ) ) {
1216
+		if ($data['give-amount'] === give_maybe_sanitize_amount(give_get_price_option_amount($data['give-form-id'], $data['give-price-id']))) {
1218 1217
 			return true;
1219 1218
 		}
1220 1219
 
1221 1220
 		// Find correct donation level from all donation levels.
1222
-		foreach ( $variable_prices as $variable_price ) {
1221
+		foreach ($variable_prices as $variable_price) {
1223 1222
 			// Sanitize level amount.
1224
-			$variable_price['_give_amount'] = give_maybe_sanitize_amount( $variable_price['_give_amount'] );
1223
+			$variable_price['_give_amount'] = give_maybe_sanitize_amount($variable_price['_give_amount']);
1225 1224
 
1226 1225
 			// Set first match donation level ID.
1227
-			if ( $data['give-amount'] === $variable_price['_give_amount'] ) {
1226
+			if ($data['give-amount'] === $variable_price['_give_amount']) {
1228 1227
 				$_POST['give-price-id'] = $variable_price['_give_id']['level_id'];
1229 1228
 				$donation_level_matched = true;
1230 1229
 				break;
@@ -1235,19 +1234,19 @@  discard block
 block discarded – undo
1235 1234
 		// If yes then set price id to custom if amount is greater then custom minimum amount (if any).
1236 1235
 		if (
1237 1236
 			! $donation_level_matched
1238
-			&& ( give_is_setting_enabled( give_get_meta( $data['give-form-id'], '_give_custom_amount', true ) ) )
1237
+			&& (give_is_setting_enabled(give_get_meta($data['give-form-id'], '_give_custom_amount', true)))
1239 1238
 		) {
1240 1239
 			// Sanitize custom minimum amount.
1241
-			$custom_minimum_amount = give_maybe_sanitize_amount( give_get_meta( $data['give-form-id'], '_give_custom_amount_minimum', true ) );
1240
+			$custom_minimum_amount = give_maybe_sanitize_amount(give_get_meta($data['give-form-id'], '_give_custom_amount_minimum', true));
1242 1241
 
1243
-			if ( $data['give-amount'] >= $custom_minimum_amount ) {
1242
+			if ($data['give-amount'] >= $custom_minimum_amount) {
1244 1243
 				$_POST['give-price-id'] = 'custom';
1245 1244
 				$donation_level_matched = true;
1246 1245
 			}
1247 1246
 		}
1248 1247
 	}// End if().
1249 1248
 
1250
-	return ( $donation_level_matched ? true : false );
1249
+	return ($donation_level_matched ? true : false);
1251 1250
 }
1252 1251
 
1253
-add_action( 'give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2 );
1252
+add_action('give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2);
Please login to merge, or discard this patch.
includes/emails/functions.php 1 patch
Spacing   +130 added lines, -130 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,11 +26,11 @@  discard block
 block discarded – undo
26 26
  *
27 27
  * @return void
28 28
  */
29
-function give_email_donation_receipt( $payment_id, $admin_notice = true ) {
29
+function give_email_donation_receipt($payment_id, $admin_notice = true) {
30 30
 
31
-	$payment_data = give_get_payment_meta( $payment_id );
31
+	$payment_data = give_get_payment_meta($payment_id);
32 32
 
33
-	$from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) );
33
+	$from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES));
34 34
 
35 35
 	/**
36 36
 	 * Filters the from name.
@@ -40,9 +40,9 @@  discard block
 block discarded – undo
40 40
 	 *
41 41
 	 * @since 1.0
42 42
 	 */
43
-	$from_name = apply_filters( 'give_donation_from_name', $from_name, $payment_id, $payment_data );
43
+	$from_name = apply_filters('give_donation_from_name', $from_name, $payment_id, $payment_data);
44 44
 
45
-	$from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) );
45
+	$from_email = give_get_option('from_email', get_bloginfo('admin_email'));
46 46
 
47 47
 	/**
48 48
 	 * Filters the from email.
@@ -52,19 +52,19 @@  discard block
 block discarded – undo
52 52
 	 *
53 53
 	 * @since 1.0
54 54
 	 */
55
-	$from_email = apply_filters( 'give_donation_from_address', $from_email, $payment_id, $payment_data );
55
+	$from_email = apply_filters('give_donation_from_address', $from_email, $payment_id, $payment_data);
56 56
 
57
-	$to_email = give_get_payment_user_email( $payment_id );
57
+	$to_email = give_get_payment_user_email($payment_id);
58 58
 
59
-	$subject = give_get_option( 'donation_subject', __( 'Donation Receipt', 'give' ) );
59
+	$subject = give_get_option('donation_subject', __('Donation Receipt', 'give'));
60 60
 
61 61
 	/**
62 62
 	 * Filters the donation email receipt subject.
63 63
 	 *
64 64
 	 * @since 1.0
65 65
 	 */
66
-	$subject = apply_filters( 'give_donation_subject', wp_strip_all_tags( $subject ), $payment_id );
67
-	$subject = give_do_email_tags( $subject, $payment_id );
66
+	$subject = apply_filters('give_donation_subject', wp_strip_all_tags($subject), $payment_id);
67
+	$subject = give_do_email_tags($subject, $payment_id);
68 68
 
69 69
 	/**
70 70
 	 * Filters the donation email receipt attachments. By default, there is no attachment but plugins can hook in to provide one more multiple for the donor. Examples would be a printable ticket or PDF receipt.
@@ -74,14 +74,14 @@  discard block
 block discarded – undo
74 74
 	 *
75 75
 	 * @since 1.0
76 76
 	 */
77
-	$attachments = apply_filters( 'give_receipt_attachments', array(), $payment_id, $payment_data );
78
-	$message     = give_do_email_tags( give_get_email_body_content( $payment_id, $payment_data ), $payment_id );
77
+	$attachments = apply_filters('give_receipt_attachments', array(), $payment_id, $payment_data);
78
+	$message     = give_do_email_tags(give_get_email_body_content($payment_id, $payment_data), $payment_id);
79 79
 
80 80
 	$emails = Give()->emails;
81 81
 
82
-	$emails->__set( 'from_name', $from_name );
83
-	$emails->__set( 'from_email', $from_email );
84
-	$emails->__set( 'heading', __( 'Donation Receipt', 'give' ) );
82
+	$emails->__set('from_name', $from_name);
83
+	$emails->__set('from_email', $from_email);
84
+	$emails->__set('heading', __('Donation Receipt', 'give'));
85 85
 
86 86
 	/**
87 87
 	 * Filters the donation receipt's email headers.
@@ -91,14 +91,14 @@  discard block
 block discarded – undo
91 91
 	 *
92 92
 	 * @since 1.0
93 93
 	 */
94
-	$headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data );
95
-	$emails->__set( 'headers', $headers );
94
+	$headers = apply_filters('give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data);
95
+	$emails->__set('headers', $headers);
96 96
 
97 97
 	//Send the donation receipt.
98
-	$emails->send( $to_email, $subject, $message, $attachments );
98
+	$emails->send($to_email, $subject, $message, $attachments);
99 99
 
100 100
 	//If admin notifications are on, send the admin notice.
101
-	if ( $admin_notice && ! give_admin_notices_disabled( $payment_id ) ) {
101
+	if ($admin_notice && ! give_admin_notices_disabled($payment_id)) {
102 102
 		/**
103 103
 		 * Fires in the donation email receipt.
104 104
 		 *
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 		 * @param int   $payment_id   Payment id.
110 110
 		 * @param mixed $payment_data Payment meta data.
111 111
 		 */
112
-		do_action( 'give_admin_donation_email', $payment_id, $payment_data );
112
+		do_action('give_admin_donation_email', $payment_id, $payment_data);
113 113
 	}
114 114
 }
115 115
 
@@ -122,41 +122,41 @@  discard block
 block discarded – undo
122 122
  */
123 123
 function give_email_test_donation_receipt() {
124 124
 
125
-	$from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) );
125
+	$from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES));
126 126
 
127 127
 	/**
128 128
 	 * Filters the from name.
129 129
 	 *
130 130
 	 * @since 1.7
131 131
 	 */
132
-	$from_name = apply_filters( 'give_donation_from_name', $from_name, 0, array() );
132
+	$from_name = apply_filters('give_donation_from_name', $from_name, 0, array());
133 133
 
134
-	$from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) );
134
+	$from_email = give_get_option('from_email', get_bloginfo('admin_email'));
135 135
 
136 136
 	/**
137 137
 	 * Filters the from email.
138 138
 	 *
139 139
 	 * @since 1.7
140 140
 	 */
141
-	$from_email = apply_filters( 'give_donation_from_address', $from_email, 0, array() );
141
+	$from_email = apply_filters('give_donation_from_address', $from_email, 0, array());
142 142
 
143
-	$subject = give_get_option( 'donation_subject', __( 'Donation Receipt', 'give' ) );
144
-	$subject = apply_filters( 'give_donation_subject', wp_strip_all_tags( $subject ), 0 );
145
-	$subject = give_do_email_tags( $subject, 0 );
143
+	$subject = give_get_option('donation_subject', __('Donation Receipt', 'give'));
144
+	$subject = apply_filters('give_donation_subject', wp_strip_all_tags($subject), 0);
145
+	$subject = give_do_email_tags($subject, 0);
146 146
 
147
-	$attachments = apply_filters( 'give_receipt_attachments', array(), 0, array() );
147
+	$attachments = apply_filters('give_receipt_attachments', array(), 0, array());
148 148
 
149
-	$message = give_email_preview_template_tags( give_get_email_body_content( 0, array() ) );
149
+	$message = give_email_preview_template_tags(give_get_email_body_content(0, array()));
150 150
 
151 151
 	$emails = Give()->emails;
152
-	$emails->__set( 'from_name', $from_name );
153
-	$emails->__set( 'from_email', $from_email );
154
-	$emails->__set( 'heading', __( 'Donation Receipt', 'give' ) );
152
+	$emails->__set('from_name', $from_name);
153
+	$emails->__set('from_email', $from_email);
154
+	$emails->__set('heading', __('Donation Receipt', 'give'));
155 155
 
156
-	$headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), 0, array() );
157
-	$emails->__set( 'headers', $headers );
156
+	$headers = apply_filters('give_receipt_headers', $emails->get_headers(), 0, array());
157
+	$emails->__set('headers', $headers);
158 158
 
159
-	$emails->send( give_get_admin_notice_emails(), $subject, $message, $attachments );
159
+	$emails->send(give_get_admin_notice_emails(), $subject, $message, $attachments);
160 160
 
161 161
 }
162 162
 
@@ -170,49 +170,49 @@  discard block
 block discarded – undo
170 170
  *
171 171
  * @return void
172 172
  */
173
-function give_admin_email_notice( $payment_id = 0, $payment_data = array() ) {
173
+function give_admin_email_notice($payment_id = 0, $payment_data = array()) {
174 174
 
175
-	$payment_id = absint( $payment_id );
175
+	$payment_id = absint($payment_id);
176 176
 
177
-	if ( empty( $payment_id ) ) {
177
+	if (empty($payment_id)) {
178 178
 		return;
179 179
 	}
180 180
 
181
-	if ( ! give_get_payment_by( 'id', $payment_id ) ) {
181
+	if ( ! give_get_payment_by('id', $payment_id)) {
182 182
 		return;
183 183
 	}
184 184
 
185
-	$from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) );
185
+	$from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES));
186 186
 
187 187
 	/**
188 188
 	 * Filters the from name.
189 189
 	 *
190 190
 	 * @since 1.0
191 191
 	 */
192
-	$from_name = apply_filters( 'give_donation_from_name', $from_name, $payment_id, $payment_data );
192
+	$from_name = apply_filters('give_donation_from_name', $from_name, $payment_id, $payment_data);
193 193
 
194
-	$from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) );
194
+	$from_email = give_get_option('from_email', get_bloginfo('admin_email'));
195 195
 
196 196
 	/**
197 197
 	 * Filters the from email.
198 198
 	 *
199 199
 	 * @since 1.0
200 200
 	 */
201
-	$from_email = apply_filters( 'give_donation_from_address', $from_email, $payment_id, $payment_data );
201
+	$from_email = apply_filters('give_donation_from_address', $from_email, $payment_id, $payment_data);
202 202
 
203 203
 	/* translators: %s: payment id */
204
-	$subject = give_get_option( 'donation_notification_subject', sprintf( esc_html__( 'New Donation - Payment #%s', 'give' ), $payment_id ) );
204
+	$subject = give_get_option('donation_notification_subject', sprintf(esc_html__('New Donation - Payment #%s', 'give'), $payment_id));
205 205
 
206 206
 	/**
207 207
 	 * Filters the donation notification subject.
208 208
 	 *
209 209
 	 * @since 1.0
210 210
 	 */
211
-	$subject = apply_filters( 'give_admin_donation_notification_subject', wp_strip_all_tags( $subject ), $payment_id );
212
-	$subject = give_do_email_tags( $subject, $payment_id );
211
+	$subject = apply_filters('give_admin_donation_notification_subject', wp_strip_all_tags($subject), $payment_id);
212
+	$subject = give_do_email_tags($subject, $payment_id);
213 213
 
214
-	$headers = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n";
215
-	$headers .= "Reply-To: " . $from_email . "\r\n";
214
+	$headers = "From: ".stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8'))." <$from_email>\r\n";
215
+	$headers .= "Reply-To: ".$from_email."\r\n";
216 216
 	//$headers  .= "MIME-Version: 1.0\r\n";
217 217
 	$headers .= "Content-Type: text/html; charset=utf-8\r\n";
218 218
 
@@ -221,28 +221,28 @@  discard block
 block discarded – undo
221 221
 	 *
222 222
 	 * @since 1.0
223 223
 	 */
224
-	$headers = apply_filters( 'give_admin_donation_notification_headers', $headers, $payment_id, $payment_data );
224
+	$headers = apply_filters('give_admin_donation_notification_headers', $headers, $payment_id, $payment_data);
225 225
 
226 226
 	/**
227 227
 	 * Filters the donation notification email attachments. By default, there is no attachment but plugins can hook in to provide one more multiple.
228 228
 	 *
229 229
 	 * @since 1.0
230 230
 	 */
231
-	$attachments = apply_filters( 'give_admin_donation_notification_attachments', array(), $payment_id, $payment_data );
231
+	$attachments = apply_filters('give_admin_donation_notification_attachments', array(), $payment_id, $payment_data);
232 232
 
233
-	$message = give_get_donation_notification_body_content( $payment_id, $payment_data );
233
+	$message = give_get_donation_notification_body_content($payment_id, $payment_data);
234 234
 
235 235
 	$emails = Give()->emails;
236
-	$emails->__set( 'from_name', $from_name );
237
-	$emails->__set( 'from_email', $from_email );
238
-	$emails->__set( 'headers', $headers );
239
-	$emails->__set( 'heading', __( 'New Donation!', 'give' ) );
236
+	$emails->__set('from_name', $from_name);
237
+	$emails->__set('from_email', $from_email);
238
+	$emails->__set('headers', $headers);
239
+	$emails->__set('heading', __('New Donation!', 'give'));
240 240
 
241
-	$emails->send( give_get_admin_notice_emails(), $subject, $message, $attachments );
241
+	$emails->send(give_get_admin_notice_emails(), $subject, $message, $attachments);
242 242
 
243 243
 }
244 244
 
245
-add_action( 'give_admin_donation_email', 'give_admin_email_notice', 10, 2 );
245
+add_action('give_admin_donation_email', 'give_admin_email_notice', 10, 2);
246 246
 
247 247
 /**
248 248
  * Retrieves the emails for which admin notifications are sent to (these can be changed in the Give Settings).
@@ -252,12 +252,12 @@  discard block
 block discarded – undo
252 252
  */
253 253
 function give_get_admin_notice_emails() {
254 254
 
255
-	$email_option = give_get_option( 'admin_notice_emails' );
255
+	$email_option = give_get_option('admin_notice_emails');
256 256
 
257
-	$emails = ! empty( $email_option ) && strlen( trim( $email_option ) ) > 0 ? $email_option : get_bloginfo( 'admin_email' );
258
-	$emails = give_clean( explode( "\n", $emails ) );
257
+	$emails = ! empty($email_option) && strlen(trim($email_option)) > 0 ? $email_option : get_bloginfo('admin_email');
258
+	$emails = give_clean(explode("\n", $emails));
259 259
 
260
-	return apply_filters( 'give_admin_notice_emails', $emails );
260
+	return apply_filters('give_admin_notice_emails', $emails);
261 261
 }
262 262
 
263 263
 /**
@@ -269,11 +269,11 @@  discard block
 block discarded – undo
269 269
  *
270 270
  * @return mixed
271 271
  */
272
-function give_admin_notices_disabled( $payment_id = 0 ) {
272
+function give_admin_notices_disabled($payment_id = 0) {
273 273
 
274 274
 	return apply_filters(
275 275
 		'give_admin_notices_disabled',
276
-		! give_is_setting_enabled( give_get_option( 'admin_notices' ) ),
276
+		! give_is_setting_enabled(give_get_option('admin_notices')),
277 277
 		$payment_id
278 278
 	);
279 279
 }
@@ -288,19 +288,19 @@  discard block
 block discarded – undo
288 288
  */
289 289
 function give_get_default_donation_notification_email() {
290 290
 
291
-	$default_email_body = __( 'Hi there,', 'give' ) . "\n\n";
292
-	$default_email_body .= __( 'This email is to inform you that a new donation has been made on your website:', 'give' ) . ' <a href="' . get_bloginfo( 'url' ) . '" target="_blank">' . get_bloginfo( 'url' ) . '</a>' . ".\n\n";
293
-	$default_email_body .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {name}' . "\n";
294
-	$default_email_body .= '<strong>' . __( 'Donation:', 'give' ) . '</strong> {donation}' . "\n";
295
-	$default_email_body .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n";
296
-	$default_email_body .= '<strong>' . __( 'Payment Method:', 'give' ) . '</strong> {payment_method}' . "\n\n";
297
-	$default_email_body .= __( 'Thank you,', 'give' ) . "\n\n";
298
-	$default_email_body .= '{sitename}' . "\n";
291
+	$default_email_body = __('Hi there,', 'give')."\n\n";
292
+	$default_email_body .= __('This email is to inform you that a new donation has been made on your website:', 'give').' <a href="'.get_bloginfo('url').'" target="_blank">'.get_bloginfo('url').'</a>'.".\n\n";
293
+	$default_email_body .= '<strong>'.__('Donor:', 'give').'</strong> {name}'."\n";
294
+	$default_email_body .= '<strong>'.__('Donation:', 'give').'</strong> {donation}'."\n";
295
+	$default_email_body .= '<strong>'.__('Amount:', 'give').'</strong> {amount}'."\n";
296
+	$default_email_body .= '<strong>'.__('Payment Method:', 'give').'</strong> {payment_method}'."\n\n";
297
+	$default_email_body .= __('Thank you,', 'give')."\n\n";
298
+	$default_email_body .= '{sitename}'."\n";
299 299
 
300
-	$custom_message = give_get_option( 'donation_notification' );
301
-	$message        = ! empty( $custom_message ) ? $custom_message : $default_email_body;
300
+	$custom_message = give_get_option('donation_notification');
301
+	$message        = ! empty($custom_message) ? $custom_message : $default_email_body;
302 302
 
303
-	return apply_filters( 'give_default_donation_notification_email', $message );
303
+	return apply_filters('give_default_donation_notification_email', $message);
304 304
 }
305 305
 
306 306
 
@@ -314,25 +314,25 @@  discard block
 block discarded – undo
314 314
  */
315 315
 function give_get_default_donation_receipt_email() {
316 316
 
317
-	$default_email_body = __( 'Dear', 'give' ) . " {name},\n\n";
318
-	$default_email_body .= __( 'Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give' ) . "\n\n";
319
-	$default_email_body .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {fullname}' . "\n";
320
-	$default_email_body .= '<strong>' . __( 'Donation:', 'give' ) . '</strong> {donation}' . "\n";
321
-	$default_email_body .= '<strong>' . __( 'Donation Date:', 'give' ) . '</strong> {date}' . "\n";
322
-	$default_email_body .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n";
323
-	$default_email_body .= '<strong>' . __( 'Payment Method:', 'give' ) . '</strong> {payment_method}' . "\n";
324
-	$default_email_body .= '<strong>' . __( 'Payment ID:', 'give' ) . '</strong> {payment_id}' . "\n";
325
-	$default_email_body .= '<strong>' . __( 'Receipt ID:', 'give' ) . '</strong> {receipt_id}' . "\n\n";
326
-	$default_email_body .= '{receipt_link}' . "\n\n";
317
+	$default_email_body = __('Dear', 'give')." {name},\n\n";
318
+	$default_email_body .= __('Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give')."\n\n";
319
+	$default_email_body .= '<strong>'.__('Donor:', 'give').'</strong> {fullname}'."\n";
320
+	$default_email_body .= '<strong>'.__('Donation:', 'give').'</strong> {donation}'."\n";
321
+	$default_email_body .= '<strong>'.__('Donation Date:', 'give').'</strong> {date}'."\n";
322
+	$default_email_body .= '<strong>'.__('Amount:', 'give').'</strong> {amount}'."\n";
323
+	$default_email_body .= '<strong>'.__('Payment Method:', 'give').'</strong> {payment_method}'."\n";
324
+	$default_email_body .= '<strong>'.__('Payment ID:', 'give').'</strong> {payment_id}'."\n";
325
+	$default_email_body .= '<strong>'.__('Receipt ID:', 'give').'</strong> {receipt_id}'."\n\n";
326
+	$default_email_body .= '{receipt_link}'."\n\n";
327 327
 	$default_email_body .= "\n\n";
328
-	$default_email_body .= __( 'Sincerely,', 'give' ) . "\n";
329
-	$default_email_body .= '{sitename}' . "\n";
328
+	$default_email_body .= __('Sincerely,', 'give')."\n";
329
+	$default_email_body .= '{sitename}'."\n";
330 330
 
331
-	$custom_message = give_get_option( 'donation_receipt' );
331
+	$custom_message = give_get_option('donation_receipt');
332 332
 
333
-	$message = ! empty( $custom_message ) ? $custom_message : $default_email_body;
333
+	$message = ! empty($custom_message) ? $custom_message : $default_email_body;
334 334
 
335
-	return apply_filters( 'give_default_donation_receipt_email', $message );
335
+	return apply_filters('give_default_donation_receipt_email', $message);
336 336
 }
337 337
 
338 338
 /**
@@ -345,22 +345,22 @@  discard block
 block discarded – undo
345 345
  *
346 346
  * @return array $email_names
347 347
  */
348
-function give_get_email_names( $user_info, $payment = false ) {
348
+function give_get_email_names($user_info, $payment = false) {
349 349
 	$email_names = array();
350 350
 
351
-	if ( is_a( $payment, 'Give_Payment' ) ) {
351
+	if (is_a($payment, 'Give_Payment')) {
352 352
 
353
-		if ( $payment->user_id > 0 ) {
353
+		if ($payment->user_id > 0) {
354 354
 
355
-			$user_data               = get_userdata( $payment->user_id );
355
+			$user_data               = get_userdata($payment->user_id);
356 356
 			$email_names['name']     = $payment->first_name;
357
-			$email_names['fullname'] = trim( $payment->first_name . ' ' . $payment->last_name );
357
+			$email_names['fullname'] = trim($payment->first_name.' '.$payment->last_name);
358 358
 			$email_names['username'] = $user_data->user_login;
359 359
 
360
-		} elseif ( ! empty( $payment->first_name ) ) {
360
+		} elseif ( ! empty($payment->first_name)) {
361 361
 
362 362
 			$email_names['name']     = $payment->first_name;
363
-			$email_names['fullname'] = trim( $payment->first_name . ' ' . $payment->last_name );
363
+			$email_names['fullname'] = trim($payment->first_name.' '.$payment->last_name);
364 364
 			$email_names['username'] = $payment->first_name;
365 365
 
366 366
 		} else {
@@ -373,30 +373,30 @@  discard block
 block discarded – undo
373 373
 	} else {
374 374
 
375 375
 		// Support for old serialized data.
376
-		if ( is_serialized( $user_info ) ) {
376
+		if (is_serialized($user_info)) {
377 377
 
378 378
 			// Security check.
379
-			preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches );
380
-			if ( ! empty( $matches ) ) {
379
+			preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches);
380
+			if ( ! empty($matches)) {
381 381
 				return array(
382 382
 					'name'     => '',
383 383
 					'fullname' => '',
384 384
 					'username' => '',
385 385
 				);
386 386
 			} else {
387
-				$user_info = maybe_unserialize( $user_info );
387
+				$user_info = maybe_unserialize($user_info);
388 388
 			}
389 389
 
390 390
 		}
391 391
 
392
-		if ( isset( $user_info['id'] ) && $user_info['id'] > 0 && isset( $user_info['first_name'] ) ) {
393
-			$user_data               = get_userdata( $user_info['id'] );
392
+		if (isset($user_info['id']) && $user_info['id'] > 0 && isset($user_info['first_name'])) {
393
+			$user_data               = get_userdata($user_info['id']);
394 394
 			$email_names['name']     = $user_info['first_name'];
395
-			$email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name'];
395
+			$email_names['fullname'] = $user_info['first_name'].' '.$user_info['last_name'];
396 396
 			$email_names['username'] = $user_data->user_login;
397
-		} elseif ( isset( $user_info['first_name'] ) ) {
397
+		} elseif (isset($user_info['first_name'])) {
398 398
 			$email_names['name']     = $user_info['first_name'];
399
-			$email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name'];
399
+			$email_names['fullname'] = $user_info['first_name'].' '.$user_info['last_name'];
400 400
 			$email_names['username'] = $user_info['first_name'];
401 401
 		} else {
402 402
 			$email_names['name']     = $user_info['email'];
@@ -416,37 +416,37 @@  discard block
 block discarded – undo
416 416
  *
417 417
  * @since 1.8.14
418 418
  */
419
-function give_admin_email_user_donor_disconnection( $user_id, $donor_id ) {
419
+function give_admin_email_user_donor_disconnection($user_id, $donor_id) {
420 420
 
421
-	$user_id  = absint( $user_id );
422
-	$donor_id = absint( $donor_id );
421
+	$user_id  = absint($user_id);
422
+	$donor_id = absint($donor_id);
423 423
 
424 424
 	// Bail Out, if user id doesn't exists.
425
-	if ( empty( $user_id ) ) {
425
+	if (empty($user_id)) {
426 426
 		return;
427 427
 	}
428 428
 
429 429
 	// Bail Out, if donor id doesn't exists.
430
-	if ( empty( $donor_id ) ) {
430
+	if (empty($donor_id)) {
431 431
 		return;
432 432
 	}
433 433
 
434
-	$from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) );
434
+	$from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES));
435 435
 
436
-	$from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) );
436
+	$from_email = give_get_option('from_email', get_bloginfo('admin_email'));
437 437
 
438 438
 	/* translators: %s: payment id */
439
-	$subject = __( 'Attention: User tries to login whose Donor profile is disconnected!', 'give' );
439
+	$subject = __('Attention: User tries to login whose Donor profile is disconnected!', 'give');
440 440
 
441 441
 	/**
442 442
 	 * Filters the Donor-User Disconnection notification subject.
443 443
 	 *
444 444
 	 * @since 1.8.14
445 445
 	 */
446
-	$subject = apply_filters( 'give_admin_donor_user_disconnection_notification_subject', wp_strip_all_tags( $subject ) );
446
+	$subject = apply_filters('give_admin_donor_user_disconnection_notification_subject', wp_strip_all_tags($subject));
447 447
 
448
-	$headers = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n";
449
-	$headers .= "Reply-To: " . $from_email . "\r\n";
448
+	$headers = "From: ".stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8'))." <$from_email>\r\n";
449
+	$headers .= "Reply-To: ".$from_email."\r\n";
450 450
 	$headers .= "Content-Type: text/html; charset=utf-8\r\n";
451 451
 
452 452
 	/**
@@ -454,25 +454,25 @@  discard block
 block discarded – undo
454 454
 	 *
455 455
 	 * @since 1.8.14
456 456
 	 */
457
-	$headers = apply_filters( 'give_admin_donor_user_disconnection_notification_headers', $headers );
457
+	$headers = apply_filters('give_admin_donor_user_disconnection_notification_headers', $headers);
458 458
 
459
-	$message = __( 'Hi Admin,', 'give' ) . "\n\n";
460
-	$message .= __( 'This email is to inform you that a user has tried logging in. But, User was unable to login due to User-Donor profile disconnection.', 'give' ) . "\n\n";
461
-	$message .= __( 'Do you want to reconnect User and Donor profile again?', 'give' ) . "\n\n";
459
+	$message = __('Hi Admin,', 'give')."\n\n";
460
+	$message .= __('This email is to inform you that a user has tried logging in. But, User was unable to login due to User-Donor profile disconnection.', 'give')."\n\n";
461
+	$message .= __('Do you want to reconnect User and Donor profile again?', 'give')."\n\n";
462 462
 	$message .= sprintf(
463 463
 		'<a href="%1$s">%2$s</a>',
464
-		esc_url( admin_url() . 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor_id . '&user_id=' . $user_id . '&give-message=reconnect-user' ),
465
-		__( 'Reconnect User', 'give' ) . "\n\n"
464
+		esc_url(admin_url().'edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor_id.'&user_id='.$user_id.'&give-message=reconnect-user'),
465
+		__('Reconnect User', 'give')."\n\n"
466 466
 	);
467
-	$message .= __( 'Thank you,', 'give' ) . "\n\n";
468
-	$message .= '{sitename}' . "\n";
467
+	$message .= __('Thank you,', 'give')."\n\n";
468
+	$message .= '{sitename}'."\n";
469 469
 
470 470
 	$emails = Give()->emails;
471
-	$emails->__set( 'from_name', $from_name );
472
-	$emails->__set( 'from_email', $from_email );
473
-	$emails->__set( 'headers', $headers );
474
-	$emails->__set( 'heading', __( 'User - Donor Profile Disconnection', 'give' ) );
471
+	$emails->__set('from_name', $from_name);
472
+	$emails->__set('from_email', $from_email);
473
+	$emails->__set('headers', $headers);
474
+	$emails->__set('heading', __('User - Donor Profile Disconnection', 'give'));
475 475
 
476
-	$emails->send( give_get_admin_notice_emails(), $subject, give_do_email_tags( $message ) );
476
+	$emails->send(give_get_admin_notice_emails(), $subject, give_do_email_tags($message));
477 477
 
478 478
 }
Please login to merge, or discard this patch.
includes/import-functions.php 2 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -666,6 +666,7 @@
 block discarded – undo
666 666
  * Check if Import donation is duplicate
667 667
  *
668 668
  * @since 1.8.13
669
+ * @param Give_Donate_Form $form
669 670
  */
670 671
 function give_check_import_donation_duplicate( $payment_data, $data, $form, $donor_data ) {
671 672
 	$return = false;
Please login to merge, or discard this patch.
Spacing   +223 added lines, -223 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
 
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
  * @since 1.8.13
21 21
  */
22 22
 function give_import_donation_report() {
23
-	return get_option( 'give_import_donation_report', array() );
23
+	return get_option('give_import_donation_report', array());
24 24
 }
25 25
 
26 26
 
@@ -29,8 +29,8 @@  discard block
 block discarded – undo
29 29
  *
30 30
  * @since 1.8.13
31 31
  */
32
-function give_import_donation_report_update( $value = array() ) {
33
-	update_option( 'give_import_donation_report', $value );
32
+function give_import_donation_report_update($value = array()) {
33
+	update_option('give_import_donation_report', $value);
34 34
 }
35 35
 
36 36
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
  * @since 1.8.13
41 41
  */
42 42
 function give_import_donation_report_reset() {
43
-	update_option( 'give_import_donation_report', array() );
43
+	update_option('give_import_donation_report', array());
44 44
 }
45 45
 
46 46
 /**
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
  *
53 53
  * @return array|bool|Give_Donate_Form|int|null|WP_Post
54 54
  */
55
-function give_import_get_form_data_from_csv( $data, $import_setting = array() ) {
55
+function give_import_get_form_data_from_csv($data, $import_setting = array()) {
56 56
 	$new_form = false;
57 57
 
58 58
 	// Get the import report
@@ -61,58 +61,58 @@  discard block
 block discarded – undo
61 61
 	$form = false;
62 62
 	$meta = array();
63 63
 
64
-	if ( ! empty( $data['form_id'] ) ) {
65
-		$form = new Give_Donate_Form( $data['form_id'] );
64
+	if ( ! empty($data['form_id'])) {
65
+		$form = new Give_Donate_Form($data['form_id']);
66 66
 		// Add support to older php version.
67 67
 		$form_id = $form->get_ID();
68
-		if ( empty( $form_id ) ) {
69
-			$report['duplicate_form'] = ( ! empty( $report['duplicate_form'] ) ? ( absint( $report['duplicate_form'] ) + 1 ) : 1 );
68
+		if (empty($form_id)) {
69
+			$report['duplicate_form'] = ( ! empty($report['duplicate_form']) ? (absint($report['duplicate_form']) + 1) : 1);
70 70
 			$form                     = false;
71 71
 		}
72 72
 	}
73 73
 
74
-	if ( false === $form && ! empty( $data['form_title'] ) ) {
75
-		$form = get_page_by_title( $data['form_title'], OBJECT, 'give_forms' );
74
+	if (false === $form && ! empty($data['form_title'])) {
75
+		$form = get_page_by_title($data['form_title'], OBJECT, 'give_forms');
76 76
 
77
-		if ( ! empty( $form->ID ) ) {
77
+		if ( ! empty($form->ID)) {
78 78
 
79
-			$report['duplicate_form'] = ( ! empty( $report['duplicate_form'] ) ? ( absint( $report['duplicate_form'] ) + 1 ) : 1 );
79
+			$report['duplicate_form'] = ( ! empty($report['duplicate_form']) ? (absint($report['duplicate_form']) + 1) : 1);
80 80
 
81
-			$form = new Give_Donate_Form( $form->ID );
81
+			$form = new Give_Donate_Form($form->ID);
82 82
 		} else {
83 83
 			$form                  = new Give_Donate_Form();
84 84
 			$args                  = array(
85 85
 				'post_title'  => $data['form_title'],
86 86
 				'post_status' => 'publish',
87 87
 			);
88
-			$form                  = $form->create( $args );
89
-			$report['create_form'] = ( ! empty( $report['create_form'] ) ? ( absint( $report['create_form'] ) + 1 ) : 1 );
88
+			$form                  = $form->create($args);
89
+			$report['create_form'] = ( ! empty($report['create_form']) ? (absint($report['create_form']) + 1) : 1);
90 90
 			$new_form              = true;
91 91
 
92 92
 		}
93 93
 
94
-		$form = get_page_by_title( $data['form_title'], OBJECT, 'give_forms' );
95
-		$form = new Give_Donate_Form( $form->ID );
94
+		$form = get_page_by_title($data['form_title'], OBJECT, 'give_forms');
95
+		$form = new Give_Donate_Form($form->ID);
96 96
 	}
97 97
 
98
-	if ( ! empty( $form ) && $form->get_ID() ) {
99
-		if ( ! empty( $data['form_level'] ) && 'custom' != (string) strtolower( $data['form_level'] ) ) {
98
+	if ( ! empty($form) && $form->get_ID()) {
99
+		if ( ! empty($data['form_level']) && 'custom' != (string) strtolower($data['form_level'])) {
100 100
 			$prices     = (array) $form->get_prices();
101 101
 			$price_text = array();
102
-			foreach ( $prices as $key => $price ) {
103
-				if ( isset( $price['_give_id']['level_id'] ) ) {
104
-					$price_text[ $price['_give_id']['level_id'] ] = ( ! empty( $price['_give_text'] ) ? $price['_give_text'] : '' );
102
+			foreach ($prices as $key => $price) {
103
+				if (isset($price['_give_id']['level_id'])) {
104
+					$price_text[$price['_give_id']['level_id']] = ( ! empty($price['_give_text']) ? $price['_give_text'] : '');
105 105
 				}
106 106
 			}
107 107
 
108
-			if ( ! in_array( $data['form_level'], $price_text ) ) {
108
+			if ( ! in_array($data['form_level'], $price_text)) {
109 109
 
110 110
 				// For generating unquiet level id.
111 111
 				$count     = 1;
112
-				$new_level = count( $prices ) + $count;
113
-				while ( array_key_exists( $new_level, $price_text ) ) {
114
-					$count ++;
115
-					$new_level = count( $prices ) + $count;
112
+				$new_level = count($prices) + $count;
113
+				while (array_key_exists($new_level, $price_text)) {
114
+					$count++;
115
+					$new_level = count($prices) + $count;
116 116
 				}
117 117
 
118 118
 				$multi_level_donations = array(
@@ -120,57 +120,57 @@  discard block
 block discarded – undo
120 120
 						'_give_id'     => array(
121 121
 							'level_id' => $new_level,
122 122
 						),
123
-						'_give_amount' => give_sanitize_amount_for_db( $data['amount'] ),
123
+						'_give_amount' => give_sanitize_amount_for_db($data['amount']),
124 124
 						'_give_text'   => $data['form_level'],
125 125
 					),
126 126
 				);
127 127
 
128
-				$price_text[ $new_level ] = $data['form_level'];
128
+				$price_text[$new_level] = $data['form_level'];
129 129
 
130
-				if ( ! empty( $prices ) && is_array( $prices ) && ! empty( $prices[0] ) ) {
131
-					$prices = wp_parse_args( $multi_level_donations, $prices );
130
+				if ( ! empty($prices) && is_array($prices) && ! empty($prices[0])) {
131
+					$prices = wp_parse_args($multi_level_donations, $prices);
132 132
 
133 133
 					// Sort $prices by amount in ascending order.
134
-					$prices = wp_list_sort( $prices, '_give_amount', 'ASC' );
134
+					$prices = wp_list_sort($prices, '_give_amount', 'ASC');
135 135
 				} else {
136 136
 					$prices = $multi_level_donations;
137 137
 				}
138 138
 
139 139
 				// Unset _give_default key from $prices.
140
-				foreach ( $prices as $key => $price ) {
141
-					if ( isset( $prices[ $key ]['_give_default'] ) ) {
142
-						unset( $prices[ $key ]['_give_default'] );
140
+				foreach ($prices as $key => $price) {
141
+					if (isset($prices[$key]['_give_default'])) {
142
+						unset($prices[$key]['_give_default']);
143 143
 					}
144 144
 				}
145 145
 
146 146
 				// Set the first $price of the $prices as defalut.
147 147
 				$prices[0]['_give_default'] = 'default';
148 148
 			}
149
-			$form->price_id = array_search( $data['form_level'], $price_text );
149
+			$form->price_id = array_search($data['form_level'], $price_text);
150 150
 
151
-			$donation_levels_amounts = wp_list_pluck( $prices, '_give_amount' );
152
-			$min_amount              = min( $donation_levels_amounts );
153
-			$max_amount              = max( $donation_levels_amounts );
151
+			$donation_levels_amounts = wp_list_pluck($prices, '_give_amount');
152
+			$min_amount              = min($donation_levels_amounts);
153
+			$max_amount              = max($donation_levels_amounts);
154 154
 
155 155
 			$meta = array(
156 156
 				'_give_levels_minimum_amount' => $min_amount,
157 157
 				'_give_levels_maximum_amount' => $max_amount,
158 158
 				'_give_price_option'          => 'multi',
159
-				'_give_donation_levels'       => array_values( $prices ),
159
+				'_give_donation_levels'       => array_values($prices),
160 160
 			);
161 161
 		} else {
162 162
 			$form->price_id = 'custom';
163 163
 		}
164 164
 
165 165
 		$defaults = array(
166
-			'_give_set_price'    => give_sanitize_amount_for_db( $data['amount'] ),
166
+			'_give_set_price'    => give_sanitize_amount_for_db($data['amount']),
167 167
 			'_give_price_option' => 'set',
168 168
 		);
169 169
 
170 170
 		// If new form is created.
171
-		if ( ! empty( $new_form ) ) {
171
+		if ( ! empty($new_form)) {
172 172
 			$new_form = array(
173
-				'_give_custom_amount_text' => ( ! empty( $data['form_custom_amount_text'] ) ? $data['form_custom_amount_text'] : 'Custom' ),
173
+				'_give_custom_amount_text' => ( ! empty($data['form_custom_amount_text']) ? $data['form_custom_amount_text'] : 'Custom'),
174 174
 				'_give_logged_in_only'     => 'enabled',
175 175
 				'_give_custom_amount'      => 'enabled',
176 176
 				'_give_payment_import'     => true,
@@ -181,18 +181,18 @@  discard block
 block discarded – undo
181 181
 				'_give_default_gateway'    => 'global',
182 182
 				'_give_show_register_form' => 'both',
183 183
 			);
184
-			$defaults = wp_parse_args( $defaults, $new_form );
184
+			$defaults = wp_parse_args($defaults, $new_form);
185 185
 		}
186 186
 
187
-		$meta = wp_parse_args( $meta, $defaults );
187
+		$meta = wp_parse_args($meta, $defaults);
188 188
 
189
-		foreach ( $meta as $key => $value ) {
190
-			give_update_meta( $form->get_ID(), $key, $value );
189
+		foreach ($meta as $key => $value) {
190
+			give_update_meta($form->get_ID(), $key, $value);
191 191
 		}
192 192
 	}
193 193
 
194 194
 	// update the report
195
-	give_import_donation_report_update( $report );
195
+	give_import_donation_report_update($report);
196 196
 
197 197
 	return $form;
198 198
 }
@@ -206,30 +206,30 @@  discard block
 block discarded – undo
206 206
  *
207 207
  * @return bool|false|WP_User
208 208
  */
209
-function give_import_get_user_from_csv( $data, $import_setting = array() ) {
209
+function give_import_get_user_from_csv($data, $import_setting = array()) {
210 210
 	$report      = give_import_donation_report();
211 211
 	$donor_data  = false;
212 212
 	$customer_id = false;
213 213
 
214 214
 	// check if donor id is not empty
215
-	if ( ! empty( $data['donor_id'] ) ) {
216
-		$donor_data = new Give_Donor( (int) $data['donor_id'] );
217
-		if ( ! empty( $donor_data->id ) ) {
218
-			$report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 );
215
+	if ( ! empty($data['donor_id'])) {
216
+		$donor_data = new Give_Donor((int) $data['donor_id']);
217
+		if ( ! empty($donor_data->id)) {
218
+			$report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1);
219 219
 		}
220 220
 	}
221 221
 
222
-	if ( empty( $donor_data->id ) && ! empty( $data['user_id'] ) ) {
222
+	if (empty($donor_data->id) && ! empty($data['user_id'])) {
223 223
 		$user_id    = (int) $data['user_id'];
224
-		$donor_data = new Give_Donor( $user_id, true );
224
+		$donor_data = new Give_Donor($user_id, true);
225 225
 
226 226
 
227
-		if ( empty( $donor_data->id ) ) {
228
-			$donor_data = get_user_by( 'id', $user_id );
229
-			if ( ! empty( $donor_data->ID ) ) {
230
-				$first_name = ( ! empty( $data['first_name'] ) ? $data['first_name'] : $donor_data->user_nicename );
231
-				$last_name  = ( ! empty( $data['last_name'] ) ? $data['last_name'] : ( ( $lastname = get_user_meta( $donor_data->ID, 'last_name', true ) ) ? $lastname : '' ) );
232
-				$name       = $first_name . ' ' . $last_name;
227
+		if (empty($donor_data->id)) {
228
+			$donor_data = get_user_by('id', $user_id);
229
+			if ( ! empty($donor_data->ID)) {
230
+				$first_name = ( ! empty($data['first_name']) ? $data['first_name'] : $donor_data->user_nicename);
231
+				$last_name  = ( ! empty($data['last_name']) ? $data['last_name'] : (($lastname = get_user_meta($donor_data->ID, 'last_name', true)) ? $lastname : ''));
232
+				$name       = $first_name.' '.$last_name;
233 233
 				$user_email = $donor_data->user_email;
234 234
 				$donor_args = array(
235 235
 					'name'    => $name,
@@ -238,44 +238,44 @@  discard block
 block discarded – undo
238 238
 				);
239 239
 
240 240
 				$donor_data = new Give_Donor();
241
-				$donor_data->create( $donor_args );
241
+				$donor_data->create($donor_args);
242 242
 
243 243
 				// Adding notes that donor is being imported from CSV.
244 244
 				$current_user = wp_get_current_user();
245
-				$donor_data->add_note( esc_html( wp_sprintf( __( 'This donor was imported by %s', 'give' ), $current_user->user_email ) ) );
245
+				$donor_data->add_note(esc_html(wp_sprintf(__('This donor was imported by %s', 'give'), $current_user->user_email)));
246 246
 
247 247
 				// Add is used to ensure duplicate emails are not added
248
-				if ( $user_email != $data['email'] && ! empty( $data['email'] ) ) {
249
-					$donor_data->add_meta( 'additional_email', $data['email'] );
248
+				if ($user_email != $data['email'] && ! empty($data['email'])) {
249
+					$donor_data->add_meta('additional_email', $data['email']);
250 250
 				}
251 251
 
252
-				$report['create_donor'] = ( ! empty( $report['create_donor'] ) ? ( absint( $report['create_donor'] ) + 1 ) : 1 );
252
+				$report['create_donor'] = ( ! empty($report['create_donor']) ? (absint($report['create_donor']) + 1) : 1);
253 253
 			} else {
254 254
 			}
255 255
 		} else {
256 256
 			// Add is used to ensure duplicate emails are not added
257
-			if ( $donor_data->email != $data['email'] ) {
258
-				$donor_data->add_meta( 'additional_email', ( ! empty( $data['email'] ) ? $data['email'] : $donor_data->email ) );
257
+			if ($donor_data->email != $data['email']) {
258
+				$donor_data->add_meta('additional_email', ( ! empty($data['email']) ? $data['email'] : $donor_data->email));
259 259
 			}
260
-			$report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 );
260
+			$report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1);
261 261
 		}
262 262
 	}
263 263
 
264
-	if ( empty( $donor_data->id ) && ! empty( $data['email'] ) ) {
264
+	if (empty($donor_data->id) && ! empty($data['email'])) {
265 265
 
266
-		$donor_data = new Give_Donor( $data['email'] );
267
-		if ( empty( $donor_data->id ) ) {
268
-			$donor_data = get_user_by( 'email', $data['email'] );
266
+		$donor_data = new Give_Donor($data['email']);
267
+		if (empty($donor_data->id)) {
268
+			$donor_data = get_user_by('email', $data['email']);
269 269
 
270
-			if ( empty( $donor_data->ID ) && ! empty( $data['first_name'] ) && ! empty( $data['last_name'] ) && isset( $import_setting['create_user'] ) && 1 === absint( $import_setting['create_user'] ) ) {
271
-				$give_role  = (array) give_get_option( 'donor_default_user_role', get_option( 'default_role', ( ( $give_donor = wp_roles()->is_role( 'give_donor' ) ) && ! empty( $give_donor ) ? 'give_donor' : 'subscriber' ) ) );
270
+			if (empty($donor_data->ID) && ! empty($data['first_name']) && ! empty($data['last_name']) && isset($import_setting['create_user']) && 1 === absint($import_setting['create_user'])) {
271
+				$give_role  = (array) give_get_option('donor_default_user_role', get_option('default_role', (($give_donor = wp_roles()->is_role('give_donor')) && ! empty($give_donor) ? 'give_donor' : 'subscriber')));
272 272
 				$donor_args = array(
273 273
 					'user_login'      => $data['email'],
274 274
 					'user_email'      => $data['email'],
275
-					'user_registered' => date( 'Y-m-d H:i:s' ),
275
+					'user_registered' => date('Y-m-d H:i:s'),
276 276
 					'user_first'      => $data['first_name'],
277 277
 					'user_last'       => $data['last_name'],
278
-					'user_pass'       => wp_generate_password( 8, true ),
278
+					'user_pass'       => wp_generate_password(8, true),
279 279
 					'role'            => $give_role,
280 280
 				);
281 281
 
@@ -284,56 +284,56 @@  discard block
 block discarded – undo
284 284
 				 *
285 285
 				 * @since 1.8.13
286 286
 				 */
287
-				$donor_args = (array) apply_filters( 'give_import_insert_user_args', $donor_args, $data, $import_setting );
287
+				$donor_args = (array) apply_filters('give_import_insert_user_args', $donor_args, $data, $import_setting);
288 288
 
289 289
 				// This action was added to remove the login when using the give register function.
290
-				add_filter( 'give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11 );
291
-				$customer_id = give_register_and_login_new_user( $donor_args );
292
-				remove_filter( 'give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11 );
290
+				add_filter('give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11);
291
+				$customer_id = give_register_and_login_new_user($donor_args);
292
+				remove_filter('give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11);
293 293
 
294
-				update_user_meta( $customer_id, '_give_payment_import', true );
295
-				$donor_data = new Give_Donor( $customer_id, true );
294
+				update_user_meta($customer_id, '_give_payment_import', true);
295
+				$donor_data = new Give_Donor($customer_id, true);
296 296
 			} else {
297
-				$customer_id = ( ! empty( $donor_data->ID ) ? $donor_data->ID : false );
297
+				$customer_id = ( ! empty($donor_data->ID) ? $donor_data->ID : false);
298 298
 			}
299 299
 
300
-			if ( ! empty( $customer_id ) || ( isset( $import_setting['create_user'] ) && 0 === absint( $import_setting['create_user'] ) ) ) {
301
-				$donor_data = new Give_Donor( $customer_id, true );
300
+			if ( ! empty($customer_id) || (isset($import_setting['create_user']) && 0 === absint($import_setting['create_user']))) {
301
+				$donor_data = new Give_Donor($customer_id, true);
302 302
 
303
-				if ( empty( $donor_data->id ) ) {
303
+				if (empty($donor_data->id)) {
304 304
 
305
-					if ( ! empty( $data['form_id'] ) ) {
306
-						$form = new Give_Donate_Form( $data['form_id'] );
305
+					if ( ! empty($data['form_id'])) {
306
+						$form = new Give_Donate_Form($data['form_id']);
307 307
 					}
308 308
 
309
-					$payment_title = ( isset( $data['form_title'] ) ? $data['form_title'] : ( isset( $form ) ? $form->get_name() : esc_html__( 'New Form', 'give' ) ) );
309
+					$payment_title = (isset($data['form_title']) ? $data['form_title'] : (isset($form) ? $form->get_name() : esc_html__('New Form', 'give')));
310 310
 					$donor_args    = array(
311
-						'name'  => ! is_email( $payment_title ) ? $data['first_name'] . ' ' . $data['last_name'] : '',
311
+						'name'  => ! is_email($payment_title) ? $data['first_name'].' '.$data['last_name'] : '',
312 312
 						'email' => $data['email'],
313 313
 					);
314 314
 
315
-					if ( ! empty( $customer_id ) ) {
315
+					if ( ! empty($customer_id)) {
316 316
 						$donor_args['user_id'] = $customer_id;
317 317
 					}
318 318
 
319
-					$donor_data->create( $donor_args );
319
+					$donor_data->create($donor_args);
320 320
 
321 321
 					// Adding notes that donor is being imported from CSV.
322 322
 					$current_user = wp_get_current_user();
323
-					$donor_data->add_note( esc_html( wp_sprintf( __( 'This donor was imported by %s', 'give' ), $current_user->user_email ) ) );
323
+					$donor_data->add_note(esc_html(wp_sprintf(__('This donor was imported by %s', 'give'), $current_user->user_email)));
324 324
 
325
-					$report['create_donor'] = ( ! empty( $report['create_donor'] ) ? ( absint( $report['create_donor'] ) + 1 ) : 1 );
325
+					$report['create_donor'] = ( ! empty($report['create_donor']) ? (absint($report['create_donor']) + 1) : 1);
326 326
 				} else {
327
-					$report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 );
327
+					$report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1);
328 328
 				}
329 329
 			}
330 330
 		} else {
331
-			$report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 );
331
+			$report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1);
332 332
 		}
333 333
 	}
334 334
 
335 335
 	// update the report
336
-	give_import_donation_report_update( $report );
336
+	give_import_donation_report_update($report);
337 337
 
338 338
 	return $donor_data;
339 339
 }
@@ -351,9 +351,9 @@  discard block
 block discarded – undo
351 351
 	 *
352 352
 	 * @return array
353 353
 	 */
354
-	return (array) apply_filters( 'give_import_default_options', array(
355
-		'' => __( 'Do not import', 'give' ),
356
-	) );
354
+	return (array) apply_filters('give_import_default_options', array(
355
+		'' => __('Do not import', 'give'),
356
+	));
357 357
 }
358 358
 
359 359
 /**
@@ -369,33 +369,33 @@  discard block
 block discarded – undo
369 369
 	 *
370 370
 	 * @return array
371 371
 	 */
372
-	return (array) apply_filters( 'give_import_donations_options', array(
373
-		'id'          => __( 'Donation ID', 'give' ),
374
-		'amount'      => __( 'Donation Amount', 'give' ),
375
-		'post_date'   => __( 'Donation Date', 'give' ),
376
-		'first_name'  => __( 'Donor First Name', 'give' ),
377
-		'last_name'   => __( 'Donor Last Name', 'give' ),
378
-		'line1'       => __( 'Address 1', 'give' ),
379
-		'line2'       => __( 'Address 2', 'give' ),
380
-		'city'        => __( 'City', 'give' ),
381
-		'state'       => __( 'State', 'give' ),
372
+	return (array) apply_filters('give_import_donations_options', array(
373
+		'id'          => __('Donation ID', 'give'),
374
+		'amount'      => __('Donation Amount', 'give'),
375
+		'post_date'   => __('Donation Date', 'give'),
376
+		'first_name'  => __('Donor First Name', 'give'),
377
+		'last_name'   => __('Donor Last Name', 'give'),
378
+		'line1'       => __('Address 1', 'give'),
379
+		'line2'       => __('Address 2', 'give'),
380
+		'city'        => __('City', 'give'),
381
+		'state'       => __('State', 'give'),
382 382
 		'country'     => array(
383
-			__( 'Country', 'give' ),
384
-			__( 'County', 'give' ),
385
-			__( 'Region', 'give' ),
386
-			__( 'Province', 'give' ),
383
+			__('Country', 'give'),
384
+			__('County', 'give'),
385
+			__('Region', 'give'),
386
+			__('Province', 'give'),
387 387
 		),
388 388
 		'zip'         => array(
389
-			__( 'Zip', 'give' ),
390
-			__( 'Postal Code', 'give' ),
389
+			__('Zip', 'give'),
390
+			__('Postal Code', 'give'),
391 391
 		),
392
-		'email'       => __( 'Donor Email', 'give' ),
393
-		'post_status' => __( 'Donation Status', 'give' ),
394
-		'gateway'     => __( 'Payment Method', 'give' ),
395
-		'notes'       => __( 'Notes', 'give' ),
396
-		'mode'        => __( 'Test Mode', 'give' ),
397
-		'post_meta'   => __( 'Import as Meta', 'give' ),
398
-	) );
392
+		'email'       => __('Donor Email', 'give'),
393
+		'post_status' => __('Donation Status', 'give'),
394
+		'gateway'     => __('Payment Method', 'give'),
395
+		'notes'       => __('Notes', 'give'),
396
+		'mode'        => __('Test Mode', 'give'),
397
+		'post_meta'   => __('Import as Meta', 'give'),
398
+	));
399 399
 }
400 400
 
401 401
 /**
@@ -411,10 +411,10 @@  discard block
 block discarded – undo
411 411
 	 *
412 412
 	 * @return array
413 413
 	 */
414
-	return (array) apply_filters( 'give_import_donor_options', array(
415
-		'donor_id' => __( 'Donor ID', 'give' ),
416
-		'user_id'  => __( 'User ID', 'give' ),
417
-	) );
414
+	return (array) apply_filters('give_import_donor_options', array(
415
+		'donor_id' => __('Donor ID', 'give'),
416
+		'user_id'  => __('User ID', 'give'),
417
+	));
418 418
 }
419 419
 
420 420
 /**
@@ -430,15 +430,15 @@  discard block
 block discarded – undo
430 430
 	 *
431 431
 	 * @return array
432 432
 	 */
433
-	return (array) apply_filters( 'give_import_donation_form_options', array(
433
+	return (array) apply_filters('give_import_donation_form_options', array(
434 434
 		'form_title'              => array(
435
-			__( 'Donation Form Title', 'give' ),
436
-			__( 'Donation Form', 'give' ),
435
+			__('Donation Form Title', 'give'),
436
+			__('Donation Form', 'give'),
437 437
 		),
438
-		'form_id'                 => __( 'Donation Form ID', 'give' ),
439
-		'form_level'              => __( 'Donation Level', 'give' ),
440
-		'form_custom_amount_text' => __( 'Custom Amount Text', 'give' ),
441
-	) );
438
+		'form_id'                 => __('Donation Form ID', 'give'),
439
+		'form_level'              => __('Donation Level', 'give'),
440
+		'form_custom_amount_text' => __('Custom Amount Text', 'give'),
441
+	));
442 442
 }
443 443
 
444 444
 /**
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
  *
452 452
  * @return array
453 453
  */
454
-function give_get_donation_data_from_csv( $file_id, $start, $end, $delimiter = 'csv' ) {
454
+function give_get_donation_data_from_csv($file_id, $start, $end, $delimiter = 'csv') {
455 455
 	/**
456 456
 	 * Filter to modify delimiter of Import.
457 457
 	 *
@@ -460,19 +460,19 @@  discard block
 block discarded – undo
460 460
 	 *
461 461
 	 * Return string $delimiter.
462 462
 	 */
463
-	$delimiter = (string) apply_filters( 'give_import_delimiter_set', $delimiter );
463
+	$delimiter = (string) apply_filters('give_import_delimiter_set', $delimiter);
464 464
 
465 465
 	$raw_data = array();
466
-	$file_dir = get_attached_file( $file_id );
466
+	$file_dir = get_attached_file($file_id);
467 467
 	$count    = 0;
468
-	if ( false !== ( $handle = fopen( $file_dir, 'r' ) ) ) {
469
-		while ( false !== ( $row = fgetcsv( $handle, 0, $delimiter ) ) ) {
470
-			if ( $count >= $start && $count <= $end ) {
468
+	if (false !== ($handle = fopen($file_dir, 'r'))) {
469
+		while (false !== ($row = fgetcsv($handle, 0, $delimiter))) {
470
+			if ($count >= $start && $count <= $end) {
471 471
 				$raw_data[] = $row;
472 472
 			}
473
-			$count ++;
473
+			$count++;
474 474
 		}
475
-		fclose( $handle );
475
+		fclose($handle);
476 476
 	}
477 477
 
478 478
 	return $raw_data;
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
  *
489 489
  * @return bool
490 490
  */
491
-function give_log_user_in_on_register_callback( $value ) {
491
+function give_log_user_in_on_register_callback($value) {
492 492
 	return false;
493 493
 }
494 494
 
@@ -504,22 +504,22 @@  discard block
 block discarded – undo
504 504
  *
505 505
  * @return bool
506 506
  */
507
-function give_save_import_donation_to_db( $raw_key, $row_data, $main_key = array(), $import_setting = array() ) {
508
-	$data                          = array_combine( $raw_key, $row_data );
507
+function give_save_import_donation_to_db($raw_key, $row_data, $main_key = array(), $import_setting = array()) {
508
+	$data                          = array_combine($raw_key, $row_data);
509 509
 	$price_id                      = false;
510 510
 	$customer_id                   = 0;
511
-	$import_setting['create_user'] = ( isset( $import_setting['create_user'] ) ? $import_setting['create_user'] : 1 );
511
+	$import_setting['create_user'] = (isset($import_setting['create_user']) ? $import_setting['create_user'] : 1);
512 512
 
513
-	$data = (array) apply_filters( 'give_save_import_donation_to_db', $data );
513
+	$data = (array) apply_filters('give_save_import_donation_to_db', $data);
514 514
 
515
-	$data['amount'] = give_maybe_sanitize_amount( $data['amount'] );
515
+	$data['amount'] = give_maybe_sanitize_amount($data['amount']);
516 516
 
517 517
 	// Here come the login function.
518
-	$donor_data = give_import_get_user_from_csv( $data, $import_setting );
519
-	if ( ! empty( $donor_data->id ) ) {
520
-		if ( ! empty( $donor_data->user_id ) ) {
518
+	$donor_data = give_import_get_user_from_csv($data, $import_setting);
519
+	if ( ! empty($donor_data->id)) {
520
+		if ( ! empty($donor_data->user_id)) {
521 521
 			$customer_id = $donor_data->user_id;
522
-		} elseif ( ! empty( $data['user_id'] ) ) {
522
+		} elseif ( ! empty($data['user_id'])) {
523 523
 			$customer_id = $data['user_id'];
524 524
 		}
525 525
 	} else {
@@ -527,95 +527,95 @@  discard block
 block discarded – undo
527 527
 	}
528 528
 
529 529
 	// get form data or register a form data.
530
-	$form = give_import_get_form_data_from_csv( $data, $import_setting );
531
-	if ( false == $form ) {
530
+	$form = give_import_get_form_data_from_csv($data, $import_setting);
531
+	if (false == $form) {
532 532
 		return false;
533 533
 	} else {
534
-		$price_id = ( ! empty( $form->price_id ) ) ? $form->price_id : false;
534
+		$price_id = ( ! empty($form->price_id)) ? $form->price_id : false;
535 535
 	}
536 536
 
537 537
 
538 538
 	$address = array(
539
-		'line1'   => ( ! empty( $data['line1'] ) ? give_clean( $data['line1'] ) : '' ),
540
-		'line2'   => ( ! empty( $data['line1'] ) ? give_clean( $data['line2'] ) : '' ),
541
-		'city'    => ( ! empty( $data['line1'] ) ? give_clean( $data['city'] ) : '' ),
542
-		'zip'     => ( ! empty( $data['zip'] ) ? give_clean( $data['zip'] ) : '' ),
543
-		'state'   => ( ! empty( $data['state'] ) ? give_clean( $data['state'] ) : '' ),
544
-		'country' => ( ! empty( $data['country'] ) ? ( ( $country_code = array_search( $data['country'], give_get_country_list() ) ) ? $country_code : $data['country'] ) : '' ),
539
+		'line1'   => ( ! empty($data['line1']) ? give_clean($data['line1']) : ''),
540
+		'line2'   => ( ! empty($data['line1']) ? give_clean($data['line2']) : ''),
541
+		'city'    => ( ! empty($data['line1']) ? give_clean($data['city']) : ''),
542
+		'zip'     => ( ! empty($data['zip']) ? give_clean($data['zip']) : ''),
543
+		'state'   => ( ! empty($data['state']) ? give_clean($data['state']) : ''),
544
+		'country' => ( ! empty($data['country']) ? (($country_code = array_search($data['country'], give_get_country_list())) ? $country_code : $data['country']) : ''),
545 545
 	);
546 546
 
547 547
 	//Create payment_data array
548 548
 	$payment_data = array(
549 549
 		'donor_id'        => $donor_data->id,
550 550
 		'price'           => $data['amount'],
551
-		'status'          => ( ! empty( $data['post_status'] ) ? $data['post_status'] : 'publish' ),
551
+		'status'          => ( ! empty($data['post_status']) ? $data['post_status'] : 'publish'),
552 552
 		'currency'        => give_get_currency(),
553 553
 		'user_info'       => array(
554 554
 			'id'         => $customer_id,
555
-			'email'      => ( ! empty( $data['email'] ) ? $data['email'] : ( isset( $donor_data->email ) ? $donor_data->email : false ) ),
556
-			'first_name' => ( ! empty( $data['first_name'] ) ? $data['first_name'] : ( ! empty( $customer_id ) && ( $first_name = get_user_meta( $customer_id, 'first_name', true ) ) ? $first_name : $donor_data->name ) ),
557
-			'last_name'  => ( ! empty( $data['last_name'] ) ? $data['last_name'] : ( ! empty( $customer_id ) && ( $last_name = get_user_meta( $customer_id, 'last_name', true ) ) ? $last_name : $donor_data->name ) ),
555
+			'email'      => ( ! empty($data['email']) ? $data['email'] : (isset($donor_data->email) ? $donor_data->email : false)),
556
+			'first_name' => ( ! empty($data['first_name']) ? $data['first_name'] : ( ! empty($customer_id) && ($first_name = get_user_meta($customer_id, 'first_name', true)) ? $first_name : $donor_data->name)),
557
+			'last_name'  => ( ! empty($data['last_name']) ? $data['last_name'] : ( ! empty($customer_id) && ($last_name = get_user_meta($customer_id, 'last_name', true)) ? $last_name : $donor_data->name)),
558 558
 			'address'    => $address,
559 559
 		),
560
-		'gateway'         => ( ! empty( $data['gateway'] ) && 'offline' != strtolower( $data['gateway'] ) ? strtolower( $data['gateway'] ) : 'manual' ),
561
-		'give_form_title' => ( ! empty( $data['form_title'] ) ? $data['form_title'] : $form->get_name() ),
560
+		'gateway'         => ( ! empty($data['gateway']) && 'offline' != strtolower($data['gateway']) ? strtolower($data['gateway']) : 'manual'),
561
+		'give_form_title' => ( ! empty($data['form_title']) ? $data['form_title'] : $form->get_name()),
562 562
 		'give_form_id'    => (string) $form->get_ID(),
563 563
 		'give_price_id'   => $price_id,
564
-		'purchase_key'    => strtolower( md5( uniqid() ) ),
564
+		'purchase_key'    => strtolower(md5(uniqid())),
565 565
 		'user_email'      => $data['email'],
566
-		'post_date'       => ( ! empty( $data['post_date'] ) ? mysql2date( 'Y-m-d H:i:s', $data['post_date'] ) : current_time( 'mysql' ) ),
567
-		'mode'            => ( ! empty( $data['mode'] ) ? ( 'true' == (string) $data['mode'] || 'TRUE' == (string) $data['mode'] ? 'test' : 'live' ) : ( isset( $import_setting['mode'] ) ? ( true == (bool) $import_setting['mode'] ? 'test' : 'live' ) : ( give_is_test_mode() ? 'test' : 'live' ) ) ),
566
+		'post_date'       => ( ! empty($data['post_date']) ? mysql2date('Y-m-d H:i:s', $data['post_date']) : current_time('mysql')),
567
+		'mode'            => ( ! empty($data['mode']) ? ('true' == (string) $data['mode'] || 'TRUE' == (string) $data['mode'] ? 'test' : 'live') : (isset($import_setting['mode']) ? (true == (bool) $import_setting['mode'] ? 'test' : 'live') : (give_is_test_mode() ? 'test' : 'live'))),
568 568
 	);
569 569
 
570
-	$payment_data = apply_filters( 'give_import_before_import_payment', $payment_data, $data, $donor_data, $form );
570
+	$payment_data = apply_filters('give_import_before_import_payment', $payment_data, $data, $donor_data, $form);
571 571
 
572 572
 	// Get the report
573 573
 	$report = give_import_donation_report();
574 574
 
575 575
 	// Check for duplicate code.
576
-	if ( true === give_check_import_donation_duplicate( $payment_data, $data, $form, $donor_data ) ) {
577
-		$report['duplicate_donation'] = ( ! empty( $report['duplicate_donation'] ) ? ( absint( $report['duplicate_donation'] ) + 1 ) : 1 );
576
+	if (true === give_check_import_donation_duplicate($payment_data, $data, $form, $donor_data)) {
577
+		$report['duplicate_donation'] = ( ! empty($report['duplicate_donation']) ? (absint($report['duplicate_donation']) + 1) : 1);
578 578
 	} else {
579
-		add_action( 'give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1, 1 );
580
-		add_filter( 'give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11, 2 );
581
-		add_filter( 'give_update_donor_information', 'give_donation_import_update_donor_information', 11, 3 );
582
-		add_action( 'give_insert_payment', 'give_import_donation_insert_payment', 11, 2 );
583
-		$payment = give_insert_payment( $payment_data );
584
-		remove_action( 'give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1 );
585
-		remove_filter( 'give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11 );
586
-		remove_filter( 'give_update_donor_information', 'give_donation_import_update_donor_information', 11 );
587
-		remove_action( 'give_insert_payment', 'give_import_donation_insert_payment', 11 );
579
+		add_action('give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1, 1);
580
+		add_filter('give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11, 2);
581
+		add_filter('give_update_donor_information', 'give_donation_import_update_donor_information', 11, 3);
582
+		add_action('give_insert_payment', 'give_import_donation_insert_payment', 11, 2);
583
+		$payment = give_insert_payment($payment_data);
584
+		remove_action('give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1);
585
+		remove_filter('give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11);
586
+		remove_filter('give_update_donor_information', 'give_donation_import_update_donor_information', 11);
587
+		remove_action('give_insert_payment', 'give_import_donation_insert_payment', 11);
588 588
 
589
-		if ( $payment ) {
589
+		if ($payment) {
590 590
 
591
-			$report['create_donation'] = ( ! empty( $report['create_donation'] ) ? ( absint( $report['create_donation'] ) + 1 ) : 1 );
591
+			$report['create_donation'] = ( ! empty($report['create_donation']) ? (absint($report['create_donation']) + 1) : 1);
592 592
 
593
-			update_post_meta( $payment, '_give_payment_import', true );
593
+			update_post_meta($payment, '_give_payment_import', true);
594 594
 
595
-			if ( ! empty( $import_setting['csv'] ) ) {
596
-				update_post_meta( $payment, '_give_payment_import_id', $import_setting['csv'] );
595
+			if ( ! empty($import_setting['csv'])) {
596
+				update_post_meta($payment, '_give_payment_import_id', $import_setting['csv']);
597 597
 			}
598 598
 
599 599
 			// Insert Notes.
600
-			if ( ! empty( $data['notes'] ) ) {
601
-				give_insert_payment_note( $payment, $data['notes'] );
600
+			if ( ! empty($data['notes'])) {
601
+				give_insert_payment_note($payment, $data['notes']);
602 602
 			}
603 603
 
604
-			$meta_exists = array_keys( $raw_key, 'post_meta' );
605
-			if ( ! empty( $main_key ) && ! empty( $meta_exists ) ) {
606
-				foreach ( $meta_exists as $meta_exist ) {
607
-					if ( ! empty( $main_key[ $meta_exist ] ) && ! empty( $row_data[ $meta_exist ] ) ) {
608
-						update_post_meta( $payment, $main_key[ $meta_exist ], $row_data[ $meta_exist ] );
604
+			$meta_exists = array_keys($raw_key, 'post_meta');
605
+			if ( ! empty($main_key) && ! empty($meta_exists)) {
606
+				foreach ($meta_exists as $meta_exist) {
607
+					if ( ! empty($main_key[$meta_exist]) && ! empty($row_data[$meta_exist])) {
608
+						update_post_meta($payment, $main_key[$meta_exist], $row_data[$meta_exist]);
609 609
 					}
610 610
 				}
611 611
 			}
612 612
 		} else {
613
-			$report['failed_donation'] = ( ! empty( $report['failed_donation'] ) ? ( absint( $report['failed_donation'] ) + 1 ) : 1 );
613
+			$report['failed_donation'] = ( ! empty($report['failed_donation']) ? (absint($report['failed_donation']) + 1) : 1);
614 614
 		}
615 615
 	}
616 616
 
617 617
 	// update the report
618
-	give_import_donation_report_update( $report );
618
+	give_import_donation_report_update($report);
619 619
 
620 620
 	return true;
621 621
 }
@@ -631,12 +631,12 @@  discard block
 block discarded – undo
631 631
  *
632 632
  * @return Give_Donor
633 633
  */
634
-function give_donation_import_update_donor_information( $donor, $payment_id, $payment_data ) {
634
+function give_donation_import_update_donor_information($donor, $payment_id, $payment_data) {
635 635
 	$old_donor = $donor;
636
-	if ( ! empty( $payment_data['donor_id'] ) ) {
637
-		$donor_id = absint( $payment_data['donor_id'] );
638
-		$donor    = new Give_Donor( $donor_id );
639
-		if ( ! empty( $donor->id ) ) {
636
+	if ( ! empty($payment_data['donor_id'])) {
637
+		$donor_id = absint($payment_data['donor_id']);
638
+		$donor    = new Give_Donor($donor_id);
639
+		if ( ! empty($donor->id)) {
640 640
 			return $donor;
641 641
 		}
642 642
 	}
@@ -649,12 +649,12 @@  discard block
 block discarded – undo
649 649
  *
650 650
  * @since 1.8.13
651 651
  */
652
-function give_import_donation_insert_payment( $payment_id, $payment_data ) {
652
+function give_import_donation_insert_payment($payment_id, $payment_data) {
653 653
 	// Update Give Customers purchase_count
654
-	if ( ! empty( $payment_data['status'] ) && ( 'complete' === (string) $payment_data['status'] || 'publish' === (string) $payment_data['status'] ) ) {
655
-		$donor_id = (int) get_post_meta( $payment_id, '_give_payment_customer_id', true );
656
-		if ( ! empty( $donor_id ) ) {
657
-			$donor = new Give_Donor( $donor_id );
654
+	if ( ! empty($payment_data['status']) && ('complete' === (string) $payment_data['status'] || 'publish' === (string) $payment_data['status'])) {
655
+		$donor_id = (int) get_post_meta($payment_id, '_give_payment_customer_id', true);
656
+		if ( ! empty($donor_id)) {
657
+			$donor = new Give_Donor($donor_id);
658 658
 			$donor->increase_purchase_count();
659 659
 		}
660 660
 	}
@@ -665,8 +665,8 @@  discard block
 block discarded – undo
665 665
  *
666 666
  * @since 1.8.13
667 667
  */
668
-function give_donation_import_give_insert_payment_args( $args, $payment_data ) {
669
-	if ( ! empty( $payment_data['user_info']['id'] ) ) {
668
+function give_donation_import_give_insert_payment_args($args, $payment_data) {
669
+	if ( ! empty($payment_data['user_info']['id'])) {
670 670
 		$args['post_author'] = (int) $payment_data['user_info']['id'];
671 671
 	}
672 672
 
@@ -678,11 +678,11 @@  discard block
 block discarded – undo
678 678
  *
679 679
  * @since 1.8.13
680 680
  */
681
-function give_check_import_donation_duplicate( $payment_data, $data, $form, $donor_data ) {
681
+function give_check_import_donation_duplicate($payment_data, $data, $form, $donor_data) {
682 682
 	$return = false;
683
-	if ( ! empty( $data['post_date'] ) ) {
684
-		$post_date = mysql2date( 'Y-m-d-H-i-s', $data['post_date'] );
685
-		$post_date = explode( '-', $post_date );
683
+	if ( ! empty($data['post_date'])) {
684
+		$post_date = mysql2date('Y-m-d-H-i-s', $data['post_date']);
685
+		$post_date = explode('-', $post_date);
686 686
 		$args      = array(
687 687
 			'post_type'              => 'give_payment',
688 688
 			'cache_results'          => false,
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
 			'meta_query'             => array(
704 704
 				array(
705 705
 					'key'     => '_give_payment_total',
706
-					'value'   => preg_replace( '/[\$,]/', '', $payment_data['price'] ),
706
+					'value'   => preg_replace('/[\$,]/', '', $payment_data['price']),
707 707
 					'compare' => 'LIKE',
708 708
 				),
709 709
 				array(
@@ -720,9 +720,9 @@  discard block
 block discarded – undo
720 720
 			),
721 721
 		);
722 722
 
723
-		$payments  = new Give_Payments_Query( $args );
723
+		$payments  = new Give_Payments_Query($args);
724 724
 		$donations = $payments->get_payments();
725
-		if ( ! empty( $donations ) ) {
725
+		if ( ! empty($donations)) {
726 726
 			return true;
727 727
 		}
728 728
 	}
@@ -739,9 +739,9 @@  discard block
 block discarded – undo
739 739
  *
740 740
  * @return void
741 741
  */
742
-function give_donation_import_insert_default_payment_note( $payment_id ) {
742
+function give_donation_import_insert_default_payment_note($payment_id) {
743 743
 	$current_user = wp_get_current_user();
744
-	give_insert_payment_note( $payment_id, esc_html( wp_sprintf( __( 'This donation was imported by %s', 'give' ), $current_user->user_email ) ) );
744
+	give_insert_payment_note($payment_id, esc_html(wp_sprintf(__('This donation was imported by %s', 'give'), $current_user->user_email)));
745 745
 }
746 746
 
747 747
 /**
@@ -753,14 +753,14 @@  discard block
 block discarded – undo
753 753
  *
754 754
  * @return string URL
755 755
  */
756
-function give_import_page_url( $parameter = array() ) {
756
+function give_import_page_url($parameter = array()) {
757 757
 	$defalut_query_arg = array(
758 758
 		'post_type'     => 'give_forms',
759 759
 		'page'          => 'give-tools',
760 760
 		'tab'           => 'import',
761 761
 		'importer-type' => 'import_donations',
762 762
 	);
763
-	$import_query_arg  = wp_parse_args( $parameter, $defalut_query_arg );
763
+	$import_query_arg = wp_parse_args($parameter, $defalut_query_arg);
764 764
 
765
-	return add_query_arg( $import_query_arg, admin_url( 'edit.php' ) );
765
+	return add_query_arg($import_query_arg, admin_url('edit.php'));
766 766
 }
767 767
\ No newline at end of file
Please login to merge, or discard this patch.
includes/gateways/manual.php 1 patch
Spacing   +15 added lines, -15 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
 
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
  * @since 1.0
21 21
  * @return void
22 22
  */
23
-add_action( 'give_manual_cc_form', '__return_false' );
23
+add_action('give_manual_cc_form', '__return_false');
24 24
 
25 25
 /**
26 26
  * Processes the donation data and uses the Manual Payment gateway to record
@@ -32,44 +32,44 @@  discard block
 block discarded – undo
32 32
  *
33 33
  * @return void
34 34
  */
35
-function give_manual_payment( $purchase_data ) {
35
+function give_manual_payment($purchase_data) {
36 36
 
37
-	if ( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'give-gateway' ) ) {
38
-		wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
37
+	if ( ! wp_verify_nonce($purchase_data['gateway_nonce'], 'give-gateway')) {
38
+		wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
39 39
 	}
40 40
 
41 41
 	//Create payment_data array
42 42
 	$payment_data = array(
43 43
 		'price'           => $purchase_data['price'],
44 44
 		'give_form_title' => $purchase_data['post_data']['give-form-title'],
45
-		'give_form_id'    => intval( $purchase_data['post_data']['give-form-id'] ),
45
+		'give_form_id'    => intval($purchase_data['post_data']['give-form-id']),
46 46
 		'give_price_id'   => isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : '',
47 47
 		'date'            => $purchase_data['date'],
48 48
 		'user_email'      => $purchase_data['user_email'],
49 49
 		'purchase_key'    => $purchase_data['purchase_key'],
50
-		'currency'        => give_get_currency( $purchase_data['post_data']['give-form-id'], $purchase_data ),
50
+		'currency'        => give_get_currency($purchase_data['post_data']['give-form-id'], $purchase_data),
51 51
 		'user_info'       => $purchase_data['user_info'],
52 52
 		'status'          => 'pending'
53 53
 	);
54 54
 	// Record the pending payment
55
-	$payment = give_insert_payment( $payment_data );
55
+	$payment = give_insert_payment($payment_data);
56 56
 
57
-	if ( $payment ) {
58
-		give_update_payment_status( $payment, 'publish' );
57
+	if ($payment) {
58
+		give_update_payment_status($payment, 'publish');
59 59
 		give_send_to_success_page();
60 60
 	} else {
61 61
 		give_record_gateway_error(
62
-			esc_html__( 'Payment Error', 'give' ),
62
+			esc_html__('Payment Error', 'give'),
63 63
 			sprintf(
64 64
 				/* translators: %s: payment data */
65
-				esc_html__( 'The payment creation failed while processing a manual (free or test) donation. Payment data: %s', 'give' ),
66
-				json_encode( $payment_data )
65
+				esc_html__('The payment creation failed while processing a manual (free or test) donation. Payment data: %s', 'give'),
66
+				json_encode($payment_data)
67 67
 			),
68 68
 			$payment
69 69
 		);
70 70
 		// If errors are present, send the user back to the donation page so they can be corrected
71
-		give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] );
71
+		give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']);
72 72
 	}
73 73
 }
74 74
 
75
-add_action( 'give_gateway_manual', 'give_manual_payment' );
75
+add_action('give_gateway_manual', 'give_manual_payment');
Please login to merge, or discard this patch.
includes/class-give-html-elements.php 1 patch
Spacing   +151 added lines, -151 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 *
36 36
 	 * @return string       Donations dropdown.
37 37
 	 */
38
-	public function donations_dropdown( $args = array() ) {
38
+	public function donations_dropdown($args = array()) {
39 39
 
40 40
 		$defaults = array(
41 41
 			'name'        => 'donations',
@@ -45,32 +45,32 @@  discard block
 block discarded – undo
45 45
 			'selected'    => 0,
46 46
 			'chosen'      => false,
47 47
 			'number'      => 30,
48
-			'placeholder' => __( 'Select a donation', 'give' ),
48
+			'placeholder' => __('Select a donation', 'give'),
49 49
 		);
50 50
 
51
-		$args = wp_parse_args( $args, $defaults );
51
+		$args = wp_parse_args($args, $defaults);
52 52
 
53
-		$payments = new Give_Payments_Query( array(
53
+		$payments = new Give_Payments_Query(array(
54 54
 			'number' => $args['number'],
55
-		) );
55
+		));
56 56
 
57 57
 		$payments = $payments->get_payments();
58 58
 
59 59
 		$options = array();
60 60
 
61 61
 		// Provide nice human readable options.
62
-		if ( $payments ) {
62
+		if ($payments) {
63 63
 			$options[0] = $args['placeholder'];
64
-			foreach ( $payments as $payment ) {
64
+			foreach ($payments as $payment) {
65 65
 
66
-				$options[ absint( $payment->ID ) ] = esc_html( '#' . $payment->ID . ' - ' . $payment->email . ' - ' . $payment->form_title );
66
+				$options[absint($payment->ID)] = esc_html('#'.$payment->ID.' - '.$payment->email.' - '.$payment->form_title);
67 67
 
68 68
 			}
69 69
 		} else {
70
-			$options[0] = __( 'No donations found.', 'give' );
70
+			$options[0] = __('No donations found.', 'give');
71 71
 		}
72 72
 
73
-		$output = $this->select( array(
73
+		$output = $this->select(array(
74 74
 			'name'             => $args['name'],
75 75
 			'selected'         => $args['selected'],
76 76
 			'id'               => $args['id'],
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 			'select_atts'      => $args['select_atts'],
83 83
 			'show_option_all'  => false,
84 84
 			'show_option_none' => false,
85
-		) );
85
+		));
86 86
 
87 87
 		return $output;
88 88
 	}
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 	 *
100 100
 	 * @return string      Give forms dropdown.
101 101
 	 */
102
-	public function forms_dropdown( $args = array() ) {
102
+	public function forms_dropdown($args = array()) {
103 103
 
104 104
 		$defaults = array(
105 105
 			'name'        => 'forms',
@@ -109,39 +109,39 @@  discard block
 block discarded – undo
109 109
 			'selected'    => 0,
110 110
 			'chosen'      => false,
111 111
 			'number'      => 30,
112
-			'placeholder' => esc_attr__( 'All Forms', 'give' ),
112
+			'placeholder' => esc_attr__('All Forms', 'give'),
113 113
 			'data'        => array(
114 114
 				'search-type' => 'form',
115 115
 			),
116 116
 		);
117 117
 
118
-		$args = wp_parse_args( $args, $defaults );
118
+		$args = wp_parse_args($args, $defaults);
119 119
 
120
-		$forms = get_posts( array(
120
+		$forms = get_posts(array(
121 121
 			'post_type'      => 'give_forms',
122 122
 			'orderby'        => 'title',
123 123
 			'order'          => 'ASC',
124 124
 			'posts_per_page' => $args['number'],
125
-		) );
125
+		));
126 126
 
127 127
 		$options = array();
128 128
 
129 129
 		// Ensure the selected.
130
-		if ( false !== $args['selected'] && $args['selected'] !== 0 ) {
131
-			$options[ $args['selected'] ] = get_the_title( $args['selected'] );
130
+		if (false !== $args['selected'] && $args['selected'] !== 0) {
131
+			$options[$args['selected']] = get_the_title($args['selected']);
132 132
 		}
133 133
 
134
-		if ( $forms ) {
134
+		if ($forms) {
135 135
 			$options[0] = $args['placeholder'];
136
-			foreach ( $forms as $form ) {
137
-				$form_title                     = empty( $form->post_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $form->ID ) : $form->post_title;
138
-				$options[ absint( $form->ID ) ] = esc_html( $form_title );
136
+			foreach ($forms as $form) {
137
+				$form_title                     = empty($form->post_title) ? sprintf(__('Untitled (#%s)', 'give'), $form->ID) : $form->post_title;
138
+				$options[absint($form->ID)] = esc_html($form_title);
139 139
 			}
140 140
 		} else {
141
-			$options[0] = esc_html__( 'No forms found.', 'give' );
141
+			$options[0] = esc_html__('No forms found.', 'give');
142 142
 		}
143 143
 
144
-		$output = $this->select( array(
144
+		$output = $this->select(array(
145 145
 			'name'             => $args['name'],
146 146
 			'selected'         => $args['selected'],
147 147
 			'id'               => $args['id'],
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 			'show_option_all'  => false,
154 154
 			'show_option_none' => false,
155 155
 			'data'             => $args['data'],
156
-		) );
156
+		));
157 157
 
158 158
 		return $output;
159 159
 	}
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 	 *
171 171
 	 * @return string      Donors dropdown.
172 172
 	 */
173
-	public function donor_dropdown( $args = array() ) {
173
+	public function donor_dropdown($args = array()) {
174 174
 
175 175
 		$defaults = array(
176 176
 			'name'        => 'donors',
@@ -179,57 +179,57 @@  discard block
 block discarded – undo
179 179
 			'multiple'    => false,
180 180
 			'selected'    => 0,
181 181
 			'chosen'      => true,
182
-			'placeholder' => esc_attr__( 'Select a Donor', 'give' ),
182
+			'placeholder' => esc_attr__('Select a Donor', 'give'),
183 183
 			'number'      => 30,
184 184
 			'data'        => array(
185 185
 				'search-type' => 'donor',
186 186
 			),
187 187
 		);
188 188
 
189
-		$args = wp_parse_args( $args, $defaults );
189
+		$args = wp_parse_args($args, $defaults);
190 190
 
191
-		$donors = Give()->donors->get_donors( array(
191
+		$donors = Give()->donors->get_donors(array(
192 192
 			'number' => $args['number']
193
-		) );
193
+		));
194 194
 
195 195
 		$options = array();
196 196
 
197
-		if ( $donors ) {
198
-			$options[0] = esc_html__( 'No donor attached', 'give' );
199
-			foreach ( $donors as $donor ) {
200
-				$options[ absint( $donor->id ) ] = esc_html( $donor->name . ' (' . $donor->email . ')' );
197
+		if ($donors) {
198
+			$options[0] = esc_html__('No donor attached', 'give');
199
+			foreach ($donors as $donor) {
200
+				$options[absint($donor->id)] = esc_html($donor->name.' ('.$donor->email.')');
201 201
 			}
202 202
 		} else {
203
-			$options[0] = esc_html__( 'No donors found.', 'give' );
203
+			$options[0] = esc_html__('No donors found.', 'give');
204 204
 		}
205 205
 
206
-		if ( ! empty( $args['selected'] ) ) {
206
+		if ( ! empty($args['selected'])) {
207 207
 
208 208
 			// If a selected customer has been specified, we need to ensure it's in the initial list of customers displayed.
209
-			if ( ! array_key_exists( $args['selected'], $options ) ) {
209
+			if ( ! array_key_exists($args['selected'], $options)) {
210 210
 
211
-				$donor = new Give_Donor( $args['selected'] );
211
+				$donor = new Give_Donor($args['selected']);
212 212
 
213
-				if ( $donor ) {
213
+				if ($donor) {
214 214
 
215
-					$options[ absint( $args['selected'] ) ] = esc_html( $donor->name . ' (' . $donor->email . ')' );
215
+					$options[absint($args['selected'])] = esc_html($donor->name.' ('.$donor->email.')');
216 216
 
217 217
 				}
218 218
 			}
219 219
 		}
220 220
 
221
-		$output = $this->select( array(
221
+		$output = $this->select(array(
222 222
 			'name'             => $args['name'],
223 223
 			'selected'         => $args['selected'],
224 224
 			'id'               => $args['id'],
225
-			'class'            => $args['class'] . ' give-customer-select',
225
+			'class'            => $args['class'].' give-customer-select',
226 226
 			'options'          => $options,
227 227
 			'multiple'         => $args['multiple'],
228 228
 			'chosen'           => $args['chosen'],
229 229
 			'show_option_all'  => false,
230 230
 			'show_option_none' => false,
231 231
 			'data'             => $args['data'],
232
-		) );
232
+		));
233 233
 
234 234
 		return $output;
235 235
 	}
@@ -248,21 +248,21 @@  discard block
 block discarded – undo
248 248
 	 *
249 249
 	 * @return string           Categories dropdown.
250 250
 	 */
251
-	public function category_dropdown( $name = 'give_forms_categories', $selected = 0, $args = array() ) {
252
-		$categories = get_terms( 'give_forms_category', apply_filters( 'give_forms_category_dropdown', array() ) );
251
+	public function category_dropdown($name = 'give_forms_categories', $selected = 0, $args = array()) {
252
+		$categories = get_terms('give_forms_category', apply_filters('give_forms_category_dropdown', array()));
253 253
 		$options    = array();
254 254
 
255
-		foreach ( $categories as $category ) {
256
-			$options[ absint( $category->term_id ) ] = esc_html( $category->name );
255
+		foreach ($categories as $category) {
256
+			$options[absint($category->term_id)] = esc_html($category->name);
257 257
 		}
258 258
 
259
-		$output = $this->select( wp_parse_args( $args, array(
259
+		$output = $this->select(wp_parse_args($args, array(
260 260
 			'name'             => $name,
261 261
 			'selected'         => $selected,
262 262
 			'options'          => $options,
263
-			'show_option_all'  => esc_html__( 'All Categories', 'give' ),
263
+			'show_option_all'  => esc_html__('All Categories', 'give'),
264 264
 			'show_option_none' => false,
265
-		) ) );
265
+		)));
266 266
 
267 267
 		return $output;
268 268
 	}
@@ -281,21 +281,21 @@  discard block
 block discarded – undo
281 281
 	 *
282 282
 	 * @return string           Tags dropdown.
283 283
 	 */
284
-	public function tags_dropdown( $name = 'give_forms_tags', $selected = 0, $args = array() ) {
285
-		$tags    = get_terms( 'give_forms_tag', apply_filters( 'give_forms_tag_dropdown', array() ) );
284
+	public function tags_dropdown($name = 'give_forms_tags', $selected = 0, $args = array()) {
285
+		$tags    = get_terms('give_forms_tag', apply_filters('give_forms_tag_dropdown', array()));
286 286
 		$options = array();
287 287
 
288
-		foreach ( $tags as $tag ) {
289
-			$options[ absint( $tag->term_id ) ] = esc_html( $tag->name );
288
+		foreach ($tags as $tag) {
289
+			$options[absint($tag->term_id)] = esc_html($tag->name);
290 290
 		}
291 291
 
292
-		$output = $this->select( wp_parse_args( $args, array(
292
+		$output = $this->select(wp_parse_args($args, array(
293 293
 			'name'             => $name,
294 294
 			'selected'         => $selected,
295 295
 			'options'          => $options,
296
-			'show_option_all'  => esc_html__( 'All Tags', 'give' ),
296
+			'show_option_all'  => esc_html__('All Tags', 'give'),
297 297
 			'show_option_none' => false,
298
-		) ) );
298
+		)));
299 299
 
300 300
 		return $output;
301 301
 	}
@@ -315,25 +315,25 @@  discard block
 block discarded – undo
315 315
 	 *
316 316
 	 * @return string               Years dropdown.
317 317
 	 */
318
-	public function year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) {
319
-		$current    = date( 'Y' );
320
-		$start_year = $current - absint( $years_before );
321
-		$end_year   = $current + absint( $years_after );
322
-		$selected   = empty( $selected ) ? date( 'Y' ) : $selected;
318
+	public function year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) {
319
+		$current    = date('Y');
320
+		$start_year = $current - absint($years_before);
321
+		$end_year   = $current + absint($years_after);
322
+		$selected   = empty($selected) ? date('Y') : $selected;
323 323
 		$options    = array();
324 324
 
325
-		while ( $start_year <= $end_year ) {
326
-			$options[ absint( $start_year ) ] = $start_year;
327
-			$start_year ++;
325
+		while ($start_year <= $end_year) {
326
+			$options[absint($start_year)] = $start_year;
327
+			$start_year++;
328 328
 		}
329 329
 
330
-		$output = $this->select( array(
330
+		$output = $this->select(array(
331 331
 			'name'             => $name,
332 332
 			'selected'         => $selected,
333 333
 			'options'          => $options,
334 334
 			'show_option_all'  => false,
335 335
 			'show_option_none' => false,
336
-		) );
336
+		));
337 337
 
338 338
 		return $output;
339 339
 	}
@@ -351,23 +351,23 @@  discard block
 block discarded – undo
351 351
 	 *
352 352
 	 * @return string           Months dropdown.
353 353
 	 */
354
-	public function month_dropdown( $name = 'month', $selected = 0 ) {
354
+	public function month_dropdown($name = 'month', $selected = 0) {
355 355
 		$month    = 1;
356 356
 		$options  = array();
357
-		$selected = empty( $selected ) ? date( 'n' ) : $selected;
357
+		$selected = empty($selected) ? date('n') : $selected;
358 358
 
359
-		while ( $month <= 12 ) {
360
-			$options[ absint( $month ) ] = give_month_num_to_name( $month );
361
-			$month ++;
359
+		while ($month <= 12) {
360
+			$options[absint($month)] = give_month_num_to_name($month);
361
+			$month++;
362 362
 		}
363 363
 
364
-		$output = $this->select( array(
364
+		$output = $this->select(array(
365 365
 			'name'             => $name,
366 366
 			'selected'         => $selected,
367 367
 			'options'          => $options,
368 368
 			'show_option_all'  => false,
369 369
 			'show_option_none' => false,
370
-		) );
370
+		));
371 371
 
372 372
 		return $output;
373 373
 	}
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 	 *
385 385
 	 * @return string      The dropdown.
386 386
 	 */
387
-	public function select( $args = array() ) {
387
+	public function select($args = array()) {
388 388
 		$defaults = array(
389 389
 			'options'          => array(),
390 390
 			'name'             => null,
@@ -395,67 +395,67 @@  discard block
 block discarded – undo
395 395
 			'placeholder'      => null,
396 396
 			'multiple'         => false,
397 397
 			'select_atts'      => false,
398
-			'show_option_all'  => __( 'All', 'give' ),
399
-			'show_option_none' => __( 'None', 'give' ),
398
+			'show_option_all'  => __('All', 'give'),
399
+			'show_option_none' => __('None', 'give'),
400 400
 			'data'             => array(),
401 401
 			'readonly'         => false,
402 402
 			'disabled'         => false,
403 403
 		);
404 404
 
405
-		$args = wp_parse_args( $args, $defaults );
405
+		$args = wp_parse_args($args, $defaults);
406 406
 
407 407
 		$data_elements = '';
408
-		foreach ( $args['data'] as $key => $value ) {
409
-			$data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
408
+		foreach ($args['data'] as $key => $value) {
409
+			$data_elements .= ' data-'.esc_attr($key).'="'.esc_attr($value).'"';
410 410
 		}
411 411
 
412
-		if ( $args['multiple'] ) {
412
+		if ($args['multiple']) {
413 413
 			$multiple = ' MULTIPLE';
414 414
 		} else {
415 415
 			$multiple = '';
416 416
 		}
417 417
 
418
-		if ( $args['chosen'] ) {
418
+		if ($args['chosen']) {
419 419
 			$args['class'] .= ' give-select-chosen';
420 420
 		}
421 421
 
422
-		if ( $args['placeholder'] ) {
422
+		if ($args['placeholder']) {
423 423
 			$placeholder = $args['placeholder'];
424 424
 		} else {
425 425
 			$placeholder = '';
426 426
 		}
427 427
 
428
-		$output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( sanitize_key( str_replace( '-', '_', $args['id'] ) ) ) . '" class="give-select ' . esc_attr( $args['class'] ) . '"' . $multiple . ' ' . $args['select_atts'] . ' data-placeholder="' . $placeholder . '"' . $data_elements . '>';
428
+		$output = '<select name="'.esc_attr($args['name']).'" id="'.esc_attr(sanitize_key(str_replace('-', '_', $args['id']))).'" class="give-select '.esc_attr($args['class']).'"'.$multiple.' '.$args['select_atts'].' data-placeholder="'.$placeholder.'"'.$data_elements.'>';
429 429
 
430
-		if ( $args['show_option_all'] ) {
431
-			if ( $args['multiple'] ) {
432
-				$selected = selected( true, in_array( 0, $args['selected'] ), false );
430
+		if ($args['show_option_all']) {
431
+			if ($args['multiple']) {
432
+				$selected = selected(true, in_array(0, $args['selected']), false);
433 433
 			} else {
434
-				$selected = selected( $args['selected'], 0, false );
434
+				$selected = selected($args['selected'], 0, false);
435 435
 			}
436
-			$output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>';
436
+			$output .= '<option value="all"'.$selected.'>'.esc_html($args['show_option_all']).'</option>';
437 437
 		}
438 438
 
439
-		if ( ! empty( $args['options'] ) ) {
439
+		if ( ! empty($args['options'])) {
440 440
 
441
-			if ( $args['show_option_none'] ) {
442
-				if ( $args['multiple'] ) {
443
-					$selected = selected( true, in_array( - 1, $args['selected'] ), false );
441
+			if ($args['show_option_none']) {
442
+				if ($args['multiple']) {
443
+					$selected = selected(true, in_array( -1, $args['selected'] ), false);
444 444
 				} else {
445
-					$selected = selected( $args['selected'], - 1, false );
445
+					$selected = selected($args['selected'], - 1, false);
446 446
 				}
447
-				$output .= '<option value="-1"' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>';
447
+				$output .= '<option value="-1"'.$selected.'>'.esc_html($args['show_option_none']).'</option>';
448 448
 			}
449 449
 
450
-			foreach ( $args['options'] as $key => $option ) {
450
+			foreach ($args['options'] as $key => $option) {
451 451
 
452
-				if ( $args['multiple'] && is_array( $args['selected'] ) ) {
453
-					$selected = selected( true, in_array( $key, $args['selected'] ), false );
452
+				if ($args['multiple'] && is_array($args['selected'])) {
453
+					$selected = selected(true, in_array($key, $args['selected']), false);
454 454
 				} else {
455
-					$selected = selected( $args['selected'], $key, false );
455
+					$selected = selected($args['selected'], $key, false);
456 456
 				}
457 457
 
458
-				$output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>';
458
+				$output .= '<option value="'.esc_attr($key).'"'.$selected.'>'.esc_html($option).'</option>';
459 459
 			}
460 460
 		}
461 461
 
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
 	 *
477 477
 	 * @return string      The checkbox.
478 478
 	 */
479
-	public function checkbox( $args = array() ) {
479
+	public function checkbox($args = array()) {
480 480
 		$defaults = array(
481 481
 			'name'    => null,
482 482
 			'current' => null,
@@ -487,16 +487,16 @@  discard block
 block discarded – undo
487 487
 			),
488 488
 		);
489 489
 
490
-		$args = wp_parse_args( $args, $defaults );
490
+		$args = wp_parse_args($args, $defaults);
491 491
 
492 492
 		$options = '';
493
-		if ( ! empty( $args['options']['disabled'] ) ) {
493
+		if ( ! empty($args['options']['disabled'])) {
494 494
 			$options .= ' disabled="disabled"';
495
-		} elseif ( ! empty( $args['options']['readonly'] ) ) {
495
+		} elseif ( ! empty($args['options']['readonly'])) {
496 496
 			$options .= ' readonly';
497 497
 		}
498 498
 
499
-		$output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />';
499
+		$output = '<input type="checkbox"'.$options.' name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" class="'.$args['class'].' '.esc_attr($args['name']).'" '.checked(1, $args['current'], false).' />';
500 500
 
501 501
 		return $output;
502 502
 	}
@@ -513,22 +513,22 @@  discard block
 block discarded – undo
513 513
 	 *
514 514
 	 * @return string      The text field.
515 515
 	 */
516
-	public function text( $args = array() ) {
516
+	public function text($args = array()) {
517 517
 		// Backwards compatibility.
518
-		if ( func_num_args() > 1 ) {
518
+		if (func_num_args() > 1) {
519 519
 			$args = func_get_args();
520 520
 
521 521
 			$name  = $args[0];
522
-			$value = isset( $args[1] ) ? $args[1] : '';
523
-			$label = isset( $args[2] ) ? $args[2] : '';
524
-			$desc  = isset( $args[3] ) ? $args[3] : '';
522
+			$value = isset($args[1]) ? $args[1] : '';
523
+			$label = isset($args[2]) ? $args[2] : '';
524
+			$desc  = isset($args[3]) ? $args[3] : '';
525 525
 		}
526 526
 
527 527
 		$defaults = array(
528
-			'name'         => isset( $name ) ? $name : 'text',
529
-			'value'        => isset( $value ) ? $value : null,
530
-			'label'        => isset( $label ) ? $label : null,
531
-			'desc'         => isset( $desc ) ? $desc : null,
528
+			'name'         => isset($name) ? $name : 'text',
529
+			'value'        => isset($value) ? $value : null,
530
+			'label'        => isset($label) ? $label : null,
531
+			'desc'         => isset($desc) ? $desc : null,
532 532
 			'placeholder'  => '',
533 533
 			'class'        => 'regular-text',
534 534
 			'disabled'     => false,
@@ -536,29 +536,29 @@  discard block
 block discarded – undo
536 536
 			'data'         => false,
537 537
 		);
538 538
 
539
-		$args = wp_parse_args( $args, $defaults );
539
+		$args = wp_parse_args($args, $defaults);
540 540
 
541 541
 		$disabled = '';
542
-		if ( $args['disabled'] ) {
542
+		if ($args['disabled']) {
543 543
 			$disabled = ' disabled="disabled"';
544 544
 		}
545 545
 
546 546
 		$data = '';
547
-		if ( ! empty( $args['data'] ) ) {
548
-			foreach ( $args['data'] as $key => $value ) {
549
-				$data .= 'data-' . $key . '="' . $value . '" ';
547
+		if ( ! empty($args['data'])) {
548
+			foreach ($args['data'] as $key => $value) {
549
+				$data .= 'data-'.$key.'="'.$value.'" ';
550 550
 			}
551 551
 		}
552 552
 
553
-		$output = '<span id="give-' . sanitize_key( $args['name'] ) . '-wrap">';
553
+		$output = '<span id="give-'.sanitize_key($args['name']).'-wrap">';
554 554
 
555
-		$output .= '<label class="give-label" for="give-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>';
555
+		$output .= '<label class="give-label" for="give-'.sanitize_key($args['name']).'">'.esc_html($args['label']).'</label>';
556 556
 
557
-		if ( ! empty( $args['desc'] ) ) {
558
-			$output .= '<span class="give-description">' . esc_html( $args['desc'] ) . '</span>';
557
+		if ( ! empty($args['desc'])) {
558
+			$output .= '<span class="give-description">'.esc_html($args['desc']).'</span>';
559 559
 		}
560 560
 
561
-		$output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $args['class'] . '" ' . $data . '' . $disabled . '/>';
561
+		$output .= '<input type="text" name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" autocomplete="'.esc_attr($args['autocomplete']).'" value="'.esc_attr($args['value']).'" placeholder="'.esc_attr($args['placeholder']).'" class="'.$args['class'].'" '.$data.''.$disabled.'/>';
562 562
 
563 563
 		$output .= '</span>';
564 564
 
@@ -577,15 +577,15 @@  discard block
 block discarded – undo
577 577
 	 *
578 578
 	 * @return string      The date picker.
579 579
 	 */
580
-	public function date_field( $args = array() ) {
580
+	public function date_field($args = array()) {
581 581
 
582
-		if ( empty( $args['class'] ) ) {
582
+		if (empty($args['class'])) {
583 583
 			$args['class'] = 'give_datepicker';
584
-		} elseif ( ! strpos( $args['class'], 'give_datepicker' ) ) {
584
+		} elseif ( ! strpos($args['class'], 'give_datepicker')) {
585 585
 			$args['class'] .= ' give_datepicker';
586 586
 		}
587 587
 
588
-		return $this->text( $args );
588
+		return $this->text($args);
589 589
 	}
590 590
 
591 591
 	/**
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
 	 *
601 601
 	 * @return string      The textarea.
602 602
 	 */
603
-	public function textarea( $args = array() ) {
603
+	public function textarea($args = array()) {
604 604
 		$defaults = array(
605 605
 			'name'     => 'textarea',
606 606
 			'value'    => null,
@@ -610,21 +610,21 @@  discard block
 block discarded – undo
610 610
 			'disabled' => false,
611 611
 		);
612 612
 
613
-		$args = wp_parse_args( $args, $defaults );
613
+		$args = wp_parse_args($args, $defaults);
614 614
 
615 615
 		$disabled = '';
616
-		if ( $args['disabled'] ) {
616
+		if ($args['disabled']) {
617 617
 			$disabled = ' disabled="disabled"';
618 618
 		}
619 619
 
620
-		$output = '<span id="give-' . sanitize_key( $args['name'] ) . '-wrap">';
620
+		$output = '<span id="give-'.sanitize_key($args['name']).'-wrap">';
621 621
 
622
-		$output .= '<label class="give-label" for="give-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>';
622
+		$output .= '<label class="give-label" for="give-'.sanitize_key($args['name']).'">'.esc_html($args['label']).'</label>';
623 623
 
624
-		$output .= '<textarea name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>';
624
+		$output .= '<textarea name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" class="'.$args['class'].'"'.$disabled.'>'.esc_attr($args['value']).'</textarea>';
625 625
 
626
-		if ( ! empty( $args['desc'] ) ) {
627
-			$output .= '<span class="give-description">' . esc_html( $args['desc'] ) . '</span>';
626
+		if ( ! empty($args['desc'])) {
627
+			$output .= '<span class="give-description">'.esc_html($args['desc']).'</span>';
628 628
 		}
629 629
 
630 630
 		$output .= '</span>';
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
 	 *
645 645
 	 * @return string      The text field with ajax search.
646 646
 	 */
647
-	public function ajax_user_search( $args = array() ) {
647
+	public function ajax_user_search($args = array()) {
648 648
 
649 649
 		$defaults = array(
650 650
 			'name'        => 'users',
@@ -655,13 +655,13 @@  discard block
 block discarded – undo
655 655
 			'chosen'      => true,
656 656
 			'number'      => 30,
657 657
 			'select_atts' => '',
658
-			'placeholder' => __( 'Select a user', 'give' ),
658
+			'placeholder' => __('Select a user', 'give'),
659 659
 			'data'        => array(
660 660
 				'search-type' => 'user',
661 661
 			),
662 662
 		);
663 663
 
664
-		$args = wp_parse_args( $args, $defaults );
664
+		$args = wp_parse_args($args, $defaults);
665 665
 
666 666
 		// Set initial args.
667 667
 		$get_users_args = array(
@@ -670,31 +670,31 @@  discard block
 block discarded – undo
670 670
 
671 671
 		// Ensure selected user is not included in initial query.
672 672
 		// This is because sites with many users, it's not a guarantee the selected user will be returned.
673
-		if ( ! empty( $args['selected'] ) ) {
673
+		if ( ! empty($args['selected'])) {
674 674
 			$get_users_args['exclude'] = $args['selected'];
675 675
 		}
676 676
 
677 677
 		// Initial users array.
678
-		$users = apply_filters( 'give_ajax_user_search_initial_results', get_users( $get_users_args ), $args );
678
+		$users = apply_filters('give_ajax_user_search_initial_results', get_users($get_users_args), $args);
679 679
 
680 680
 		// Now add the selected user to the $users array if the arg is present.
681
-		if ( ! empty( $args['selected'] ) ) {
682
-			$selected_user =  apply_filters( 'give_ajax_user_search_selected_results', get_users( "include={$args['selected']}" ), $args );;
683
-			$users         = array_merge( $users, $selected_user );
681
+		if ( ! empty($args['selected'])) {
682
+			$selected_user = apply_filters('give_ajax_user_search_selected_results', get_users("include={$args['selected']}"), $args); ;
683
+			$users         = array_merge($users, $selected_user);
684 684
 		}
685 685
 
686 686
 		$options = array();
687 687
 
688
-		if ( $users ) {
688
+		if ($users) {
689 689
 			$options[0] = $args['placeholder'];
690
-			foreach ( $users as $user ) {
691
-				$options[ absint( $user->ID ) ] = esc_html( $user->user_login . ' (' . $user->user_email . ')' );
690
+			foreach ($users as $user) {
691
+				$options[absint($user->ID)] = esc_html($user->user_login.' ('.$user->user_email.')');
692 692
 			}
693 693
 		} else {
694
-			$options[0] = __( 'No users found.', 'give' );
694
+			$options[0] = __('No users found.', 'give');
695 695
 		}
696 696
 
697
-		$output = $this->select( array(
697
+		$output = $this->select(array(
698 698
 			'name'             => $args['name'],
699 699
 			'selected'         => $args['selected'],
700 700
 			'id'               => $args['id'],
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
 			'show_option_all'  => false,
708 708
 			'show_option_none' => false,
709 709
 			'data'             => $args['data'],
710
-		) );
710
+		));
711 711
 
712 712
 		return $output;
713 713
 
Please login to merge, or discard this patch.
includes/admin/donors/class-donor-table.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -258,7 +258,7 @@
 block discarded – undo
258 258
 	 * @access public
259 259
 	 * @since  1.0
260 260
 	 *
261
-	 * @return mixed string If search is present, false otherwise.
261
+	 * @return string|false string If search is present, false otherwise.
262 262
 	 */
263 263
 	public function get_search() {
264 264
 		return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false;
Please login to merge, or discard this patch.
Spacing   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -12,13 +12,13 @@  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
 
19 19
 // Load WP_List_Table if not loaded.
20
-if ( ! class_exists( 'WP_List_Table' ) ) {
21
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
20
+if ( ! class_exists('WP_List_Table')) {
21
+	require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php';
22 22
 }
23 23
 
24 24
 /**
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
 	public function __construct() {
62 62
 
63 63
 		// Set parent defaults.
64
-		parent::__construct( array(
65
-			'singular' => __( 'Donor', 'give' ), // Singular name of the listed records.
66
-			'plural'   => __( 'Donors', 'give' ), // Plural name of the listed records.
64
+		parent::__construct(array(
65
+			'singular' => __('Donor', 'give'), // Singular name of the listed records.
66
+			'plural'   => __('Donors', 'give'), // Plural name of the listed records.
67 67
 			'ajax'     => false, // Does this table support ajax?.
68
-		) );
68
+		));
69 69
 
70 70
 	}
71 71
 
@@ -80,23 +80,23 @@  discard block
 block discarded – undo
80 80
 	 *
81 81
 	 * @return void
82 82
 	 */
83
-	public function search_box( $text, $input_id ) {
84
-		$input_id = $input_id . '-search-input';
83
+	public function search_box($text, $input_id) {
84
+		$input_id = $input_id.'-search-input';
85 85
 
86
-		if ( ! empty( $_REQUEST['orderby'] ) ) {
87
-			echo sprintf( '<input type="hidden" name="orderby" value="%1$s" />', esc_attr( $_REQUEST['orderby'] ) );
86
+		if ( ! empty($_REQUEST['orderby'])) {
87
+			echo sprintf('<input type="hidden" name="orderby" value="%1$s" />', esc_attr($_REQUEST['orderby']));
88 88
 		}
89 89
 
90
-		if ( ! empty( $_REQUEST['order'] ) ) {
91
-			echo sprintf( '<input type="hidden" name="order" value="%1$s" />', esc_attr( $_REQUEST['order'] ) );
90
+		if ( ! empty($_REQUEST['order'])) {
91
+			echo sprintf('<input type="hidden" name="order" value="%1$s" />', esc_attr($_REQUEST['order']));
92 92
 		}
93 93
 		?>
94 94
 		<p class="search-box" role="search">
95 95
 			<label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label>
96 96
 			<input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>"/>
97
-			<?php submit_button( $text, 'button', false, false, array(
97
+			<?php submit_button($text, 'button', false, false, array(
98 98
 				'ID' => 'search-submit',
99
-			) ); ?>
99
+			)); ?>
100 100
 		</p>
101 101
 		<?php
102 102
 	}
@@ -112,32 +112,32 @@  discard block
 block discarded – undo
112 112
 	 *
113 113
 	 * @return string Column Name.
114 114
 	 */
115
-	public function column_default( $donor, $column_name ) {
115
+	public function column_default($donor, $column_name) {
116 116
 
117
-		switch ( $column_name ) {
117
+		switch ($column_name) {
118 118
 
119 119
 			case 'num_donations' :
120 120
 				$value = sprintf(
121 121
 					'<a href="%s">%s</a>',
122
-					admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&donor=' . absint( $donor['id'] ) ),
123
-					esc_html( $donor['num_donations'] )
122
+					admin_url('edit.php?post_type=give_forms&page=give-payment-history&donor='.absint($donor['id'])),
123
+					esc_html($donor['num_donations'])
124 124
 				);
125 125
 				break;
126 126
 
127 127
 			case 'amount_spent' :
128
-				$value = give_currency_filter( give_format_amount( $donor[ $column_name ], array( 'sanitize' => false ) ) );
128
+				$value = give_currency_filter(give_format_amount($donor[$column_name], array('sanitize' => false)));
129 129
 				break;
130 130
 
131 131
 			case 'date_created' :
132
-				$value = date_i18n( give_date_format(), strtotime( $donor['date_created'] ) );
132
+				$value = date_i18n(give_date_format(), strtotime($donor['date_created']));
133 133
 				break;
134 134
 
135 135
 			default:
136
-				$value = isset( $donor[ $column_name ] ) ? $donor[ $column_name ] : null;
136
+				$value = isset($donor[$column_name]) ? $donor[$column_name] : null;
137 137
 				break;
138 138
 		}
139 139
 
140
-		return apply_filters( "give_donors_column_{$column_name}", $value, $donor['id'] );
140
+		return apply_filters("give_donors_column_{$column_name}", $value, $donor['id']);
141 141
 
142 142
 	}
143 143
 
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 	 *
152 152
 	 * @return string
153 153
 	 */
154
-	public function column_cb( $donor ){
154
+	public function column_cb($donor) {
155 155
 		return sprintf(
156 156
 			'<input class="donor-selector" type="checkbox" name="%1$s[]" value="%2$d" data-name="%3$s" />',
157 157
 			$this->_args['singular'],
@@ -170,13 +170,13 @@  discard block
 block discarded – undo
170 170
 	 *
171 171
 	 * @return string
172 172
 	 */
173
-	public function column_name( $donor ) {
174
-		$name     = '#' . $donor['id'] . ' ';
175
-		$name     .= ! empty( $donor['name'] ) ? $donor['name'] : '<em>' . __( 'Unnamed Donor', 'give' ) . '</em>';
176
-		$view_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor['id'] );
177
-		$actions  = $this->get_row_actions( $donor );
173
+	public function column_name($donor) {
174
+		$name     = '#'.$donor['id'].' ';
175
+		$name .= ! empty($donor['name']) ? $donor['name'] : '<em>'.__('Unnamed Donor', 'give').'</em>';
176
+		$view_url = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor['id']);
177
+		$actions  = $this->get_row_actions($donor);
178 178
 
179
-		return '<a href="' . esc_url( $view_url ) . '">' . $name . '</a>' . $this->row_actions( $actions );
179
+		return '<a href="'.esc_url($view_url).'">'.$name.'</a>'.$this->row_actions($actions);
180 180
 	}
181 181
 
182 182
 	/**
@@ -190,14 +190,14 @@  discard block
 block discarded – undo
190 190
 	public function get_columns() {
191 191
 		$columns = array(
192 192
 			'cb'            => '<input type="checkbox" />', // Render a checkbox instead of text.
193
-			'name'          => __( 'Name', 'give' ),
194
-			'email'         => __( 'Email', 'give' ),
195
-			'num_donations' => __( 'Donations', 'give' ),
196
-			'amount_spent'  => __( 'Total Donated', 'give' ),
197
-			'date_created'  => __( 'Date Created', 'give' ),
193
+			'name'          => __('Name', 'give'),
194
+			'email'         => __('Email', 'give'),
195
+			'num_donations' => __('Donations', 'give'),
196
+			'amount_spent'  => __('Total Donated', 'give'),
197
+			'date_created'  => __('Date Created', 'give'),
198 198
 		);
199 199
 
200
-		return apply_filters( 'give_list_donors_columns', $columns );
200
+		return apply_filters('give_list_donors_columns', $columns);
201 201
 
202 202
 	}
203 203
 
@@ -211,13 +211,13 @@  discard block
 block discarded – undo
211 211
 	public function get_sortable_columns() {
212 212
 
213 213
 		$columns = array(
214
-			'date_created'  => array( 'date_created', true ),
215
-			'name'          => array( 'name', true ),
216
-			'num_donations' => array( 'purchase_count', false ),
217
-			'amount_spent'  => array( 'purchase_value', false ),
214
+			'date_created'  => array('date_created', true),
215
+			'name'          => array('name', true),
216
+			'num_donations' => array('purchase_count', false),
217
+			'amount_spent'  => array('purchase_value', false),
218 218
 		);
219 219
 
220
-		return apply_filters( 'give_list_donors_sortable_columns', $columns );
220
+		return apply_filters('give_list_donors_sortable_columns', $columns);
221 221
 	}
222 222
 
223 223
 	/**
@@ -230,15 +230,15 @@  discard block
 block discarded – undo
230 230
 	 *
231 231
 	 * @return array An array of action links.
232 232
 	 */
233
-	public function get_row_actions( $donor ) {
233
+	public function get_row_actions($donor) {
234 234
 
235 235
 		$actions = array(
236
-			'view'   => sprintf( '<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor['id'] ), sprintf( esc_attr__( 'View "%s"', 'give' ), $donor['name'] ), __( 'View Donor', 'give' ) ),
237
-			'notes'  => sprintf( '<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=notes&id=' . $donor['id'] ), sprintf( esc_attr__( 'Notes for "%s"', 'give' ), $donor['name'] ), __( 'Notes', 'give' ) ),
238
-			'delete' => sprintf( '<a class="%1$s" href="#" aria-label="%2$s">%3$s</a>', 'give-single-donor-delete', sprintf( esc_attr__( 'Delete "%s"', 'give' ), $donor['name'] ), __( 'Delete', 'give' ) ),
236
+			'view'   => sprintf('<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor['id']), sprintf(esc_attr__('View "%s"', 'give'), $donor['name']), __('View Donor', 'give')),
237
+			'notes'  => sprintf('<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url('edit.php?post_type=give_forms&page=give-donors&view=notes&id='.$donor['id']), sprintf(esc_attr__('Notes for "%s"', 'give'), $donor['name']), __('Notes', 'give')),
238
+			'delete' => sprintf('<a class="%1$s" href="#" aria-label="%2$s">%3$s</a>', 'give-single-donor-delete', sprintf(esc_attr__('Delete "%s"', 'give'), $donor['name']), __('Delete', 'give')),
239 239
 		);
240 240
 
241
-		return apply_filters( 'give_donor_row_actions', $actions, $donor );
241
+		return apply_filters('give_donor_row_actions', $actions, $donor);
242 242
 
243 243
 	}
244 244
 
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 	 * @return int Current page number.
252 252
 	 */
253 253
 	public function get_paged() {
254
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
254
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
255 255
 	}
256 256
 
257 257
 	/**
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 	 * @return mixed string If search is present, false otherwise.
264 264
 	 */
265 265
 	public function get_search() {
266
-		return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false;
266
+		return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false;
267 267
 	}
268 268
 
269 269
 	/**
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 	 */
277 277
 	public function get_bulk_actions() {
278 278
 		$actions = array(
279
-			'delete' => __( 'Delete', 'give' ),
279
+			'delete' => __('Delete', 'give'),
280 280
 		);
281 281
 		return $actions;
282 282
 	}
@@ -289,19 +289,19 @@  discard block
 block discarded – undo
289 289
 	 * @access protected
290 290
 	 * @since  1.8.16
291 291
 	 */
292
-	protected function display_tablenav( $which ) {
293
-		if ( 'top' === $which ) {
294
-			wp_nonce_field( 'bulk-' . $this->_args['plural'], '_wpnonce', false );
292
+	protected function display_tablenav($which) {
293
+		if ('top' === $which) {
294
+			wp_nonce_field('bulk-'.$this->_args['plural'], '_wpnonce', false);
295 295
 		}
296 296
 		?>
297
-		<div class="tablenav <?php echo esc_attr( $which ); ?>">
298
-			<?php if ( $this->has_items() ): ?>
297
+		<div class="tablenav <?php echo esc_attr($which); ?>">
298
+			<?php if ($this->has_items()): ?>
299 299
 				<div class="alignleft actions bulkactions">
300
-					<?php $this->bulk_actions( $which ); ?>
300
+					<?php $this->bulk_actions($which); ?>
301 301
 				</div>
302 302
 			<?php endif;
303
-			$this->extra_tablenav( $which );
304
-			$this->pagination( $which );
303
+			$this->extra_tablenav($which);
304
+			$this->pagination($which);
305 305
 			?>
306 306
 			<br class="clear" />
307 307
 		</div>
@@ -322,13 +322,13 @@  discard block
 block discarded – undo
322 322
 
323 323
 		// Get donor query.
324 324
 		$args   = $this->get_donor_query();
325
-		$donors = Give()->donors->get_donors( $args );
325
+		$donors = Give()->donors->get_donors($args);
326 326
 
327
-		if ( $donors ) {
327
+		if ($donors) {
328 328
 
329
-			foreach ( $donors as $donor ) {
329
+			foreach ($donors as $donor) {
330 330
 
331
-				$user_id = ! empty( $donor->user_id ) ? intval( $donor->user_id ) : 0;
331
+				$user_id = ! empty($donor->user_id) ? intval($donor->user_id) : 0;
332 332
 
333 333
 				$data[] = array(
334 334
 					'id'            => $donor->id,
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 			}
343 343
 		}
344 344
 
345
-		return apply_filters( 'give_donors_column_query_data', $data );
345
+		return apply_filters('give_donors_column_query_data', $data);
346 346
 	}
347 347
 
348 348
 	/**
@@ -357,9 +357,9 @@  discard block
 block discarded – undo
357 357
 
358 358
 		$_donor_query['number'] = - 1;
359 359
 		$_donor_query['offset'] = 0;
360
-		$donors                 = Give()->donors->get_donors( $_donor_query );
360
+		$donors                 = Give()->donors->get_donors($_donor_query);
361 361
 
362
-		return count( $donors );
362
+		return count($donors);
363 363
 	}
364 364
 
365 365
 	/**
@@ -372,10 +372,10 @@  discard block
 block discarded – undo
372 372
 	 */
373 373
 	public function get_donor_query() {
374 374
 		$paged   = $this->get_paged();
375
-		$offset  = $this->per_page * ( $paged - 1 );
375
+		$offset  = $this->per_page * ($paged - 1);
376 376
 		$search  = $this->get_search();
377
-		$order   = isset( $_GET['order'] ) ? sanitize_text_field( $_GET['order'] ) : 'DESC';
378
-		$orderby = isset( $_GET['orderby'] ) ? sanitize_text_field( $_GET['orderby'] ) : 'id';
377
+		$order   = isset($_GET['order']) ? sanitize_text_field($_GET['order']) : 'DESC';
378
+		$orderby = isset($_GET['orderby']) ? sanitize_text_field($_GET['orderby']) : 'id';
379 379
 
380 380
 		$args = array(
381 381
 			'number'  => $this->per_page,
@@ -384,10 +384,10 @@  discard block
 block discarded – undo
384 384
 			'orderby' => $orderby,
385 385
 		);
386 386
 
387
-		if ( $search ) {
388
-			if ( is_email( $search ) ) {
387
+		if ($search) {
388
+			if (is_email($search)) {
389 389
 				$args['email'] = $search;
390
-			} elseif ( is_numeric( $search ) ) {
390
+			} elseif (is_numeric($search)) {
391 391
 				$args['id'] = $search;
392 392
 			} else {
393 393
 				$args['name'] = $search;
@@ -405,9 +405,9 @@  discard block
 block discarded – undo
405 405
 	 * @since  1.8.17
406 406
 	 * @access public
407 407
 	 */
408
-	public function single_row( $item ) {
409
-		echo sprintf( '<tr id="donor-%1$d" data-id="%2$d" data-name="%3$s">', $item['id'], $item['id'], $item['name'] );
410
-		$this->single_row_columns( $item );
408
+	public function single_row($item) {
409
+		echo sprintf('<tr id="donor-%1$d" data-id="%2$d" data-name="%3$s">', $item['id'], $item['id'], $item['name']);
410
+		$this->single_row_columns($item);
411 411
 		echo '</tr>';
412 412
 	}
413 413
 
@@ -420,11 +420,11 @@  discard block
 block discarded – undo
420 420
 	public function display() {
421 421
 		$singular = $this->_args['singular'];
422 422
 
423
-		$this->display_tablenav( 'top' );
423
+		$this->display_tablenav('top');
424 424
 
425
-		$this->screen->render_screen_reader_content( 'heading_list' );
425
+		$this->screen->render_screen_reader_content('heading_list');
426 426
 		?>
427
-		<table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>">
427
+		<table class="wp-list-table <?php echo implode(' ', $this->get_table_classes()); ?>">
428 428
 			<thead>
429 429
 			<tr>
430 430
 				<?php $this->print_column_headers(); ?>
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 			</thead>
433 433
 
434 434
 			<tbody id="the-list"<?php
435
-			if ( $singular ) {
435
+			if ($singular) {
436 436
 				echo " data-wp-lists='list:$singular'";
437 437
 			} ?>>
438 438
 			<tr class="hidden"></tr>
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
 				<td colspan="6" class="colspanchange">
441 441
 
442 442
 					<fieldset class="inline-edit-col-left">
443
-						<legend class="inline-edit-legend"><?php _e( 'BULK DELETE', 'give' ); ?></legend>
443
+						<legend class="inline-edit-legend"><?php _e('BULK DELETE', 'give'); ?></legend>
444 444
 						<div class="inline-edit-col">
445 445
 							<div id="bulk-titles">
446 446
 								<div id="give-bulk-donors" class="give-bulk-donors">
@@ -453,22 +453,22 @@  discard block
 block discarded – undo
453 453
 						<div class="inline-edit-col">
454 454
 							<label>
455 455
 								<input id="give-delete-donor-confirm" type="checkbox" name="give-delete-donor-confirm"/>
456
-								<?php _e( 'Are you sure you want to delete the selected donor(s)?', 'give' ); ?>
456
+								<?php _e('Are you sure you want to delete the selected donor(s)?', 'give'); ?>
457 457
 							</label>
458 458
 							<label>
459 459
 								<input id="give-delete-donor-records" type="checkbox" name="give-delete-donor-records"/>
460
-								<?php _e( 'Delete all associated donations and records?', 'give' ); ?>
460
+								<?php _e('Delete all associated donations and records?', 'give'); ?>
461 461
 							</label>
462 462
 						</div>
463 463
 					</fieldset>
464 464
 
465 465
 					<p class="submit inline-edit-save">
466 466
 						<input type="hidden" name="give_action" value="delete_donor"/>
467
-						<input type="hidden" name="s" value="<?php echo ( ! empty( $_GET['s'] ) ) ? $_GET['s'] : ''; ?>"/>
468
-						<input type="hidden" name="orderby" value="<?php echo ( ! empty( $_GET['orderby'] ) ) ? $_GET['orderby'] : 'id'; ?>"/>
469
-						<input type="hidden" name="order" value="<?php echo ( ! empty( $_GET['order'] ) ) ? $_GET['order'] : 'desc'; ?>"/>
470
-						<button type="button" id="give-bulk-delete-cancel" class="button cancel alignleft"><?php _e( 'Cancel', 'give' ); ?></button>
471
-						<input type="submit" id="give-bulk-delete-button" disabled class="button button-primary alignright" value="<?php _e( 'Delete', 'give' ); ?>">
467
+						<input type="hidden" name="s" value="<?php echo ( ! empty($_GET['s'])) ? $_GET['s'] : ''; ?>"/>
468
+						<input type="hidden" name="orderby" value="<?php echo ( ! empty($_GET['orderby'])) ? $_GET['orderby'] : 'id'; ?>"/>
469
+						<input type="hidden" name="order" value="<?php echo ( ! empty($_GET['order'])) ? $_GET['order'] : 'desc'; ?>"/>
470
+						<button type="button" id="give-bulk-delete-cancel" class="button cancel alignleft"><?php _e('Cancel', 'give'); ?></button>
471
+						<input type="submit" id="give-bulk-delete-button" disabled class="button button-primary alignright" value="<?php _e('Delete', 'give'); ?>">
472 472
 						<br class="clear">
473 473
 					</p>
474 474
 				</td>
@@ -478,13 +478,13 @@  discard block
 block discarded – undo
478 478
 
479 479
 			<tfoot>
480 480
 			<tr>
481
-				<?php $this->print_column_headers( false ); ?>
481
+				<?php $this->print_column_headers(false); ?>
482 482
 			</tr>
483 483
 			</tfoot>
484 484
 
485 485
 		</table>
486 486
 		<?php
487
-		$this->display_tablenav( 'bottom' );
487
+		$this->display_tablenav('bottom');
488 488
 	}
489 489
 
490 490
 	/**
@@ -501,16 +501,16 @@  discard block
 block discarded – undo
501 501
 		$hidden   = array(); // No hidden columns.
502 502
 		$sortable = $this->get_sortable_columns();
503 503
 
504
-		$this->_column_headers = array( $columns, $hidden, $sortable );
504
+		$this->_column_headers = array($columns, $hidden, $sortable);
505 505
 
506 506
 		$this->items = $this->donor_data();
507 507
 
508 508
 		$this->total = $this->get_donor_count();
509 509
 
510
-		$this->set_pagination_args( array(
510
+		$this->set_pagination_args(array(
511 511
 			'total_items' => $this->total,
512 512
 			'per_page'    => $this->per_page,
513
-			'total_pages' => ceil( $this->total / $this->per_page ),
514
-		) );
513
+			'total_pages' => ceil($this->total / $this->per_page),
514
+		));
515 515
 	}
516 516
 }
Please login to merge, or discard this patch.
includes/admin/donors/donor-actions.php 2 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
  *
22 22
  * @since 1.0
23 23
  *
24
- * @return array|bool $output Response messages
24
+ * @return false|null $output Response messages
25 25
  */
26 26
 function give_edit_donor( $args ) {
27 27
 
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
  *
228 228
  * @since 1.0
229 229
  *
230
- * @return int Whether it was a successful deletion.
230
+ * @return false|null Whether it was a successful deletion.
231 231
  */
232 232
 function give_donor_delete( $args ) {
233 233
 
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
  *
522 522
  * @since  1.7
523 523
  *
524
- * @return bool|null
524
+ * @return false|null
525 525
  */
526 526
 function give_remove_donor_email() {
527 527
 	if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
  *
566 566
  * @since  1.7
567 567
  *
568
- * @return bool|null
568
+ * @return false|null
569 569
  */
570 570
 function give_set_donor_primary_email() {
571 571
 	if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
Please login to merge, or discard this patch.
Spacing   +222 added lines, -222 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -23,17 +23,17 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * @return array|bool $output Response messages
25 25
  */
26
-function give_edit_donor( $args ) {
26
+function give_edit_donor($args) {
27 27
 
28
-	$donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' );
28
+	$donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments');
29 29
 
30
-	if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) {
31
-		wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array(
30
+	if ( ! is_admin() || ! current_user_can($donor_edit_role)) {
31
+		wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array(
32 32
 			'response' => 403,
33
-		) );
33
+		));
34 34
 	}
35 35
 
36
-	if ( empty( $args ) ) {
36
+	if (empty($args)) {
37 37
 		return false;
38 38
 	}
39 39
 
@@ -41,15 +41,15 @@  discard block
 block discarded – undo
41 41
 	$donor_id   = (int) $args['customerinfo']['id'];
42 42
 	$nonce      = $args['_wpnonce'];
43 43
 
44
-	if ( ! wp_verify_nonce( $nonce, 'edit-donor' ) ) {
45
-		wp_die( __( 'Cheatin&#8217; uh?', 'give' ), __( 'Error', 'give' ), array(
44
+	if ( ! wp_verify_nonce($nonce, 'edit-donor')) {
45
+		wp_die(__('Cheatin&#8217; uh?', 'give'), __('Error', 'give'), array(
46 46
 			'response' => 400,
47
-		) );
47
+		));
48 48
 	}
49 49
 
50
-	$donor = new Give_Donor( $donor_id );
50
+	$donor = new Give_Donor($donor_id);
51 51
 
52
-	if ( empty( $donor->id ) ) {
52
+	if (empty($donor->id)) {
53 53
 		return false;
54 54
 	}
55 55
 
@@ -64,79 +64,79 @@  discard block
 block discarded – undo
64 64
 		'country' => '',
65 65
 	);
66 66
 
67
-	$donor_info = wp_parse_args( $donor_info, $defaults );
67
+	$donor_info = wp_parse_args($donor_info, $defaults);
68 68
 
69
-	if ( (int) $donor_info['user_id'] !== (int) $donor->user_id ) {
69
+	if ((int) $donor_info['user_id'] !== (int) $donor->user_id) {
70 70
 
71 71
 		// Make sure we don't already have this user attached to a donor.
72
-		if ( ! empty( $donor_info['user_id'] ) && false !== Give()->donors->get_donor_by( 'user_id', $donor_info['user_id'] ) ) {
73
-			give_set_error( 'give-invalid-donor-user_id', sprintf( __( 'The User ID #%d is already associated with a different donor.', 'give' ), $donor_info['user_id'] ) );
72
+		if ( ! empty($donor_info['user_id']) && false !== Give()->donors->get_donor_by('user_id', $donor_info['user_id'])) {
73
+			give_set_error('give-invalid-donor-user_id', sprintf(__('The User ID #%d is already associated with a different donor.', 'give'), $donor_info['user_id']));
74 74
 		}
75 75
 
76 76
 		// Make sure it's actually a user.
77
-		$user = get_user_by( 'id', $donor_info['user_id'] );
78
-		if ( ! empty( $donor_info['user_id'] ) && false === $user ) {
79
-			give_set_error( 'give-invalid-user_id', sprintf( __( 'The User ID #%d does not exist. Please assign an existing user.', 'give' ), $donor_info['user_id'] ) );
77
+		$user = get_user_by('id', $donor_info['user_id']);
78
+		if ( ! empty($donor_info['user_id']) && false === $user) {
79
+			give_set_error('give-invalid-user_id', sprintf(__('The User ID #%d does not exist. Please assign an existing user.', 'give'), $donor_info['user_id']));
80 80
 		}
81 81
 	}
82 82
 
83
-	if ( give_get_errors() ) {
83
+	if (give_get_errors()) {
84 84
 		return false;
85 85
 	}
86 86
 
87 87
 	// Setup the donor address, if present.
88 88
 	$address = array();
89
-	if ( intval( $donor_info['user_id'] ) > 0 ) {
90
-
91
-		$current_address = (array) get_user_meta( $donor_info['user_id'], '_give_user_address', true );
92
-
93
-		if ( is_array( $current_address ) && 0 < count( $current_address ) ) {
94
-			$current_address    = wp_parse_args( $current_address, $defaults );
95
-			$address['line1']   = ! empty( $donor_info['line1'] ) ? $donor_info['line1'] : $current_address['line1'];
96
-			$address['line2']   = ! empty( $donor_info['line2'] ) ? $donor_info['line2'] : $current_address['line2'];
97
-			$address['city']    = ! empty( $donor_info['city'] ) ? $donor_info['city'] : $current_address['city'];
98
-			$address['country'] = ! empty( $donor_info['country'] ) ? $donor_info['country'] : $current_address['country'];
99
-			$address['zip']     = ! empty( $donor_info['zip'] ) ? $donor_info['zip'] : $current_address['zip'];
100
-			$address['state']   = ! empty( $donor_info['state'] ) ? $donor_info['state'] : $current_address['state'];
89
+	if (intval($donor_info['user_id']) > 0) {
90
+
91
+		$current_address = (array) get_user_meta($donor_info['user_id'], '_give_user_address', true);
92
+
93
+		if (is_array($current_address) && 0 < count($current_address)) {
94
+			$current_address    = wp_parse_args($current_address, $defaults);
95
+			$address['line1']   = ! empty($donor_info['line1']) ? $donor_info['line1'] : $current_address['line1'];
96
+			$address['line2']   = ! empty($donor_info['line2']) ? $donor_info['line2'] : $current_address['line2'];
97
+			$address['city']    = ! empty($donor_info['city']) ? $donor_info['city'] : $current_address['city'];
98
+			$address['country'] = ! empty($donor_info['country']) ? $donor_info['country'] : $current_address['country'];
99
+			$address['zip']     = ! empty($donor_info['zip']) ? $donor_info['zip'] : $current_address['zip'];
100
+			$address['state']   = ! empty($donor_info['state']) ? $donor_info['state'] : $current_address['state'];
101 101
 		} else {
102
-			$address['line1']   = ! empty( $donor_info['line1'] ) ? $donor_info['line1'] : '';
103
-			$address['line2']   = ! empty( $donor_info['line2'] ) ? $donor_info['line2'] : '';
104
-			$address['city']    = ! empty( $donor_info['city'] ) ? $donor_info['city'] : '';
105
-			$address['country'] = ! empty( $donor_info['country'] ) ? $donor_info['country'] : '';
106
-			$address['zip']     = ! empty( $donor_info['zip'] ) ? $donor_info['zip'] : '';
107
-			$address['state']   = ! empty( $donor_info['state'] ) ? $donor_info['state'] : '';
102
+			$address['line1']   = ! empty($donor_info['line1']) ? $donor_info['line1'] : '';
103
+			$address['line2']   = ! empty($donor_info['line2']) ? $donor_info['line2'] : '';
104
+			$address['city']    = ! empty($donor_info['city']) ? $donor_info['city'] : '';
105
+			$address['country'] = ! empty($donor_info['country']) ? $donor_info['country'] : '';
106
+			$address['zip']     = ! empty($donor_info['zip']) ? $donor_info['zip'] : '';
107
+			$address['state']   = ! empty($donor_info['state']) ? $donor_info['state'] : '';
108 108
 		}
109 109
 
110 110
 	}
111 111
 
112 112
 	// Sanitize the inputs.
113 113
 	$donor_data            = array();
114
-	$donor_data['name']    = strip_tags( stripslashes( $donor_info['name'] ) );
114
+	$donor_data['name']    = strip_tags(stripslashes($donor_info['name']));
115 115
 	$donor_data['user_id'] = $donor_info['user_id'];
116 116
 
117
-	$donor_data = apply_filters( 'give_edit_donor_info', $donor_data, $donor_id );
118
-	$address    = apply_filters( 'give_edit_donor_address', $address, $donor_id );
117
+	$donor_data = apply_filters('give_edit_donor_info', $donor_data, $donor_id);
118
+	$address    = apply_filters('give_edit_donor_address', $address, $donor_id);
119 119
 
120
-	$donor_data = array_map( 'sanitize_text_field', $donor_data );
121
-	$address    = array_map( 'sanitize_text_field', $address );
120
+	$donor_data = array_map('sanitize_text_field', $donor_data);
121
+	$address    = array_map('sanitize_text_field', $address);
122 122
 
123
-	$output = give_connect_user_donor_profile( $donor, $donor_data, $address );
123
+	$output = give_connect_user_donor_profile($donor, $donor_data, $address);
124 124
 
125
-	if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
126
-		header( 'Content-Type: application/json' );
127
-		echo json_encode( $output );
125
+	if (defined('DOING_AJAX') && DOING_AJAX) {
126
+		header('Content-Type: application/json');
127
+		echo json_encode($output);
128 128
 		wp_die();
129 129
 	}
130 130
 
131
-	if ( $output['success'] ) {
132
-		wp_redirect( admin_url( "edit.php?post_type=give_forms&page=give-donors&view=overview&id={$donor_id}&give-message=profile-updated" ) );
131
+	if ($output['success']) {
132
+		wp_redirect(admin_url("edit.php?post_type=give_forms&page=give-donors&view=overview&id={$donor_id}&give-message=profile-updated"));
133 133
 	}
134 134
 
135 135
 	exit;
136 136
 
137 137
 }
138 138
 
139
-add_action( 'give_edit-donor', 'give_edit_donor', 10, 1 );
139
+add_action('give_edit-donor', 'give_edit_donor', 10, 1);
140 140
 
141 141
 /**
142 142
  * Save a donor note.
@@ -147,40 +147,40 @@  discard block
 block discarded – undo
147 147
  *
148 148
  * @return int The Note ID that was saved, or 0 if nothing was saved.
149 149
  */
150
-function give_donor_save_note( $args ) {
150
+function give_donor_save_note($args) {
151 151
 
152
-	$donor_view_role = apply_filters( 'give_view_donors_role', 'view_give_reports' );
152
+	$donor_view_role = apply_filters('give_view_donors_role', 'view_give_reports');
153 153
 
154
-	if ( ! is_admin() || ! current_user_can( $donor_view_role ) ) {
155
-		wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array(
154
+	if ( ! is_admin() || ! current_user_can($donor_view_role)) {
155
+		wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array(
156 156
 			'response' => 403,
157
-		) );
157
+		));
158 158
 	}
159 159
 
160
-	if ( empty( $args ) ) {
160
+	if (empty($args)) {
161 161
 		return false;
162 162
 	}
163 163
 
164
-	$donor_note = trim( sanitize_text_field( $args['donor_note'] ) );
164
+	$donor_note = trim(sanitize_text_field($args['donor_note']));
165 165
 	$donor_id   = (int) $args['customer_id'];
166 166
 	$nonce      = $args['add_donor_note_nonce'];
167 167
 
168
-	if ( ! wp_verify_nonce( $nonce, 'add-donor-note' ) ) {
169
-		wp_die( __( 'Cheatin&#8217; uh?', 'give' ), __( 'Error', 'give' ), array(
168
+	if ( ! wp_verify_nonce($nonce, 'add-donor-note')) {
169
+		wp_die(__('Cheatin&#8217; uh?', 'give'), __('Error', 'give'), array(
170 170
 			'response' => 400,
171
-		) );
171
+		));
172 172
 	}
173 173
 
174
-	if ( empty( $donor_note ) ) {
175
-		give_set_error( 'empty-donor-note', __( 'A note is required.', 'give' ) );
174
+	if (empty($donor_note)) {
175
+		give_set_error('empty-donor-note', __('A note is required.', 'give'));
176 176
 	}
177 177
 
178
-	if ( give_get_errors() ) {
178
+	if (give_get_errors()) {
179 179
 		return false;
180 180
 	}
181 181
 
182
-	$donor    = new Give_Donor( $donor_id );
183
-	$new_note = $donor->add_note( $donor_note );
182
+	$donor    = new Give_Donor($donor_id);
183
+	$new_note = $donor->add_note($donor_note);
184 184
 
185 185
 	/**
186 186
 	 * Fires before inserting donor note.
@@ -190,22 +190,22 @@  discard block
 block discarded – undo
190 190
 	 *
191 191
 	 * @since 1.0
192 192
 	 */
193
-	do_action( 'give_pre_insert_donor_note', $donor_id, $new_note );
193
+	do_action('give_pre_insert_donor_note', $donor_id, $new_note);
194 194
 
195
-	if ( ! empty( $new_note ) && ! empty( $donor->id ) ) {
195
+	if ( ! empty($new_note) && ! empty($donor->id)) {
196 196
 
197 197
 		ob_start();
198 198
 		?>
199 199
 		<div class="donor-note-wrapper dashboard-comment-wrap comment-item">
200 200
 			<span class="note-content-wrap">
201
-				<?php echo stripslashes( $new_note ); ?>
201
+				<?php echo stripslashes($new_note); ?>
202 202
 			</span>
203 203
 		</div>
204 204
 		<?php
205 205
 		$output = ob_get_contents();
206 206
 		ob_end_clean();
207 207
 
208
-		if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
208
+		if (defined('DOING_AJAX') && DOING_AJAX) {
209 209
 			echo $output;
210 210
 			exit;
211 211
 		}
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 
219 219
 }
220 220
 
221
-add_action( 'give_add-donor-note', 'give_donor_save_note', 10, 1 );
221
+add_action('give_add-donor-note', 'give_donor_save_note', 10, 1);
222 222
 
223 223
 /**
224 224
  * Delete a donor.
@@ -229,41 +229,41 @@  discard block
 block discarded – undo
229 229
  *
230 230
  * @return int Whether it was a successful deletion.
231 231
  */
232
-function give_donor_delete( $args ) {
232
+function give_donor_delete($args) {
233 233
 
234
-	$donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' );
234
+	$donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments');
235 235
 
236
-	if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) {
237
-		wp_die( __( 'You do not have permission to delete donors.', 'give' ), __( 'Error', 'give' ), array(
236
+	if ( ! is_admin() || ! current_user_can($donor_edit_role)) {
237
+		wp_die(__('You do not have permission to delete donors.', 'give'), __('Error', 'give'), array(
238 238
 			'response' => 403,
239
-		) );
239
+		));
240 240
 	}
241 241
 
242
-	if ( empty( $args ) ) {
242
+	if (empty($args)) {
243 243
 		return false;
244 244
 	}
245 245
 
246 246
 	$donor_id    = (int) $args['customer_id'];
247
-	$confirm     = ! empty( $args['give-donor-delete-confirm'] ) ? true : false;
248
-	$remove_data = ! empty( $args['give-donor-delete-records'] ) ? true : false;
247
+	$confirm     = ! empty($args['give-donor-delete-confirm']) ? true : false;
248
+	$remove_data = ! empty($args['give-donor-delete-records']) ? true : false;
249 249
 	$nonce       = $args['_wpnonce'];
250 250
 
251
-	if ( ! wp_verify_nonce( $nonce, 'delete-donor' ) ) {
252
-		wp_die( __( 'Cheatin&#8217; uh?', 'give' ), __( 'Error', 'give' ), array(
251
+	if ( ! wp_verify_nonce($nonce, 'delete-donor')) {
252
+		wp_die(__('Cheatin&#8217; uh?', 'give'), __('Error', 'give'), array(
253 253
 			'response' => 400,
254
-		) );
254
+		));
255 255
 	}
256 256
 
257
-	if ( ! $confirm ) {
258
-		give_set_error( 'donor-delete-no-confirm', __( 'Please confirm you want to delete this donor.', 'give' ) );
257
+	if ( ! $confirm) {
258
+		give_set_error('donor-delete-no-confirm', __('Please confirm you want to delete this donor.', 'give'));
259 259
 	}
260 260
 
261
-	if ( give_get_errors() ) {
262
-		wp_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor_id ) );
261
+	if (give_get_errors()) {
262
+		wp_redirect(admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor_id));
263 263
 		exit;
264 264
 	}
265 265
 
266
-	$donor = new Give_Donor( $donor_id );
266
+	$donor = new Give_Donor($donor_id);
267 267
 
268 268
 	/**
269 269
 	 * Fires before deleting donor.
@@ -274,50 +274,50 @@  discard block
 block discarded – undo
274 274
 	 *
275 275
 	 * @since 1.0
276 276
 	 */
277
-	do_action( 'give_pre_delete_donor', $donor_id, $confirm, $remove_data );
277
+	do_action('give_pre_delete_donor', $donor_id, $confirm, $remove_data);
278 278
 
279
-	if ( $donor->id > 0 ) {
279
+	if ($donor->id > 0) {
280 280
 
281
-		$payments_array = explode( ',', $donor->payment_ids );
282
-		$success        = Give()->donors->delete( $donor->id );
281
+		$payments_array = explode(',', $donor->payment_ids);
282
+		$success        = Give()->donors->delete($donor->id);
283 283
 
284
-		if ( $success ) {
284
+		if ($success) {
285 285
 
286
-			if ( $remove_data ) {
286
+			if ($remove_data) {
287 287
 
288 288
 				// Remove all donations, logs, etc.
289
-				foreach ( $payments_array as $payment_id ) {
290
-					give_delete_donation( $payment_id );
289
+				foreach ($payments_array as $payment_id) {
290
+					give_delete_donation($payment_id);
291 291
 				}
292 292
 			} else {
293 293
 
294 294
 				// Just set the donations to customer_id of 0.
295
-				foreach ( $payments_array as $payment_id ) {
296
-					give_update_payment_meta( $payment_id, '_give_payment_customer_id', 0 );
295
+				foreach ($payments_array as $payment_id) {
296
+					give_update_payment_meta($payment_id, '_give_payment_customer_id', 0);
297 297
 				}
298 298
 			}
299 299
 
300
-			$redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&give-message=donor-deleted' );
300
+			$redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&give-message=donor-deleted');
301 301
 
302 302
 		} else {
303 303
 
304
-			give_set_error( 'give-donor-delete-failed', __( 'Error deleting donor.', 'give' ) );
305
-			$redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $donor_id );
304
+			give_set_error('give-donor-delete-failed', __('Error deleting donor.', 'give'));
305
+			$redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$donor_id);
306 306
 
307 307
 		}
308 308
 	} else {
309 309
 
310
-		give_set_error( 'give-donor-delete-invalid-id', __( 'Invalid Donor ID.', 'give' ) );
311
-		$redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors' );
310
+		give_set_error('give-donor-delete-invalid-id', __('Invalid Donor ID.', 'give'));
311
+		$redirect = admin_url('edit.php?post_type=give_forms&page=give-donors');
312 312
 
313 313
 	}
314 314
 
315
-	wp_redirect( $redirect );
315
+	wp_redirect($redirect);
316 316
 	exit;
317 317
 
318 318
 }
319 319
 
320
-add_action( 'give_delete-donor', 'give_donor_delete', 10, 1 );
320
+add_action('give_delete-donor', 'give_donor_delete', 10, 1);
321 321
 
322 322
 /**
323 323
  * Disconnect a user ID from a donor
@@ -328,17 +328,17 @@  discard block
 block discarded – undo
328 328
  *
329 329
  * @return bool|array If the disconnect was successful.
330 330
  */
331
-function give_disconnect_donor_user_id( $args ) {
331
+function give_disconnect_donor_user_id($args) {
332 332
 
333
-	$donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' );
333
+	$donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments');
334 334
 
335
-	if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) {
336
-		wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array(
335
+	if ( ! is_admin() || ! current_user_can($donor_edit_role)) {
336
+		wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array(
337 337
 			'response' => 403,
338
-		) );
338
+		));
339 339
 	}
340 340
 
341
-	if ( empty( $args ) ) {
341
+	if (empty($args)) {
342 342
 		return false;
343 343
 	}
344 344
 
@@ -346,14 +346,14 @@  discard block
 block discarded – undo
346 346
 
347 347
 	$nonce = $args['_wpnonce'];
348 348
 
349
-	if ( ! wp_verify_nonce( $nonce, 'edit-donor' ) ) {
350
-		wp_die( __( 'Cheatin&#8217; uh?', 'give' ), __( 'Error', 'give' ), array(
349
+	if ( ! wp_verify_nonce($nonce, 'edit-donor')) {
350
+		wp_die(__('Cheatin&#8217; uh?', 'give'), __('Error', 'give'), array(
351 351
 			'response' => 400,
352
-		) );
352
+		));
353 353
 	}
354 354
 
355
-	$donor = new Give_Donor( $donor_id );
356
-	if ( empty( $donor->id ) ) {
355
+	$donor = new Give_Donor($donor_id);
356
+	if (empty($donor->id)) {
357 357
 		return false;
358 358
 	}
359 359
 
@@ -367,34 +367,34 @@  discard block
 block discarded – undo
367 367
 	 *
368 368
 	 * @since 1.0
369 369
 	 */
370
-	do_action( 'give_pre_donor_disconnect_user_id', $donor_id, $user_id );
370
+	do_action('give_pre_donor_disconnect_user_id', $donor_id, $user_id);
371 371
 
372 372
 	$output     = array();
373 373
 	$donor_args = array(
374 374
 		'user_id' => 0,
375 375
 	);
376 376
 
377
-	if ( $donor->update( $donor_args ) ) {
377
+	if ($donor->update($donor_args)) {
378 378
 		global $wpdb;
379 379
 
380
-		if ( ! empty( $donor->payment_ids ) ) {
381
-			$wpdb->query( "UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $donor->payment_ids )" );
380
+		if ( ! empty($donor->payment_ids)) {
381
+			$wpdb->query("UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $donor->payment_ids )");
382 382
 		}
383 383
 
384 384
 		// Set Donor Disconnection status true, if user and donor are disconnected with each other.
385
-		update_user_meta( $user_id, '_give_is_donor_disconnected', true );
386
-		update_user_meta( $user_id, '_give_disconnected_donor_id', $donor->id );
387
-		$donor->update_meta( '_give_disconnected_user_id', $user_id );
385
+		update_user_meta($user_id, '_give_is_donor_disconnected', true);
386
+		update_user_meta($user_id, '_give_disconnected_donor_id', $donor->id);
387
+		$donor->update_meta('_give_disconnected_user_id', $user_id);
388 388
 
389 389
 		$output['success'] = true;
390 390
 
391 391
 	} else {
392 392
 
393 393
 		$output['success'] = false;
394
-		give_set_error( 'give-disconnect-user-fail', __( 'Failed to disconnect user from donor.', 'give' ) );
394
+		give_set_error('give-disconnect-user-fail', __('Failed to disconnect user from donor.', 'give'));
395 395
 	}
396 396
 
397
-	$output['redirect'] = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' ) . $donor_id;
397
+	$output['redirect'] = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id=').$donor_id;
398 398
 
399 399
 	/**
400 400
 	 * Fires after disconnecting user ID from a donor.
@@ -403,11 +403,11 @@  discard block
 block discarded – undo
403 403
 	 *
404 404
 	 * @since 1.0
405 405
 	 */
406
-	do_action( 'give_post_donor_disconnect_user_id', $donor_id );
406
+	do_action('give_post_donor_disconnect_user_id', $donor_id);
407 407
 
408
-	if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
409
-		header( 'Content-Type: application/json' );
410
-		echo json_encode( $output );
408
+	if (defined('DOING_AJAX') && DOING_AJAX) {
409
+		header('Content-Type: application/json');
410
+		echo json_encode($output);
411 411
 		wp_die();
412 412
 	}
413 413
 
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 
416 416
 }
417 417
 
418
-add_action( 'give_disconnect-userid', 'give_disconnect_donor_user_id', 10, 1 );
418
+add_action('give_disconnect-userid', 'give_disconnect_donor_user_id', 10, 1);
419 419
 
420 420
 /**
421 421
  * Add an email address to the donor from within the admin and log a donor note.
@@ -426,86 +426,86 @@  discard block
 block discarded – undo
426 426
  *
427 427
  * @return mixed If DOING_AJAX echos out JSON, otherwise returns array of success (bool) and message (string).
428 428
  */
429
-function give_add_donor_email( $args ) {
429
+function give_add_donor_email($args) {
430 430
 
431 431
 	$donor_id = '';
432
-	$donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' );
432
+	$donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments');
433 433
 
434
-	if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) {
435
-		wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array(
434
+	if ( ! is_admin() || ! current_user_can($donor_edit_role)) {
435
+		wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array(
436 436
 			'response' => 403,
437
-		) );
437
+		));
438 438
 	}
439 439
 
440 440
 	$output = array();
441
-	if ( empty( $args ) || empty( $args['email'] ) || empty( $args['customer_id'] ) ) {
441
+	if (empty($args) || empty($args['email']) || empty($args['customer_id'])) {
442 442
 		$output['success'] = false;
443
-		if ( empty( $args['email'] ) ) {
444
-			$output['message'] = __( 'Email address is required.', 'give' );
445
-		} elseif ( empty( $args['customer_id'] ) ) {
446
-			$output['message'] = __( 'Donor ID is required.', 'give' );
443
+		if (empty($args['email'])) {
444
+			$output['message'] = __('Email address is required.', 'give');
445
+		} elseif (empty($args['customer_id'])) {
446
+			$output['message'] = __('Donor ID is required.', 'give');
447 447
 		} else {
448
-			$output['message'] = __( 'An error has occurred. Please try again.', 'give' );
448
+			$output['message'] = __('An error has occurred. Please try again.', 'give');
449 449
 		}
450
-	} elseif ( ! wp_verify_nonce( $args['_wpnonce'], 'give_add_donor_email' ) ) {
450
+	} elseif ( ! wp_verify_nonce($args['_wpnonce'], 'give_add_donor_email')) {
451 451
 		$output = array(
452 452
 			'success' => false,
453
-			'message' => __( 'Nonce verification failed.', 'give' ),
453
+			'message' => __('Nonce verification failed.', 'give'),
454 454
 		);
455
-	} elseif ( ! is_email( $args['email'] ) ) {
455
+	} elseif ( ! is_email($args['email'])) {
456 456
 		$output = array(
457 457
 			'success' => false,
458
-			'message' => __( 'Invalid email.', 'give' ),
458
+			'message' => __('Invalid email.', 'give'),
459 459
 		);
460 460
 	} else {
461
-		$email    = sanitize_email( $args['email'] );
461
+		$email    = sanitize_email($args['email']);
462 462
 		$donor_id = (int) $args['customer_id'];
463 463
 		$primary  = 'true' === $args['primary'] ? true : false;
464
-		$donor    = new Give_Donor( $donor_id );
465
-		if ( false === $donor->add_email( $email, $primary ) ) {
466
-			if ( in_array( $email, $donor->emails ) ) {
464
+		$donor    = new Give_Donor($donor_id);
465
+		if (false === $donor->add_email($email, $primary)) {
466
+			if (in_array($email, $donor->emails)) {
467 467
 				$output = array(
468 468
 					'success' => false,
469
-					'message' => __( 'Email already associated with this donor.', 'give' ),
469
+					'message' => __('Email already associated with this donor.', 'give'),
470 470
 				);
471 471
 			} else {
472 472
 				$output = array(
473 473
 					'success' => false,
474
-					'message' => __( 'Email address is already associated with another donor.', 'give' ),
474
+					'message' => __('Email address is already associated with another donor.', 'give'),
475 475
 				);
476 476
 			}
477 477
 		} else {
478
-			$redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor_id . '&give-message=email-added' );
478
+			$redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor_id.'&give-message=email-added');
479 479
 			$output   = array(
480 480
 				'success'  => true,
481
-				'message'  => __( 'Email successfully added to donor.', 'give' ),
481
+				'message'  => __('Email successfully added to donor.', 'give'),
482 482
 				'redirect' => $redirect,
483 483
 			);
484 484
 
485 485
 			$user       = wp_get_current_user();
486
-			$user_login = ! empty( $user->user_login ) ? $user->user_login : __( 'System', 'give' );
487
-			$donor_note = sprintf( __( 'Email address %1$s added by %2$s', 'give' ), $email, $user_login );
488
-			$donor->add_note( $donor_note );
486
+			$user_login = ! empty($user->user_login) ? $user->user_login : __('System', 'give');
487
+			$donor_note = sprintf(__('Email address %1$s added by %2$s', 'give'), $email, $user_login);
488
+			$donor->add_note($donor_note);
489 489
 
490
-			if ( $primary ) {
491
-				$donor_note = sprintf( __( 'Email address %1$s set as primary by %2$s', 'give' ), $email, $user_login );
492
-				$donor->add_note( $donor_note );
490
+			if ($primary) {
491
+				$donor_note = sprintf(__('Email address %1$s set as primary by %2$s', 'give'), $email, $user_login);
492
+				$donor->add_note($donor_note);
493 493
 			}
494 494
 		}
495 495
 	} // End if().
496 496
 
497
-	do_action( 'give_post_add_donor_email', $donor_id, $args );
497
+	do_action('give_post_add_donor_email', $donor_id, $args);
498 498
 
499
-	if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
500
-		header( 'Content-Type: application/json' );
501
-		echo json_encode( $output );
499
+	if (defined('DOING_AJAX') && DOING_AJAX) {
500
+		header('Content-Type: application/json');
501
+		echo json_encode($output);
502 502
 		wp_die();
503 503
 	}
504 504
 
505 505
 	return $output;
506 506
 }
507 507
 
508
-add_action( 'give_add_donor_email', 'give_add_donor_email', 10, 1 );
508
+add_action('give_add_donor_email', 'give_add_donor_email', 10, 1);
509 509
 
510 510
 
511 511
 /**
@@ -516,39 +516,39 @@  discard block
 block discarded – undo
516 516
  * @return bool|null
517 517
  */
518 518
 function give_remove_donor_email() {
519
-	if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
519
+	if (empty($_GET['id']) || ! is_numeric($_GET['id'])) {
520 520
 		return false;
521 521
 	}
522
-	if ( empty( $_GET['email'] ) || ! is_email( $_GET['email'] ) ) {
522
+	if (empty($_GET['email']) || ! is_email($_GET['email'])) {
523 523
 		return false;
524 524
 	}
525
-	if ( empty( $_GET['_wpnonce'] ) ) {
525
+	if (empty($_GET['_wpnonce'])) {
526 526
 		return false;
527 527
 	}
528 528
 
529 529
 	$nonce = $_GET['_wpnonce'];
530
-	if ( ! wp_verify_nonce( $nonce, 'give-remove-donor-email' ) ) {
531
-		wp_die( __( 'Nonce verification failed', 'give' ), __( 'Error', 'give' ), array(
530
+	if ( ! wp_verify_nonce($nonce, 'give-remove-donor-email')) {
531
+		wp_die(__('Nonce verification failed', 'give'), __('Error', 'give'), array(
532 532
 			'response' => 403,
533
-		) );
533
+		));
534 534
 	}
535 535
 
536
-	$donor = new Give_Donor( $_GET['id'] );
537
-	if ( $donor->remove_email( $_GET['email'] ) ) {
538
-		$url        = add_query_arg( 'give-message', 'email-removed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) );
536
+	$donor = new Give_Donor($_GET['id']);
537
+	if ($donor->remove_email($_GET['email'])) {
538
+		$url        = add_query_arg('give-message', 'email-removed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id));
539 539
 		$user       = wp_get_current_user();
540
-		$user_login = ! empty( $user->user_login ) ? $user->user_login : __( 'System', 'give' );
541
-		$donor_note = sprintf( __( 'Email address %1$s removed by %2$s', 'give' ), $_GET['email'], $user_login );
542
-		$donor->add_note( $donor_note );
540
+		$user_login = ! empty($user->user_login) ? $user->user_login : __('System', 'give');
541
+		$donor_note = sprintf(__('Email address %1$s removed by %2$s', 'give'), $_GET['email'], $user_login);
542
+		$donor->add_note($donor_note);
543 543
 	} else {
544
-		$url = add_query_arg( 'give-message', 'email-remove-failed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) );
544
+		$url = add_query_arg('give-message', 'email-remove-failed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id));
545 545
 	}
546 546
 
547
-	wp_safe_redirect( $url );
547
+	wp_safe_redirect($url);
548 548
 	exit;
549 549
 }
550 550
 
551
-add_action( 'give_remove_donor_email', 'give_remove_donor_email', 10 );
551
+add_action('give_remove_donor_email', 'give_remove_donor_email', 10);
552 552
 
553 553
 
554 554
 /**
@@ -560,44 +560,44 @@  discard block
 block discarded – undo
560 560
  * @return bool|null
561 561
  */
562 562
 function give_set_donor_primary_email() {
563
-	if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
563
+	if (empty($_GET['id']) || ! is_numeric($_GET['id'])) {
564 564
 		return false;
565 565
 	}
566 566
 
567
-	if ( empty( $_GET['email'] ) || ! is_email( $_GET['email'] ) ) {
567
+	if (empty($_GET['email']) || ! is_email($_GET['email'])) {
568 568
 		return false;
569 569
 	}
570 570
 
571
-	if ( empty( $_GET['_wpnonce'] ) ) {
571
+	if (empty($_GET['_wpnonce'])) {
572 572
 		return false;
573 573
 	}
574 574
 
575 575
 	$nonce = $_GET['_wpnonce'];
576 576
 
577
-	if ( ! wp_verify_nonce( $nonce, 'give-set-donor-primary-email' ) ) {
578
-		wp_die( __( 'Nonce verification failed', 'give' ), __( 'Error', 'give' ), array(
577
+	if ( ! wp_verify_nonce($nonce, 'give-set-donor-primary-email')) {
578
+		wp_die(__('Nonce verification failed', 'give'), __('Error', 'give'), array(
579 579
 			'response' => 403,
580
-		) );
580
+		));
581 581
 	}
582 582
 
583
-	$donor = new Give_Donor( $_GET['id'] );
583
+	$donor = new Give_Donor($_GET['id']);
584 584
 
585
-	if ( $donor->set_primary_email( $_GET['email'] ) ) {
586
-		$url        = add_query_arg( 'give-message', 'primary-email-updated', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) );
585
+	if ($donor->set_primary_email($_GET['email'])) {
586
+		$url        = add_query_arg('give-message', 'primary-email-updated', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id));
587 587
 		$user       = wp_get_current_user();
588
-		$user_login = ! empty( $user->user_login ) ? $user->user_login : __( 'System', 'give' );
589
-		$donor_note = sprintf( __( 'Email address %1$s set as primary by %2$s', 'give' ), $_GET['email'], $user_login );
588
+		$user_login = ! empty($user->user_login) ? $user->user_login : __('System', 'give');
589
+		$donor_note = sprintf(__('Email address %1$s set as primary by %2$s', 'give'), $_GET['email'], $user_login);
590 590
 
591
-		$donor->add_note( $donor_note );
591
+		$donor->add_note($donor_note);
592 592
 	} else {
593
-		$url = add_query_arg( 'give-message', 'primary-email-failed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) );
593
+		$url = add_query_arg('give-message', 'primary-email-failed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id));
594 594
 	}
595 595
 
596
-	wp_safe_redirect( $url );
596
+	wp_safe_redirect($url);
597 597
 	exit;
598 598
 }
599 599
 
600
-add_action( 'give_set_donor_primary_email', 'give_set_donor_primary_email', 10 );
600
+add_action('give_set_donor_primary_email', 'give_set_donor_primary_email', 10);
601 601
 
602 602
 /**
603 603
  * Delete Donor using Bulk Actions.
@@ -608,57 +608,57 @@  discard block
 block discarded – undo
608 608
  *
609 609
  * @return void
610 610
  */
611
-function give_delete_donor( $args ) {
611
+function give_delete_donor($args) {
612 612
 
613
-	$donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' );
613
+	$donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments');
614 614
 
615
-	if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) {
616
-		wp_die( __( 'You do not have permission to delete donors.', 'give' ), __( 'Error', 'give' ), array(
615
+	if ( ! is_admin() || ! current_user_can($donor_edit_role)) {
616
+		wp_die(__('You do not have permission to delete donors.', 'give'), __('Error', 'give'), array(
617 617
 			'response' => 403,
618
-		) );
618
+		));
619 619
 	}
620 620
 
621 621
 	$give_args            = array();
622
-	$donor_ids            = ( ! empty( $_GET['donor'] ) && is_array( $_GET['donor'] ) && count( $_GET['donor'] ) > 0 ) ? $_GET['donor'] : array();
623
-	$delete_donor         = ! empty( $_GET['give-delete-donor-confirm'] ) ? $_GET['give-delete-donor-confirm'] : '';
624
-	$delete_donations     = ! empty( $_GET['give-delete-donor-records'] ) ? $_GET['give-delete-donor-records'] : '';
625
-	$search_keyword       = ! empty( $_GET['s'] ) ? $_GET['s'] : '';
626
-	$give_args['orderby'] = ! empty( $_GET['orderby'] ) ? $_GET['orderby'] : 'id';
627
-	$give_args['order']   = ! empty( $_GET['order'] ) ? $_GET['order'] : 'desc';
622
+	$donor_ids            = ( ! empty($_GET['donor']) && is_array($_GET['donor']) && count($_GET['donor']) > 0) ? $_GET['donor'] : array();
623
+	$delete_donor         = ! empty($_GET['give-delete-donor-confirm']) ? $_GET['give-delete-donor-confirm'] : '';
624
+	$delete_donations     = ! empty($_GET['give-delete-donor-records']) ? $_GET['give-delete-donor-records'] : '';
625
+	$search_keyword       = ! empty($_GET['s']) ? $_GET['s'] : '';
626
+	$give_args['orderby'] = ! empty($_GET['orderby']) ? $_GET['orderby'] : 'id';
627
+	$give_args['order']   = ! empty($_GET['order']) ? $_GET['order'] : 'desc';
628 628
 	$nonce                = $args['_wpnonce'];
629 629
 
630 630
 	// Verify Nonce for deleting bulk donors.
631
-	if ( ! wp_verify_nonce( $nonce, 'bulk-donors' ) ) {
632
-		wp_die( __( 'Cheatin&#8217; uh?', 'give' ), __( 'Error', 'give' ), array(
631
+	if ( ! wp_verify_nonce($nonce, 'bulk-donors')) {
632
+		wp_die(__('Cheatin&#8217; uh?', 'give'), __('Error', 'give'), array(
633 633
 			'response' => 400,
634
-		) );
634
+		));
635 635
 	}
636 636
 
637
-	if( count( $donor_ids ) > 0 ) {
638
-		foreach ( $donor_ids as $donor_id ) {
639
-			$donor = new Give_Donor( $donor_id );
637
+	if (count($donor_ids) > 0) {
638
+		foreach ($donor_ids as $donor_id) {
639
+			$donor = new Give_Donor($donor_id);
640 640
 
641
-			if ( $donor->id > 0 ) {
641
+			if ($donor->id > 0) {
642 642
 
643
-				if( $delete_donor ) {
644
-					$donor_deleted = Give()->donors->delete( $donor->id );
643
+				if ($delete_donor) {
644
+					$donor_deleted = Give()->donors->delete($donor->id);
645 645
 
646
-					if ( $donor_deleted ) {
647
-						$donation_ids  = explode( ',', $donor->payment_ids );
646
+					if ($donor_deleted) {
647
+						$donation_ids = explode(',', $donor->payment_ids);
648 648
 
649
-						if( $delete_donations ) {
649
+						if ($delete_donations) {
650 650
 
651 651
 							// Remove all donations, logs, etc.
652
-							foreach ( $donation_ids as $donation_id ) {
653
-								give_delete_donation( $donation_id );
652
+							foreach ($donation_ids as $donation_id) {
653
+								give_delete_donation($donation_id);
654 654
 							}
655 655
 
656 656
 							$give_args['give-message'] = 'donor-donations-deleted';
657 657
 						} else {
658 658
 
659 659
 							// Just set the donations to customer_id of 0.
660
-							foreach ( $donation_ids as $donation_id ) {
661
-								give_update_payment_meta( $donation_id, '_give_payment_customer_id', 0 );
660
+							foreach ($donation_ids as $donation_id) {
661
+								give_update_payment_meta($donation_id, '_give_payment_customer_id', 0);
662 662
 							}
663 663
 
664 664
 							$give_args['give-message'] = 'donor-deleted';
@@ -675,13 +675,13 @@  discard block
 block discarded – undo
675 675
 		}
676 676
 
677 677
 		// Add Search Keyword on redirection, if it exists.
678
-		if ( ! empty( $search_keyword ) ) {
678
+		if ( ! empty($search_keyword)) {
679 679
 			$give_args['s'] = $search_keyword;
680 680
 		}
681 681
 
682
-		wp_redirect( add_query_arg( $give_args, admin_url( 'edit.php?post_type=give_forms&page=give-donors' ) ) );
682
+		wp_redirect(add_query_arg($give_args, admin_url('edit.php?post_type=give_forms&page=give-donors')));
683 683
 		give_die();
684 684
 	}
685 685
 }
686 686
 
687
-add_action( 'give_delete_donor', 'give_delete_donor' );
688 687
\ No newline at end of file
688
+add_action('give_delete_donor', 'give_delete_donor');
689 689
\ No newline at end of file
Please login to merge, or discard this patch.
includes/payments/functions.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
  *
706 706
  * @since 1.0
707 707
  *
708
- * @return int $earnings Earnings
708
+ * @return double $earnings Earnings
709 709
  */
710 710
 function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) {
711 711
 
@@ -993,7 +993,7 @@  discard block
 block discarded – undo
993 993
  *
994 994
  * @since 1.0
995 995
  *
996
- * @return array $user_info User Info Meta Values.
996
+ * @return string $user_info User Info Meta Values.
997 997
  */
998 998
 function give_get_payment_meta_user_info( $payment_id ) {
999 999
 	$payment = new Give_Payment( $payment_id );
@@ -1010,7 +1010,7 @@  discard block
 block discarded – undo
1010 1010
  *
1011 1011
  * @since 1.0
1012 1012
  *
1013
- * @return int $form_id Form ID.
1013
+ * @return string $form_id Form ID.
1014 1014
  */
1015 1015
 function give_get_payment_form_id( $payment_id ) {
1016 1016
 	$payment = new Give_Payment( $payment_id );
Please login to merge, or discard this patch.
Spacing   +421 added lines, -421 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,15 +43,15 @@  discard block
 block discarded – undo
43 43
  *
44 44
  * @return array $payments Payments retrieved from the database
45 45
  */
46
-function give_get_payments( $args = array() ) {
46
+function give_get_payments($args = array()) {
47 47
 
48 48
 	// Fallback to post objects to ensure backwards compatibility.
49
-	if ( ! isset( $args['output'] ) ) {
49
+	if ( ! isset($args['output'])) {
50 50
 		$args['output'] = 'posts';
51 51
 	}
52 52
 
53
-	$args     = apply_filters( 'give_get_payments_args', $args );
54
-	$payments = new Give_Payments_Query( $args );
53
+	$args     = apply_filters('give_get_payments_args', $args);
54
+	$payments = new Give_Payments_Query($args);
55 55
 
56 56
 	return $payments->get_payments();
57 57
 }
@@ -66,48 +66,48 @@  discard block
 block discarded – undo
66 66
  *
67 67
  * @return mixed
68 68
  */
69
-function give_get_payment_by( $field = '', $value = '' ) {
69
+function give_get_payment_by($field = '', $value = '') {
70 70
 
71
-	if ( empty( $field ) || empty( $value ) ) {
71
+	if (empty($field) || empty($value)) {
72 72
 		return false;
73 73
 	}
74 74
 
75
-	switch ( strtolower( $field ) ) {
75
+	switch (strtolower($field)) {
76 76
 
77 77
 		case 'id':
78
-			$payment = new Give_Payment( $value );
78
+			$payment = new Give_Payment($value);
79 79
 			$id      = $payment->ID;
80 80
 
81
-			if ( empty( $id ) ) {
81
+			if (empty($id)) {
82 82
 				return false;
83 83
 			}
84 84
 
85 85
 			break;
86 86
 
87 87
 		case 'key':
88
-			$payment = give_get_payments( array(
88
+			$payment = give_get_payments(array(
89 89
 				'meta_key'       => '_give_payment_purchase_key',
90 90
 				'meta_value'     => $value,
91 91
 				'posts_per_page' => 1,
92 92
 				'fields'         => 'ids',
93
-			) );
93
+			));
94 94
 
95
-			if ( $payment ) {
96
-				$payment = new Give_Payment( $payment[0] );
95
+			if ($payment) {
96
+				$payment = new Give_Payment($payment[0]);
97 97
 			}
98 98
 
99 99
 			break;
100 100
 
101 101
 		case 'payment_number':
102
-			$payment = give_get_payments( array(
102
+			$payment = give_get_payments(array(
103 103
 				'meta_key'       => '_give_payment_number',
104 104
 				'meta_value'     => $value,
105 105
 				'posts_per_page' => 1,
106 106
 				'fields'         => 'ids',
107
-			) );
107
+			));
108 108
 
109
-			if ( $payment ) {
110
-				$payment = new Give_Payment( $payment[0] );
109
+			if ($payment) {
110
+				$payment = new Give_Payment($payment[0]);
111 111
 			}
112 112
 
113 113
 			break;
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 			return false;
117 117
 	}// End switch().
118 118
 
119
-	if ( $payment ) {
119
+	if ($payment) {
120 120
 		return $payment;
121 121
 	}
122 122
 
@@ -132,9 +132,9 @@  discard block
 block discarded – undo
132 132
  *
133 133
  * @return int|bool Payment ID if payment is inserted, false otherwise.
134 134
  */
135
-function give_insert_payment( $payment_data = array() ) {
135
+function give_insert_payment($payment_data = array()) {
136 136
 
137
-	if ( empty( $payment_data ) ) {
137
+	if (empty($payment_data)) {
138 138
 		return false;
139 139
 	}
140 140
 
@@ -145,25 +145,25 @@  discard block
 block discarded – undo
145 145
 	 *
146 146
 	 * @param array $payment_data Arguments passed.
147 147
 	 */
148
-	$payment_data = apply_filters( 'give_pre_insert_payment', $payment_data );
148
+	$payment_data = apply_filters('give_pre_insert_payment', $payment_data);
149 149
 
150 150
 	$payment    = new Give_Payment();
151
-	$gateway    = ! empty( $payment_data['gateway'] ) ? $payment_data['gateway'] : '';
152
-	$gateway    = empty( $gateway ) && isset( $_POST['give-gateway'] ) ? $_POST['give-gateway'] : $gateway;
153
-	$form_id    = isset( $payment_data['give_form_id'] ) ? $payment_data['give_form_id'] : 0;
154
-	$price_id   = give_get_payment_meta_price_id( $payment_data );
155
-	$form_title = isset( $payment_data['give_form_title'] ) ? $payment_data['give_form_title'] : get_the_title( $form_id );
151
+	$gateway    = ! empty($payment_data['gateway']) ? $payment_data['gateway'] : '';
152
+	$gateway    = empty($gateway) && isset($_POST['give-gateway']) ? $_POST['give-gateway'] : $gateway;
153
+	$form_id    = isset($payment_data['give_form_id']) ? $payment_data['give_form_id'] : 0;
154
+	$price_id   = give_get_payment_meta_price_id($payment_data);
155
+	$form_title = isset($payment_data['give_form_title']) ? $payment_data['give_form_title'] : get_the_title($form_id);
156 156
 
157 157
 	// Set properties.
158 158
 	$payment->total          = $payment_data['price'];
159
-	$payment->status         = ! empty( $payment_data['status'] ) ? $payment_data['status'] : 'pending';
160
-	$payment->currency       = ! empty( $payment_data['currency'] ) ? $payment_data['currency'] : give_get_currency( $payment_data['give_form_id'], $payment_data );
159
+	$payment->status         = ! empty($payment_data['status']) ? $payment_data['status'] : 'pending';
160
+	$payment->currency       = ! empty($payment_data['currency']) ? $payment_data['currency'] : give_get_currency($payment_data['give_form_id'], $payment_data);
161 161
 	$payment->user_info      = $payment_data['user_info'];
162 162
 	$payment->gateway        = $gateway;
163 163
 	$payment->form_title     = $form_title;
164 164
 	$payment->form_id        = $form_id;
165 165
 	$payment->price_id       = $price_id;
166
-	$payment->donor_id       = ( ! empty( $payment_data['donor_id'] ) ? $payment_data['donor_id'] : '' );
166
+	$payment->donor_id       = ( ! empty($payment_data['donor_id']) ? $payment_data['donor_id'] : '');
167 167
 	$payment->user_id        = $payment_data['user_info']['id'];
168 168
 	$payment->email          = $payment_data['user_email'];
169 169
 	$payment->first_name     = $payment_data['user_info']['first_name'];
@@ -171,8 +171,8 @@  discard block
 block discarded – undo
171 171
 	$payment->email          = $payment_data['user_info']['email'];
172 172
 	$payment->ip             = give_get_ip();
173 173
 	$payment->key            = $payment_data['purchase_key'];
174
-	$payment->mode           = ( ! empty( $payment_data['mode'] ) ? (string) $payment_data['mode'] : ( give_is_test_mode() ? 'test' : 'live' ) );
175
-	$payment->parent_payment = ! empty( $payment_data['parent'] ) ? absint( $payment_data['parent'] ) : '';
174
+	$payment->mode           = ( ! empty($payment_data['mode']) ? (string) $payment_data['mode'] : (give_is_test_mode() ? 'test' : 'live'));
175
+	$payment->parent_payment = ! empty($payment_data['parent']) ? absint($payment_data['parent']) : '';
176 176
 
177 177
 	// Add the donation.
178 178
 	$args = array(
@@ -180,19 +180,19 @@  discard block
 block discarded – undo
180 180
 		'price_id' => $payment->price_id,
181 181
 	);
182 182
 
183
-	$payment->add_donation( $payment->form_id, $args );
183
+	$payment->add_donation($payment->form_id, $args);
184 184
 
185 185
 
186 186
 	// Set date if present.
187
-	if ( isset( $payment_data['post_date'] ) ) {
187
+	if (isset($payment_data['post_date'])) {
188 188
 		$payment->date = $payment_data['post_date'];
189 189
 	}
190 190
 
191 191
 	// Handle sequential payments.
192
-	if ( give_get_option( 'enable_sequential' ) ) {
192
+	if (give_get_option('enable_sequential')) {
193 193
 		$number          = give_get_next_payment_number();
194
-		$payment->number = give_format_payment_number( $number );
195
-		update_option( 'give_last_payment_number', $number );
194
+		$payment->number = give_format_payment_number($number);
195
+		update_option('give_last_payment_number', $number);
196 196
 	}
197 197
 
198 198
 	// Save payment.
@@ -206,10 +206,10 @@  discard block
 block discarded – undo
206 206
 	 * @param int   $payment_id   The payment ID.
207 207
 	 * @param array $payment_data Arguments passed.
208 208
 	 */
209
-	do_action( 'give_insert_payment', $payment->ID, $payment_data );
209
+	do_action('give_insert_payment', $payment->ID, $payment_data);
210 210
 
211 211
 	// Return payment ID upon success.
212
-	if ( ! empty( $payment->ID ) ) {
212
+	if ( ! empty($payment->ID)) {
213 213
 		return $payment->ID;
214 214
 	}
215 215
 
@@ -225,10 +225,10 @@  discard block
 block discarded – undo
225 225
  *
226 226
  * @return bool|int
227 227
  */
228
-function give_create_payment( $payment_data ) {
228
+function give_create_payment($payment_data) {
229 229
 
230
-	$form_id  = intval( $payment_data['post_data']['give-form-id'] );
231
-	$price_id = isset( $payment_data['post_data']['give-price-id'] ) ? $payment_data['post_data']['give-price-id'] : '';
230
+	$form_id  = intval($payment_data['post_data']['give-form-id']);
231
+	$price_id = isset($payment_data['post_data']['give-price-id']) ? $payment_data['post_data']['give-price-id'] : '';
232 232
 
233 233
 	// Collect payment data.
234 234
 	$insert_payment_data = array(
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 		'date'            => $payment_data['date'],
240 240
 		'user_email'      => $payment_data['user_email'],
241 241
 		'purchase_key'    => $payment_data['purchase_key'],
242
-		'currency'        => give_get_currency( $form_id, $payment_data ),
242
+		'currency'        => give_get_currency($form_id, $payment_data),
243 243
 		'user_info'       => $payment_data['user_info'],
244 244
 		'status'          => 'pending',
245 245
 		'gateway'         => 'paypal',
@@ -252,10 +252,10 @@  discard block
 block discarded – undo
252 252
 	 *
253 253
 	 * @param array $insert_payment_data
254 254
 	 */
255
-	$insert_payment_data = apply_filters( 'give_create_payment', $insert_payment_data );
255
+	$insert_payment_data = apply_filters('give_create_payment', $insert_payment_data);
256 256
 
257 257
 	// Record the pending payment.
258
-	return give_insert_payment( $insert_payment_data );
258
+	return give_insert_payment($insert_payment_data);
259 259
 }
260 260
 
261 261
 /**
@@ -268,12 +268,12 @@  discard block
 block discarded – undo
268 268
  *
269 269
  * @return bool
270 270
  */
271
-function give_update_payment_status( $payment_id, $new_status = 'publish' ) {
271
+function give_update_payment_status($payment_id, $new_status = 'publish') {
272 272
 
273 273
 	$updated = false;
274
-	$payment = new Give_Payment( $payment_id );
274
+	$payment = new Give_Payment($payment_id);
275 275
 
276
-	if ( $payment && $payment->ID > 0 ) {
276
+	if ($payment && $payment->ID > 0) {
277 277
 
278 278
 		$payment->status = $new_status;
279 279
 		$updated         = $payment->save();
@@ -295,48 +295,48 @@  discard block
 block discarded – undo
295 295
  *
296 296
  * @return void
297 297
  */
298
-function give_delete_donation( $payment_id = 0, $update_donor = true ) {
298
+function give_delete_donation($payment_id = 0, $update_donor = true) {
299 299
 
300 300
 	global $give_logs;
301 301
 
302
-	$payment  = new Give_Payment( $payment_id );
302
+	$payment = new Give_Payment($payment_id);
303 303
 
304 304
 	// Bailout.
305
-	if( ! $payment->ID ) {
305
+	if ( ! $payment->ID) {
306 306
 		return;
307 307
 	}
308 308
 
309
-	$amount   = give_donation_amount( $payment_id );
309
+	$amount   = give_donation_amount($payment_id);
310 310
 	$status   = $payment->post_status;
311
-	$donor_id = give_get_payment_donor_id( $payment_id );
312
-	$donor    = new Give_Donor( $donor_id );
311
+	$donor_id = give_get_payment_donor_id($payment_id);
312
+	$donor    = new Give_Donor($donor_id);
313 313
 
314 314
 	// Only undo donations that aren't these statuses.
315
-	$dont_undo_statuses = apply_filters( 'give_undo_donation_statuses', array(
315
+	$dont_undo_statuses = apply_filters('give_undo_donation_statuses', array(
316 316
 		'pending',
317 317
 		'cancelled',
318
-	) );
318
+	));
319 319
 
320
-	if ( ! in_array( $status, $dont_undo_statuses ) ) {
321
-		give_undo_donation( $payment_id );
320
+	if ( ! in_array($status, $dont_undo_statuses)) {
321
+		give_undo_donation($payment_id);
322 322
 	}
323 323
 
324 324
 	// Only undo donations that aren't these statuses.
325
-	$status_to_decrease_stats = apply_filters( 'give_decrease_donor_statuses', array( 'publish' ) );
325
+	$status_to_decrease_stats = apply_filters('give_decrease_donor_statuses', array('publish'));
326 326
 
327
-	if ( in_array( $status, $status_to_decrease_stats ) ) {
327
+	if (in_array($status, $status_to_decrease_stats)) {
328 328
 
329 329
 		// Only decrease earnings if they haven't already been decreased (or were never increased for this payment).
330
-		give_decrease_total_earnings( $amount );
330
+		give_decrease_total_earnings($amount);
331 331
 
332 332
 		// @todo: Refresh only range related stat cache
333 333
 		give_delete_donation_stats();
334 334
 
335
-		if ( $donor->id && $update_donor ) {
335
+		if ($donor->id && $update_donor) {
336 336
 
337 337
 			// Decrement the stats for the donor.
338 338
 			$donor->decrease_donation_count();
339
-			$donor->decrease_value( $amount );
339
+			$donor->decrease_value($amount);
340 340
 
341 341
 		}
342 342
 	}
@@ -348,23 +348,23 @@  discard block
 block discarded – undo
348 348
 	 *
349 349
 	 * @since 1.0
350 350
 	 */
351
-	do_action( 'give_payment_delete', $payment_id );
351
+	do_action('give_payment_delete', $payment_id);
352 352
 
353
-	if ( $donor->id && $update_donor ) {
353
+	if ($donor->id && $update_donor) {
354 354
 		// Remove the payment ID from the donor.
355
-		$donor->remove_payment( $payment_id );
355
+		$donor->remove_payment($payment_id);
356 356
 	}
357 357
 
358 358
 	// Remove the payment.
359
-	wp_delete_post( $payment_id, true );
359
+	wp_delete_post($payment_id, true);
360 360
 
361 361
 	// Remove related sale log entries.
362
-	$give_logs->delete_logs( null, 'sale', array(
362
+	$give_logs->delete_logs(null, 'sale', array(
363 363
 		array(
364 364
 			'key'   => '_give_log_payment_id',
365 365
 			'value' => $payment_id,
366 366
 		),
367
-	) );
367
+	));
368 368
 
369 369
 	/**
370 370
 	 * Fires after payment deleted.
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 	 *
374 374
 	 * @since 1.0
375 375
 	 */
376
-	do_action( 'give_payment_deleted', $payment_id );
376
+	do_action('give_payment_deleted', $payment_id);
377 377
 }
378 378
 
379 379
 /**
@@ -388,20 +388,20 @@  discard block
 block discarded – undo
388 388
  *
389 389
  * @return void
390 390
  */
391
-function give_undo_donation( $payment_id ) {
391
+function give_undo_donation($payment_id) {
392 392
 
393
-	$payment = new Give_Payment( $payment_id );
393
+	$payment = new Give_Payment($payment_id);
394 394
 
395
-	$maybe_decrease_earnings = apply_filters( 'give_decrease_earnings_on_undo', true, $payment, $payment->form_id );
396
-	if ( true === $maybe_decrease_earnings ) {
395
+	$maybe_decrease_earnings = apply_filters('give_decrease_earnings_on_undo', true, $payment, $payment->form_id);
396
+	if (true === $maybe_decrease_earnings) {
397 397
 		// Decrease earnings.
398
-		give_decrease_form_earnings( $payment->form_id, $payment->total );
398
+		give_decrease_form_earnings($payment->form_id, $payment->total);
399 399
 	}
400 400
 
401
-	$maybe_decrease_donations = apply_filters( 'give_decrease_donations_on_undo', true, $payment, $payment->form_id );
402
-	if ( true === $maybe_decrease_donations ) {
401
+	$maybe_decrease_donations = apply_filters('give_decrease_donations_on_undo', true, $payment, $payment->form_id);
402
+	if (true === $maybe_decrease_donations) {
403 403
 		// Decrease donation count.
404
-		give_decrease_donation_count( $payment->form_id );
404
+		give_decrease_donation_count($payment->form_id);
405 405
 	}
406 406
 
407 407
 }
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
  *
419 419
  * @return object $stats Contains the number of payments per payment status.
420 420
  */
421
-function give_count_payments( $args = array() ) {
421
+function give_count_payments($args = array()) {
422 422
 
423 423
 	global $wpdb;
424 424
 
@@ -430,18 +430,18 @@  discard block
 block discarded – undo
430 430
 		'form_id'    => null,
431 431
 	);
432 432
 
433
-	$args = wp_parse_args( $args, $defaults );
433
+	$args = wp_parse_args($args, $defaults);
434 434
 
435 435
 	$select = 'SELECT p.post_status,count( * ) AS num_posts';
436 436
 	$join   = '';
437
-	$where  = "WHERE p.post_type = 'give_payment' AND p.post_status IN ('" . implode( "','", give_get_payment_status_keys() ) . "')";
437
+	$where  = "WHERE p.post_type = 'give_payment' AND p.post_status IN ('".implode("','", give_get_payment_status_keys())."')";
438 438
 
439 439
 	// Count payments for a specific user.
440
-	if ( ! empty( $args['user'] ) ) {
440
+	if ( ! empty($args['user'])) {
441 441
 
442
-		if ( is_email( $args['user'] ) ) {
442
+		if (is_email($args['user'])) {
443 443
 			$field = 'email';
444
-		} elseif ( is_numeric( $args['user'] ) ) {
444
+		} elseif (is_numeric($args['user'])) {
445 445
 			$field = 'id';
446 446
 		} else {
447 447
 			$field = '';
@@ -449,101 +449,101 @@  discard block
 block discarded – undo
449 449
 
450 450
 		$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
451 451
 
452
-		if ( ! empty( $field ) ) {
452
+		if ( ! empty($field)) {
453 453
 			$where .= "
454 454
 				AND m.meta_key = '_give_payment_user_{$field}'
455 455
 				AND m.meta_value = '{$args['user']}'";
456 456
 		}
457
-	} elseif ( ! empty( $args['donor'] ) ) {
457
+	} elseif ( ! empty($args['donor'])) {
458 458
 
459
-		$join  = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
459
+		$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
460 460
 		$where .= "
461 461
 			AND m.meta_key = '_give_payment_customer_id'
462 462
 			AND m.meta_value = '{$args['donor']}'";
463 463
 
464 464
 		// Count payments for a search.
465
-	} elseif ( ! empty( $args['s'] ) ) {
465
+	} elseif ( ! empty($args['s'])) {
466 466
 
467
-		if ( is_email( $args['s'] ) || strlen( $args['s'] ) == 32 ) {
467
+		if (is_email($args['s']) || strlen($args['s']) == 32) {
468 468
 
469
-			if ( is_email( $args['s'] ) ) {
469
+			if (is_email($args['s'])) {
470 470
 				$field = '_give_payment_user_email';
471 471
 			} else {
472 472
 				$field = '_give_payment_purchase_key';
473 473
 			}
474 474
 
475
-			$join  = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
476
-			$where .= $wpdb->prepare( '
475
+			$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
476
+			$where .= $wpdb->prepare('
477 477
                 AND m.meta_key = %s
478
-                AND m.meta_value = %s', $field, $args['s'] );
478
+                AND m.meta_value = %s', $field, $args['s']);
479 479
 
480
-		} elseif ( '#' == substr( $args['s'], 0, 1 ) ) {
480
+		} elseif ('#' == substr($args['s'], 0, 1)) {
481 481
 
482
-			$search = str_replace( '#:', '', $args['s'] );
483
-			$search = str_replace( '#', '', $search );
482
+			$search = str_replace('#:', '', $args['s']);
483
+			$search = str_replace('#', '', $search);
484 484
 
485 485
 			$select = 'SELECT p.post_status,count( * ) AS num_posts ';
486 486
 			$join   = '';
487
-			$where  = $wpdb->prepare( 'WHERE p.post_type=%s  AND p.ID = %d ', 'give_payment', $search );
487
+			$where  = $wpdb->prepare('WHERE p.post_type=%s  AND p.ID = %d ', 'give_payment', $search);
488 488
 
489
-		} elseif ( is_numeric( $args['s'] ) ) {
489
+		} elseif (is_numeric($args['s'])) {
490 490
 
491
-			$join  = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
492
-			$where .= $wpdb->prepare( "
491
+			$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
492
+			$where .= $wpdb->prepare("
493 493
 				AND m.meta_key = '_give_payment_user_id'
494
-				AND m.meta_value = %d", $args['s'] );
494
+				AND m.meta_value = %d", $args['s']);
495 495
 
496 496
 		} else {
497
-			$search = $wpdb->esc_like( $args['s'] );
498
-			$search = '%' . $search . '%';
497
+			$search = $wpdb->esc_like($args['s']);
498
+			$search = '%'.$search.'%';
499 499
 
500
-			$where .= $wpdb->prepare( 'AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search );
500
+			$where .= $wpdb->prepare('AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search);
501 501
 		}// End if().
502 502
 	}// End if().
503 503
 
504
-	if ( ! empty( $args['form_id'] ) && is_numeric( $args['form_id'] ) ) {
504
+	if ( ! empty($args['form_id']) && is_numeric($args['form_id'])) {
505 505
 
506
-		$join  = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
507
-		$where .= $wpdb->prepare( '
506
+		$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
507
+		$where .= $wpdb->prepare('
508 508
                 AND m.meta_key = %s
509
-                AND m.meta_value = %s', '_give_payment_form_id', $args['form_id'] );
509
+                AND m.meta_value = %s', '_give_payment_form_id', $args['form_id']);
510 510
 	}
511 511
 
512 512
 	// Limit payments count by date.
513
-	if ( ! empty( $args['start-date'] ) && false !== strpos( $args['start-date'], '/' ) ) {
513
+	if ( ! empty($args['start-date']) && false !== strpos($args['start-date'], '/')) {
514 514
 
515
-		$date_parts = explode( '/', $args['start-date'] );
516
-		$month      = ! empty( $date_parts[0] ) && is_numeric( $date_parts[0] ) ? $date_parts[0] : 0;
517
-		$day        = ! empty( $date_parts[1] ) && is_numeric( $date_parts[1] ) ? $date_parts[1] : 0;
518
-		$year       = ! empty( $date_parts[2] ) && is_numeric( $date_parts[2] ) ? $date_parts[2] : 0;
515
+		$date_parts = explode('/', $args['start-date']);
516
+		$month      = ! empty($date_parts[0]) && is_numeric($date_parts[0]) ? $date_parts[0] : 0;
517
+		$day        = ! empty($date_parts[1]) && is_numeric($date_parts[1]) ? $date_parts[1] : 0;
518
+		$year       = ! empty($date_parts[2]) && is_numeric($date_parts[2]) ? $date_parts[2] : 0;
519 519
 
520
-		$is_date = checkdate( $month, $day, $year );
521
-		if ( false !== $is_date ) {
520
+		$is_date = checkdate($month, $day, $year);
521
+		if (false !== $is_date) {
522 522
 
523
-			$date  = new DateTime( $args['start-date'] );
524
-			$where .= $wpdb->prepare( " AND p.post_date >= '%s'", $date->format( 'Y-m-d' ) );
523
+			$date = new DateTime($args['start-date']);
524
+			$where .= $wpdb->prepare(" AND p.post_date >= '%s'", $date->format('Y-m-d'));
525 525
 
526 526
 		}
527 527
 
528 528
 		// Fixes an issue with the payments list table counts when no end date is specified (with stats class).
529
-		if ( empty( $args['end-date'] ) ) {
529
+		if (empty($args['end-date'])) {
530 530
 			$args['end-date'] = $args['start-date'];
531 531
 		}
532 532
 	}
533 533
 
534
-	if ( ! empty( $args['end-date'] ) && false !== strpos( $args['end-date'], '/' ) ) {
534
+	if ( ! empty($args['end-date']) && false !== strpos($args['end-date'], '/')) {
535 535
 
536
-		$date_parts = explode( '/', $args['end-date'] );
536
+		$date_parts = explode('/', $args['end-date']);
537 537
 
538
-		$month = ! empty( $date_parts[0] ) ? $date_parts[0] : 0;
539
-		$day   = ! empty( $date_parts[1] ) ? $date_parts[1] : 0;
540
-		$year  = ! empty( $date_parts[2] ) ? $date_parts[2] : 0;
538
+		$month = ! empty($date_parts[0]) ? $date_parts[0] : 0;
539
+		$day   = ! empty($date_parts[1]) ? $date_parts[1] : 0;
540
+		$year  = ! empty($date_parts[2]) ? $date_parts[2] : 0;
541 541
 
542
-		$is_date = checkdate( $month, $day, $year );
543
-		if ( false !== $is_date ) {
542
+		$is_date = checkdate($month, $day, $year);
543
+		if (false !== $is_date) {
544 544
 
545
-			$date  = new DateTime( $args['end-date'] );
546
-			$where .= $wpdb->prepare( " AND p.post_date <= '%s'", $date->format( 'Y-m-d' ) );
545
+			$date = new DateTime($args['end-date']);
546
+			$where .= $wpdb->prepare(" AND p.post_date <= '%s'", $date->format('Y-m-d'));
547 547
 
548 548
 		}
549 549
 	}
@@ -555,36 +555,36 @@  discard block
 block discarded – undo
555 555
 		GROUP BY p.post_status
556 556
 	";
557 557
 
558
-	$cache_key = md5( $query );
558
+	$cache_key = md5($query);
559 559
 
560
-	$count = wp_cache_get( $cache_key, 'counts' );
561
-	if ( false !== $count ) {
560
+	$count = wp_cache_get($cache_key, 'counts');
561
+	if (false !== $count) {
562 562
 		return $count;
563 563
 	}
564 564
 
565
-	$count = $wpdb->get_results( $query, ARRAY_A );
565
+	$count = $wpdb->get_results($query, ARRAY_A);
566 566
 
567 567
 	$stats    = array();
568 568
 	$statuses = get_post_stati();
569
-	if ( isset( $statuses['private'] ) && empty( $args['s'] ) ) {
570
-		unset( $statuses['private'] );
569
+	if (isset($statuses['private']) && empty($args['s'])) {
570
+		unset($statuses['private']);
571 571
 	}
572 572
 
573
-	foreach ( $statuses as $state ) {
574
-		$stats[ $state ] = 0;
573
+	foreach ($statuses as $state) {
574
+		$stats[$state] = 0;
575 575
 	}
576 576
 
577
-	foreach ( (array) $count as $row ) {
577
+	foreach ((array) $count as $row) {
578 578
 
579
-		if ( 'private' == $row['post_status'] && empty( $args['s'] ) ) {
579
+		if ('private' == $row['post_status'] && empty($args['s'])) {
580 580
 			continue;
581 581
 		}
582 582
 
583
-		$stats[ $row['post_status'] ] = $row['num_posts'];
583
+		$stats[$row['post_status']] = $row['num_posts'];
584 584
 	}
585 585
 
586 586
 	$stats = (object) $stats;
587
-	wp_cache_set( $cache_key, $stats, 'counts' );
587
+	wp_cache_set($cache_key, $stats, 'counts');
588 588
 
589 589
 	return $stats;
590 590
 }
@@ -599,11 +599,11 @@  discard block
 block discarded – undo
599 599
  *
600 600
  * @return bool $exists True if payment exists, false otherwise.
601 601
  */
602
-function give_check_for_existing_payment( $payment_id ) {
602
+function give_check_for_existing_payment($payment_id) {
603 603
 	$exists  = false;
604
-	$payment = new Give_Payment( $payment_id );
604
+	$payment = new Give_Payment($payment_id);
605 605
 
606
-	if ( $payment_id === $payment->ID && 'publish' === $payment->status ) {
606
+	if ($payment_id === $payment->ID && 'publish' === $payment->status) {
607 607
 		$exists = true;
608 608
 	}
609 609
 
@@ -620,41 +620,41 @@  discard block
 block discarded – undo
620 620
  *
621 621
  * @return bool|mixed True if payment status exists, false otherwise.
622 622
  */
623
-function give_get_payment_status( $payment, $return_label = false ) {
623
+function give_get_payment_status($payment, $return_label = false) {
624 624
 
625
-	if ( is_numeric( $payment ) ) {
625
+	if (is_numeric($payment)) {
626 626
 
627
-		$payment = new Give_Payment( $payment );
627
+		$payment = new Give_Payment($payment);
628 628
 
629
-		if ( ! $payment->ID > 0 ) {
629
+		if ( ! $payment->ID > 0) {
630 630
 			return false;
631 631
 		}
632 632
 
633 633
 	}
634 634
 
635
-	if ( ! is_object( $payment ) || ! isset( $payment->post_status ) ) {
635
+	if ( ! is_object($payment) || ! isset($payment->post_status)) {
636 636
 		return false;
637 637
 	}
638 638
 
639 639
 	$statuses = give_get_payment_statuses();
640 640
 
641
-	if ( ! is_array( $statuses ) || empty( $statuses ) ) {
641
+	if ( ! is_array($statuses) || empty($statuses)) {
642 642
 		return false;
643 643
 	}
644 644
 
645 645
 	// Get payment object if not already given.
646
-	$payment = $payment instanceof Give_Payment ? $payment : new Give_Payment( $payment->ID );
646
+	$payment = $payment instanceof Give_Payment ? $payment : new Give_Payment($payment->ID);
647 647
 
648
-	if ( array_key_exists( $payment->status, $statuses ) ) {
649
-		if ( true === $return_label ) {
648
+	if (array_key_exists($payment->status, $statuses)) {
649
+		if (true === $return_label) {
650 650
 			// Return translated status label.
651
-			return $statuses[ $payment->status ];
651
+			return $statuses[$payment->status];
652 652
 		} else {
653 653
 			// Account that our 'publish' status is labeled 'Complete'
654 654
 			$post_status = 'publish' === $payment->status ? 'Complete' : $payment->post_status;
655 655
 
656 656
 			// Make sure we're matching cases, since they matter
657
-			return array_search( strtolower( $post_status ), array_map( 'strtolower', $statuses ) );
657
+			return array_search(strtolower($post_status), array_map('strtolower', $statuses));
658 658
 		}
659 659
 	}
660 660
 
@@ -670,18 +670,18 @@  discard block
 block discarded – undo
670 670
  */
671 671
 function give_get_payment_statuses() {
672 672
 	$payment_statuses = array(
673
-		'pending'     => __( 'Pending', 'give' ),
674
-		'publish'     => __( 'Complete', 'give' ),
675
-		'refunded'    => __( 'Refunded', 'give' ),
676
-		'failed'      => __( 'Failed', 'give' ),
677
-		'cancelled'   => __( 'Cancelled', 'give' ),
678
-		'abandoned'   => __( 'Abandoned', 'give' ),
679
-		'preapproval' => __( 'Pre-Approved', 'give' ),
680
-		'processing'  => __( 'Processing', 'give' ),
681
-		'revoked'     => __( 'Revoked', 'give' ),
673
+		'pending'     => __('Pending', 'give'),
674
+		'publish'     => __('Complete', 'give'),
675
+		'refunded'    => __('Refunded', 'give'),
676
+		'failed'      => __('Failed', 'give'),
677
+		'cancelled'   => __('Cancelled', 'give'),
678
+		'abandoned'   => __('Abandoned', 'give'),
679
+		'preapproval' => __('Pre-Approved', 'give'),
680
+		'processing'  => __('Processing', 'give'),
681
+		'revoked'     => __('Revoked', 'give'),
682 682
 	);
683 683
 
684
-	return apply_filters( 'give_payment_statuses', $payment_statuses );
684
+	return apply_filters('give_payment_statuses', $payment_statuses);
685 685
 }
686 686
 
687 687
 /**
@@ -694,10 +694,10 @@  discard block
 block discarded – undo
694 694
  * @return array $payment_status All the available payment statuses.
695 695
  */
696 696
 function give_get_payment_status_keys() {
697
-	$statuses = array_keys( give_get_payment_statuses() );
698
-	asort( $statuses );
697
+	$statuses = array_keys(give_get_payment_statuses());
698
+	asort($statuses);
699 699
 
700
-	return array_values( $statuses );
700
+	return array_values($statuses);
701 701
 }
702 702
 
703 703
 /**
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
  *
713 713
  * @return int $earnings Earnings
714 714
  */
715
-function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) {
715
+function give_get_earnings_by_date($day = null, $month_num, $year = null, $hour = null) {
716 716
 
717 717
 	// This is getting deprecated soon. Use Give_Payment_Stats with the get_earnings() method instead.
718 718
 	global $wpdb;
@@ -722,33 +722,33 @@  discard block
 block discarded – undo
722 722
 		'nopaging'               => true,
723 723
 		'year'                   => $year,
724 724
 		'monthnum'               => $month_num,
725
-		'post_status'            => array( 'publish' ),
725
+		'post_status'            => array('publish'),
726 726
 		'fields'                 => 'ids',
727 727
 		'update_post_term_cache' => false,
728 728
 	);
729
-	if ( ! empty( $day ) ) {
729
+	if ( ! empty($day)) {
730 730
 		$args['day'] = $day;
731 731
 	}
732 732
 
733
-	if ( isset( $hour ) ) {
733
+	if (isset($hour)) {
734 734
 		$args['hour'] = $hour;
735 735
 	}
736 736
 
737
-	$args = apply_filters( 'give_get_earnings_by_date_args', $args );
738
-	$key  = Give_Cache::get_key( 'give_stats', $args );
737
+	$args = apply_filters('give_get_earnings_by_date_args', $args);
738
+	$key  = Give_Cache::get_key('give_stats', $args);
739 739
 
740
-	if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) {
740
+	if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) {
741 741
 		$earnings = false;
742 742
 	} else {
743
-		$earnings = Give_Cache::get( $key );
743
+		$earnings = Give_Cache::get($key);
744 744
 	}
745 745
 
746
-	if ( false === $earnings ) {
747
-		$donations = get_posts( $args );
746
+	if (false === $earnings) {
747
+		$donations = get_posts($args);
748 748
 		$earnings  = 0;
749
-		if ( $donations ) {
750
-			$donations      = implode( ',', $donations );
751
-			$earning_totals = $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$donations})" );
749
+		if ($donations) {
750
+			$donations      = implode(',', $donations);
751
+			$earning_totals = $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$donations})");
752 752
 
753 753
 			/**
754 754
 			 * Filter The earnings by dates.
@@ -759,13 +759,13 @@  discard block
 block discarded – undo
759 759
 			 * @param array $donations      Donations lists.
760 760
 			 * @param array $args           Donation query args.
761 761
 			 */
762
-			$earnings = apply_filters( 'give_get_earnings_by_date', $earning_totals, $donations, $args );
762
+			$earnings = apply_filters('give_get_earnings_by_date', $earning_totals, $donations, $args);
763 763
 		}
764 764
 		// Cache the results for one hour.
765
-		Give_Cache::set( $key, $earnings, HOUR_IN_SECONDS );
765
+		Give_Cache::set($key, $earnings, HOUR_IN_SECONDS);
766 766
 	}
767 767
 
768
-	return round( $earnings, 2 );
768
+	return round($earnings, 2);
769 769
 }
770 770
 
771 771
 /**
@@ -780,7 +780,7 @@  discard block
 block discarded – undo
780 780
  *
781 781
  * @return int $count Sales
782 782
  */
783
-function give_get_sales_by_date( $day = null, $month_num = null, $year = null, $hour = null ) {
783
+function give_get_sales_by_date($day = null, $month_num = null, $year = null, $hour = null) {
784 784
 
785 785
 	// This is getting deprecated soon. Use Give_Payment_Stats with the get_sales() method instead.
786 786
 	$args = array(
@@ -788,14 +788,14 @@  discard block
 block discarded – undo
788 788
 		'nopaging'               => true,
789 789
 		'year'                   => $year,
790 790
 		'fields'                 => 'ids',
791
-		'post_status'            => array( 'publish' ),
791
+		'post_status'            => array('publish'),
792 792
 		'update_post_meta_cache' => false,
793 793
 		'update_post_term_cache' => false,
794 794
 	);
795 795
 
796
-	$show_free = apply_filters( 'give_sales_by_date_show_free', true, $args );
796
+	$show_free = apply_filters('give_sales_by_date_show_free', true, $args);
797 797
 
798
-	if ( false === $show_free ) {
798
+	if (false === $show_free) {
799 799
 		$args['meta_query'] = array(
800 800
 			array(
801 801
 				'key'     => '_give_payment_total',
@@ -806,33 +806,33 @@  discard block
 block discarded – undo
806 806
 		);
807 807
 	}
808 808
 
809
-	if ( ! empty( $month_num ) ) {
809
+	if ( ! empty($month_num)) {
810 810
 		$args['monthnum'] = $month_num;
811 811
 	}
812 812
 
813
-	if ( ! empty( $day ) ) {
813
+	if ( ! empty($day)) {
814 814
 		$args['day'] = $day;
815 815
 	}
816 816
 
817
-	if ( isset( $hour ) ) {
817
+	if (isset($hour)) {
818 818
 		$args['hour'] = $hour;
819 819
 	}
820 820
 
821
-	$args = apply_filters( 'give_get_sales_by_date_args', $args );
821
+	$args = apply_filters('give_get_sales_by_date_args', $args);
822 822
 
823
-	$key = Give_Cache::get_key( 'give_stats', $args );
823
+	$key = Give_Cache::get_key('give_stats', $args);
824 824
 
825
-	if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) {
825
+	if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) {
826 826
 		$count = false;
827 827
 	} else {
828
-		$count = Give_Cache::get( $key );
828
+		$count = Give_Cache::get($key);
829 829
 	}
830 830
 
831
-	if ( false === $count ) {
832
-		$donations = new WP_Query( $args );
831
+	if (false === $count) {
832
+		$donations = new WP_Query($args);
833 833
 		$count     = (int) $donations->post_count;
834 834
 		// Cache the results for one hour.
835
-		Give_Cache::set( $key, $count, HOUR_IN_SECONDS );
835
+		Give_Cache::set($key, $count, HOUR_IN_SECONDS);
836 836
 	}
837 837
 
838 838
 	return $count;
@@ -847,19 +847,19 @@  discard block
 block discarded – undo
847 847
  *
848 848
  * @return bool $ret True if complete, false otherwise.
849 849
  */
850
-function give_is_payment_complete( $payment_id ) {
851
-	$payment = new Give_Payment( $payment_id );
850
+function give_is_payment_complete($payment_id) {
851
+	$payment = new Give_Payment($payment_id);
852 852
 
853 853
 	$ret = false;
854 854
 
855
-	if ( $payment->ID > 0 ) {
855
+	if ($payment->ID > 0) {
856 856
 
857
-		if ( (int) $payment_id === (int) $payment->ID && 'publish' == $payment->status ) {
857
+		if ((int) $payment_id === (int) $payment->ID && 'publish' == $payment->status) {
858 858
 			$ret = true;
859 859
 		}
860 860
 	}
861 861
 
862
-	return apply_filters( 'give_is_payment_complete', $ret, $payment_id, $payment->post_status );
862
+	return apply_filters('give_is_payment_complete', $ret, $payment_id, $payment->post_status);
863 863
 }
864 864
 
865 865
 /**
@@ -885,49 +885,49 @@  discard block
 block discarded – undo
885 885
  *
886 886
  * @return float $total Total earnings.
887 887
  */
888
-function give_get_total_earnings( $recalculate = false ) {
888
+function give_get_total_earnings($recalculate = false) {
889 889
 
890
-	$total = get_option( 'give_earnings_total', 0 );
890
+	$total = get_option('give_earnings_total', 0);
891 891
 
892 892
 	// Calculate total earnings.
893
-	if ( ! $total || $recalculate ) {
893
+	if ( ! $total || $recalculate) {
894 894
 		global $wpdb;
895 895
 
896 896
 		$total = (float) 0;
897 897
 
898
-		$args = apply_filters( 'give_get_total_earnings_args', array(
898
+		$args = apply_filters('give_get_total_earnings_args', array(
899 899
 			'offset' => 0,
900
-			'number' => - 1,
901
-			'status' => array( 'publish' ),
900
+			'number' => -1,
901
+			'status' => array('publish'),
902 902
 			'fields' => 'ids',
903
-		) );
903
+		));
904 904
 
905
-		$payments = give_get_payments( $args );
906
-		if ( $payments ) {
905
+		$payments = give_get_payments($args);
906
+		if ($payments) {
907 907
 
908 908
 			/**
909 909
 			 * If performing a donation, we need to skip the very last payment in the database,
910 910
 			 * since it calls give_increase_total_earnings() on completion,
911 911
 			 * which results in duplicated earnings for the very first donation.
912 912
 			 */
913
-			if ( did_action( 'give_update_payment_status' ) ) {
914
-				array_pop( $payments );
913
+			if (did_action('give_update_payment_status')) {
914
+				array_pop($payments);
915 915
 			}
916 916
 
917
-			if ( ! empty( $payments ) ) {
918
-				$payments = implode( ',', $payments );
919
-				$total    += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})" );
917
+			if ( ! empty($payments)) {
918
+				$payments = implode(',', $payments);
919
+				$total += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})");
920 920
 			}
921 921
 		}
922 922
 
923
-		update_option( 'give_earnings_total', $total, 'no' );
923
+		update_option('give_earnings_total', $total, 'no');
924 924
 	}
925 925
 
926
-	if ( $total < 0 ) {
926
+	if ($total < 0) {
927 927
 		$total = 0; // Don't ever show negative earnings.
928 928
 	}
929 929
 
930
-	return apply_filters( 'give_total_earnings', round( $total, give_get_price_decimals() ), $total );
930
+	return apply_filters('give_total_earnings', round($total, give_get_price_decimals()), $total);
931 931
 }
932 932
 
933 933
 /**
@@ -939,10 +939,10 @@  discard block
 block discarded – undo
939 939
  *
940 940
  * @return float $total Total earnings.
941 941
  */
942
-function give_increase_total_earnings( $amount = 0 ) {
942
+function give_increase_total_earnings($amount = 0) {
943 943
 	$total = give_get_total_earnings();
944 944
 	$total += $amount;
945
-	update_option( 'give_earnings_total', $total );
945
+	update_option('give_earnings_total', $total);
946 946
 
947 947
 	return $total;
948 948
 }
@@ -956,13 +956,13 @@  discard block
 block discarded – undo
956 956
  *
957 957
  * @return float $total Total earnings.
958 958
  */
959
-function give_decrease_total_earnings( $amount = 0 ) {
959
+function give_decrease_total_earnings($amount = 0) {
960 960
 	$total = give_get_total_earnings();
961 961
 	$total -= $amount;
962
-	if ( $total < 0 ) {
962
+	if ($total < 0) {
963 963
 		$total = 0;
964 964
 	}
965
-	update_option( 'give_earnings_total', $total );
965
+	update_option('give_earnings_total', $total);
966 966
 
967 967
 	return $total;
968 968
 }
@@ -978,10 +978,10 @@  discard block
 block discarded – undo
978 978
  *
979 979
  * @return mixed $meta Payment Meta.
980 980
  */
981
-function give_get_payment_meta( $payment_id = 0, $meta_key = '_give_payment_meta', $single = true ) {
982
-	$payment = new Give_Payment( $payment_id );
981
+function give_get_payment_meta($payment_id = 0, $meta_key = '_give_payment_meta', $single = true) {
982
+	$payment = new Give_Payment($payment_id);
983 983
 
984
-	return $payment->get_meta( $meta_key, $single );
984
+	return $payment->get_meta($meta_key, $single);
985 985
 }
986 986
 
987 987
 /**
@@ -994,10 +994,10 @@  discard block
 block discarded – undo
994 994
  *
995 995
  * @return mixed Meta ID if successful, false if unsuccessful.
996 996
  */
997
-function give_update_payment_meta( $payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '' ) {
998
-	$payment = new Give_Payment( $payment_id );
997
+function give_update_payment_meta($payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '') {
998
+	$payment = new Give_Payment($payment_id);
999 999
 
1000
-	return $payment->update_meta( $meta_key, $meta_value, $prev_value );
1000
+	return $payment->update_meta($meta_key, $meta_value, $prev_value);
1001 1001
 }
1002 1002
 
1003 1003
 /**
@@ -1009,8 +1009,8 @@  discard block
 block discarded – undo
1009 1009
  *
1010 1010
  * @return array $user_info User Info Meta Values.
1011 1011
  */
1012
-function give_get_payment_meta_user_info( $payment_id ) {
1013
-	$payment = new Give_Payment( $payment_id );
1012
+function give_get_payment_meta_user_info($payment_id) {
1013
+	$payment = new Give_Payment($payment_id);
1014 1014
 
1015 1015
 	return $payment->user_info;
1016 1016
 }
@@ -1026,8 +1026,8 @@  discard block
 block discarded – undo
1026 1026
  *
1027 1027
  * @return int $form_id Form ID.
1028 1028
  */
1029
-function give_get_payment_form_id( $payment_id ) {
1030
-	$payment = new Give_Payment( $payment_id );
1029
+function give_get_payment_form_id($payment_id) {
1030
+	$payment = new Give_Payment($payment_id);
1031 1031
 
1032 1032
 	return $payment->form_id;
1033 1033
 }
@@ -1041,8 +1041,8 @@  discard block
 block discarded – undo
1041 1041
  *
1042 1042
  * @return string $email User email.
1043 1043
  */
1044
-function give_get_payment_user_email( $payment_id ) {
1045
-	$payment = new Give_Payment( $payment_id );
1044
+function give_get_payment_user_email($payment_id) {
1045
+	$payment = new Give_Payment($payment_id);
1046 1046
 
1047 1047
 	return $payment->email;
1048 1048
 }
@@ -1056,11 +1056,11 @@  discard block
 block discarded – undo
1056 1056
  *
1057 1057
  * @return bool $is_guest_payment If the payment is associated with a user (false) or not (true)
1058 1058
  */
1059
-function give_is_guest_payment( $payment_id ) {
1060
-	$payment_user_id  = give_get_payment_user_id( $payment_id );
1061
-	$is_guest_payment = ! empty( $payment_user_id ) && $payment_user_id > 0 ? false : true;
1059
+function give_is_guest_payment($payment_id) {
1060
+	$payment_user_id  = give_get_payment_user_id($payment_id);
1061
+	$is_guest_payment = ! empty($payment_user_id) && $payment_user_id > 0 ? false : true;
1062 1062
 
1063
-	return (bool) apply_filters( 'give_is_guest_payment', $is_guest_payment, $payment_id );
1063
+	return (bool) apply_filters('give_is_guest_payment', $is_guest_payment, $payment_id);
1064 1064
 }
1065 1065
 
1066 1066
 /**
@@ -1072,8 +1072,8 @@  discard block
 block discarded – undo
1072 1072
  *
1073 1073
  * @return int $user_id User ID.
1074 1074
  */
1075
-function give_get_payment_user_id( $payment_id ) {
1076
-	$payment = new Give_Payment( $payment_id );
1075
+function give_get_payment_user_id($payment_id) {
1076
+	$payment = new Give_Payment($payment_id);
1077 1077
 
1078 1078
 	return $payment->user_id;
1079 1079
 }
@@ -1087,8 +1087,8 @@  discard block
 block discarded – undo
1087 1087
  *
1088 1088
  * @return int $payment->customer_id Donor ID.
1089 1089
  */
1090
-function give_get_payment_donor_id( $payment_id ) {
1091
-	$payment = new Give_Payment( $payment_id );
1090
+function give_get_payment_donor_id($payment_id) {
1091
+	$payment = new Give_Payment($payment_id);
1092 1092
 
1093 1093
 	return $payment->customer_id;
1094 1094
 }
@@ -1102,8 +1102,8 @@  discard block
 block discarded – undo
1102 1102
  *
1103 1103
  * @return string $ip User IP.
1104 1104
  */
1105
-function give_get_payment_user_ip( $payment_id ) {
1106
-	$payment = new Give_Payment( $payment_id );
1105
+function give_get_payment_user_ip($payment_id) {
1106
+	$payment = new Give_Payment($payment_id);
1107 1107
 
1108 1108
 	return $payment->ip;
1109 1109
 }
@@ -1117,8 +1117,8 @@  discard block
 block discarded – undo
1117 1117
  *
1118 1118
  * @return string $date The date the payment was completed.
1119 1119
  */
1120
-function give_get_payment_completed_date( $payment_id = 0 ) {
1121
-	$payment = new Give_Payment( $payment_id );
1120
+function give_get_payment_completed_date($payment_id = 0) {
1121
+	$payment = new Give_Payment($payment_id);
1122 1122
 
1123 1123
 	return $payment->completed_date;
1124 1124
 }
@@ -1132,8 +1132,8 @@  discard block
 block discarded – undo
1132 1132
  *
1133 1133
  * @return string $gateway Gateway.
1134 1134
  */
1135
-function give_get_payment_gateway( $payment_id ) {
1136
-	$payment = new Give_Payment( $payment_id );
1135
+function give_get_payment_gateway($payment_id) {
1136
+	$payment = new Give_Payment($payment_id);
1137 1137
 
1138 1138
 	return $payment->gateway;
1139 1139
 }
@@ -1147,8 +1147,8 @@  discard block
 block discarded – undo
1147 1147
  *
1148 1148
  * @return string $currency The currency code.
1149 1149
  */
1150
-function give_get_payment_currency_code( $payment_id = 0 ) {
1151
-	$payment = new Give_Payment( $payment_id );
1150
+function give_get_payment_currency_code($payment_id = 0) {
1151
+	$payment = new Give_Payment($payment_id);
1152 1152
 
1153 1153
 	return $payment->currency;
1154 1154
 }
@@ -1162,10 +1162,10 @@  discard block
 block discarded – undo
1162 1162
  *
1163 1163
  * @return string $currency The currency name.
1164 1164
  */
1165
-function give_get_payment_currency( $payment_id = 0 ) {
1166
-	$currency = give_get_payment_currency_code( $payment_id );
1165
+function give_get_payment_currency($payment_id = 0) {
1166
+	$currency = give_get_payment_currency_code($payment_id);
1167 1167
 
1168
-	return apply_filters( 'give_payment_currency', give_get_currency_name( $currency ), $payment_id );
1168
+	return apply_filters('give_payment_currency', give_get_currency_name($currency), $payment_id);
1169 1169
 }
1170 1170
 
1171 1171
 /**
@@ -1177,8 +1177,8 @@  discard block
 block discarded – undo
1177 1177
  *
1178 1178
  * @return string $key Donation key.
1179 1179
  */
1180
-function give_get_payment_key( $payment_id = 0 ) {
1181
-	$payment = new Give_Payment( $payment_id );
1180
+function give_get_payment_key($payment_id = 0) {
1181
+	$payment = new Give_Payment($payment_id);
1182 1182
 
1183 1183
 	return $payment->key;
1184 1184
 }
@@ -1194,8 +1194,8 @@  discard block
 block discarded – undo
1194 1194
  *
1195 1195
  * @return string $number Payment order number.
1196 1196
  */
1197
-function give_get_payment_number( $payment_id = 0 ) {
1198
-	$payment = new Give_Payment( $payment_id );
1197
+function give_get_payment_number($payment_id = 0) {
1198
+	$payment = new Give_Payment($payment_id);
1199 1199
 
1200 1200
 	return $payment->number;
1201 1201
 }
@@ -1209,23 +1209,23 @@  discard block
 block discarded – undo
1209 1209
  *
1210 1210
  * @return string      The formatted payment number.
1211 1211
  */
1212
-function give_format_payment_number( $number ) {
1212
+function give_format_payment_number($number) {
1213 1213
 
1214
-	if ( ! give_get_option( 'enable_sequential' ) ) {
1214
+	if ( ! give_get_option('enable_sequential')) {
1215 1215
 		return $number;
1216 1216
 	}
1217 1217
 
1218
-	if ( ! is_numeric( $number ) ) {
1218
+	if ( ! is_numeric($number)) {
1219 1219
 		return $number;
1220 1220
 	}
1221 1221
 
1222
-	$prefix  = give_get_option( 'sequential_prefix' );
1223
-	$number  = absint( $number );
1224
-	$postfix = give_get_option( 'sequential_postfix' );
1222
+	$prefix  = give_get_option('sequential_prefix');
1223
+	$number  = absint($number);
1224
+	$postfix = give_get_option('sequential_postfix');
1225 1225
 
1226
-	$formatted_number = $prefix . $number . $postfix;
1226
+	$formatted_number = $prefix.$number.$postfix;
1227 1227
 
1228
-	return apply_filters( 'give_format_payment_number', $formatted_number, $prefix, $number, $postfix );
1228
+	return apply_filters('give_format_payment_number', $formatted_number, $prefix, $number, $postfix);
1229 1229
 }
1230 1230
 
1231 1231
 /**
@@ -1239,17 +1239,17 @@  discard block
 block discarded – undo
1239 1239
  */
1240 1240
 function give_get_next_payment_number() {
1241 1241
 
1242
-	if ( ! give_get_option( 'enable_sequential' ) ) {
1242
+	if ( ! give_get_option('enable_sequential')) {
1243 1243
 		return false;
1244 1244
 	}
1245 1245
 
1246
-	$number           = get_option( 'give_last_payment_number' );
1247
-	$start            = give_get_option( 'sequential_start', 1 );
1246
+	$number           = get_option('give_last_payment_number');
1247
+	$start            = give_get_option('sequential_start', 1);
1248 1248
 	$increment_number = true;
1249 1249
 
1250
-	if ( false !== $number ) {
1250
+	if (false !== $number) {
1251 1251
 
1252
-		if ( empty( $number ) ) {
1252
+		if (empty($number)) {
1253 1253
 
1254 1254
 			$number           = $start;
1255 1255
 			$increment_number = false;
@@ -1258,24 +1258,24 @@  discard block
 block discarded – undo
1258 1258
 	} else {
1259 1259
 
1260 1260
 		// This case handles the first addition of the new option, as well as if it get's deleted for any reason.
1261
-		$payments     = new Give_Payments_Query( array(
1261
+		$payments = new Give_Payments_Query(array(
1262 1262
 			'number'  => 1,
1263 1263
 			'order'   => 'DESC',
1264 1264
 			'orderby' => 'ID',
1265 1265
 			'output'  => 'posts',
1266 1266
 			'fields'  => 'ids',
1267
-		) );
1267
+		));
1268 1268
 		$last_payment = $payments->get_payments();
1269 1269
 
1270
-		if ( ! empty( $last_payment ) ) {
1270
+		if ( ! empty($last_payment)) {
1271 1271
 
1272
-			$number = give_get_payment_number( $last_payment[0] );
1272
+			$number = give_get_payment_number($last_payment[0]);
1273 1273
 
1274 1274
 		}
1275 1275
 
1276
-		if ( ! empty( $number ) && $number !== (int) $last_payment[0] ) {
1276
+		if ( ! empty($number) && $number !== (int) $last_payment[0]) {
1277 1277
 
1278
-			$number = give_remove_payment_prefix_postfix( $number );
1278
+			$number = give_remove_payment_prefix_postfix($number);
1279 1279
 
1280 1280
 		} else {
1281 1281
 
@@ -1284,13 +1284,13 @@  discard block
 block discarded – undo
1284 1284
 		}
1285 1285
 	}// End if().
1286 1286
 
1287
-	$increment_number = apply_filters( 'give_increment_payment_number', $increment_number, $number );
1287
+	$increment_number = apply_filters('give_increment_payment_number', $increment_number, $number);
1288 1288
 
1289
-	if ( $increment_number ) {
1290
-		$number ++;
1289
+	if ($increment_number) {
1290
+		$number++;
1291 1291
 	}
1292 1292
 
1293
-	return apply_filters( 'give_get_next_payment_number', $number );
1293
+	return apply_filters('give_get_next_payment_number', $number);
1294 1294
 }
1295 1295
 
1296 1296
 /**
@@ -1302,25 +1302,25 @@  discard block
 block discarded – undo
1302 1302
  *
1303 1303
  * @return string The new Payment number without prefix and postfix.
1304 1304
  */
1305
-function give_remove_payment_prefix_postfix( $number ) {
1305
+function give_remove_payment_prefix_postfix($number) {
1306 1306
 
1307
-	$prefix  = give_get_option( 'sequential_prefix' );
1308
-	$postfix = give_get_option( 'sequential_postfix' );
1307
+	$prefix  = give_get_option('sequential_prefix');
1308
+	$postfix = give_get_option('sequential_postfix');
1309 1309
 
1310 1310
 	// Remove prefix.
1311
-	$number = preg_replace( '/' . $prefix . '/', '', $number, 1 );
1311
+	$number = preg_replace('/'.$prefix.'/', '', $number, 1);
1312 1312
 
1313 1313
 	// Remove the postfix.
1314
-	$length      = strlen( $number );
1315
-	$postfix_pos = strrpos( $number, $postfix );
1316
-	if ( false !== $postfix_pos ) {
1317
-		$number = substr_replace( $number, '', $postfix_pos, $length );
1314
+	$length      = strlen($number);
1315
+	$postfix_pos = strrpos($number, $postfix);
1316
+	if (false !== $postfix_pos) {
1317
+		$number = substr_replace($number, '', $postfix_pos, $length);
1318 1318
 	}
1319 1319
 
1320 1320
 	// Ensure it's a whole number.
1321
-	$number = intval( $number );
1321
+	$number = intval($number);
1322 1322
 
1323
-	return apply_filters( 'give_remove_payment_prefix_postfix', $number, $prefix, $postfix );
1323
+	return apply_filters('give_remove_payment_prefix_postfix', $number, $prefix, $postfix);
1324 1324
 
1325 1325
 }
1326 1326
 
@@ -1338,13 +1338,13 @@  discard block
 block discarded – undo
1338 1338
  *
1339 1339
  * @return string $amount Fully formatted donation amount.
1340 1340
  */
1341
-function give_donation_amount( $donation, $format_args = false ) {
1341
+function give_donation_amount($donation, $format_args = false) {
1342 1342
 	/* @var Give_Payment $donation */
1343
-	if ( ! ( $donation instanceof Give_Payment ) ) {
1344
-		$donation = new Give_Payment( absint( $donation ) );
1343
+	if ( ! ($donation instanceof Give_Payment)) {
1344
+		$donation = new Give_Payment(absint($donation));
1345 1345
 	}
1346 1346
 
1347
-	if ( ! is_array( $format_args ) ) {
1347
+	if ( ! is_array($format_args)) {
1348 1348
 		$format_args = array(
1349 1349
 			'currency' => (bool) $format_args,
1350 1350
 			'amount'   => (bool) $format_args,
@@ -1362,7 +1362,7 @@  discard block
 block discarded – undo
1362 1362
 	$amount           = $donation->total;
1363 1363
 	$formatted_amount = $amount;
1364 1364
 
1365
-	if ( $format_args['amount'] ) {
1365
+	if ($format_args['amount']) {
1366 1366
 		$formatted_amount = give_format_amount(
1367 1367
 			$amount,
1368 1368
 			array(
@@ -1372,8 +1372,8 @@  discard block
 block discarded – undo
1372 1372
 		);
1373 1373
 	}
1374 1374
 
1375
-	if ( $format_args['currency'] ) {
1376
-		$formatted_amount = give_currency_filter( $formatted_amount, $donation->currency );
1375
+	if ($format_args['currency']) {
1376
+		$formatted_amount = give_currency_filter($formatted_amount, $donation->currency);
1377 1377
 	}
1378 1378
 
1379 1379
 	/**
@@ -1385,7 +1385,7 @@  discard block
 block discarded – undo
1385 1385
 	 * @param float  $amount           Donation amount.
1386 1386
 	 * @param int    $donation_id      Donation ID.
1387 1387
 	 */
1388
-	return apply_filters( 'give_donation_amount', (string) $formatted_amount, $amount, $donation );
1388
+	return apply_filters('give_donation_amount', (string) $formatted_amount, $amount, $donation);
1389 1389
 }
1390 1390
 
1391 1391
 /**
@@ -1402,10 +1402,10 @@  discard block
 block discarded – undo
1402 1402
  *
1403 1403
  * @return array Fully formatted payment subtotal.
1404 1404
  */
1405
-function give_payment_subtotal( $payment_id = 0 ) {
1406
-	$subtotal = give_get_payment_subtotal( $payment_id );
1405
+function give_payment_subtotal($payment_id = 0) {
1406
+	$subtotal = give_get_payment_subtotal($payment_id);
1407 1407
 
1408
-	return give_currency_filter( give_format_amount( $subtotal, array( 'sanitize' => false ) ), give_get_payment_currency_code( $payment_id ) );
1408
+	return give_currency_filter(give_format_amount($subtotal, array('sanitize' => false)), give_get_payment_currency_code($payment_id));
1409 1409
 }
1410 1410
 
1411 1411
 /**
@@ -1419,8 +1419,8 @@  discard block
 block discarded – undo
1419 1419
  *
1420 1420
  * @return float $subtotal Subtotal for payment (non formatted).
1421 1421
  */
1422
-function give_get_payment_subtotal( $payment_id = 0 ) {
1423
-	$payment = new Give_Payment( $payment_id );
1422
+function give_get_payment_subtotal($payment_id = 0) {
1423
+	$payment = new Give_Payment($payment_id);
1424 1424
 
1425 1425
 	return $payment->subtotal;
1426 1426
 }
@@ -1434,8 +1434,8 @@  discard block
 block discarded – undo
1434 1434
  *
1435 1435
  * @return string The donation ID.
1436 1436
  */
1437
-function give_get_payment_transaction_id( $payment_id = 0 ) {
1438
-	$payment = new Give_Payment( $payment_id );
1437
+function give_get_payment_transaction_id($payment_id = 0) {
1438
+	$payment = new Give_Payment($payment_id);
1439 1439
 
1440 1440
 	return $payment->transaction_id;
1441 1441
 }
@@ -1450,15 +1450,15 @@  discard block
 block discarded – undo
1450 1450
  *
1451 1451
  * @return bool|mixed
1452 1452
  */
1453
-function give_set_payment_transaction_id( $payment_id = 0, $transaction_id = '' ) {
1453
+function give_set_payment_transaction_id($payment_id = 0, $transaction_id = '') {
1454 1454
 
1455
-	if ( empty( $payment_id ) || empty( $transaction_id ) ) {
1455
+	if (empty($payment_id) || empty($transaction_id)) {
1456 1456
 		return false;
1457 1457
 	}
1458 1458
 
1459
-	$transaction_id = apply_filters( 'give_set_payment_transaction_id', $transaction_id, $payment_id );
1459
+	$transaction_id = apply_filters('give_set_payment_transaction_id', $transaction_id, $payment_id);
1460 1460
 
1461
-	return give_update_payment_meta( $payment_id, '_give_payment_transaction_id', $transaction_id );
1461
+	return give_update_payment_meta($payment_id, '_give_payment_transaction_id', $transaction_id);
1462 1462
 }
1463 1463
 
1464 1464
 /**
@@ -1471,12 +1471,12 @@  discard block
 block discarded – undo
1471 1471
  *
1472 1472
  * @return int $purchase Donation ID.
1473 1473
  */
1474
-function give_get_purchase_id_by_key( $key ) {
1474
+function give_get_purchase_id_by_key($key) {
1475 1475
 	global $wpdb;
1476 1476
 
1477
-	$purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key ) );
1477
+	$purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key));
1478 1478
 
1479
-	if ( $purchase != null ) {
1479
+	if ($purchase != null) {
1480 1480
 		return $purchase;
1481 1481
 	}
1482 1482
 
@@ -1494,12 +1494,12 @@  discard block
 block discarded – undo
1494 1494
  *
1495 1495
  * @return int $purchase Donation ID.
1496 1496
  */
1497
-function give_get_purchase_id_by_transaction_id( $key ) {
1497
+function give_get_purchase_id_by_transaction_id($key) {
1498 1498
 	global $wpdb;
1499 1499
 
1500
-	$purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key ) );
1500
+	$purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key));
1501 1501
 
1502
-	if ( $purchase != null ) {
1502
+	if ($purchase != null) {
1503 1503
 		return $purchase;
1504 1504
 	}
1505 1505
 
@@ -1516,23 +1516,23 @@  discard block
 block discarded – undo
1516 1516
  *
1517 1517
  * @return array $notes Donation Notes
1518 1518
  */
1519
-function give_get_payment_notes( $payment_id = 0, $search = '' ) {
1519
+function give_get_payment_notes($payment_id = 0, $search = '') {
1520 1520
 
1521
-	if ( empty( $payment_id ) && empty( $search ) ) {
1521
+	if (empty($payment_id) && empty($search)) {
1522 1522
 		return false;
1523 1523
 	}
1524 1524
 
1525
-	remove_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1526
-	remove_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10 );
1525
+	remove_action('pre_get_comments', 'give_hide_payment_notes', 10);
1526
+	remove_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10);
1527 1527
 
1528
-	$notes = get_comments( array(
1528
+	$notes = get_comments(array(
1529 1529
 		'post_id' => $payment_id,
1530 1530
 		'order'   => 'ASC',
1531 1531
 		'search'  => $search,
1532
-	) );
1532
+	));
1533 1533
 
1534
-	add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1535
-	add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 );
1534
+	add_action('pre_get_comments', 'give_hide_payment_notes', 10);
1535
+	add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2);
1536 1536
 
1537 1537
 	return $notes;
1538 1538
 }
@@ -1548,8 +1548,8 @@  discard block
 block discarded – undo
1548 1548
  *
1549 1549
  * @return int The new note ID
1550 1550
  */
1551
-function give_insert_payment_note( $payment_id = 0, $note = '' ) {
1552
-	if ( empty( $payment_id ) ) {
1551
+function give_insert_payment_note($payment_id = 0, $note = '') {
1552
+	if (empty($payment_id)) {
1553 1553
 		return false;
1554 1554
 	}
1555 1555
 
@@ -1561,14 +1561,14 @@  discard block
 block discarded – undo
1561 1561
 	 *
1562 1562
 	 * @since 1.0
1563 1563
 	 */
1564
-	do_action( 'give_pre_insert_payment_note', $payment_id, $note );
1564
+	do_action('give_pre_insert_payment_note', $payment_id, $note);
1565 1565
 
1566
-	$note_id = wp_insert_comment( wp_filter_comment( array(
1566
+	$note_id = wp_insert_comment(wp_filter_comment(array(
1567 1567
 		'comment_post_ID'      => $payment_id,
1568 1568
 		'comment_content'      => $note,
1569 1569
 		'user_id'              => is_admin() ? get_current_user_id() : 0,
1570
-		'comment_date'         => current_time( 'mysql' ),
1571
-		'comment_date_gmt'     => current_time( 'mysql', 1 ),
1570
+		'comment_date'         => current_time('mysql'),
1571
+		'comment_date_gmt'     => current_time('mysql', 1),
1572 1572
 		'comment_approved'     => 1,
1573 1573
 		'comment_parent'       => 0,
1574 1574
 		'comment_author'       => '',
@@ -1577,7 +1577,7 @@  discard block
 block discarded – undo
1577 1577
 		'comment_author_email' => '',
1578 1578
 		'comment_type'         => 'give_payment_note',
1579 1579
 
1580
-	) ) );
1580
+	)));
1581 1581
 
1582 1582
 	/**
1583 1583
 	 * Fires after payment note inserted.
@@ -1588,7 +1588,7 @@  discard block
 block discarded – undo
1588 1588
 	 *
1589 1589
 	 * @since 1.0
1590 1590
 	 */
1591
-	do_action( 'give_insert_payment_note', $note_id, $payment_id, $note );
1591
+	do_action('give_insert_payment_note', $note_id, $payment_id, $note);
1592 1592
 
1593 1593
 	return $note_id;
1594 1594
 }
@@ -1603,8 +1603,8 @@  discard block
 block discarded – undo
1603 1603
  *
1604 1604
  * @return bool True on success, false otherwise.
1605 1605
  */
1606
-function give_delete_payment_note( $comment_id = 0, $payment_id = 0 ) {
1607
-	if ( empty( $comment_id ) ) {
1606
+function give_delete_payment_note($comment_id = 0, $payment_id = 0) {
1607
+	if (empty($comment_id)) {
1608 1608
 		return false;
1609 1609
 	}
1610 1610
 
@@ -1616,9 +1616,9 @@  discard block
 block discarded – undo
1616 1616
 	 *
1617 1617
 	 * @since 1.0
1618 1618
 	 */
1619
-	do_action( 'give_pre_delete_payment_note', $comment_id, $payment_id );
1619
+	do_action('give_pre_delete_payment_note', $comment_id, $payment_id);
1620 1620
 
1621
-	$ret = wp_delete_comment( $comment_id, true );
1621
+	$ret = wp_delete_comment($comment_id, true);
1622 1622
 
1623 1623
 	/**
1624 1624
 	 * Fires after donation note deleted.
@@ -1628,7 +1628,7 @@  discard block
 block discarded – undo
1628 1628
 	 *
1629 1629
 	 * @since 1.0
1630 1630
 	 */
1631
-	do_action( 'give_post_delete_payment_note', $comment_id, $payment_id );
1631
+	do_action('give_post_delete_payment_note', $comment_id, $payment_id);
1632 1632
 
1633 1633
 	return $ret;
1634 1634
 }
@@ -1643,32 +1643,32 @@  discard block
 block discarded – undo
1643 1643
  *
1644 1644
  * @return string
1645 1645
  */
1646
-function give_get_payment_note_html( $note, $payment_id = 0 ) {
1646
+function give_get_payment_note_html($note, $payment_id = 0) {
1647 1647
 
1648
-	if ( is_numeric( $note ) ) {
1649
-		$note = get_comment( $note );
1648
+	if (is_numeric($note)) {
1649
+		$note = get_comment($note);
1650 1650
 	}
1651 1651
 
1652
-	if ( ! empty( $note->user_id ) ) {
1653
-		$user = get_userdata( $note->user_id );
1652
+	if ( ! empty($note->user_id)) {
1653
+		$user = get_userdata($note->user_id);
1654 1654
 		$user = $user->display_name;
1655 1655
 	} else {
1656
-		$user = __( 'System', 'give' );
1656
+		$user = __('System', 'give');
1657 1657
 	}
1658 1658
 
1659
-	$date_format = give_date_format() . ', ' . get_option( 'time_format' );
1659
+	$date_format = give_date_format().', '.get_option('time_format');
1660 1660
 
1661
-	$delete_note_url = wp_nonce_url( add_query_arg( array(
1661
+	$delete_note_url = wp_nonce_url(add_query_arg(array(
1662 1662
 		'give-action' => 'delete_payment_note',
1663 1663
 		'note_id'     => $note->comment_ID,
1664 1664
 		'payment_id'  => $payment_id,
1665
-	) ), 'give_delete_payment_note_' . $note->comment_ID );
1665
+	)), 'give_delete_payment_note_'.$note->comment_ID);
1666 1666
 
1667
-	$note_html = '<div class="give-payment-note" id="give-payment-note-' . $note->comment_ID . '">';
1667
+	$note_html = '<div class="give-payment-note" id="give-payment-note-'.$note->comment_ID.'">';
1668 1668
 	$note_html .= '<p>';
1669
-	$note_html .= '<strong>' . $user . '</strong>&nbsp;&ndash;&nbsp;<span style="color:#aaa;font-style:italic;">' . date_i18n( $date_format, strtotime( $note->comment_date ) ) . '</span><br/>';
1669
+	$note_html .= '<strong>'.$user.'</strong>&nbsp;&ndash;&nbsp;<span style="color:#aaa;font-style:italic;">'.date_i18n($date_format, strtotime($note->comment_date)).'</span><br/>';
1670 1670
 	$note_html .= $note->comment_content;
1671
-	$note_html .= '&nbsp;&ndash;&nbsp;<a href="' . esc_url( $delete_note_url ) . '" class="give-delete-payment-note" data-note-id="' . absint( $note->comment_ID ) . '" data-payment-id="' . absint( $payment_id ) . '" aria-label="' . __( 'Delete this donation note.', 'give' ) . '">' . __( 'Delete', 'give' ) . '</a>';
1671
+	$note_html .= '&nbsp;&ndash;&nbsp;<a href="'.esc_url($delete_note_url).'" class="give-delete-payment-note" data-note-id="'.absint($note->comment_ID).'" data-payment-id="'.absint($payment_id).'" aria-label="'.__('Delete this donation note.', 'give').'">'.__('Delete', 'give').'</a>';
1672 1672
 	$note_html .= '</p>';
1673 1673
 	$note_html .= '</div>';
1674 1674
 
@@ -1686,18 +1686,18 @@  discard block
 block discarded – undo
1686 1686
  *
1687 1687
  * @return void
1688 1688
  */
1689
-function give_hide_payment_notes( $query ) {
1690
-	if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '>=' ) ) {
1691
-		$types = isset( $query->query_vars['type__not_in'] ) ? $query->query_vars['type__not_in'] : array();
1692
-		if ( ! is_array( $types ) ) {
1693
-			$types = array( $types );
1689
+function give_hide_payment_notes($query) {
1690
+	if (version_compare(floatval(get_bloginfo('version')), '4.1', '>=')) {
1691
+		$types = isset($query->query_vars['type__not_in']) ? $query->query_vars['type__not_in'] : array();
1692
+		if ( ! is_array($types)) {
1693
+			$types = array($types);
1694 1694
 		}
1695 1695
 		$types[]                           = 'give_payment_note';
1696 1696
 		$query->query_vars['type__not_in'] = $types;
1697 1697
 	}
1698 1698
 }
1699 1699
 
1700
-add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1700
+add_action('pre_get_comments', 'give_hide_payment_notes', 10);
1701 1701
 
1702 1702
 /**
1703 1703
  * Exclude notes (comments) on give_payment post type from showing in Recent Comments widgets
@@ -1709,15 +1709,15 @@  discard block
 block discarded – undo
1709 1709
  *
1710 1710
  * @return array $clauses Updated comment clauses.
1711 1711
  */
1712
-function give_hide_payment_notes_pre_41( $clauses, $wp_comment_query ) {
1713
-	if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '<' ) ) {
1712
+function give_hide_payment_notes_pre_41($clauses, $wp_comment_query) {
1713
+	if (version_compare(floatval(get_bloginfo('version')), '4.1', '<')) {
1714 1714
 		$clauses['where'] .= ' AND comment_type != "give_payment_note"';
1715 1715
 	}
1716 1716
 
1717 1717
 	return $clauses;
1718 1718
 }
1719 1719
 
1720
-add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 );
1720
+add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2);
1721 1721
 
1722 1722
 
1723 1723
 /**
@@ -1730,15 +1730,15 @@  discard block
 block discarded – undo
1730 1730
  *
1731 1731
  * @return string $where
1732 1732
  */
1733
-function give_hide_payment_notes_from_feeds( $where, $wp_comment_query ) {
1733
+function give_hide_payment_notes_from_feeds($where, $wp_comment_query) {
1734 1734
 	global $wpdb;
1735 1735
 
1736
-	$where .= $wpdb->prepare( ' AND comment_type != %s', 'give_payment_note' );
1736
+	$where .= $wpdb->prepare(' AND comment_type != %s', 'give_payment_note');
1737 1737
 
1738 1738
 	return $where;
1739 1739
 }
1740 1740
 
1741
-add_filter( 'comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2 );
1741
+add_filter('comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2);
1742 1742
 
1743 1743
 
1744 1744
 /**
@@ -1752,32 +1752,32 @@  discard block
 block discarded – undo
1752 1752
  *
1753 1753
  * @return array|object Array of comment counts.
1754 1754
  */
1755
-function give_remove_payment_notes_in_comment_counts( $stats, $post_id ) {
1755
+function give_remove_payment_notes_in_comment_counts($stats, $post_id) {
1756 1756
 	global $wpdb, $pagenow;
1757 1757
 
1758
-	if ( 'index.php' != $pagenow ) {
1758
+	if ('index.php' != $pagenow) {
1759 1759
 		return $stats;
1760 1760
 	}
1761 1761
 
1762 1762
 	$post_id = (int) $post_id;
1763 1763
 
1764
-	if ( apply_filters( 'give_count_payment_notes_in_comments', false ) ) {
1764
+	if (apply_filters('give_count_payment_notes_in_comments', false)) {
1765 1765
 		return $stats;
1766 1766
 	}
1767 1767
 
1768
-	$stats = wp_cache_get( "comments-{$post_id}", 'counts' );
1768
+	$stats = wp_cache_get("comments-{$post_id}", 'counts');
1769 1769
 
1770
-	if ( false !== $stats ) {
1770
+	if (false !== $stats) {
1771 1771
 		return $stats;
1772 1772
 	}
1773 1773
 
1774 1774
 	$where = 'WHERE comment_type != "give_payment_note"';
1775 1775
 
1776
-	if ( $post_id > 0 ) {
1777
-		$where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id );
1776
+	if ($post_id > 0) {
1777
+		$where .= $wpdb->prepare(' AND comment_post_ID = %d', $post_id);
1778 1778
 	}
1779 1779
 
1780
-	$count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A );
1780
+	$count = $wpdb->get_results("SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A);
1781 1781
 
1782 1782
 	$total    = 0;
1783 1783
 	$approved = array(
@@ -1787,30 +1787,30 @@  discard block
 block discarded – undo
1787 1787
 		'trash'        => 'trash',
1788 1788
 		'post-trashed' => 'post-trashed',
1789 1789
 	);
1790
-	foreach ( (array) $count as $row ) {
1790
+	foreach ((array) $count as $row) {
1791 1791
 		// Don't count post-trashed toward totals.
1792
-		if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) {
1792
+		if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) {
1793 1793
 			$total += $row['num_comments'];
1794 1794
 		}
1795
-		if ( isset( $approved[ $row['comment_approved'] ] ) ) {
1796
-			$stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments'];
1795
+		if (isset($approved[$row['comment_approved']])) {
1796
+			$stats[$approved[$row['comment_approved']]] = $row['num_comments'];
1797 1797
 		}
1798 1798
 	}
1799 1799
 
1800 1800
 	$stats['total_comments'] = $total;
1801
-	foreach ( $approved as $key ) {
1802
-		if ( empty( $stats[ $key ] ) ) {
1803
-			$stats[ $key ] = 0;
1801
+	foreach ($approved as $key) {
1802
+		if (empty($stats[$key])) {
1803
+			$stats[$key] = 0;
1804 1804
 		}
1805 1805
 	}
1806 1806
 
1807 1807
 	$stats = (object) $stats;
1808
-	wp_cache_set( "comments-{$post_id}", $stats, 'counts' );
1808
+	wp_cache_set("comments-{$post_id}", $stats, 'counts');
1809 1809
 
1810 1810
 	return $stats;
1811 1811
 }
1812 1812
 
1813
-add_filter( 'wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2 );
1813
+add_filter('wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2);
1814 1814
 
1815 1815
 
1816 1816
 /**
@@ -1823,9 +1823,9 @@  discard block
 block discarded – undo
1823 1823
  *
1824 1824
  * @return string $where Modified where clause.
1825 1825
  */
1826
-function give_filter_where_older_than_week( $where = '' ) {
1826
+function give_filter_where_older_than_week($where = '') {
1827 1827
 	// Payments older than one week.
1828
-	$start = date( 'Y-m-d', strtotime( '-7 days' ) );
1828
+	$start = date('Y-m-d', strtotime('-7 days'));
1829 1829
 	$where .= " AND post_date <= '{$start}'";
1830 1830
 
1831 1831
 	return $where;
@@ -1845,38 +1845,38 @@  discard block
 block discarded – undo
1845 1845
  *
1846 1846
  * @return string $form_title Returns the full title if $only_level is false, otherwise returns the levels title.
1847 1847
  */
1848
-function give_get_payment_form_title( $payment_meta, $only_level = false, $separator = '' ) {
1848
+function give_get_payment_form_title($payment_meta, $only_level = false, $separator = '') {
1849 1849
 
1850
-	$form_id    = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0;
1851
-	$price_id   = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null;
1852
-	$form_title = isset( $payment_meta['form_title'] ) ? $payment_meta['form_title'] : '';
1850
+	$form_id    = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0;
1851
+	$price_id   = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null;
1852
+	$form_title = isset($payment_meta['form_title']) ? $payment_meta['form_title'] : '';
1853 1853
 
1854
-	if ( $only_level == true ) {
1854
+	if ($only_level == true) {
1855 1855
 		$form_title = '';
1856 1856
 	}
1857 1857
 
1858 1858
 	// If multi-level, append to the form title.
1859
-	if ( give_has_variable_prices( $form_id ) ) {
1859
+	if (give_has_variable_prices($form_id)) {
1860 1860
 
1861 1861
 		// Only add separator if there is a form title.
1862
-		if ( ! empty( $form_title ) ) {
1863
-			$form_title .= ' ' . $separator . ' ';
1862
+		if ( ! empty($form_title)) {
1863
+			$form_title .= ' '.$separator.' ';
1864 1864
 		}
1865 1865
 
1866 1866
 		$form_title .= '<span class="donation-level-text-wrap">';
1867 1867
 
1868
-		if ( 'custom' === $price_id ) {
1869
-			$custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true );
1870
-			$form_title         .= ! empty( $custom_amount_text ) ? $custom_amount_text : __( 'Custom Amount', 'give' );
1868
+		if ('custom' === $price_id) {
1869
+			$custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true);
1870
+			$form_title .= ! empty($custom_amount_text) ? $custom_amount_text : __('Custom Amount', 'give');
1871 1871
 		} else {
1872
-			$form_title .= give_get_price_option_name( $form_id, $price_id );
1872
+			$form_title .= give_get_price_option_name($form_id, $price_id);
1873 1873
 		}
1874 1874
 
1875 1875
 		$form_title .= '</span>';
1876 1876
 
1877 1877
 	}
1878 1878
 
1879
-	return apply_filters( 'give_get_payment_form_title', $form_title, $payment_meta );
1879
+	return apply_filters('give_get_payment_form_title', $form_title, $payment_meta);
1880 1880
 
1881 1881
 }
1882 1882
 
@@ -1890,19 +1890,19 @@  discard block
 block discarded – undo
1890 1890
  *
1891 1891
  * @return string $price_id
1892 1892
  */
1893
-function give_get_price_id( $form_id, $price ) {
1893
+function give_get_price_id($form_id, $price) {
1894 1894
 	$price_id = null;
1895 1895
 
1896
-	if ( give_has_variable_prices( $form_id ) ) {
1896
+	if (give_has_variable_prices($form_id)) {
1897 1897
 
1898
-		$levels = give_get_meta( $form_id, '_give_donation_levels', true );
1898
+		$levels = give_get_meta($form_id, '_give_donation_levels', true);
1899 1899
 
1900
-		foreach ( $levels as $level ) {
1900
+		foreach ($levels as $level) {
1901 1901
 
1902
-			$level_amount = give_maybe_sanitize_amount( $level['_give_amount'] );
1902
+			$level_amount = give_maybe_sanitize_amount($level['_give_amount']);
1903 1903
 
1904 1904
 			// Check that this indeed the recurring price.
1905
-			if ( $level_amount == $price ) {
1905
+			if ($level_amount == $price) {
1906 1906
 
1907 1907
 				$price_id = $level['_give_id']['level_id'];
1908 1908
 				break;
@@ -1910,13 +1910,13 @@  discard block
 block discarded – undo
1910 1910
 			}
1911 1911
 		}
1912 1912
 
1913
-		if ( is_null( $price_id ) && give_is_custom_price_mode( $form_id ) ) {
1913
+		if (is_null($price_id) && give_is_custom_price_mode($form_id)) {
1914 1914
 			$price_id = 'custom';
1915 1915
 		}
1916 1916
 	}
1917 1917
 
1918 1918
 	// Price ID must be numeric or string.
1919
-	$price_id = ! is_numeric( $price_id ) && ! is_string( $price_id ) ? 0 : $price_id;
1919
+	$price_id = ! is_numeric($price_id) && ! is_string($price_id) ? 0 : $price_id;
1920 1920
 
1921 1921
 	return $price_id;
1922 1922
 }
@@ -1934,10 +1934,10 @@  discard block
 block discarded – undo
1934 1934
  *
1935 1935
  * @return string
1936 1936
  */
1937
-function give_get_form_dropdown( $args = array(), $echo = false ) {
1938
-	$form_dropdown_html = Give()->html->forms_dropdown( $args );
1937
+function give_get_form_dropdown($args = array(), $echo = false) {
1938
+	$form_dropdown_html = Give()->html->forms_dropdown($args);
1939 1939
 
1940
-	if ( ! $echo ) {
1940
+	if ( ! $echo) {
1941 1941
 		return $form_dropdown_html;
1942 1942
 	}
1943 1943
 
@@ -1954,17 +1954,17 @@  discard block
 block discarded – undo
1954 1954
  *
1955 1955
  * @return string|bool
1956 1956
  */
1957
-function give_get_form_variable_price_dropdown( $args = array(), $echo = false ) {
1957
+function give_get_form_variable_price_dropdown($args = array(), $echo = false) {
1958 1958
 
1959 1959
 	// Check for give form id.
1960
-	if ( empty( $args['id'] ) ) {
1960
+	if (empty($args['id'])) {
1961 1961
 		return false;
1962 1962
 	}
1963 1963
 
1964
-	$form = new Give_Donate_Form( $args['id'] );
1964
+	$form = new Give_Donate_Form($args['id']);
1965 1965
 
1966 1966
 	// Check if form has variable prices or not.
1967
-	if ( ! $form->ID || ! $form->has_variable_prices() ) {
1967
+	if ( ! $form->ID || ! $form->has_variable_prices()) {
1968 1968
 		return false;
1969 1969
 	}
1970 1970
 
@@ -1972,24 +1972,24 @@  discard block
 block discarded – undo
1972 1972
 	$variable_price_options = array();
1973 1973
 
1974 1974
 	// Check if multi donation form support custom donation or not.
1975
-	if ( $form->is_custom_price_mode() ) {
1976
-		$variable_price_options['custom'] = _x( 'Custom', 'custom donation dropdown item', 'give' );
1975
+	if ($form->is_custom_price_mode()) {
1976
+		$variable_price_options['custom'] = _x('Custom', 'custom donation dropdown item', 'give');
1977 1977
 	}
1978 1978
 
1979 1979
 	// Get variable price and ID from variable price array.
1980
-	foreach ( $variable_prices as $variable_price ) {
1981
-		$variable_price_options[ $variable_price['_give_id']['level_id'] ] = ! empty( $variable_price['_give_text'] ) ? $variable_price['_give_text'] : give_currency_filter( give_format_amount( $variable_price['_give_amount'], array( 'sanitize' => false ) ) );
1980
+	foreach ($variable_prices as $variable_price) {
1981
+		$variable_price_options[$variable_price['_give_id']['level_id']] = ! empty($variable_price['_give_text']) ? $variable_price['_give_text'] : give_currency_filter(give_format_amount($variable_price['_give_amount'], array('sanitize' => false)));
1982 1982
 	}
1983 1983
 
1984 1984
 	// Update options.
1985
-	$args = array_merge( $args, array(
1985
+	$args = array_merge($args, array(
1986 1986
 		'options' => $variable_price_options,
1987
-	) );
1987
+	));
1988 1988
 
1989 1989
 	// Generate select html.
1990
-	$form_dropdown_html = Give()->html->select( $args );
1990
+	$form_dropdown_html = Give()->html->select($args);
1991 1991
 
1992
-	if ( ! $echo ) {
1992
+	if ( ! $echo) {
1993 1993
 		return $form_dropdown_html;
1994 1994
 	}
1995 1995
 
@@ -2008,16 +2008,16 @@  discard block
 block discarded – undo
2008 2008
  *
2009 2009
  * @return string
2010 2010
  */
2011
-function give_get_payment_meta_price_id( $payment_meta ) {
2011
+function give_get_payment_meta_price_id($payment_meta) {
2012 2012
 
2013
-	if ( isset( $payment_meta['give_price_id'] ) ) {
2013
+	if (isset($payment_meta['give_price_id'])) {
2014 2014
 		$price_id = $payment_meta['give_price_id'];
2015
-	} elseif ( isset( $payment_meta['price_id'] ) ) {
2015
+	} elseif (isset($payment_meta['price_id'])) {
2016 2016
 		$price_id = $payment_meta['price_id'];
2017 2017
 	} else {
2018
-		$price_id = give_get_price_id( $payment_meta['give_form_id'], $payment_meta['price'] );
2018
+		$price_id = give_get_price_id($payment_meta['give_form_id'], $payment_meta['price']);
2019 2019
 	}
2020 2020
 
2021
-	return apply_filters( 'give_get_payment_meta_price_id', $price_id );
2021
+	return apply_filters('give_get_payment_meta_price_id', $price_id);
2022 2022
 
2023 2023
 }
Please login to merge, or discard this patch.
includes/admin/class-addon-activation-banner.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 // Exit if accessed directly.
11
-if ( ! defined( 'ABSPATH' ) ) {
11
+if ( ! defined('ABSPATH')) {
12 12
 	exit;
13 13
 }
14 14
 
@@ -32,14 +32,14 @@  discard block
 block discarded – undo
32 32
 	 *                               'testing'           => false, // (required) Never leave as "true" in production!!!
33 33
 	 *                               }
34 34
 	 */
35
-	function __construct( $_banner_details ) {
35
+	function __construct($_banner_details) {
36 36
 		$current_user = wp_get_current_user();
37 37
 
38 38
 		$this->plugin_activate_by   = 0;
39 39
 		$this->banner_details       = $_banner_details;
40
-		$this->test_mode            = ( $this->banner_details['testing'] == 'true' ) ? true : false;
41
-		$this->nag_meta_key         = 'give_addon_activation_ignore_' . sanitize_title( $this->banner_details['name'] );
42
-		$this->activate_by_meta_key = 'give_addon_' . sanitize_title( $this->banner_details['name'] ) . '_active_by_user';
40
+		$this->test_mode            = ($this->banner_details['testing'] == 'true') ? true : false;
41
+		$this->nag_meta_key         = 'give_addon_activation_ignore_'.sanitize_title($this->banner_details['name']);
42
+		$this->activate_by_meta_key = 'give_addon_'.sanitize_title($this->banner_details['name']).'_active_by_user';
43 43
 
44 44
 		//Get current user
45 45
 		$this->user_id = $current_user->ID;
@@ -62,19 +62,19 @@  discard block
 block discarded – undo
62 62
 	public function init() {
63 63
 
64 64
 		//Testing?
65
-		if ( $this->test_mode ) {
66
-			delete_user_meta( $this->user_id, $this->nag_meta_key );
65
+		if ($this->test_mode) {
66
+			delete_user_meta($this->user_id, $this->nag_meta_key);
67 67
 		}
68 68
 
69 69
 		//Get the current page to add the notice to
70
-		add_action( 'current_screen', array( $this, 'give_addon_notice_ignore' ) );
71
-		add_action( 'admin_notices', array( $this, 'give_addon_activation_admin_notice' ) );
70
+		add_action('current_screen', array($this, 'give_addon_notice_ignore'));
71
+		add_action('admin_notices', array($this, 'give_addon_activation_admin_notice'));
72 72
 
73 73
 		// File path of addon must be included in banner detail other addon activate meta will not delete.
74 74
 		$file_name = $this->get_plugin_file_name();
75 75
 
76
-		if ( ! empty( $file_name ) ) {
77
-			add_action( 'deactivate_' . $file_name, array( $this, 'remove_addon_activate_meta' ) );
76
+		if ( ! empty($file_name)) {
77
+			add_action('deactivate_'.$file_name, array($this, 'remove_addon_activate_meta'));
78 78
 		}
79 79
 	}
80 80
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	private function is_plugin_page() {
90 90
 		$screen = get_current_screen();
91 91
 
92
-		return ( $screen->parent_file === 'plugins.php' );
92
+		return ($screen->parent_file === 'plugins.php');
93 93
 	}
94 94
 
95 95
 
@@ -102,12 +102,12 @@  discard block
 block discarded – undo
102 102
 	public function give_addon_activation_admin_notice() {
103 103
 
104 104
 		// Bailout.
105
-		if ( ! $this->is_plugin_page() || $this->user_id !== $this->plugin_activate_by ) {
105
+		if ( ! $this->is_plugin_page() || $this->user_id !== $this->plugin_activate_by) {
106 106
 			return;
107 107
 		}
108 108
 
109 109
 		// If the user hasn't already dismissed the alert, output activation banner.
110
-		if ( ! get_user_meta( $this->user_id, $this->nag_meta_key ) ) {
110
+		if ( ! get_user_meta($this->user_id, $this->nag_meta_key)) {
111 111
 
112 112
 			$this->print_css();
113 113
 
@@ -125,44 +125,44 @@  discard block
 block discarded – undo
125 125
 					<h3><?php
126 126
 						printf(
127 127
 						/* translators: %s: Add-on name */
128
-							esc_html__( "Thank you for installing Give's %s Add-on!", 'give' ),
129
-							'<span>' . $this->banner_details['name'] . '</span>'
128
+							esc_html__("Thank you for installing Give's %s Add-on!", 'give'),
129
+							'<span>'.$this->banner_details['name'].'</span>'
130 130
 						);
131 131
 						?></h3>
132 132
 
133 133
 					<a href="<?php
134 134
 					//The Dismiss Button.
135
-					$nag_admin_dismiss_url = 'plugins.php?' . $this->nag_meta_key . '=0';
136
-					echo admin_url( $nag_admin_dismiss_url ); ?>" class="dismiss"><span
135
+					$nag_admin_dismiss_url = 'plugins.php?'.$this->nag_meta_key.'=0';
136
+					echo admin_url($nag_admin_dismiss_url); ?>" class="dismiss"><span
137 137
 							class="dashicons dashicons-dismiss"></span></a>
138 138
 
139 139
 					<div class="alert-actions">
140 140
 
141 141
 						<?php //Point them to your settings page.
142
-						if ( isset( $this->banner_details['settings_url'] ) ) { ?>
142
+						if (isset($this->banner_details['settings_url'])) { ?>
143 143
 							<a href="<?php echo $this->banner_details['settings_url']; ?>">
144
-								<span class="dashicons dashicons-admin-settings"></span><?php esc_html_e( 'Go to Settings', 'give' ); ?>
144
+								<span class="dashicons dashicons-admin-settings"></span><?php esc_html_e('Go to Settings', 'give'); ?>
145 145
 							</a>
146 146
 						<?php } ?>
147 147
 
148 148
 						<?php
149 149
 						// Show them how to configure the Addon.
150
-						if ( isset( $this->banner_details['documentation_url'] ) ) { ?>
150
+						if (isset($this->banner_details['documentation_url'])) { ?>
151 151
 							<a href="<?php echo $this->banner_details['documentation_url'] ?>" target="_blank">
152 152
 								<span class="dashicons dashicons-media-text"></span><?php
153 153
 								printf(
154 154
 								/* translators: %s: Add-on name */
155
-									esc_html__( 'Documentation: %s Add-on', 'give' ),
155
+									esc_html__('Documentation: %s Add-on', 'give'),
156 156
 									$this->banner_details['name']
157 157
 								);
158 158
 								?></a>
159 159
 						<?php } ?>
160 160
 						<?php
161 161
 						//Let them signup for plugin updates
162
-						if ( isset( $this->banner_details['support_url'] ) ) { ?>
162
+						if (isset($this->banner_details['support_url'])) { ?>
163 163
 
164 164
 							<a href="<?php echo $this->banner_details['support_url'] ?>" target="_blank">
165
-								<span class="dashicons dashicons-sos"></span><?php esc_html_e( 'Get Support', 'give' ); ?>
165
+								<span class="dashicons dashicons-sos"></span><?php esc_html_e('Get Support', 'give'); ?>
166 166
 							</a>
167 167
 
168 168
 						<?php } ?>
@@ -176,12 +176,12 @@  discard block
 block discarded – undo
176 176
 			
177 177
 			
178 178
 			// Register notice.
179
-			Give()->notices->register_notice( array(
180
-				'id'          => 'give_' . sanitize_title( $this->banner_details['name'] ) . '_notice',
179
+			Give()->notices->register_notice(array(
180
+				'id'          => 'give_'.sanitize_title($this->banner_details['name']).'_notice',
181 181
 				'type'        => 'updated',
182 182
 				'description_html' => $notice_html,
183 183
 				'show'        => true,
184
-			) );
184
+			));
185 185
 		}
186 186
 	}
187 187
 
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	 * @since 1.8.16
193 193
 	 * @access private
194 194
 	 */
195
-	private function print_css(){
195
+	private function print_css() {
196 196
 		?>
197 197
 		<style>
198 198
 			div.give-addon-alert.updated {
@@ -280,13 +280,13 @@  discard block
 block discarded – undo
280 280
 		 * If user clicks to ignore the notice, add that to their user meta the banner then checks whether this tag exists already or not.
281 281
 		 * See here: http://codex.wordpress.org/Function_Reference/add_user_meta
282 282
 		 */
283
-		if ( isset( $_GET[ $this->nag_meta_key ] ) && '0' == $_GET[ $this->nag_meta_key ] ) {
283
+		if (isset($_GET[$this->nag_meta_key]) && '0' == $_GET[$this->nag_meta_key]) {
284 284
 
285 285
 			//Get the global user
286 286
 			$current_user = wp_get_current_user();
287 287
 			$user_id      = $current_user->ID;
288 288
 
289
-			add_user_meta( $user_id, $this->nag_meta_key, 'true', true );
289
+			add_user_meta($user_id, $this->nag_meta_key, 'true', true);
290 290
 		}
291 291
 	}
292 292
 
@@ -297,11 +297,11 @@  discard block
 block discarded – undo
297 297
 	 * @access private
298 298
 	 */
299 299
 	private function add_addon_activate_meta() {
300
-		$user_id                  = get_option( $this->activate_by_meta_key );
300
+		$user_id                  = get_option($this->activate_by_meta_key);
301 301
 		$this->plugin_activate_by = (int) $user_id;
302 302
 
303
-		if ( ! $user_id ) {
304
-			add_option( $this->activate_by_meta_key, $this->user_id, '', 'no' );
303
+		if ( ! $user_id) {
304
+			add_option($this->activate_by_meta_key, $this->user_id, '', 'no');
305 305
 			$this->plugin_activate_by = (int) $this->user_id;
306 306
 		}
307 307
 	}
@@ -314,10 +314,10 @@  discard block
 block discarded – undo
314 314
 	 * @access public
315 315
 	 */
316 316
 	public function remove_addon_activate_meta() {
317
-		$user_id = get_option( $this->activate_by_meta_key );
317
+		$user_id = get_option($this->activate_by_meta_key);
318 318
 
319
-		if ( $user_id ) {
320
-			delete_option( $this->activate_by_meta_key );
319
+		if ($user_id) {
320
+			delete_option($this->activate_by_meta_key);
321 321
 		}
322 322
 	}
323 323
 
@@ -330,39 +330,39 @@  discard block
 block discarded – undo
330 330
 	 * @return mixed
331 331
 	 */
332 332
 	private function get_plugin_file_name() {
333
-		$active_plugins = get_option( 'active_plugins' );
333
+		$active_plugins = get_option('active_plugins');
334 334
 		$file_name      = '';
335 335
 
336 336
 		try {
337 337
 
338 338
 			// Check addon file path.
339
-			if ( ! empty( $this->banner_details['file'] ) ) {
339
+			if ( ! empty($this->banner_details['file'])) {
340 340
 				$file_name = '';
341
-				if ( $file_path = explode( '/plugins/', $this->banner_details['file'] ) ) {
342
-					$file_path = array_pop( $file_path );
343
-					$file_name = current( explode( '/', $file_path ) );
341
+				if ($file_path = explode('/plugins/', $this->banner_details['file'])) {
342
+					$file_path = array_pop($file_path);
343
+					$file_name = current(explode('/', $file_path));
344 344
 				}
345 345
 
346
-				if ( empty( $file_name ) ) {
346
+				if (empty($file_name)) {
347 347
 					return false;
348 348
 				}
349 349
 
350
-				foreach ( $active_plugins as $plugin ) {
351
-					if ( false !== strpos( $plugin, $file_name ) ) {
350
+				foreach ($active_plugins as $plugin) {
351
+					if (false !== strpos($plugin, $file_name)) {
352 352
 						$file_name = $plugin;
353 353
 						break;
354 354
 					}
355 355
 				}
356
-			} elseif ( WP_DEBUG ) {
357
-				throw new Exception( __( "File path must be added within the {$this->banner_details['name']} add-on in the banner details.", 'give' ) );
356
+			} elseif (WP_DEBUG) {
357
+				throw new Exception(__("File path must be added within the {$this->banner_details['name']} add-on in the banner details.", 'give'));
358 358
 			}
359 359
 
360 360
 			// Check plugin path calculated by addon file path.
361
-			if ( empty( $file_name ) && WP_DEBUG ) {
362
-				throw new Exception( __( "Empty add-on plugin path for {$this->banner_details['name']} add-on.", 'give' ) );
361
+			if (empty($file_name) && WP_DEBUG) {
362
+				throw new Exception(__("Empty add-on plugin path for {$this->banner_details['name']} add-on.", 'give'));
363 363
 			}
364 364
 
365
-		} catch ( Exception $e ) {
365
+		} catch (Exception $e) {
366 366
 			echo $e->getMessage();
367 367
 		}
368 368
 
Please login to merge, or discard this patch.