Test Failed
Pull Request — master (#2482)
by Devin
05:37
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/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.
includes/admin/reports/graphing.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -819,12 +819,12 @@
 block discarded – undo
819 819
 	) ), 'give-refresh-reports' );
820 820
 
821 821
 	echo '<a href="'
822
-	     . esc_url_raw( $url )
823
-	     . '" data-tooltip="'. __( 'Clicking this will clear the reports cache.', 'give' )
824
-	     . '" data-tooltip-my-position="right center"  data-tooltip-target-position="left center" class="button alignright give-admin-button give-tooltip">'
825
-	     . '<span class="give-admin-button-icon give-admin-button-icon-update"></span>'
826
-	     . __( 'Refresh Report Data', 'give' )
827
-	     . '</a>';
822
+		 . esc_url_raw( $url )
823
+		 . '" data-tooltip="'. __( 'Clicking this will clear the reports cache.', 'give' )
824
+		 . '" data-tooltip-my-position="right center"  data-tooltip-target-position="left center" class="button alignright give-admin-button give-tooltip">'
825
+		 . '<span class="give-admin-button-icon give-admin-button-icon-update"></span>'
826
+		 . __( 'Refresh Report Data', 'give' )
827
+		 . '</a>';
828 828
 
829 829
 }
830 830
 
Please login to merge, or discard this patch.
Spacing   +247 added lines, -247 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	$dates = give_get_report_dates();
26 26
 
27 27
 	// Determine graph options.
28
-	switch ( $dates['range'] ) :
28
+	switch ($dates['range']) :
29 29
 		case 'today' :
30 30
 		case 'yesterday' :
31 31
 			$day_by_day = true;
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 			$day_by_day = false;
38 38
 			break;
39 39
 		case 'other' :
40
-			if ( $dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year'] && ( $dates['m_start'] != '12' && $dates['m_end'] != '1' ) ) {
40
+			if ($dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year'] && ($dates['m_start'] != '12' && $dates['m_end'] != '1')) {
41 41
 				$day_by_day = false;
42 42
 			} else {
43 43
 				$day_by_day = true;
@@ -54,57 +54,57 @@  discard block
 block discarded – undo
54 54
 	$earnings_data = array();
55 55
 	$sales_data    = array();
56 56
 
57
-	if ( $dates['range'] == 'today' || $dates['range'] == 'yesterday' ) {
57
+	if ($dates['range'] == 'today' || $dates['range'] == 'yesterday') {
58 58
 		// Hour by hour.
59 59
 		$hour  = 0;
60
-		$month = date( 'n', current_time( 'timestamp' ) );
61
-		while ( $hour <= 23 ) :
60
+		$month = date('n', current_time('timestamp'));
61
+		while ($hour <= 23) :
62 62
 
63
-			$sales    = give_get_sales_by_date( $dates['day'], $month, $dates['year'], $hour );
64
-			$earnings = give_get_earnings_by_date( $dates['day'], $month, $dates['year'], $hour );
63
+			$sales    = give_get_sales_by_date($dates['day'], $month, $dates['year'], $hour);
64
+			$earnings = give_get_earnings_by_date($dates['day'], $month, $dates['year'], $hour);
65 65
 
66 66
 			$sales_totals += $sales;
67 67
 			$earnings_totals += $earnings;
68 68
 
69
-			$date            = mktime( $hour, 0, 0, $month, $dates['day'], $dates['year'] ) * 1000;
69
+			$date            = mktime($hour, 0, 0, $month, $dates['day'], $dates['year']) * 1000;
70 70
 
71
-			$sales_data[]    = array( $date, $sales );
72
-			$earnings_data[] = array( $date, $earnings );
71
+			$sales_data[]    = array($date, $sales);
72
+			$earnings_data[] = array($date, $earnings);
73 73
 
74
-			$hour ++;
74
+			$hour++;
75 75
 		endwhile;
76 76
 
77
-	} elseif ( $dates['range'] == 'this_week' || $dates['range'] == 'last_week' ) {
77
+	} elseif ($dates['range'] == 'this_week' || $dates['range'] == 'last_week') {
78 78
 
79 79
 		// Day by day.
80 80
 		$day     = $dates['day'];
81 81
 		$day_end = $dates['day_end'];
82 82
 		$month   = $dates['m_start'];
83
-		while ( $day <= $day_end ) :
84
-			$sales = give_get_sales_by_date( $day, $month, $dates['year'] );
83
+		while ($day <= $day_end) :
84
+			$sales = give_get_sales_by_date($day, $month, $dates['year']);
85 85
 			$sales_totals += $sales;
86 86
 
87
-			$earnings = give_get_earnings_by_date( $day, $month, $dates['year'] );
87
+			$earnings = give_get_earnings_by_date($day, $month, $dates['year']);
88 88
 			$earnings_totals += $earnings;
89 89
 
90
-			$date            = mktime( 0, 0, 0, $month, $day, $dates['year'] ) * 1000;
91
-			$sales_data[]    = array( $date, $sales );
92
-			$earnings_data[] = array( $date, $earnings );
93
-			$day ++;
90
+			$date            = mktime(0, 0, 0, $month, $day, $dates['year']) * 1000;
91
+			$sales_data[]    = array($date, $sales);
92
+			$earnings_data[] = array($date, $earnings);
93
+			$day++;
94 94
 		endwhile;
95 95
 
96 96
 	} else {
97 97
 
98 98
 		$y = $dates['year'];
99
-		while ( $y <= $dates['year_end'] ) :
99
+		while ($y <= $dates['year_end']) :
100 100
 
101
-			if ( $dates['year'] == $dates['year_end'] ) {
101
+			if ($dates['year'] == $dates['year_end']) {
102 102
 				$month_start = $dates['m_start'];
103 103
 				$month_end   = $dates['m_end'];
104
-			} elseif ( $y == $dates['year'] ) {
104
+			} elseif ($y == $dates['year']) {
105 105
 				$month_start = $dates['m_start'];
106 106
 				$month_end   = 12;
107
-			} elseif ( $y == $dates['year_end'] ) {
107
+			} elseif ($y == $dates['year_end']) {
108 108
 				$month_start = 1;
109 109
 				$month_end   = $dates['m_end'];
110 110
 			} else {
@@ -113,48 +113,48 @@  discard block
 block discarded – undo
113 113
 			}
114 114
 
115 115
 			$i = $month_start;
116
-			while ( $i <= $month_end ) :
116
+			while ($i <= $month_end) :
117 117
 
118
-				if ( $day_by_day ) {
118
+				if ($day_by_day) {
119 119
 
120
-					if ( $i == $month_end ) {
120
+					if ($i == $month_end) {
121 121
 
122 122
 						$num_of_days = $dates['day_end'];
123 123
 
124 124
 					} else {
125 125
 
126
-						$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
126
+						$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
127 127
 
128 128
 					}
129 129
 
130 130
 					$d = $dates['day'];
131 131
 
132
-					while ( $d <= $num_of_days ) :
132
+					while ($d <= $num_of_days) :
133 133
 
134
-						$sales = give_get_sales_by_date( $d, $i, $y );
134
+						$sales = give_get_sales_by_date($d, $i, $y);
135 135
 						$sales_totals += $sales;
136 136
 
137
-						$earnings = give_get_earnings_by_date( $d, $i, $y );
137
+						$earnings = give_get_earnings_by_date($d, $i, $y);
138 138
 						$earnings_totals += $earnings;
139 139
 
140
-						$date            = mktime( 0, 0, 0, $i, $d, $y ) * 1000;
141
-						$sales_data[]    = array( $date, $sales );
142
-						$earnings_data[] = array( $date, $earnings );
143
-						$d ++;
140
+						$date            = mktime(0, 0, 0, $i, $d, $y) * 1000;
141
+						$sales_data[]    = array($date, $sales);
142
+						$earnings_data[] = array($date, $earnings);
143
+						$d++;
144 144
 
145 145
 					endwhile;
146 146
 
147 147
 				} else {
148 148
 
149
-					$sales = give_get_sales_by_date( null, $i, $y );
149
+					$sales = give_get_sales_by_date(null, $i, $y);
150 150
 					$sales_totals += $sales;
151 151
 
152
-					$earnings = give_get_earnings_by_date( null, $i, $y );
152
+					$earnings = give_get_earnings_by_date(null, $i, $y);
153 153
 					$earnings_totals += $earnings;
154 154
 
155
-					if ( $i == $month_end ) {
155
+					if ($i == $month_end) {
156 156
 
157
-						$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
157
+						$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
158 158
 
159 159
 					} else {
160 160
 
@@ -162,24 +162,24 @@  discard block
 block discarded – undo
162 162
 
163 163
 					}
164 164
 
165
-					$date            = mktime( 0, 0, 0, $i, $num_of_days, $y ) * 1000;
166
-					$sales_data[]    = array( $date, $sales );
167
-					$earnings_data[] = array( $date, $earnings );
165
+					$date            = mktime(0, 0, 0, $i, $num_of_days, $y) * 1000;
166
+					$sales_data[]    = array($date, $sales);
167
+					$earnings_data[] = array($date, $earnings);
168 168
 
169 169
 				}
170 170
 
171
-				$i ++;
171
+				$i++;
172 172
 
173 173
 			endwhile;
174 174
 
175
-			$y ++;
175
+			$y++;
176 176
 		endwhile;
177 177
 
178 178
 	}
179 179
 
180 180
 	$data = array(
181
-		__( 'Income', 'give' )    => $earnings_data,
182
-		__( 'Donations', 'give' ) => $sales_data
181
+		__('Income', 'give')    => $earnings_data,
182
+		__('Donations', 'give') => $sales_data
183 183
 	);
184 184
 
185 185
 	// start our own output buffer.
@@ -192,12 +192,12 @@  discard block
 block discarded – undo
192 192
 				<div class="inside">
193 193
 					<?php give_reports_graph_controls(); ?>
194 194
 					<?php
195
-					$graph = new Give_Graph( $data, array( 'dataType' => array( 'amount', 'count' ) ) );
196
-					$graph->set( 'x_mode', 'time' );
197
-					$graph->set( 'multiple_y_axes', true );
195
+					$graph = new Give_Graph($data, array('dataType' => array('amount', 'count')));
196
+					$graph->set('x_mode', 'time');
197
+					$graph->set('multiple_y_axes', true);
198 198
 					$graph->display();
199 199
 
200
-					if ( 'this_month' === $dates['range'] ) {
200
+					if ('this_month' === $dates['range']) {
201 201
 						$estimated = give_estimated_monthly_stats();
202 202
 					}
203 203
 					?>
@@ -206,21 +206,21 @@  discard block
 block discarded – undo
206 206
 			<table class="widefat reports-table alignleft" style="max-width:450px">
207 207
 				<tbody>
208 208
 				<tr>
209
-					<th scope="row"><strong><?php _e( 'Total income for period:', 'give' ); ?></strong></th>
210
-					<td><?php echo give_currency_filter( give_format_amount( $earnings_totals, array( 'sanitize' => false ) ) ); ?></td>
209
+					<th scope="row"><strong><?php _e('Total income for period:', 'give'); ?></strong></th>
210
+					<td><?php echo give_currency_filter(give_format_amount($earnings_totals, array('sanitize' => false))); ?></td>
211 211
 				</tr>
212 212
 				<tr class="alternate">
213
-					<th scope="row"><strong><?php _e( 'Total donations for period:', 'give' ); ?><strong></th>
213
+					<th scope="row"><strong><?php _e('Total donations for period:', 'give'); ?><strong></th>
214 214
 					<td><?php echo $sales_totals; ?></td>
215 215
 				</tr>
216
-				<?php if ( 'this_month' == $dates['range'] ) : ?>
216
+				<?php if ('this_month' == $dates['range']) : ?>
217 217
 					<tr>
218
-						<th scope="row"><strong><?php _e( 'Estimated monthly income:', 'give' ); ?></strong></th>
219
-						<td><?php echo give_currency_filter( give_format_amount( $estimated['earnings'], array( 'sanitize' => false ) ) ); ?></td>
218
+						<th scope="row"><strong><?php _e('Estimated monthly income:', 'give'); ?></strong></th>
219
+						<td><?php echo give_currency_filter(give_format_amount($estimated['earnings'], array('sanitize' => false))); ?></td>
220 220
 					</tr>
221 221
 					<tr class="alternate">
222
-						<th scope="row"><strong><?php _e( 'Estimated monthly donations:', 'give' ); ?></strong></th>
223
-						<td><?php echo floor( $estimated['sales'] ); ?></td>
222
+						<th scope="row"><strong><?php _e('Estimated monthly donations:', 'give'); ?></strong></th>
223
+						<td><?php echo floor($estimated['sales']); ?></td>
224 224
 					</tr>
225 225
 				<?php endif; ?>
226 226
 			</table>
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 			 *
234 234
 			 * @since 1.0
235 235
 			 */
236
-			do_action( 'give_reports_graph_additional_stats' );
236
+			do_action('give_reports_graph_additional_stats');
237 237
 			?>
238 238
 
239 239
 		</div>
@@ -253,12 +253,12 @@  discard block
 block discarded – undo
253 253
  *
254 254
  * @return void
255 255
  */
256
-function give_reports_graph_of_form( $form_id = 0 ) {
256
+function give_reports_graph_of_form($form_id = 0) {
257 257
 	// Retrieve the queried dates.
258 258
 	$dates = give_get_report_dates();
259 259
 
260 260
 	// Determine graph options.
261
-	switch ( $dates['range'] ) :
261
+	switch ($dates['range']) :
262 262
 		case 'today' :
263 263
 		case 'yesterday' :
264 264
 			$day_by_day = true;
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 			$day_by_day = false;
277 277
 			break;
278 278
 		case 'other' :
279
-			if ( $dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year'] ) {
279
+			if ($dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year']) {
280 280
 				$day_by_day = false;
281 281
 			} else {
282 282
 				$day_by_day = true;
@@ -288,75 +288,75 @@  discard block
 block discarded – undo
288 288
 	endswitch;
289 289
 
290 290
 	$earnings_totals = (float) 0.00; // Total earnings for time period shown.
291
-	$sales_totals    = 0;            // Total sales for time period shown.
291
+	$sales_totals    = 0; // Total sales for time period shown.
292 292
 
293 293
 	$earnings_data = array();
294 294
 	$sales_data    = array();
295 295
 	$stats         = new Give_Payment_Stats;
296 296
 
297
-	if ( $dates['range'] == 'today' || $dates['range'] == 'yesterday' ) {
297
+	if ($dates['range'] == 'today' || $dates['range'] == 'yesterday') {
298 298
 
299 299
 		// Hour by hour
300 300
 		$month  = $dates['m_start'];
301 301
 		$hour   = 0;
302 302
 		$minute = 0;
303 303
 		$second = 0;
304
-		while ( $hour <= 23 ) :
304
+		while ($hour <= 23) :
305 305
 
306
-			if ( $hour == 23 ) {
306
+			if ($hour == 23) {
307 307
 				$minute = $second = 59;
308 308
 			}
309 309
 
310
-			$date     = mktime( $hour, $minute, $second, $month, $dates['day'], $dates['year'] );
311
-			$date_end = mktime( $hour + 1, $minute, $second, $month, $dates['day'], $dates['year'] );
310
+			$date     = mktime($hour, $minute, $second, $month, $dates['day'], $dates['year']);
311
+			$date_end = mktime($hour + 1, $minute, $second, $month, $dates['day'], $dates['year']);
312 312
 
313
-			$sales = $stats->get_sales( $form_id, $date, $date_end );
313
+			$sales = $stats->get_sales($form_id, $date, $date_end);
314 314
 			$sales_totals += $sales;
315 315
 
316
-			$earnings = $stats->get_earnings( $form_id, $date, $date_end );
316
+			$earnings = $stats->get_earnings($form_id, $date, $date_end);
317 317
 			$earnings_totals += $earnings;
318 318
 
319
-			$sales_data[]    = array( $date * 1000, $sales );
320
-			$earnings_data[] = array( $date * 1000, $earnings );
319
+			$sales_data[]    = array($date * 1000, $sales);
320
+			$earnings_data[] = array($date * 1000, $earnings);
321 321
 
322
-			$hour ++;
322
+			$hour++;
323 323
 		endwhile;
324 324
 
325
-	} elseif ( $dates['range'] == 'this_week' || $dates['range'] == 'last_week' ) {
325
+	} elseif ($dates['range'] == 'this_week' || $dates['range'] == 'last_week') {
326 326
 
327 327
 		//Day by day.
328 328
 		$day     = $dates['day'];
329 329
 		$day_end = $dates['day_end'];
330 330
 		$month   = $dates['m_start'];
331
-		while ( $day <= $day_end ) :
331
+		while ($day <= $day_end) :
332 332
 
333
-			$date     = mktime( 0, 0, 0, $month, $day, $dates['year'] );
334
-			$date_end = mktime( 0, 0, 0, $month, $day + 1, $dates['year'] );
335
-			$sales    = $stats->get_sales( $form_id, $date, $date_end );
333
+			$date     = mktime(0, 0, 0, $month, $day, $dates['year']);
334
+			$date_end = mktime(0, 0, 0, $month, $day + 1, $dates['year']);
335
+			$sales    = $stats->get_sales($form_id, $date, $date_end);
336 336
 			$sales_totals += $sales;
337 337
 
338
-			$earnings = $stats->get_earnings( $form_id, $date, $date_end );
338
+			$earnings = $stats->get_earnings($form_id, $date, $date_end);
339 339
 			$earnings_totals += $earnings;
340 340
 
341
-			$sales_data[]    = array( $date * 1000, $sales );
342
-			$earnings_data[] = array( $date * 1000, $earnings );
341
+			$sales_data[]    = array($date * 1000, $sales);
342
+			$earnings_data[] = array($date * 1000, $earnings);
343 343
 
344
-			$day ++;
344
+			$day++;
345 345
 		endwhile;
346 346
 
347 347
 	} else {
348 348
 
349 349
 		$y = $dates['year'];
350 350
 
351
-		while ( $y <= $dates['year_end'] ) :
351
+		while ($y <= $dates['year_end']) :
352 352
 
353 353
 			$last_year = false;
354 354
 
355
-			if ( $dates['year'] == $dates['year_end'] ) {
355
+			if ($dates['year'] == $dates['year_end']) {
356 356
 				$month_start = $dates['m_start'];
357 357
 				$month_end   = $dates['m_end'];
358 358
 				$last_year   = true;
359
-			} elseif ( $y == $dates['year'] ) {
359
+			} elseif ($y == $dates['year']) {
360 360
 				$month_start = $dates['m_start'];
361 361
 				$month_end   = 12;
362 362
 			} else {
@@ -365,76 +365,76 @@  discard block
 block discarded – undo
365 365
 			}
366 366
 
367 367
 			$i = $month_start;
368
-			while ( $i <= $month_end ) :
368
+			while ($i <= $month_end) :
369 369
 
370
-				if ( $day_by_day ) {
370
+				if ($day_by_day) {
371 371
 
372
-					if ( $i == $month_end && $last_year ) {
372
+					if ($i == $month_end && $last_year) {
373 373
 
374 374
 						$num_of_days = $dates['day_end'];
375 375
 
376 376
 					} else {
377 377
 
378
-						$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
378
+						$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
379 379
 
380 380
 					}
381 381
 
382 382
 					$d = $dates['day'];
383
-					while ( $d <= $num_of_days ) :
383
+					while ($d <= $num_of_days) :
384 384
 
385
-						$date     = mktime( 0, 0, 0, $i, $d, $y );
386
-						$end_date = mktime( 23, 59, 59, $i, $d, $y );
385
+						$date     = mktime(0, 0, 0, $i, $d, $y);
386
+						$end_date = mktime(23, 59, 59, $i, $d, $y);
387 387
 
388
-						$sales = $stats->get_sales( $form_id, $date, $end_date );
388
+						$sales = $stats->get_sales($form_id, $date, $end_date);
389 389
 						$sales_totals += $sales;
390 390
 
391
-						$earnings = $stats->get_earnings( $form_id, $date, $end_date );
391
+						$earnings = $stats->get_earnings($form_id, $date, $end_date);
392 392
 						$earnings_totals += $earnings;
393 393
 
394
-						$sales_data[]    = array( $date * 1000, $sales );
395
-						$earnings_data[] = array( $date * 1000, $earnings );
396
-						$d ++;
394
+						$sales_data[]    = array($date * 1000, $sales);
395
+						$earnings_data[] = array($date * 1000, $earnings);
396
+						$d++;
397 397
 
398 398
 					endwhile;
399 399
 
400 400
 				} else {
401 401
 
402
-					$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
402
+					$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
403 403
 
404
-					$date     = mktime( 0, 0, 0, $i, 1, $y );
405
-					$end_date = mktime( 23, 59, 59, $i, $num_of_days, $y );
404
+					$date     = mktime(0, 0, 0, $i, 1, $y);
405
+					$end_date = mktime(23, 59, 59, $i, $num_of_days, $y);
406 406
 
407
-					$sales = $stats->get_sales( $form_id, $date, $end_date );
407
+					$sales = $stats->get_sales($form_id, $date, $end_date);
408 408
 					$sales_totals += $sales;
409 409
 
410
-					$earnings = $stats->get_earnings( $form_id, $date, $end_date );
410
+					$earnings = $stats->get_earnings($form_id, $date, $end_date);
411 411
 					$earnings_totals += $earnings;
412 412
 
413
-					$sales_data[]    = array( $date * 1000, $sales );
414
-					$earnings_data[] = array( $date * 1000, $earnings );
413
+					$sales_data[]    = array($date * 1000, $sales);
414
+					$earnings_data[] = array($date * 1000, $earnings);
415 415
 
416 416
 				}
417 417
 
418
-				$i ++;
418
+				$i++;
419 419
 
420 420
 			endwhile;
421 421
 
422
-			$y ++;
422
+			$y++;
423 423
 		endwhile;
424 424
 
425 425
 	}
426 426
 
427 427
 	$data = array(
428
-		__( 'Income', 'give' )    => $earnings_data,
429
-		__( 'Donations', 'give' ) => $sales_data
428
+		__('Income', 'give')    => $earnings_data,
429
+		__('Donations', 'give') => $sales_data
430 430
 	);
431 431
 
432 432
 	?>
433 433
 	<h3><span><?php
434 434
 			printf(
435 435
 			/* translators: %s: form title */
436
-				esc_html__( 'Income Report for %s', 'give' ),
437
-				get_the_title( $form_id )
436
+				esc_html__('Income Report for %s', 'give'),
437
+				get_the_title($form_id)
438 438
 			);
439 439
 			?></span></h3>
440 440
 	<div id="give-dashboard-widgets-wrap">
@@ -443,9 +443,9 @@  discard block
 block discarded – undo
443 443
 				<div class="inside">
444 444
 					<?php give_reports_graph_controls(); ?>
445 445
 					<?php
446
-					$graph = new Give_Graph( $data, array( 'dataType' => array( 'amount', 'count' ) ) );
447
-					$graph->set( 'x_mode', 'time' );
448
-					$graph->set( 'multiple_y_axes', true );
446
+					$graph = new Give_Graph($data, array('dataType' => array('amount', 'count')));
447
+					$graph->set('x_mode', 'time');
448
+					$graph->set('multiple_y_axes', true);
449 449
 					$graph->display();
450 450
 					?>
451 451
 				</div>
@@ -454,20 +454,20 @@  discard block
 block discarded – undo
454 454
 			<table class="widefat reports-table alignleft" style="max-width:450px">
455 455
 				<tbody>
456 456
 				<tr>
457
-					<th scope="row"><strong><?php _e( 'Total income for period:', 'give' ); ?></strong></th>
458
-					<td><?php echo give_currency_filter( give_format_amount( $earnings_totals, array( 'sanitize' => false ) ) ); ?></td>
457
+					<th scope="row"><strong><?php _e('Total income for period:', 'give'); ?></strong></th>
458
+					<td><?php echo give_currency_filter(give_format_amount($earnings_totals, array('sanitize' => false))); ?></td>
459 459
 				</tr>
460 460
 				<tr class="alternate">
461
-					<th scope="row"><strong><?php _e( 'Total donations for period:', 'give' ); ?></strong></th>
461
+					<th scope="row"><strong><?php _e('Total donations for period:', 'give'); ?></strong></th>
462 462
 					<td><?php echo $sales_totals; ?></td>
463 463
 				</tr>
464 464
 				<tr>
465
-					<th scope="row"><strong><?php _e( 'Average monthly income:', 'give' ); ?></strong></th>
466
-					<td><?php echo give_currency_filter( give_format_amount( give_get_average_monthly_form_earnings( $form_id ), array( 'sanitize' => false ) ) ); ?></td>
465
+					<th scope="row"><strong><?php _e('Average monthly income:', 'give'); ?></strong></th>
466
+					<td><?php echo give_currency_filter(give_format_amount(give_get_average_monthly_form_earnings($form_id), array('sanitize' => false))); ?></td>
467 467
 				</tr>
468 468
 				<tr class="alternate">
469
-					<th scope="row"><strong><?php _e( 'Average monthly donations:', 'give' ); ?></strong></th>
470
-					<td><?php echo number_format( give_get_average_monthly_form_sales( $form_id ), 0 ); ?></td>
469
+					<th scope="row"><strong><?php _e('Average monthly donations:', 'give'); ?></strong></th>
470
+					<td><?php echo number_format(give_get_average_monthly_form_sales($form_id), 0); ?></td>
471 471
 				</tr>
472 472
 				</tbody>
473 473
 			</table>
@@ -486,26 +486,26 @@  discard block
 block discarded – undo
486 486
  * @return void
487 487
  */
488 488
 function give_reports_graph_controls() {
489
-	$date_options = apply_filters( 'give_report_date_options', array(
490
-		'today'        => __( 'Today', 'give' ),
491
-		'yesterday'    => __( 'Yesterday', 'give' ),
492
-		'this_week'    => __( 'This Week', 'give' ),
493
-		'last_week'    => __( 'Last Week', 'give' ),
494
-		'this_month'   => __( 'This Month', 'give' ),
495
-		'last_month'   => __( 'Last Month', 'give' ),
496
-		'this_quarter' => __( 'This Quarter', 'give' ),
497
-		'last_quarter' => __( 'Last Quarter', 'give' ),
498
-		'this_year'    => __( 'This Year', 'give' ),
499
-		'last_year'    => __( 'Last Year', 'give' ),
500
-		'other'        => __( 'Custom', 'give' )
501
-	) );
489
+	$date_options = apply_filters('give_report_date_options', array(
490
+		'today'        => __('Today', 'give'),
491
+		'yesterday'    => __('Yesterday', 'give'),
492
+		'this_week'    => __('This Week', 'give'),
493
+		'last_week'    => __('Last Week', 'give'),
494
+		'this_month'   => __('This Month', 'give'),
495
+		'last_month'   => __('Last Month', 'give'),
496
+		'this_quarter' => __('This Quarter', 'give'),
497
+		'last_quarter' => __('Last Quarter', 'give'),
498
+		'this_year'    => __('This Year', 'give'),
499
+		'last_year'    => __('Last Year', 'give'),
500
+		'other'        => __('Custom', 'give')
501
+	));
502 502
 
503 503
 	$dates   = give_get_report_dates();
504 504
 	$display = $dates['range'] == 'other' ? '' : 'display: none;';
505
-	$tab     = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'earnings';
505
+	$tab     = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'earnings';
506 506
 
507
-	if ( empty( $dates['day_end'] ) ) {
508
-		$dates['day_end'] = cal_days_in_month( CAL_GREGORIAN, date( 'n' ), date( 'Y' ) );
507
+	if (empty($dates['day_end'])) {
508
+		$dates['day_end'] = cal_days_in_month(CAL_GREGORIAN, date('n'), date('Y'));
509 509
 	}
510 510
 
511 511
 	/**
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
 	 *
514 514
 	 * @since 1.0
515 515
 	 */
516
-	do_action( 'give_report_graph_controls_before' );
516
+	do_action('give_report_graph_controls_before');
517 517
 	?>
518 518
 	<form id="give-graphs-filter" method="get">
519 519
 		<div class="tablenav top">
@@ -521,56 +521,56 @@  discard block
 block discarded – undo
521 521
 
522 522
 				<input type="hidden" name="post_type" value="give_forms" />
523 523
 				<input type="hidden" name="page" value="give-reports" />
524
-				<input type="hidden" name="tab" value="<?php echo esc_attr( $tab ); ?>" />
524
+				<input type="hidden" name="tab" value="<?php echo esc_attr($tab); ?>" />
525 525
 
526
-				<?php if ( isset( $_GET['form-id'] ) ) : ?>
527
-					<input type="hidden" name="form-id" value="<?php echo absint( $_GET['form-id'] ); ?>" />
526
+				<?php if (isset($_GET['form-id'])) : ?>
527
+					<input type="hidden" name="form-id" value="<?php echo absint($_GET['form-id']); ?>" />
528 528
 				<?php endif; ?>
529 529
 
530 530
 				<div id="give-graphs-date-options-wrap">
531 531
 					<select id="give-graphs-date-options" name="range">
532
-						<?php foreach ( $date_options as $key => $option ) : ?>
533
-							<option value="<?php echo esc_attr( $key ); ?>"<?php selected( $key, $dates['range'] ); ?>><?php echo esc_html( $option ); ?></option>
532
+						<?php foreach ($date_options as $key => $option) : ?>
533
+							<option value="<?php echo esc_attr($key); ?>"<?php selected($key, $dates['range']); ?>><?php echo esc_html($option); ?></option>
534 534
 						<?php endforeach; ?>
535 535
 					</select>
536 536
 
537
-					<div id="give-date-range-options" style="<?php echo esc_attr( $display ); ?>">
538
-						<span class="screen-reader-text"><?php _e( 'From', 'give' ); ?>&nbsp;</span>
537
+					<div id="give-date-range-options" style="<?php echo esc_attr($display); ?>">
538
+						<span class="screen-reader-text"><?php _e('From', 'give'); ?>&nbsp;</span>
539 539
 						<select id="give-graphs-month-start" name="m_start" aria-label="Start Month">
540
-							<?php for ( $i = 1; $i <= 12; $i ++ ) : ?>
541
-								<option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['m_start'] ) ); ?>><?php echo esc_html( give_month_num_to_name( $i ) ); ?></option>
540
+							<?php for ($i = 1; $i <= 12; $i++) : ?>
541
+								<option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['m_start'])); ?>><?php echo esc_html(give_month_num_to_name($i)); ?></option>
542 542
 							<?php endfor; ?>
543 543
 						</select>
544 544
 						<select id="give-graphs-day-start" name="day" aria-label="Start Day">
545
-							<?php for ( $i = 1; $i <= 31; $i ++ ) : ?>
546
-								<option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['day'] ) ); ?>><?php echo esc_html( $i ); ?></option>
545
+							<?php for ($i = 1; $i <= 31; $i++) : ?>
546
+								<option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['day'])); ?>><?php echo esc_html($i); ?></option>
547 547
 							<?php endfor; ?>
548 548
 						</select>
549 549
 						<select id="give-graphs-year-start" name="year" aria-label="Start Year">
550
-							<?php for ( $i = 2007; $i <= date( 'Y' ); $i ++ ) : ?>
551
-								<option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['year'] ) ); ?>><?php echo esc_html( $i ); ?></option>
550
+							<?php for ($i = 2007; $i <= date('Y'); $i++) : ?>
551
+								<option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['year'])); ?>><?php echo esc_html($i); ?></option>
552 552
 							<?php endfor; ?>
553 553
 						</select>
554
-						<span class="screen-reader-text"><?php esc_html_e( 'To', 'give' ); ?>&nbsp;</span>
554
+						<span class="screen-reader-text"><?php esc_html_e('To', 'give'); ?>&nbsp;</span>
555 555
 						<span>&ndash;</span>
556 556
 						<select id="give-graphs-month-end" name="m_end" aria-label="End Month">
557
-							<?php for ( $i = 1; $i <= 12; $i ++ ) : ?>
558
-								<option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['m_end'] ) ); ?>><?php echo esc_html( give_month_num_to_name( $i ) ); ?></option>
557
+							<?php for ($i = 1; $i <= 12; $i++) : ?>
558
+								<option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['m_end'])); ?>><?php echo esc_html(give_month_num_to_name($i)); ?></option>
559 559
 							<?php endfor; ?>
560 560
 						</select>
561 561
 						<select id="give-graphs-day-end" name="day_end" aria-label="End Day">
562
-							<?php for ( $i = 1; $i <= 31; $i ++ ) : ?>
563
-								<option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['day_end'] ) ); ?>><?php echo esc_html( $i ); ?></option>
562
+							<?php for ($i = 1; $i <= 31; $i++) : ?>
563
+								<option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['day_end'])); ?>><?php echo esc_html($i); ?></option>
564 564
 							<?php endfor; ?>
565 565
 						</select>
566 566
 						<select id="give-graphs-year-end" name="year_end" aria-label="End Year">
567
-							<?php for ( $i = 2007; $i <= date( 'Y' ); $i ++ ) : ?>
568
-								<option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['year_end'] ) ); ?>><?php echo esc_html( $i ); ?></option>
567
+							<?php for ($i = 2007; $i <= date('Y'); $i++) : ?>
568
+								<option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['year_end'])); ?>><?php echo esc_html($i); ?></option>
569 569
 							<?php endfor; ?>
570 570
 						</select>
571 571
 					</div>
572 572
 
573
-					<input type="submit" class="button-secondary" value="<?php _e( 'Filter', 'give' ); ?>" />
573
+					<input type="submit" class="button-secondary" value="<?php _e('Filter', 'give'); ?>" />
574 574
 				</div>
575 575
 
576 576
 				<input type="hidden" name="give_action" value="filter_reports" />
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
 	 *
584 584
 	 * @since 1.0
585 585
 	 */
586
-	do_action( 'give_report_graph_controls_after' );
586
+	do_action('give_report_graph_controls_after');
587 587
 }
588 588
 
589 589
 /**
@@ -599,67 +599,67 @@  discard block
 block discarded – undo
599 599
 function give_get_report_dates() {
600 600
 	$dates = array();
601 601
 
602
-	$current_time = current_time( 'timestamp' );
602
+	$current_time = current_time('timestamp');
603 603
 
604
-	$dates['range']    = isset( $_GET['range'] ) ? $_GET['range'] : 'this_month';
605
-	$dates['year']     = isset( $_GET['year'] ) ? $_GET['year'] : date( 'Y' );
606
-	$dates['year_end'] = isset( $_GET['year_end'] ) ? $_GET['year_end'] : date( 'Y' );
607
-	$dates['m_start']  = isset( $_GET['m_start'] ) ? $_GET['m_start'] : 1;
608
-	$dates['m_end']    = isset( $_GET['m_end'] ) ? $_GET['m_end'] : 12;
609
-	$dates['day']      = isset( $_GET['day'] ) ? $_GET['day'] : 1;
610
-	$dates['day_end']  = isset( $_GET['day_end'] ) ? $_GET['day_end'] : cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] );
604
+	$dates['range']    = isset($_GET['range']) ? $_GET['range'] : 'this_month';
605
+	$dates['year']     = isset($_GET['year']) ? $_GET['year'] : date('Y');
606
+	$dates['year_end'] = isset($_GET['year_end']) ? $_GET['year_end'] : date('Y');
607
+	$dates['m_start']  = isset($_GET['m_start']) ? $_GET['m_start'] : 1;
608
+	$dates['m_end']    = isset($_GET['m_end']) ? $_GET['m_end'] : 12;
609
+	$dates['day']      = isset($_GET['day']) ? $_GET['day'] : 1;
610
+	$dates['day_end']  = isset($_GET['day_end']) ? $_GET['day_end'] : cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']);
611 611
 
612 612
 	// Modify dates based on predefined ranges.
613
-	switch ( $dates['range'] ) :
613
+	switch ($dates['range']) :
614 614
 
615 615
 		case 'this_month' :
616
-			$dates['m_start']  = date( 'n', $current_time );
617
-			$dates['m_end']    = date( 'n', $current_time );
616
+			$dates['m_start']  = date('n', $current_time);
617
+			$dates['m_end']    = date('n', $current_time);
618 618
 			$dates['day']      = 1;
619
-			$dates['day_end']  = cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] );
620
-			$dates['year']     = date( 'Y' );
621
-			$dates['year_end'] = date( 'Y' );
619
+			$dates['day_end']  = cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']);
620
+			$dates['year']     = date('Y');
621
+			$dates['year_end'] = date('Y');
622 622
 			break;
623 623
 
624 624
 		case 'last_month' :
625
-			if ( date( 'n' ) == 1 ) {
625
+			if (date('n') == 1) {
626 626
 				$dates['m_start']  = 12;
627 627
 				$dates['m_end']    = 12;
628
-				$dates['year']     = date( 'Y', $current_time ) - 1;
629
-				$dates['year_end'] = date( 'Y', $current_time ) - 1;
628
+				$dates['year']     = date('Y', $current_time) - 1;
629
+				$dates['year_end'] = date('Y', $current_time) - 1;
630 630
 			} else {
631
-				$dates['m_start']  = date( 'n' ) - 1;
632
-				$dates['m_end']    = date( 'n' ) - 1;
631
+				$dates['m_start']  = date('n') - 1;
632
+				$dates['m_end']    = date('n') - 1;
633 633
 				$dates['year_end'] = $dates['year'];
634 634
 			}
635
-			$dates['day_end'] = cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] );
635
+			$dates['day_end'] = cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']);
636 636
 			break;
637 637
 
638 638
 		case 'today' :
639
-			$dates['day']      = date( 'd', $current_time );
640
-			$dates['day_end']  = date( 'd', $current_time );
641
-			$dates['m_start']  = date( 'n', $current_time );
642
-			$dates['m_end']    = date( 'n', $current_time );
643
-			$dates['year']     = date( 'Y', $current_time );
644
-			$dates['year_end'] = date( 'Y', $current_time );
639
+			$dates['day']      = date('d', $current_time);
640
+			$dates['day_end']  = date('d', $current_time);
641
+			$dates['m_start']  = date('n', $current_time);
642
+			$dates['m_end']    = date('n', $current_time);
643
+			$dates['year']     = date('Y', $current_time);
644
+			$dates['year_end'] = date('Y', $current_time);
645 645
 			break;
646 646
 
647 647
 		case 'yesterday' :
648 648
 
649
-			$year  = date( 'Y', $current_time );
650
-			$month = date( 'n', $current_time );
651
-			$day   = date( 'd', $current_time );
649
+			$year  = date('Y', $current_time);
650
+			$month = date('n', $current_time);
651
+			$day   = date('d', $current_time);
652 652
 
653
-			if ( $month == 1 && $day == 1 ) {
653
+			if ($month == 1 && $day == 1) {
654 654
 
655 655
 				$year -= 1;
656 656
 				$month = 12;
657
-				$day   = cal_days_in_month( CAL_GREGORIAN, $month, $year );
657
+				$day   = cal_days_in_month(CAL_GREGORIAN, $month, $year);
658 658
 
659
-			} elseif ( $month > 1 && $day == 1 ) {
659
+			} elseif ($month > 1 && $day == 1) {
660 660
 
661 661
 				$month -= 1;
662
-				$day = cal_days_in_month( CAL_GREGORIAN, $month, $year );
662
+				$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
663 663
 
664 664
 			} else {
665 665
 
@@ -675,91 +675,91 @@  discard block
 block discarded – undo
675 675
 			break;
676 676
 
677 677
 		case 'this_week' :
678
-			$dates['day'] = date( 'd', $current_time - ( date( 'w', $current_time ) - 1 ) * 60 * 60 * 24 ) - 1;
679
-			$dates['day'] += get_option( 'start_of_week' );
678
+			$dates['day'] = date('d', $current_time - (date('w', $current_time) - 1) * 60 * 60 * 24) - 1;
679
+			$dates['day'] += get_option('start_of_week');
680 680
 			$dates['day_end'] = $dates['day'] + 6;
681
-			$dates['m_start'] = date( 'n', $current_time );
682
-			$dates['m_end']   = date( 'n', $current_time );
683
-			$dates['year']    = date( 'Y', $current_time );
681
+			$dates['m_start'] = date('n', $current_time);
682
+			$dates['m_end']   = date('n', $current_time);
683
+			$dates['year']    = date('Y', $current_time);
684 684
 			break;
685 685
 
686 686
 		case 'last_week' :
687
-			$dates['day'] = date( 'd', $current_time - ( date( 'w' ) - 1 ) * 60 * 60 * 24 ) - 8;
688
-			$dates['day'] += get_option( 'start_of_week' );
687
+			$dates['day'] = date('d', $current_time - (date('w') - 1) * 60 * 60 * 24) - 8;
688
+			$dates['day'] += get_option('start_of_week');
689 689
 			$dates['day_end'] = $dates['day'] + 6;
690
-			$dates['year']    = date( 'Y' );
691
-
692
-			if ( date( 'j', $current_time ) <= 7 ) {
693
-				$dates['m_start'] = date( 'n', $current_time ) - 1;
694
-				$dates['m_end']   = date( 'n', $current_time ) - 1;
695
-				if ( $dates['m_start'] <= 1 ) {
696
-					$dates['year']     = date( 'Y', $current_time ) - 1;
697
-					$dates['year_end'] = date( 'Y', $current_time ) - 1;
690
+			$dates['year']    = date('Y');
691
+
692
+			if (date('j', $current_time) <= 7) {
693
+				$dates['m_start'] = date('n', $current_time) - 1;
694
+				$dates['m_end']   = date('n', $current_time) - 1;
695
+				if ($dates['m_start'] <= 1) {
696
+					$dates['year']     = date('Y', $current_time) - 1;
697
+					$dates['year_end'] = date('Y', $current_time) - 1;
698 698
 				}
699 699
 			} else {
700
-				$dates['m_start'] = date( 'n', $current_time );
701
-				$dates['m_end']   = date( 'n', $current_time );
700
+				$dates['m_start'] = date('n', $current_time);
701
+				$dates['m_end']   = date('n', $current_time);
702 702
 			}
703 703
 			break;
704 704
 
705 705
 		case 'this_quarter' :
706
-			$month_now = date( 'n', $current_time );
706
+			$month_now = date('n', $current_time);
707 707
 
708
-			if ( $month_now <= 3 ) {
708
+			if ($month_now <= 3) {
709 709
 
710 710
 				$dates['m_start'] = 1;
711 711
 				$dates['m_end']   = 4;
712
-				$dates['year']    = date( 'Y', $current_time );
712
+				$dates['year']    = date('Y', $current_time);
713 713
 
714
-			} else if ( $month_now <= 6 ) {
714
+			} else if ($month_now <= 6) {
715 715
 
716 716
 				$dates['m_start'] = 4;
717 717
 				$dates['m_end']   = 7;
718
-				$dates['year']    = date( 'Y', $current_time );
718
+				$dates['year']    = date('Y', $current_time);
719 719
 
720
-			} else if ( $month_now <= 9 ) {
720
+			} else if ($month_now <= 9) {
721 721
 
722 722
 				$dates['m_start'] = 7;
723 723
 				$dates['m_end']   = 10;
724
-				$dates['year']    = date( 'Y', $current_time );
724
+				$dates['year']    = date('Y', $current_time);
725 725
 
726 726
 			} else {
727 727
 
728 728
 				$dates['m_start']  = 10;
729 729
 				$dates['m_end']    = 1;
730
-				$dates['year']     = date( 'Y', $current_time );
731
-				$dates['year_end'] = date( 'Y', $current_time ) + 1;
730
+				$dates['year']     = date('Y', $current_time);
731
+				$dates['year_end'] = date('Y', $current_time) + 1;
732 732
 
733 733
 			}
734 734
 			break;
735 735
 
736 736
 		case 'last_quarter' :
737
-			$month_now = date( 'n' );
737
+			$month_now = date('n');
738 738
 
739
-			if ( $month_now <= 3 ) {
739
+			if ($month_now <= 3) {
740 740
 
741 741
 				$dates['m_start']  = 10;
742 742
 				$dates['m_end']    = 12;
743
-				$dates['year']     = date( 'Y', $current_time ) - 1; // Previous year
744
-				$dates['year_end'] = date( 'Y', $current_time ) - 1; // Previous year
743
+				$dates['year']     = date('Y', $current_time) - 1; // Previous year
744
+				$dates['year_end'] = date('Y', $current_time) - 1; // Previous year
745 745
 
746
-			} else if ( $month_now <= 6 ) {
746
+			} else if ($month_now <= 6) {
747 747
 
748 748
 				$dates['m_start'] = 1;
749 749
 				$dates['m_end']   = 3;
750
-				$dates['year']    = date( 'Y', $current_time );
750
+				$dates['year']    = date('Y', $current_time);
751 751
 
752
-			} else if ( $month_now <= 9 ) {
752
+			} else if ($month_now <= 9) {
753 753
 
754 754
 				$dates['m_start'] = 4;
755 755
 				$dates['m_end']   = 6;
756
-				$dates['year']    = date( 'Y', $current_time );
756
+				$dates['year']    = date('Y', $current_time);
757 757
 
758 758
 			} else {
759 759
 
760 760
 				$dates['m_start'] = 7;
761 761
 				$dates['m_end']   = 9;
762
-				$dates['year']    = date( 'Y', $current_time );
762
+				$dates['year']    = date('Y', $current_time);
763 763
 
764 764
 			}
765 765
 			break;
@@ -767,19 +767,19 @@  discard block
 block discarded – undo
767 767
 		case 'this_year' :
768 768
 			$dates['m_start'] = 1;
769 769
 			$dates['m_end']   = 12;
770
-			$dates['year']    = date( 'Y', $current_time );
770
+			$dates['year']    = date('Y', $current_time);
771 771
 			break;
772 772
 
773 773
 		case 'last_year' :
774 774
 			$dates['m_start']  = 1;
775 775
 			$dates['m_end']    = 12;
776
-			$dates['year']     = date( 'Y', $current_time ) - 1;
777
-			$dates['year_end'] = date( 'Y', $current_time ) - 1;
776
+			$dates['year']     = date('Y', $current_time) - 1;
777
+			$dates['year_end'] = date('Y', $current_time) - 1;
778 778
 			break;
779 779
 
780 780
 	endswitch;
781 781
 
782
-	return apply_filters( 'give_report_dates', $dates );
782
+	return apply_filters('give_report_dates', $dates);
783 783
 }
784 784
 
785 785
 /**
@@ -790,18 +790,18 @@  discard block
 block discarded – undo
790 790
  *
791 791
  * @param $data
792 792
  */
793
-function give_parse_report_dates( $data ) {
793
+function give_parse_report_dates($data) {
794 794
 	$dates = give_get_report_dates();
795 795
 
796 796
 	$view = give_get_reporting_view();
797
-	$tab  = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'earnings';
798
-	$id   = isset( $_GET['form-id'] ) ? $_GET['form-id'] : null;
797
+	$tab  = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'earnings';
798
+	$id   = isset($_GET['form-id']) ? $_GET['form-id'] : null;
799 799
 
800
-	wp_redirect( add_query_arg( $dates, admin_url( 'edit.php?post_type=give_forms&page=give-reports&tab=' . esc_attr( $tab ) . '&view=' . esc_attr( $view ) . '&form-id=' . absint( $id ) ) ) );
800
+	wp_redirect(add_query_arg($dates, admin_url('edit.php?post_type=give_forms&page=give-reports&tab='.esc_attr($tab).'&view='.esc_attr($view).'&form-id='.absint($id))));
801 801
 	give_die();
802 802
 }
803 803
 
804
-add_action( 'give_filter_reports', 'give_parse_report_dates' );
804
+add_action('give_filter_reports', 'give_parse_report_dates');
805 805
 
806 806
 
807 807
 /**
@@ -813,22 +813,22 @@  discard block
 block discarded – undo
813 813
  */
814 814
 function give_reports_refresh_button() {
815 815
 
816
-	$url = wp_nonce_url( add_query_arg( array(
816
+	$url = wp_nonce_url(add_query_arg(array(
817 817
 		'give_action'  => 'refresh_reports_transients',
818 818
 		'give-message' => 'refreshed-reports'
819
-	) ), 'give-refresh-reports' );
819
+	)), 'give-refresh-reports');
820 820
 
821 821
 	echo '<a href="'
822
-	     . esc_url_raw( $url )
823
-	     . '" data-tooltip="'. __( 'Clicking this will clear the reports cache.', 'give' )
822
+	     . esc_url_raw($url)
823
+	     . '" data-tooltip="'.__('Clicking this will clear the reports cache.', 'give')
824 824
 	     . '" data-tooltip-my-position="right center"  data-tooltip-target-position="left center" class="button alignright give-admin-button give-tooltip">'
825 825
 	     . '<span class="give-admin-button-icon give-admin-button-icon-update"></span>'
826
-	     . __( 'Refresh Report Data', 'give' )
826
+	     . __('Refresh Report Data', 'give')
827 827
 	     . '</a>';
828 828
 
829 829
 }
830 830
 
831
-add_action( 'give_reports_graph_additional_stats', 'give_reports_refresh_button' );
831
+add_action('give_reports_graph_additional_stats', 'give_reports_refresh_button');
832 832
 
833 833
 /**
834 834
  * Trigger the refresh of reports transients
@@ -839,20 +839,20 @@  discard block
 block discarded – undo
839 839
  *
840 840
  * @return void
841 841
  */
842
-function give_run_refresh_reports_transients( $data ) {
842
+function give_run_refresh_reports_transients($data) {
843 843
 
844
-	if ( ! wp_verify_nonce( $data['_wpnonce'], 'give-refresh-reports' ) ) {
844
+	if ( ! wp_verify_nonce($data['_wpnonce'], 'give-refresh-reports')) {
845 845
 		return;
846 846
 	}
847 847
 
848 848
 	// Monthly stats.
849
-	Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) );
849
+	Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats'));
850 850
 
851 851
 	// Total earning.
852
-	delete_option( 'give_earnings_total' );
852
+	delete_option('give_earnings_total');
853 853
 
854 854
 	// @todo: Refresh only range related stat cache
855 855
 	give_delete_donation_stats();
856 856
 }
857 857
 
858
-add_action( 'give_refresh_reports_transients', 'give_run_refresh_reports_transients' );
859 858
\ No newline at end of file
859
+add_action('give_refresh_reports_transients', 'give_run_refresh_reports_transients');
860 860
\ No newline at end of file
Please login to merge, or discard this patch.