Test Failed
Push — master ( bb0b3f...21ce85 )
by Devin
06:53 queued 01:10
created
includes/shortcodes.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -789,7 +789,7 @@
 block discarded – undo
789 789
  * @type string $display_style       How the form is displayed, either in new page or modal popup.
790 790
  *                                       Default 'redirect'. Accepts 'redirect', 'modal'.
791 791
  * }
792
- * @return string|bool The markup of the form grid or false.
792
+ * @return string|null The markup of the form grid or false.
793 793
  */
794 794
 function give_form_grid_shortcode( $atts ) {
795 795
 
Please login to merge, or discard this patch.
Spacing   +213 added lines, -213 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,42 +26,42 @@  discard block
 block discarded – undo
26 26
  *
27 27
  * @return string|bool
28 28
  */
29
-function give_donation_history( $atts, $content = false ) {
29
+function give_donation_history($atts, $content = false) {
30 30
 
31
-	$donation_history_args = shortcode_atts( array(
31
+	$donation_history_args = shortcode_atts(array(
32 32
 		'id'             => true,
33 33
 		'date'           => true,
34 34
 		'donor'          => false,
35 35
 		'amount'         => true,
36 36
 		'status'         => false,
37 37
 		'payment_method' => false,
38
-	), $atts, 'donation_history' );
38
+	), $atts, 'donation_history');
39 39
 
40 40
 	// Always show receipt link.
41 41
 	$donation_history_args['details'] = true;
42 42
 
43 43
 	// Set Donation History Shortcode Arguments in session variable.
44
-	Give()->session->set( 'give_donation_history_args', $donation_history_args );
44
+	Give()->session->set('give_donation_history_args', $donation_history_args);
45 45
 
46 46
 	// If payment_key query arg exists, return receipt instead of donation history.
47
-	if ( isset( $_GET['payment_key'] ) ) {
47
+	if (isset($_GET['payment_key'])) {
48 48
 		ob_start();
49 49
 
50
-		echo give_receipt_shortcode( array() );
50
+		echo give_receipt_shortcode(array());
51 51
 
52 52
 		// Display donation history link only if Receipt Access Session is available.
53
-		if ( give_get_receipt_session() ) {
53
+		if (give_get_receipt_session()) {
54 54
 			echo sprintf(
55 55
 				'<a href="%s">%s</a>',
56
-				esc_url( give_get_history_page_uri() ),
57
-				__( '&laquo; Return to All Donations', 'give' )
56
+				esc_url(give_get_history_page_uri()),
57
+				__('&laquo; Return to All Donations', 'give')
58 58
 			);
59 59
 		}
60 60
 
61 61
 		return ob_get_clean();
62 62
 	}
63 63
 
64
-	$email_access = give_get_option( 'email_access' );
64
+	$email_access = give_get_option('email_access');
65 65
 
66 66
 	ob_start();
67 67
 
@@ -74,23 +74,23 @@  discard block
 block discarded – undo
74 74
 	if (
75 75
 		is_user_logged_in()
76 76
 		|| false !== Give()->session->get_session_expiration()
77
-		|| ( give_is_setting_enabled( $email_access ) && Give()->email_access->token_exists )
77
+		|| (give_is_setting_enabled($email_access) && Give()->email_access->token_exists)
78 78
 		|| true === give_get_history_session()
79 79
 	) {
80
-		give_get_template_part( 'history', 'donations' );
80
+		give_get_template_part('history', 'donations');
81 81
 
82
-		if ( ! empty( $content ) ) {
83
-			echo do_shortcode( $content );
82
+		if ( ! empty($content)) {
83
+			echo do_shortcode($content);
84 84
 		}
85 85
 
86
-	} elseif ( give_is_setting_enabled( $email_access ) ) {
86
+	} elseif (give_is_setting_enabled($email_access)) {
87 87
 		// Is Email-based access enabled?
88
-		give_get_template_part( 'email', 'login-form' );
88
+		give_get_template_part('email', 'login-form');
89 89
 
90 90
 	} else {
91 91
 
92
-		echo apply_filters( 'give_donation_history_nonuser_message', Give()->notices->print_frontend_notice( __( 'You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give' ), false ) );
93
-		echo do_shortcode( '[give_login]' );
92
+		echo apply_filters('give_donation_history_nonuser_message', Give()->notices->print_frontend_notice(__('You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give'), false));
93
+		echo do_shortcode('[give_login]');
94 94
 	}
95 95
 
96 96
 	/**
@@ -104,10 +104,10 @@  discard block
 block discarded – undo
104 104
 	 *
105 105
 	 * @return string HTML content
106 106
 	 */
107
-	return apply_filters( 'give_donation_history_shortcode_html', ob_get_clean(), $atts, $content );
107
+	return apply_filters('give_donation_history_shortcode_html', ob_get_clean(), $atts, $content);
108 108
 }
109 109
 
110
-add_shortcode( 'donation_history', 'give_donation_history' );
110
+add_shortcode('donation_history', 'give_donation_history');
111 111
 
112 112
 /**
113 113
  * Donation Form Shortcode
@@ -120,8 +120,8 @@  discard block
 block discarded – undo
120 120
  *
121 121
  * @return string
122 122
  */
123
-function give_form_shortcode( $atts ) {
124
-	$atts = shortcode_atts( array(
123
+function give_form_shortcode($atts) {
124
+	$atts = shortcode_atts(array(
125 125
 		'id'                    => '',
126 126
 		'show_title'            => true,
127 127
 		'show_goal'             => true,
@@ -129,21 +129,21 @@  discard block
 block discarded – undo
129 129
 		'float_labels'          => '',
130 130
 		'display_style'         => '',
131 131
 		'continue_button_title' => '',
132
-	), $atts, 'give_form' );
132
+	), $atts, 'give_form');
133 133
 
134 134
 	// Convert string to bool.
135
-	$atts['show_title'] = filter_var( $atts['show_title'], FILTER_VALIDATE_BOOLEAN );
136
-	$atts['show_goal']  = filter_var( $atts['show_goal'], FILTER_VALIDATE_BOOLEAN );
135
+	$atts['show_title'] = filter_var($atts['show_title'], FILTER_VALIDATE_BOOLEAN);
136
+	$atts['show_goal']  = filter_var($atts['show_goal'], FILTER_VALIDATE_BOOLEAN);
137 137
 
138 138
 	// get the Give Form
139 139
 	ob_start();
140
-	give_get_donation_form( $atts );
140
+	give_get_donation_form($atts);
141 141
 	$final_output = ob_get_clean();
142 142
 
143
-	return apply_filters( 'give_donate_form', $final_output, $atts );
143
+	return apply_filters('give_donate_form', $final_output, $atts);
144 144
 }
145 145
 
146
-add_shortcode( 'give_form', 'give_form_shortcode' );
146
+add_shortcode('give_form', 'give_form_shortcode');
147 147
 
148 148
 /**
149 149
  * Donation Form Goal Shortcode.
@@ -156,36 +156,36 @@  discard block
 block discarded – undo
156 156
  *
157 157
  * @return string
158 158
  */
159
-function give_goal_shortcode( $atts ) {
160
-	$atts = shortcode_atts( array(
159
+function give_goal_shortcode($atts) {
160
+	$atts = shortcode_atts(array(
161 161
 		'id'        => '',
162 162
 		'show_text' => true,
163 163
 		'show_bar'  => true,
164
-	), $atts, 'give_goal' );
164
+	), $atts, 'give_goal');
165 165
 
166 166
 	// get the Give Form.
167 167
 	ob_start();
168 168
 
169 169
 	// Sanity check 1: ensure there is an ID Provided.
170
-	if ( empty( $atts['id'] ) ) {
171
-		Give()->notices->print_frontend_notice( __( 'The shortcode is missing Donation Form ID attribute.', 'give' ), true );
170
+	if (empty($atts['id'])) {
171
+		Give()->notices->print_frontend_notice(__('The shortcode is missing Donation Form ID attribute.', 'give'), true);
172 172
 	}
173 173
 
174 174
 	// Sanity check 2: Check the form even has Goals enabled.
175
-	if ( ! give_is_setting_enabled( give_get_meta( $atts['id'], '_give_goal_option', true ) ) ) {
175
+	if ( ! give_is_setting_enabled(give_get_meta($atts['id'], '_give_goal_option', true))) {
176 176
 
177
-		Give()->notices->print_frontend_notice( __( 'The form does not have Goals enabled.', 'give' ), true );
177
+		Give()->notices->print_frontend_notice(__('The form does not have Goals enabled.', 'give'), true);
178 178
 	} else {
179 179
 		// Passed all sanity checks: output Goal.
180
-		give_show_goal_progress( $atts['id'], $atts );
180
+		give_show_goal_progress($atts['id'], $atts);
181 181
 	}
182 182
 
183 183
 	$final_output = ob_get_clean();
184 184
 
185
-	return apply_filters( 'give_goal_shortcode_output', $final_output, $atts );
185
+	return apply_filters('give_goal_shortcode_output', $final_output, $atts);
186 186
 }
187 187
 
188
-add_shortcode( 'give_goal', 'give_goal_shortcode' );
188
+add_shortcode('give_goal', 'give_goal_shortcode');
189 189
 
190 190
 
191 191
 /**
@@ -202,22 +202,22 @@  discard block
 block discarded – undo
202 202
  *
203 203
  * @return string
204 204
  */
205
-function give_login_form_shortcode( $atts ) {
205
+function give_login_form_shortcode($atts) {
206 206
 
207
-	$atts = shortcode_atts( array(
207
+	$atts = shortcode_atts(array(
208 208
 		// Add backward compatibility for redirect attribute.
209 209
 		'redirect'        => '',
210 210
 		'login-redirect'  => '',
211 211
 		'logout-redirect' => '',
212
-	), $atts, 'give_login' );
212
+	), $atts, 'give_login');
213 213
 
214 214
 	// Check login-redirect attribute first, if it empty or not found then check for redirect attribute and add value of this to login-redirect attribute.
215
-	$atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect'] ) ? $atts['redirect'] : '' );
215
+	$atts['login-redirect'] = ! empty($atts['login-redirect']) ? $atts['login-redirect'] : ( ! empty($atts['redirect']) ? $atts['redirect'] : '');
216 216
 
217
-	return give_login_form( $atts['login-redirect'], $atts['logout-redirect'] );
217
+	return give_login_form($atts['login-redirect'], $atts['logout-redirect']);
218 218
 }
219 219
 
220
-add_shortcode( 'give_login', 'give_login_form_shortcode' );
220
+add_shortcode('give_login', 'give_login_form_shortcode');
221 221
 
222 222
 /**
223 223
  * Register Shortcode.
@@ -232,15 +232,15 @@  discard block
 block discarded – undo
232 232
  *
233 233
  * @return string
234 234
  */
235
-function give_register_form_shortcode( $atts ) {
236
-	$atts = shortcode_atts( array(
235
+function give_register_form_shortcode($atts) {
236
+	$atts = shortcode_atts(array(
237 237
 		'redirect' => '',
238
-	), $atts, 'give_register' );
238
+	), $atts, 'give_register');
239 239
 
240
-	return give_register_form( $atts['redirect'] );
240
+	return give_register_form($atts['redirect']);
241 241
 }
242 242
 
243
-add_shortcode( 'give_register', 'give_register_form_shortcode' );
243
+add_shortcode('give_register', 'give_register_form_shortcode');
244 244
 
245 245
 /**
246 246
  * Receipt Shortcode.
@@ -253,13 +253,13 @@  discard block
 block discarded – undo
253 253
  *
254 254
  * @return string
255 255
  */
256
-function give_receipt_shortcode( $atts ) {
256
+function give_receipt_shortcode($atts) {
257 257
 
258 258
 	global $give_receipt_args;
259 259
 	$payment_key = '';
260 260
 
261
-	$give_receipt_args = shortcode_atts( array(
262
-		'error'          => __( 'You are missing the payment key to view this donation receipt.', 'give' ),
261
+	$give_receipt_args = shortcode_atts(array(
262
+		'error'          => __('You are missing the payment key to view this donation receipt.', 'give'),
263 263
 		'price'          => true,
264 264
 		'donor'          => true,
265 265
 		'date'           => true,
@@ -269,62 +269,62 @@  discard block
 block discarded – undo
269 269
 		'payment_status' => false,
270 270
 		'company_name'   => false,
271 271
 		'status_notice'  => true,
272
-	), $atts, 'give_receipt' );
272
+	), $atts, 'give_receipt');
273 273
 
274 274
 	// set $session var
275 275
 	$session = give_get_purchase_session();
276 276
 
277 277
 	// set payment key var
278
-	if ( isset( $_GET['payment_key'] ) ) {
279
-		$payment_key = urldecode( $_GET['payment_key'] );
280
-	} elseif ( $session ) {
278
+	if (isset($_GET['payment_key'])) {
279
+		$payment_key = urldecode($_GET['payment_key']);
280
+	} elseif ($session) {
281 281
 		$payment_key = $session['purchase_key'];
282
-	} elseif ( $give_receipt_args['payment_key'] ) {
282
+	} elseif ($give_receipt_args['payment_key']) {
283 283
 		$payment_key = $give_receipt_args['payment_key'];
284 284
 	}
285 285
 
286
-	if( ! wp_doing_ajax() ) {
286
+	if ( ! wp_doing_ajax()) {
287 287
 		ob_start();
288
-		give_get_template_part( 'receipt/placeholder' );
288
+		give_get_template_part('receipt/placeholder');
289 289
 		$placeholder = ob_get_clean();
290 290
 
291 291
 		return sprintf(
292 292
 			'<div id="give-receipt" data-shortcode="%s" data-donation-key="%s">%s</div>',
293
-			urlencode_deep( wp_json_encode( $atts ) ),
293
+			urlencode_deep(wp_json_encode($atts)),
294 294
 			$payment_key,
295 295
 			$placeholder
296 296
 		);
297 297
 	}
298 298
 
299
-	$email_access = give_get_option( 'email_access' );
299
+	$email_access = give_get_option('email_access');
300 300
 
301 301
 	// No payment_key found & Email Access is Turned on.
302
-	if ( ! isset( $payment_key ) && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) {
302
+	if ( ! isset($payment_key) && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) {
303 303
 
304 304
 		ob_start();
305 305
 
306
-		give_get_template_part( 'email-login-form' );
306
+		give_get_template_part('email-login-form');
307 307
 
308 308
 		return ob_get_clean();
309 309
 
310
-	} elseif ( ! isset( $payment_key ) ) {
310
+	} elseif ( ! isset($payment_key)) {
311 311
 
312
-		return Give()->notices->print_frontend_notice( $give_receipt_args['error'], false, 'error' );
312
+		return Give()->notices->print_frontend_notice($give_receipt_args['error'], false, 'error');
313 313
 
314 314
 	}
315 315
 
316
-	$user_can_view = give_can_view_receipt( $payment_key );
316
+	$user_can_view = give_can_view_receipt($payment_key);
317 317
 
318 318
 	// Key was provided, but user is logged out. Offer them the ability to login and view the receipt.
319
-	if ( ! $user_can_view && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) {
319
+	if ( ! $user_can_view && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) {
320 320
 
321 321
 		ob_start();
322 322
 
323
-		give_get_template_part( 'email-login-form' );
323
+		give_get_template_part('email-login-form');
324 324
 
325 325
 		return ob_get_clean();
326 326
 
327
-	} elseif ( ! $user_can_view ) {
327
+	} elseif ( ! $user_can_view) {
328 328
 
329 329
 		global $give_login_redirect;
330 330
 
@@ -332,9 +332,9 @@  discard block
 block discarded – undo
332 332
 
333 333
 		ob_start();
334 334
 
335
-		Give()->notices->print_frontend_notice( apply_filters( 'give_must_be_logged_in_error_message', __( 'You must be logged in to view this donation receipt.', 'give' ) ) );
335
+		Give()->notices->print_frontend_notice(apply_filters('give_must_be_logged_in_error_message', __('You must be logged in to view this donation receipt.', 'give')));
336 336
 
337
-		give_get_template_part( 'shortcode', 'login' );
337
+		give_get_template_part('shortcode', 'login');
338 338
 
339 339
 		$login_form = ob_get_clean();
340 340
 
@@ -348,20 +348,20 @@  discard block
 block discarded – undo
348 348
 	 * or if user is logged out and donation was made as a guest, the donation session is checked for
349 349
 	 * or if user is logged in and the user can view sensitive shop data.
350 350
 	 */
351
-	if ( ! apply_filters( 'give_user_can_view_receipt', $user_can_view, $give_receipt_args ) ) {
352
-		return Give()->notices->print_frontend_notice( $give_receipt_args['error'], false, 'error' );
351
+	if ( ! apply_filters('give_user_can_view_receipt', $user_can_view, $give_receipt_args)) {
352
+		return Give()->notices->print_frontend_notice($give_receipt_args['error'], false, 'error');
353 353
 	}
354 354
 
355 355
 	ob_start();
356 356
 
357
-	give_get_template_part( 'shortcode', 'receipt' );
357
+	give_get_template_part('shortcode', 'receipt');
358 358
 
359 359
 	$display = ob_get_clean();
360 360
 
361 361
 	return $display;
362 362
 }
363 363
 
364
-add_shortcode( 'give_receipt', 'give_receipt_shortcode' );
364
+add_shortcode('give_receipt', 'give_receipt_shortcode');
365 365
 
366 366
 /**
367 367
  * Profile Editor Shortcode.
@@ -380,26 +380,26 @@  discard block
 block discarded – undo
380 380
  *
381 381
  * @return string Output generated from the profile editor
382 382
  */
383
-function give_profile_editor_shortcode( $atts ) {
383
+function give_profile_editor_shortcode($atts) {
384 384
 
385 385
 	ob_start();
386 386
 
387 387
 	// Restrict access to donor profile, if donor and user are disconnected.
388
-	$is_donor_disconnected = get_user_meta( get_current_user_id(), '_give_is_donor_disconnected', true );
389
-	if ( is_user_logged_in() && $is_donor_disconnected ) {
390
-		Give()->notices->print_frontend_notice( __( 'Your Donor and User profile are no longer connected. Please contact the site administrator.', 'give' ), true, 'error' );
388
+	$is_donor_disconnected = get_user_meta(get_current_user_id(), '_give_is_donor_disconnected', true);
389
+	if (is_user_logged_in() && $is_donor_disconnected) {
390
+		Give()->notices->print_frontend_notice(__('Your Donor and User profile are no longer connected. Please contact the site administrator.', 'give'), true, 'error');
391 391
 
392 392
 		return false;
393 393
 	}
394 394
 
395
-	give_get_template_part( 'shortcode', 'profile-editor' );
395
+	give_get_template_part('shortcode', 'profile-editor');
396 396
 
397 397
 	$display = ob_get_clean();
398 398
 
399 399
 	return $display;
400 400
 }
401 401
 
402
-add_shortcode( 'give_profile_editor', 'give_profile_editor_shortcode' );
402
+add_shortcode('give_profile_editor', 'give_profile_editor_shortcode');
403 403
 
404 404
 /**
405 405
  * Process Profile Updater Form.
@@ -412,31 +412,31 @@  discard block
 block discarded – undo
412 412
  *
413 413
  * @return bool
414 414
  */
415
-function give_process_profile_editor_updates( $data ) {
415
+function give_process_profile_editor_updates($data) {
416 416
 	// Profile field change request.
417
-	if ( empty( $_POST['give_profile_editor_submit'] ) && ! is_user_logged_in() ) {
417
+	if (empty($_POST['give_profile_editor_submit']) && ! is_user_logged_in()) {
418 418
 		return false;
419 419
 	}
420 420
 
421 421
 	// Nonce security.
422
-	if ( ! wp_verify_nonce( $data['give_profile_editor_nonce'], 'give-profile-editor-nonce' ) ) {
422
+	if ( ! wp_verify_nonce($data['give_profile_editor_nonce'], 'give-profile-editor-nonce')) {
423 423
 		return false;
424 424
 	}
425 425
 
426 426
 	$user_id       = get_current_user_id();
427
-	$old_user_data = get_userdata( $user_id );
427
+	$old_user_data = get_userdata($user_id);
428 428
 
429 429
 	/* @var Give_Donor $donor */
430
-	$donor            = new Give_Donor( $user_id, true );
430
+	$donor            = new Give_Donor($user_id, true);
431 431
 	$old_company_name = $donor->get_company_name();
432 432
 
433
-	$display_name     = isset( $data['give_display_name'] ) ? sanitize_text_field( $data['give_display_name'] ) : $old_user_data->display_name;
434
-	$first_name       = isset( $data['give_first_name'] ) ? sanitize_text_field( $data['give_first_name'] ) : $old_user_data->first_name;
435
-	$last_name        = isset( $data['give_last_name'] ) ? sanitize_text_field( $data['give_last_name'] ) : $old_user_data->last_name;
436
-	$company_name     = ! empty( $data['give_company_name'] ) ? sanitize_text_field( $data['give_company_name'] ) : $old_company_name;
437
-	$email            = isset( $data['give_email'] ) ? sanitize_email( $data['give_email'] ) : $old_user_data->user_email;
438
-	$password         = ! empty( $data['give_new_user_pass1'] ) ? $data['give_new_user_pass1'] : '';
439
-	$confirm_password = ! empty( $data['give_new_user_pass2'] ) ? $data['give_new_user_pass2'] : '';
433
+	$display_name     = isset($data['give_display_name']) ? sanitize_text_field($data['give_display_name']) : $old_user_data->display_name;
434
+	$first_name       = isset($data['give_first_name']) ? sanitize_text_field($data['give_first_name']) : $old_user_data->first_name;
435
+	$last_name        = isset($data['give_last_name']) ? sanitize_text_field($data['give_last_name']) : $old_user_data->last_name;
436
+	$company_name     = ! empty($data['give_company_name']) ? sanitize_text_field($data['give_company_name']) : $old_company_name;
437
+	$email            = isset($data['give_email']) ? sanitize_email($data['give_email']) : $old_user_data->user_email;
438
+	$password         = ! empty($data['give_new_user_pass1']) ? $data['give_new_user_pass1'] : '';
439
+	$confirm_password = ! empty($data['give_new_user_pass2']) ? $data['give_new_user_pass2'] : '';
440 440
 
441 441
 	$userdata = array(
442 442
 		'ID'           => $user_id,
@@ -456,60 +456,60 @@  discard block
 block discarded – undo
456 456
 	 * @param int   $user_id  The ID of the user.
457 457
 	 * @param array $userdata User info, including ID, first name, last name, display name and email.
458 458
 	 */
459
-	do_action( 'give_pre_update_user_profile', $user_id, $userdata );
459
+	do_action('give_pre_update_user_profile', $user_id, $userdata);
460 460
 
461 461
 	// Make sure to validate first name of existing donors.
462
-	if ( empty( $first_name ) ) {
462
+	if (empty($first_name)) {
463 463
 		// Empty First Name.
464
-		give_set_error( 'empty_first_name', __( 'Please enter your first name.', 'give' ) );
464
+		give_set_error('empty_first_name', __('Please enter your first name.', 'give'));
465 465
 	}
466 466
 
467 467
 	// Make sure to validate passwords for existing Donors.
468
-	give_validate_user_password( $password, $confirm_password );
468
+	give_validate_user_password($password, $confirm_password);
469 469
 
470
-	if ( empty( $email ) ) {
470
+	if (empty($email)) {
471 471
 		// Make sure email should not be empty.
472
-		give_set_error( 'email_empty', __( 'The email you entered is empty.', 'give' ) );
472
+		give_set_error('email_empty', __('The email you entered is empty.', 'give'));
473 473
 
474
-	} elseif ( ! is_email( $email ) ) {
474
+	} elseif ( ! is_email($email)) {
475 475
 		// Make sure email should be valid.
476
-		give_set_error( 'email_not_valid', __( 'The email you entered is not valid. Please use another', 'give' ) );
476
+		give_set_error('email_not_valid', __('The email you entered is not valid. Please use another', 'give'));
477 477
 
478
-	} elseif ( $email != $old_user_data->user_email ) {
478
+	} elseif ($email != $old_user_data->user_email) {
479 479
 		// Make sure the new email doesn't belong to another user.
480
-		if ( email_exists( $email ) ) {
481
-			give_set_error( 'user_email_exists', __( 'The email you entered belongs to another user. Please use another.', 'give' ) );
482
-		} elseif ( Give()->donors->get_donor_by( 'email', $email ) ) {
480
+		if (email_exists($email)) {
481
+			give_set_error('user_email_exists', __('The email you entered belongs to another user. Please use another.', 'give'));
482
+		} elseif (Give()->donors->get_donor_by('email', $email)) {
483 483
 			// Make sure the new email doesn't belong to another user.
484
-			give_set_error( 'donor_email_exists', __( 'The email you entered belongs to another donor. Please use another.', 'give' ) );
484
+			give_set_error('donor_email_exists', __('The email you entered belongs to another donor. Please use another.', 'give'));
485 485
 		}
486 486
 	}
487 487
 
488 488
 	// Check for errors.
489 489
 	$errors = give_get_errors();
490 490
 
491
-	if ( $errors ) {
491
+	if ($errors) {
492 492
 		// Send back to the profile editor if there are errors.
493
-		wp_redirect( $data['give_redirect'] );
493
+		wp_redirect($data['give_redirect']);
494 494
 		give_die();
495 495
 	}
496 496
 
497 497
 	// Update Donor First Name and Last Name.
498
-	Give()->donors->update( $donor->id, array(
499
-		'name' => trim( "{$first_name} {$last_name}" ),
500
-	) );
501
-	Give()->donor_meta->update_meta( $donor->id, '_give_donor_first_name', $first_name );
502
-	Give()->donor_meta->update_meta( $donor->id, '_give_donor_last_name', $last_name );
503
-	Give()->donor_meta->update_meta( $donor->id, '_give_donor_company', $company_name );
498
+	Give()->donors->update($donor->id, array(
499
+		'name' => trim("{$first_name} {$last_name}"),
500
+	));
501
+	Give()->donor_meta->update_meta($donor->id, '_give_donor_first_name', $first_name);
502
+	Give()->donor_meta->update_meta($donor->id, '_give_donor_last_name', $last_name);
503
+	Give()->donor_meta->update_meta($donor->id, '_give_donor_company', $company_name);
504 504
 
505 505
 	$current_user = wp_get_current_user();
506 506
 
507 507
 	// Compares new values with old values to detect change in values.
508
-	$email_update        = ( $email !== $current_user->user_email ) ? true : false;
509
-	$display_name_update = ( $display_name !== $current_user->display_name ) ? true : false;
510
-	$first_name_update   = ( $first_name !== $current_user->first_name ) ? true : false;
511
-	$last_name_update    = ( $last_name !== $current_user->last_name ) ? true : false;
512
-	$company_name_update = ( $company_name !== $old_company_name ) ? true : false;
508
+	$email_update        = ($email !== $current_user->user_email) ? true : false;
509
+	$display_name_update = ($display_name !== $current_user->display_name) ? true : false;
510
+	$first_name_update   = ($first_name !== $current_user->first_name) ? true : false;
511
+	$last_name_update    = ($last_name !== $current_user->last_name) ? true : false;
512
+	$company_name_update = ($company_name !== $old_company_name) ? true : false;
513 513
 	$update_code         = 0;
514 514
 
515 515
 	/**
@@ -517,35 +517,35 @@  discard block
 block discarded – undo
517 517
 	 *
518 518
 	 * @var boolean
519 519
 	 */
520
-	$profile_update = ( $email_update || $display_name_update || $first_name_update || $last_name_update || $company_name_update );
520
+	$profile_update = ($email_update || $display_name_update || $first_name_update || $last_name_update || $company_name_update);
521 521
 
522 522
 	/**
523 523
 	 * True if password fields are filled.
524 524
 	 *
525 525
 	 * @var boolean
526 526
 	 */
527
-	$password_update = ( ! empty( $password ) && ! empty( $confirm_password ) );
527
+	$password_update = ( ! empty($password) && ! empty($confirm_password));
528 528
 
529
-	if ( $profile_update ) {
529
+	if ($profile_update) {
530 530
 
531 531
 		// If only profile fields are updated.
532 532
 		$update_code = '1';
533 533
 
534
-		if ( $password_update ) {
534
+		if ($password_update) {
535 535
 
536 536
 			// If profile fields AND password both are updated.
537 537
 			$update_code = '2';
538 538
 		}
539
-	} elseif ( $password_update ) {
539
+	} elseif ($password_update) {
540 540
 
541 541
 		// If only password is updated.
542 542
 		$update_code = '3';
543 543
 	}
544 544
 
545 545
 	// Update the user.
546
-	$updated = wp_update_user( $userdata );
546
+	$updated = wp_update_user($userdata);
547 547
 
548
-	if ( $updated ) {
548
+	if ($updated) {
549 549
 
550 550
 		/**
551 551
 		 * Fires after updating user profile.
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
 		 * @param int   $user_id  The ID of the user.
556 556
 		 * @param array $userdata User info, including ID, first name, last name, display name and email.
557 557
 		 */
558
-		do_action( 'give_user_profile_updated', $user_id, $userdata );
558
+		do_action('give_user_profile_updated', $user_id, $userdata);
559 559
 
560 560
 		$profile_edit_redirect_args = array(
561 561
 			'updated'     => 'true',
@@ -566,10 +566,10 @@  discard block
 block discarded – undo
566 566
 		 * Update codes '2' and '3' indicate a password change.
567 567
 		 * If the password is changed, then logout and redirect to the same page.
568 568
 		 */
569
-		if ( '2' === $update_code || '3' === $update_code ) {
570
-			wp_logout( wp_redirect( add_query_arg( $profile_edit_redirect_args, $data['give_redirect'] ) ) );
569
+		if ('2' === $update_code || '3' === $update_code) {
570
+			wp_logout(wp_redirect(add_query_arg($profile_edit_redirect_args, $data['give_redirect'])));
571 571
 		} else {
572
-			wp_redirect( add_query_arg( $profile_edit_redirect_args, $data['give_redirect'] ) );
572
+			wp_redirect(add_query_arg($profile_edit_redirect_args, $data['give_redirect']));
573 573
 		}
574 574
 
575 575
 		give_die();
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
 	return false;
579 579
 }
580 580
 
581
-add_action( 'give_edit_user_profile', 'give_process_profile_editor_updates' );
581
+add_action('give_edit_user_profile', 'give_process_profile_editor_updates');
582 582
 
583 583
 /**
584 584
  * Give totals Shortcode.
@@ -591,24 +591,24 @@  discard block
 block discarded – undo
591 591
  *
592 592
  * @return string
593 593
  */
594
-function give_totals_shortcode( $atts ) {
595
-	$total = get_option( 'give_earnings_total', false );
594
+function give_totals_shortcode($atts) {
595
+	$total = get_option('give_earnings_total', false);
596 596
 
597
-	$message = apply_filters( 'give_totals_message', __( 'Hey! We\'ve raised {total} of the {total_goal} we are trying to raise for this campaign!', 'give' ) );
597
+	$message = apply_filters('give_totals_message', __('Hey! We\'ve raised {total} of the {total_goal} we are trying to raise for this campaign!', 'give'));
598 598
 
599
-	$atts = shortcode_atts( array(
599
+	$atts = shortcode_atts(array(
600 600
 		'total_goal'   => 0, // integer
601 601
 		'ids'          => 0, // integer|array
602 602
 		'cats'         => 0, // integer|array
603 603
 		'tags'         => 0, // integer|array
604 604
 		'message'      => $message,
605 605
 		'link'         => '', // URL
606
-		'link_text'    => __( 'Donate Now', 'give' ), // string,
606
+		'link_text'    => __('Donate Now', 'give'), // string,
607 607
 		'progress_bar' => true, // boolean
608
-	), $atts, 'give_totals' );
608
+	), $atts, 'give_totals');
609 609
 
610 610
 	// Total Goal.
611
-	$total_goal = give_maybe_sanitize_amount( $atts['total_goal'] );
611
+	$total_goal = give_maybe_sanitize_amount($atts['total_goal']);
612 612
 
613 613
 	/**
614 614
 	 * Give Action fire before the shortcode is rendering is started.
@@ -617,14 +617,14 @@  discard block
 block discarded – undo
617 617
 	 *
618 618
 	 * @param array $atts shortcode attribute.
619 619
 	 */
620
-	do_action( 'give_totals_goal_shortcode_before_render', $atts );
620
+	do_action('give_totals_goal_shortcode_before_render', $atts);
621 621
 
622 622
 	// Build query based on cat, tag and Form ids.
623
-	if ( ! empty( $atts['cats'] ) || ! empty( $atts['tags'] ) || ! empty( $atts['ids'] ) ) {
623
+	if ( ! empty($atts['cats']) || ! empty($atts['tags']) || ! empty($atts['ids'])) {
624 624
 
625 625
 		$form_ids = array();
626
-		if ( ! empty( $atts['ids'] ) ) {
627
-			$form_ids = array_filter( array_map( 'trim', explode( ',', $atts['ids'] ) ) );
626
+		if ( ! empty($atts['ids'])) {
627
+			$form_ids = array_filter(array_map('trim', explode(',', $atts['ids'])));
628 628
 		}
629 629
 
630 630
 		/**
@@ -638,23 +638,23 @@  discard block
 block discarded – undo
638 638
 			'post_type'        => 'give_forms',
639 639
 			'post_status'      => 'publish',
640 640
 			'post__in'         => $form_ids,
641
-			'posts_per_page'   => - 1,
641
+			'posts_per_page'   => -1,
642 642
 			'fields'           => 'ids',
643 643
 			'tax_query'        => array(
644 644
 				'relation' => 'AND',
645 645
 			),
646 646
 		);
647 647
 
648
-		if ( ! empty( $atts['cats'] ) ) {
649
-			$cats                     = array_filter( array_map( 'trim', explode( ',', $atts['cats'] ) ) );
648
+		if ( ! empty($atts['cats'])) {
649
+			$cats                     = array_filter(array_map('trim', explode(',', $atts['cats'])));
650 650
 			$form_args['tax_query'][] = array(
651 651
 				'taxonomy' => 'give_forms_category',
652 652
 				'terms'    => $cats,
653 653
 			);
654 654
 		}
655 655
 
656
-		if ( ! empty( $atts['tags'] ) ) {
657
-			$tags                     = array_filter( array_map( 'trim', explode( ',', $atts['tags'] ) ) );
656
+		if ( ! empty($atts['tags'])) {
657
+			$tags                     = array_filter(array_map('trim', explode(',', $atts['tags'])));
658 658
 			$form_args['tax_query'][] = array(
659 659
 				'taxonomy' => 'give_forms_tag',
660 660
 				'terms'    => $tags,
@@ -670,15 +670,15 @@  discard block
 block discarded – undo
670 670
 		 *
671 671
 		 * @return array $form_args WP query argument for Total Goal.
672 672
 		 */
673
-		$form_args = (array) apply_filters( 'give_totals_goal_shortcode_query_args', $form_args );
673
+		$form_args = (array) apply_filters('give_totals_goal_shortcode_query_args', $form_args);
674 674
 
675
-		$forms = new WP_Query( $form_args );
675
+		$forms = new WP_Query($form_args);
676 676
 
677
-		if ( isset( $forms->posts ) ) {
677
+		if (isset($forms->posts)) {
678 678
 			$total = 0;
679
-			foreach ( $forms->posts as $post ) {
680
-				$form_earning = give_get_meta( $post, '_give_form_earnings', true );
681
-				$form_earning = ! empty( $form_earning ) ? $form_earning : 0;
679
+			foreach ($forms->posts as $post) {
680
+				$form_earning = give_get_meta($post, '_give_form_earnings', true);
681
+				$form_earning = ! empty($form_earning) ? $form_earning : 0;
682 682
 
683 683
 				/**
684 684
 				 * Update Form earnings.
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
 				 * @param int $post Form ID.
689 689
 				 * @param string $form_earning Total earning of Form.
690 690
 				 */
691
-				$total += apply_filters( 'give_totals_form_earning', $form_earning, $post );
691
+				$total += apply_filters('give_totals_form_earning', $form_earning, $post);
692 692
 			}
693 693
 		}
694 694
 
@@ -696,23 +696,23 @@  discard block
 block discarded – undo
696 696
 
697 697
 	// Append link with text.
698 698
 	$donate_link = '';
699
-	if ( ! empty( $atts['link'] ) ) {
700
-		$donate_link = sprintf( ' <a class="give-totals-text-link" href="%1$s">%2$s</a>', esc_url( $atts['link'] ), esc_html( $atts['link_text'] ) );
699
+	if ( ! empty($atts['link'])) {
700
+		$donate_link = sprintf(' <a class="give-totals-text-link" href="%1$s">%2$s</a>', esc_url($atts['link']), esc_html($atts['link_text']));
701 701
 	}
702 702
 
703 703
 	// Replace {total} in message.
704
-	$message = str_replace( '{total}', give_currency_filter(
705
-		give_format_amount( $total,
706
-			array( 'sanitize' => false )
704
+	$message = str_replace('{total}', give_currency_filter(
705
+		give_format_amount($total,
706
+			array('sanitize' => false)
707 707
 		)
708
-	), esc_html( $atts['message'] ) );
708
+	), esc_html($atts['message']));
709 709
 
710 710
 	// Replace {total_goal} in message.
711
-	$message = str_replace( '{total_goal}', give_currency_filter(
712
-		give_format_amount( $total_goal,
713
-			array( 'sanitize' => true )
711
+	$message = str_replace('{total_goal}', give_currency_filter(
712
+		give_format_amount($total_goal,
713
+			array('sanitize' => true)
714 714
 		)
715
-	), $message );
715
+	), $message);
716 716
 
717 717
 	/**
718 718
 	 * Update Give totals shortcode output.
@@ -722,19 +722,19 @@  discard block
 block discarded – undo
722 722
 	 * @param string $message Shortcode Message.
723 723
 	 * @param array $atts ShortCode attributes.
724 724
 	 */
725
-	$message = apply_filters( 'give_totals_shortcode_message', $message, $atts );
725
+	$message = apply_filters('give_totals_shortcode_message', $message, $atts);
726 726
 
727 727
 	ob_start();
728 728
 	?>
729 729
 	<div class="give-totals-shortcode-wrap">
730 730
 		<?php
731 731
 		// Show Progress Bar if progress_bar set true.
732
-		$show_progress_bar = isset( $atts['progress_bar'] ) ? filter_var( $atts['progress_bar'], FILTER_VALIDATE_BOOLEAN ) : true;
733
-		if ( $show_progress_bar ) {
734
-			give_show_goal_totals_progress( $total, $total_goal );
732
+		$show_progress_bar = isset($atts['progress_bar']) ? filter_var($atts['progress_bar'], FILTER_VALIDATE_BOOLEAN) : true;
733
+		if ($show_progress_bar) {
734
+			give_show_goal_totals_progress($total, $total_goal);
735 735
 		}
736 736
 
737
-		echo sprintf( $message ) . $donate_link;
737
+		echo sprintf($message).$donate_link;
738 738
 		?>
739 739
 	</div>
740 740
 	<?php
@@ -749,7 +749,7 @@  discard block
 block discarded – undo
749 749
 	 * @param array  $atts               shortcode attribute.
750 750
 	 * @param string $give_totals_output shortcode output.
751 751
 	 */
752
-	do_action( 'give_totals_goal_shortcode_after_render', $atts, $give_totals_output );
752
+	do_action('give_totals_goal_shortcode_after_render', $atts, $give_totals_output);
753 753
 
754 754
 	/**
755 755
 	 * Give Totals Shortcode output.
@@ -758,11 +758,11 @@  discard block
 block discarded – undo
758 758
 	 *
759 759
 	 * @param string $give_totals_output
760 760
 	 */
761
-	return apply_filters( 'give_totals_shortcode_output', $give_totals_output );
761
+	return apply_filters('give_totals_shortcode_output', $give_totals_output);
762 762
 
763 763
 }
764 764
 
765
-add_shortcode( 'give_totals', 'give_totals_shortcode' );
765
+add_shortcode('give_totals', 'give_totals_shortcode');
766 766
 
767 767
 
768 768
 /**
@@ -793,11 +793,11 @@  discard block
 block discarded – undo
793 793
  * }
794 794
  * @return string|bool The markup of the form grid or false.
795 795
  */
796
-function give_form_grid_shortcode( $atts ) {
796
+function give_form_grid_shortcode($atts) {
797 797
 
798 798
 	$give_settings = give_get_settings();
799 799
 
800
-	$atts = shortcode_atts( array(
800
+	$atts = shortcode_atts(array(
801 801
 		'forms_per_page'      => 12,
802 802
 		'paged'               => true,
803 803
 		'ids'                 => '',
@@ -814,11 +814,11 @@  discard block
 block discarded – undo
814 814
 		'excerpt_length'      => 16,
815 815
 		'display_style'       => 'modal_reveal',
816 816
 		'status'              => '', // open or closed
817
-	), $atts );
817
+	), $atts);
818 818
 
819 819
 	// Validate integer attributes.
820
-	$atts['forms_per_page'] = intval( $atts['forms_per_page'] );
821
-	$atts['excerpt_length'] = intval( $atts['excerpt_length'] );
820
+	$atts['forms_per_page'] = intval($atts['forms_per_page']);
821
+	$atts['excerpt_length'] = intval($atts['excerpt_length']);
822 822
 
823 823
 	// Validate boolean attributes.
824 824
 	$boolean_attributes = array(
@@ -829,8 +829,8 @@  discard block
 block discarded – undo
829 829
 		'show_featured_image',
830 830
 	);
831 831
 
832
-	foreach ( $boolean_attributes as $att ) {
833
-		$atts[ $att ] = filter_var( $atts[ $att ], FILTER_VALIDATE_BOOLEAN );
832
+	foreach ($boolean_attributes as $att) {
833
+		$atts[$att] = filter_var($atts[$att], FILTER_VALIDATE_BOOLEAN);
834 834
 	}
835 835
 
836 836
 	// Set default form query args.
@@ -844,9 +844,9 @@  discard block
 block discarded – undo
844 844
 	);
845 845
 
846 846
 	// Filter results of form grid based on form status.
847
-	$form_closed_status = trim( $atts['status'] );
847
+	$form_closed_status = trim($atts['status']);
848 848
 
849
-	if ( ! empty( $form_closed_status ) ) {
849
+	if ( ! empty($form_closed_status)) {
850 850
 		$form_args['meta_query'] = array(
851 851
 			array(
852 852
 				'key'   => '_give_form_status',
@@ -856,25 +856,25 @@  discard block
 block discarded – undo
856 856
 	}
857 857
 
858 858
 	// Maybe add pagination.
859
-	if ( true === $atts['paged'] ) {
860
-		$form_args['paged'] = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
859
+	if (true === $atts['paged']) {
860
+		$form_args['paged'] = get_query_var('paged') ? get_query_var('paged') : 1;
861 861
 	}
862 862
 
863 863
 	// Maybe filter forms by IDs.
864
-	if ( ! empty( $atts['ids'] ) ) {
865
-		$form_args['post__in'] = array_filter( array_map( 'trim', explode( ',', $atts['ids'] ) ) );
864
+	if ( ! empty($atts['ids'])) {
865
+		$form_args['post__in'] = array_filter(array_map('trim', explode(',', $atts['ids'])));
866 866
 	}
867 867
 
868 868
 	// Convert comma-separated form IDs into array.
869
-	if ( ! empty( $atts['exclude'] ) ) {
870
-		$form_args['post__not_in'] = array_filter( array_map( function( $item ) {
871
-			return intval( trim( $item ) );
872
-		}, explode( ',', $atts['exclude'] ) ) );
869
+	if ( ! empty($atts['exclude'])) {
870
+		$form_args['post__not_in'] = array_filter(array_map(function($item) {
871
+			return intval(trim($item));
872
+		}, explode(',', $atts['exclude'])));
873 873
 	}
874 874
 
875 875
 	// Maybe filter by form category.
876
-	if ( ! empty( $atts['cats'] ) ) {
877
-		$cats                     = array_filter( array_map( 'trim', explode( ',', $atts['cats'] ) ) );
876
+	if ( ! empty($atts['cats'])) {
877
+		$cats                     = array_filter(array_map('trim', explode(',', $atts['cats'])));
878 878
 		$tax_query                = array(
879 879
 			'taxonomy' => 'give_forms_category',
880 880
 			'terms'    => $cats,
@@ -883,8 +883,8 @@  discard block
 block discarded – undo
883 883
 	}
884 884
 
885 885
 	// Maybe filter by form tag.
886
-	if ( ! empty( $atts['tags'] ) ) {
887
-		$tags                     = array_filter( array_map( 'trim', explode( ',', $atts['tags'] ) ) );
886
+	if ( ! empty($atts['tags'])) {
887
+		$tags                     = array_filter(array_map('trim', explode(',', $atts['tags'])));
888 888
 		$tax_query                = array(
889 889
 			'taxonomy' => 'give_forms_tag',
890 890
 			'terms'    => $tags,
@@ -893,24 +893,24 @@  discard block
 block discarded – undo
893 893
 	}
894 894
 
895 895
 	// Query to output donation forms.
896
-	$form_query = new WP_Query( $form_args );
896
+	$form_query = new WP_Query($form_args);
897 897
 
898
-	if ( $form_query->have_posts() ) {
898
+	if ($form_query->have_posts()) {
899 899
 		ob_start();
900 900
 
901
-		add_filter( 'add_give_goal_progress_class', 'add_give_goal_progress_class', 10, 1 );
902
-		add_filter( 'add_give_goal_progress_bar_class', 'add_give_goal_progress_bar_class', 10, 1 );
903
-		add_filter( 'give_form_wrap_classes', 'add_class_for_form_grid', 10, 3 );
904
-		add_action( 'give_donation_form_top', 'give_is_form_grid_page_hidden_field', 10, 3 );
901
+		add_filter('add_give_goal_progress_class', 'add_give_goal_progress_class', 10, 1);
902
+		add_filter('add_give_goal_progress_bar_class', 'add_give_goal_progress_bar_class', 10, 1);
903
+		add_filter('give_form_wrap_classes', 'add_class_for_form_grid', 10, 3);
904
+		add_action('give_donation_form_top', 'give_is_form_grid_page_hidden_field', 10, 3);
905 905
 
906 906
 		echo '<div class="give-wrap">';
907
-		echo '<div class="give-grid give-grid--' . esc_attr( $atts['columns'] ) . '">';
907
+		echo '<div class="give-grid give-grid--'.esc_attr($atts['columns']).'">';
908 908
 
909
-		while ( $form_query->have_posts() ) {
909
+		while ($form_query->have_posts()) {
910 910
 			$form_query->the_post();
911 911
 
912 912
 			// Give/templates/shortcode-form-grid.php.
913
-			give_get_template( 'shortcode-form-grid', array( $give_settings, $atts ) );
913
+			give_get_template('shortcode-form-grid', array($give_settings, $atts));
914 914
 
915 915
 		}
916 916
 
@@ -918,28 +918,28 @@  discard block
 block discarded – undo
918 918
 
919 919
 		echo '</div><!-- .give-grid -->';
920 920
 
921
-		remove_filter( 'add_give_goal_progress_class', 'add_give_goal_progress_class' );
922
-		remove_filter( 'add_give_goal_progress_bar_class', 'add_give_goal_progress_bar_class' );
923
-		remove_filter( 'give_form_wrap_classes', 'add_class_for_form_grid', 10 );
924
-		remove_action( 'give_donation_form_top', 'give_is_form_grid_page_hidden_field', 10 );
921
+		remove_filter('add_give_goal_progress_class', 'add_give_goal_progress_class');
922
+		remove_filter('add_give_goal_progress_bar_class', 'add_give_goal_progress_bar_class');
923
+		remove_filter('give_form_wrap_classes', 'add_class_for_form_grid', 10);
924
+		remove_action('give_donation_form_top', 'give_is_form_grid_page_hidden_field', 10);
925 925
 
926
-		if ( false !== $atts['paged'] ) {
926
+		if (false !== $atts['paged']) {
927 927
 			$paginate_args = array(
928
-				'current'   => max( 1, get_query_var( 'paged' ) ),
928
+				'current'   => max(1, get_query_var('paged')),
929 929
 				'total'     => $form_query->max_num_pages,
930 930
 				'show_all'  => false,
931 931
 				'end_size'  => 1,
932 932
 				'mid_size'  => 2,
933 933
 				'prev_next' => true,
934
-				'prev_text' => __( '« Previous', 'give' ),
935
-				'next_text' => __( 'Next »', 'give' ),
934
+				'prev_text' => __('« Previous', 'give'),
935
+				'next_text' => __('Next »', 'give'),
936 936
 				'type'      => 'plain',
937 937
 				'add_args'  => false,
938 938
 			);
939 939
 
940 940
 			printf(
941 941
 				'<div class="give-page-numbers">%s</div>',
942
-				paginate_links( $paginate_args )
942
+				paginate_links($paginate_args)
943 943
 			);
944 944
 		}
945 945
 		echo '</div><!-- .give-wrap -->';
@@ -948,4 +948,4 @@  discard block
 block discarded – undo
948 948
 	}
949 949
 }
950 950
 
951
-add_shortcode( 'give_form_grid', 'give_form_grid_shortcode' );
951
+add_shortcode('give_form_grid', 'give_form_grid_shortcode');
Please login to merge, or discard this patch.
templates/shortcode-receipt.php 1 patch
Spacing   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -6,29 +6,29 @@  discard block
 block discarded – undo
6 6
 global $give_receipt_args, $payment;
7 7
 
8 8
 // Validation: Ensure $payment var is set.
9
-if ( empty( $payment ) ) {
10
-	$payment = ! empty( $give_receipt_args['id'] ) ? get_post( $give_receipt_args['id'] ) : 0;
9
+if (empty($payment)) {
10
+	$payment = ! empty($give_receipt_args['id']) ? get_post($give_receipt_args['id']) : 0;
11 11
 }
12 12
 
13 13
 // Double-Validation: Check for $payment global.
14
-if ( empty( $payment ) ) {
15
-	Give()->notices->print_frontend_notice( __( 'The specified receipt ID appears to be invalid.', 'give' ) );
14
+if (empty($payment)) {
15
+	Give()->notices->print_frontend_notice(__('The specified receipt ID appears to be invalid.', 'give'));
16 16
 
17 17
 	return;
18 18
 }
19 19
 
20 20
 $donation_id  = $payment->ID;
21
-$donation_number = Give()->seq_donation_number->get_serial_code( $payment->ID );
22
-$form_id      = give_get_payment_meta( $donation_id, '_give_payment_form_id', true );
23
-$donation     = give_get_donation_form_title( $donation_id );
24
-$user         = give_get_payment_meta_user_info( $donation_id );
25
-$email        = give_get_payment_user_email( $donation_id );
21
+$donation_number = Give()->seq_donation_number->get_serial_code($payment->ID);
22
+$form_id      = give_get_payment_meta($donation_id, '_give_payment_form_id', true);
23
+$donation     = give_get_donation_form_title($donation_id);
24
+$user         = give_get_payment_meta_user_info($donation_id);
25
+$email        = give_get_payment_user_email($donation_id);
26 26
 $status       = $payment->post_status;
27
-$status_label = give_get_payment_status( $payment, true );
28
-$company_name = give_get_payment_meta( $donation_id, '_give_donation_company', true );
27
+$status_label = give_get_payment_status($payment, true);
28
+$company_name = give_get_payment_meta($donation_id, '_give_donation_company', true);
29 29
 
30 30
 // Update donor name, if title prefix is set.
31
-$full_name    = give_get_donor_name_with_title_prefixes( $user['title'], "{$user['first_name']} {$user['last_name']}" );
31
+$full_name    = give_get_donor_name_with_title_prefixes($user['title'], "{$user['first_name']} {$user['last_name']}");
32 32
 
33 33
 /**
34 34
  * Generate Donation Receipt Arguments.
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
  * @since 1.8.8
40 40
  */
41 41
 $give_receipt_args['donation_receipt']['donor'] = array(
42
-	'name'    => __( 'Donor', 'give' ),
42
+	'name'    => __('Donor', 'give'),
43 43
 	'value'   => $full_name,
44 44
 	'display' => $give_receipt_args['donor'],
45 45
 );
@@ -54,51 +54,51 @@  discard block
 block discarded – undo
54 54
  * @return bool show/hide company name in donation receipt page.
55 55
  */
56 56
 $give_receipt_args['donation_receipt']['company_name'] = array(
57
-	'name'    => __( 'Company Name', 'give' ),
58
-	'value'   => esc_attr( $company_name ),
57
+	'name'    => __('Company Name', 'give'),
58
+	'value'   => esc_attr($company_name),
59 59
 	// Do not show company field if empty
60
-	'display' => empty( $company_name ) ? false : $give_receipt_args['company_name'],
60
+	'display' => empty($company_name) ? false : $give_receipt_args['company_name'],
61 61
 );
62 62
 
63 63
 $give_receipt_args['donation_receipt']['date'] = array(
64
-	'name'    => __( 'Date', 'give' ),
65
-	'value'   => date_i18n( give_date_format(), strtotime( give_get_payment_completed_date( $donation_id ) ) ),
64
+	'name'    => __('Date', 'give'),
65
+	'value'   => date_i18n(give_date_format(), strtotime(give_get_payment_completed_date($donation_id))),
66 66
 	'display' => $give_receipt_args['date'],
67 67
 );
68 68
 
69 69
 $give_receipt_args['donation_receipt']['total_donation'] = array(
70
-	'name'    => __( 'Total Donation', 'give' ),
71
-	'value'   => give_donation_amount( $donation_id, array( 'currency' => true, 'amount' => true, 'type' => 'receipt' ) ),
70
+	'name'    => __('Total Donation', 'give'),
71
+	'value'   => give_donation_amount($donation_id, array('currency' => true, 'amount' => true, 'type' => 'receipt')),
72 72
 	'display' => $give_receipt_args['price'],
73 73
 );
74 74
 
75 75
 $give_receipt_args['donation_receipt']['donation'] = array(
76
-	'name'    => __( 'Donation', 'give' ),
76
+	'name'    => __('Donation', 'give'),
77 77
 	'value'   => $donation,
78 78
 	'display' => true,
79 79
 );
80 80
 
81 81
 $give_receipt_args['donation_receipt']['donation_status'] = array(
82
-	'name'    => __( 'Donation Status', 'give' ),
83
-	'value'   => esc_attr( $status_label ),
82
+	'name'    => __('Donation Status', 'give'),
83
+	'value'   => esc_attr($status_label),
84 84
 	'display' => $give_receipt_args['payment_status'],
85 85
 );
86 86
 
87 87
 $give_receipt_args['donation_receipt']['donation_id'] = array(
88
-	'name'    => __( 'Donation ID', 'give' ),
88
+	'name'    => __('Donation ID', 'give'),
89 89
 	'value'   => $donation_number,
90 90
 	'display' => $give_receipt_args['payment_id'],
91 91
 );
92 92
 
93 93
 $give_receipt_args['donation_receipt']['payment_key'] = array(
94
-	'name'    => __( 'Payment Key', 'give' ),
95
-	'value'   => get_post_meta( $donation_id, '_give_payment_purchase_key', true ),
94
+	'name'    => __('Payment Key', 'give'),
95
+	'value'   => get_post_meta($donation_id, '_give_payment_purchase_key', true),
96 96
 	'display' => $give_receipt_args['payment_key'],
97 97
 );
98 98
 
99 99
 $give_receipt_args['donation_receipt']['payment_method'] = array(
100
-	'name'    => __( 'Payment Method', 'give' ),
101
-	'value'   => give_get_gateway_checkout_label( give_get_payment_gateway( $donation_id ) ),
100
+	'name'    => __('Payment Method', 'give'),
101
+	'value'   => give_get_gateway_checkout_label(give_get_payment_gateway($donation_id)),
102 102
 	'display' => $give_receipt_args['payment_method'],
103 103
 );
104 104
 
@@ -113,10 +113,10 @@  discard block
 block discarded – undo
113 113
  *
114 114
  * @since 1.8.8
115 115
  */
116
-$give_receipt_args['donation_receipt'] = apply_filters( 'give_donation_receipt_args', $give_receipt_args['donation_receipt'], $donation_id, $form_id );
116
+$give_receipt_args['donation_receipt'] = apply_filters('give_donation_receipt_args', $give_receipt_args['donation_receipt'], $donation_id, $form_id);
117 117
 
118 118
 // When the donation were made through offline donation, We won't show receipt and payment status though.
119
-if ( 'offline' === give_get_payment_gateway( $payment->ID ) && 'pending' === $status ) {
119
+if ('offline' === give_get_payment_gateway($payment->ID) && 'pending' === $status) {
120 120
 
121 121
 	/**
122 122
 	 * Before the offline donation receipt content starts.
@@ -126,13 +126,13 @@  discard block
 block discarded – undo
126 126
 	 * @param Give_Payment $payment           Donation payment object.
127 127
 	 * @param array        $give_receipt_args Receipt Arguments.
128 128
 	 */
129
-	do_action( 'give_receipt_before_offline_payment', $payment, $give_receipt_args );
129
+	do_action('give_receipt_before_offline_payment', $payment, $give_receipt_args);
130 130
 	?>
131
-	<h2><?php echo apply_filters( 'give_receipt_offline_payment_heading', __( 'Your Donation is Almost Complete!', 'give' ) ); ?></h2>
132
-	<div id="give_donation_receipt" class="<?php echo esc_attr( apply_filters( 'give_receipt_offline_payment_classes', 'give_receipt_offline_payment' ) ); ?>">
131
+	<h2><?php echo apply_filters('give_receipt_offline_payment_heading', __('Your Donation is Almost Complete!', 'give')); ?></h2>
132
+	<div id="give_donation_receipt" class="<?php echo esc_attr(apply_filters('give_receipt_offline_payment_classes', 'give_receipt_offline_payment')); ?>">
133 133
 		<?php
134 134
 		// Instruction for offline donation.
135
-		$offline_instruction = give_get_offline_payment_instruction( $form_id, true );
135
+		$offline_instruction = give_get_offline_payment_instruction($form_id, true);
136 136
 
137 137
 		/**
138 138
 		 * Instruction for the offline donation.
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 		 * @param Give_Payment $payment             Payment object.
144 144
 		 * @param integer      $form_id             Donation form id.
145 145
 		 */
146
-		echo apply_filters( 'give_receipt_offline_payment_instruction', $offline_instruction, $payment, $form_id );
146
+		echo apply_filters('give_receipt_offline_payment_instruction', $offline_instruction, $payment, $form_id);
147 147
 		?>
148 148
 	</div>
149 149
 	<?php
@@ -155,52 +155,52 @@  discard block
 block discarded – undo
155 155
 	 * @param Give_Payment $payment           Donation payment object.
156 156
 	 * @param array        $give_receipt_args Receipt Arguments.
157 157
 	 */
158
-	do_action( 'give_receipt_after_offline_payment', $payment, $give_receipt_args );
158
+	do_action('give_receipt_after_offline_payment', $payment, $give_receipt_args);
159 159
 
160 160
 	return;
161 161
 }
162 162
 
163 163
 // Show payment status notice based on shortcode attribute.
164
-if ( filter_var( $give_receipt_args['status_notice'], FILTER_VALIDATE_BOOLEAN ) ) {
164
+if (filter_var($give_receipt_args['status_notice'], FILTER_VALIDATE_BOOLEAN)) {
165 165
 	$notice_message = '';
166 166
 	$notice_type    = 'warning';
167 167
 
168
-	switch ( $status ) {
168
+	switch ($status) {
169 169
 		case 'publish':
170
-			$notice_message = __( 'Payment Complete: Thank you for your donation.', 'give' );
170
+			$notice_message = __('Payment Complete: Thank you for your donation.', 'give');
171 171
 			$notice_type    = 'success';
172 172
 			break;
173 173
 		case 'pending':
174
-			$notice_message = __( 'Payment Pending: Your donation is currently processing.', 'give' );
174
+			$notice_message = __('Payment Pending: Your donation is currently processing.', 'give');
175 175
 			$notice_type    = 'warning';
176 176
 			break;
177 177
 		case 'refunded':
178
-			$notice_message = __( 'Payment Refunded: Your donation has been refunded.', 'give' );
178
+			$notice_message = __('Payment Refunded: Your donation has been refunded.', 'give');
179 179
 			$notice_type    = 'warning';
180 180
 			break;
181 181
 		case 'preapproval':
182
-			$notice_message = __( 'Payment Preapproved: Thank you for your donation.', 'give' );
182
+			$notice_message = __('Payment Preapproved: Thank you for your donation.', 'give');
183 183
 			$notice_type    = 'warning';
184 184
 			break;
185 185
 		case 'failed':
186
-			$notice_message = __( 'Payment Failed: Please contact the site owner for assistance.', 'give' );
186
+			$notice_message = __('Payment Failed: Please contact the site owner for assistance.', 'give');
187 187
 			$notice_type    = 'error';
188 188
 			break;
189 189
 		case 'cancelled':
190
-			$notice_message = __( 'Payment Cancelled: Your donation has been cancelled.', 'give' );
190
+			$notice_message = __('Payment Cancelled: Your donation has been cancelled.', 'give');
191 191
 			$notice_type    = 'error';
192 192
 			break;
193 193
 		case 'abandoned':
194
-			$notice_message = __( 'Payment Abandoned: This donation has not been completed.', 'give' );
194
+			$notice_message = __('Payment Abandoned: This donation has not been completed.', 'give');
195 195
 			$notice_type    = 'error';
196 196
 			break;
197 197
 		case 'revoked':
198
-			$notice_message = __( 'Payment Revoked: Please contact the site owner for assistance.', 'give' );
198
+			$notice_message = __('Payment Revoked: Please contact the site owner for assistance.', 'give');
199 199
 			$notice_type    = 'error';
200 200
 			break;
201 201
 	}
202 202
 
203
-	if ( ! empty( $notice_message ) ) {
203
+	if ( ! empty($notice_message)) {
204 204
 		/**
205 205
 		 * Filters payment status notice for receipts.
206 206
 		 *
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 		 * @param string $status Payment status.
216 216
 		 * @param int $donation_id Donation ID.
217 217
 		 */
218
-		echo apply_filters( 'give_receipt_status_notice', Give()->notices->print_frontend_notice( $notice_message, false, $notice_type ), $id, $status, $donation_id );
218
+		echo apply_filters('give_receipt_status_notice', Give()->notices->print_frontend_notice($notice_message, false, $notice_type), $id, $status, $donation_id);
219 219
 	}
220 220
 }// End if().
221 221
 
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
  * @param object $payment           The payment object.
230 230
  * @param array  $give_receipt_args Receipt_argument.
231 231
  */
232
-do_action( 'give_payment_receipt_before_table', $payment, $give_receipt_args );
232
+do_action('give_payment_receipt_before_table', $payment, $give_receipt_args);
233 233
 ?>
234 234
 
235 235
 <table id="give_donation_receipt" class="give-table">
@@ -245,11 +245,11 @@  discard block
 block discarded – undo
245 245
 	 * @param object $payment           The payment object.
246 246
 	 * @param array  $give_receipt_args Receipt_argument.
247 247
 	 */
248
-	do_action( 'give_payment_receipt_header_before', $payment, $give_receipt_args );
248
+	do_action('give_payment_receipt_header_before', $payment, $give_receipt_args);
249 249
 	?>
250 250
 	<tr>
251 251
 		<th scope="colgroup" colspan="2">
252
-			<span class="give-receipt-thead-text"><?php esc_html_e( 'Donation Receipt', 'give' ) ?></span>
252
+			<span class="give-receipt-thead-text"><?php esc_html_e('Donation Receipt', 'give') ?></span>
253 253
 		</th>
254 254
 	</tr>
255 255
 	<?php
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 	 * @param object $payment           The payment object.
264 264
 	 * @param array  $give_receipt_args Receipt_argument.
265 265
 	 */
266
-	do_action( 'give_payment_receipt_header_after', $payment, $give_receipt_args );
266
+	do_action('give_payment_receipt_header_after', $payment, $give_receipt_args);
267 267
 	?>
268 268
 	</thead>
269 269
 
@@ -279,11 +279,11 @@  discard block
 block discarded – undo
279 279
 	 * @param object $payment           The payment object.
280 280
 	 * @param array  $give_receipt_args Receipt_argument.
281 281
 	 */
282
-	do_action( 'give_payment_receipt_before', $payment, $give_receipt_args );
282
+	do_action('give_payment_receipt_before', $payment, $give_receipt_args);
283 283
 	?>
284 284
 
285
-	<?php foreach ( $give_receipt_args['donation_receipt'] as $receipt_item ) { ?>
286
-		<?php if ( filter_var( $receipt_item['display'], FILTER_VALIDATE_BOOLEAN ) ) : ?>
285
+	<?php foreach ($give_receipt_args['donation_receipt'] as $receipt_item) { ?>
286
+		<?php if (filter_var($receipt_item['display'], FILTER_VALIDATE_BOOLEAN)) : ?>
287 287
 			<tr>
288 288
 				<td scope="row"><strong><?php echo $receipt_item['name']; ?></strong></td>
289 289
 				<td><?php echo $receipt_item['value']; ?></td>
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 	 * @param object $payment           The payment object.
303 303
 	 * @param array  $give_receipt_args Receipt_argument.
304 304
 	 */
305
-	do_action( 'give_payment_receipt_after', $payment, $give_receipt_args );
305
+	do_action('give_payment_receipt_after', $payment, $give_receipt_args);
306 306
 	?>
307 307
 	</tbody>
308 308
 </table>
@@ -318,5 +318,5 @@  discard block
 block discarded – undo
318 318
  * @param object $payment           The payment object.
319 319
  * @param array  $give_receipt_args Receipt_argument.
320 320
  */
321
-do_action( 'give_payment_receipt_after_table', $payment, $give_receipt_args );
321
+do_action('give_payment_receipt_after_table', $payment, $give_receipt_args);
322 322
 ?>
Please login to merge, or discard this patch.
includes/emails/functions.php 1 patch
Spacing   +74 added lines, -74 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,14 +26,14 @@  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 31
 	 * Fire the action
32 32
 	 */
33
-	do_action( 'give_donation-receipt_email_notification', $payment_id );
33
+	do_action('give_donation-receipt_email_notification', $payment_id);
34 34
 
35 35
 	// If admin notifications are on, send the admin notice.
36
-	if ( $admin_notice && give_is_setting_enabled( Give_Email_Notification::get_instance('new-donation' )->get_notification_status() ) ) {
36
+	if ($admin_notice && give_is_setting_enabled(Give_Email_Notification::get_instance('new-donation')->get_notification_status())) {
37 37
 		/**
38 38
 		 * Fires in the donation email receipt.
39 39
 		 *
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 		 * @param int   $payment_id   Payment id.
45 45
 		 * @param mixed $payment_data Payment meta data.
46 46
 		 */
47
-		do_action( 'give_new-donation_email_notification', $payment_id, give_get_payment_meta( $payment_id ) );
47
+		do_action('give_new-donation_email_notification', $payment_id, give_get_payment_meta($payment_id));
48 48
 	}
49 49
 }
50 50
 
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
  *
58 58
  * @return void
59 59
  */
60
-function give_admin_email_notice( $payment_id ) {
60
+function give_admin_email_notice($payment_id) {
61 61
 	/**
62 62
 	 * Fires in the donation email receipt.
63 63
 	 *
@@ -68,10 +68,10 @@  discard block
 block discarded – undo
68 68
 	 * @param int   $payment_id   Payment id.
69 69
 	 * @param mixed $payment_data Payment meta data.
70 70
 	 */
71
-	do_action( 'give_new-donation_email_notification', $payment_id );
71
+	do_action('give_new-donation_email_notification', $payment_id);
72 72
 }
73 73
 
74
-add_action( 'give_admin_donation_email', 'give_admin_email_notice' );
74
+add_action('give_admin_donation_email', 'give_admin_email_notice');
75 75
 
76 76
 
77 77
 /**
@@ -84,16 +84,16 @@  discard block
 block discarded – undo
84 84
  */
85 85
 function give_get_default_donation_notification_email() {
86 86
 
87
-	$default_email_body = __( 'Hi there,', 'give' ) . "\n\n";
88
-	$default_email_body .= __( 'This email is to inform you that a new donation has been made on your website:', 'give' ) . ' {site_url}' . ".\n\n";
89
-	$default_email_body .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {name}' . "\n";
90
-	$default_email_body .= '<strong>' . __( 'Donation:', 'give' ) . '</strong> {donation}' . "\n";
91
-	$default_email_body .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n";
92
-	$default_email_body .= '<strong>' . __( 'Payment Method:', 'give' ) . '</strong> {payment_method}' . "\n\n";
93
-	$default_email_body .= __( 'Thank you,', 'give' ) . "\n\n";
94
-	$default_email_body .= '{sitename}' . "\n";
87
+	$default_email_body = __('Hi there,', 'give')."\n\n";
88
+	$default_email_body .= __('This email is to inform you that a new donation has been made on your website:', 'give').' {site_url}'.".\n\n";
89
+	$default_email_body .= '<strong>'.__('Donor:', 'give').'</strong> {name}'."\n";
90
+	$default_email_body .= '<strong>'.__('Donation:', 'give').'</strong> {donation}'."\n";
91
+	$default_email_body .= '<strong>'.__('Amount:', 'give').'</strong> {amount}'."\n";
92
+	$default_email_body .= '<strong>'.__('Payment Method:', 'give').'</strong> {payment_method}'."\n\n";
93
+	$default_email_body .= __('Thank you,', 'give')."\n\n";
94
+	$default_email_body .= '{sitename}'."\n";
95 95
 
96
-	return apply_filters( 'give_default_donation_notification_email', $default_email_body );
96
+	return apply_filters('give_default_donation_notification_email', $default_email_body);
97 97
 }
98 98
 
99 99
 
@@ -107,21 +107,21 @@  discard block
 block discarded – undo
107 107
  */
108 108
 function give_get_default_donation_receipt_email() {
109 109
 
110
-	$default_email_body = __( 'Dear', 'give' ) . " {name},\n\n";
111
-	$default_email_body .= __( 'Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give' ) . "\n\n";
112
-	$default_email_body .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {fullname}' . "\n";
113
-	$default_email_body .= '<strong>' . __( 'Donation:', 'give' ) . '</strong> {donation}' . "\n";
114
-	$default_email_body .= '<strong>' . __( 'Donation Date:', 'give' ) . '</strong> {date}' . "\n";
115
-	$default_email_body .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n";
116
-	$default_email_body .= '<strong>' . __( 'Payment Method:', 'give' ) . '</strong> {payment_method}' . "\n";
117
-	$default_email_body .= '<strong>' . __( 'Payment ID:', 'give' ) . '</strong> {payment_id}' . "\n";
118
-	$default_email_body .= '<strong>' . __( 'Receipt ID:', 'give' ) . '</strong> {receipt_id}' . "\n\n";
119
-	$default_email_body .= '{receipt_link}' . "\n\n";
110
+	$default_email_body = __('Dear', 'give')." {name},\n\n";
111
+	$default_email_body .= __('Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give')."\n\n";
112
+	$default_email_body .= '<strong>'.__('Donor:', 'give').'</strong> {fullname}'."\n";
113
+	$default_email_body .= '<strong>'.__('Donation:', 'give').'</strong> {donation}'."\n";
114
+	$default_email_body .= '<strong>'.__('Donation Date:', 'give').'</strong> {date}'."\n";
115
+	$default_email_body .= '<strong>'.__('Amount:', 'give').'</strong> {amount}'."\n";
116
+	$default_email_body .= '<strong>'.__('Payment Method:', 'give').'</strong> {payment_method}'."\n";
117
+	$default_email_body .= '<strong>'.__('Payment ID:', 'give').'</strong> {payment_id}'."\n";
118
+	$default_email_body .= '<strong>'.__('Receipt ID:', 'give').'</strong> {receipt_id}'."\n\n";
119
+	$default_email_body .= '{receipt_link}'."\n\n";
120 120
 	$default_email_body .= "\n\n";
121
-	$default_email_body .= __( 'Sincerely,', 'give' ) . "\n";
122
-	$default_email_body .= '{sitename}' . "\n";
121
+	$default_email_body .= __('Sincerely,', 'give')."\n";
122
+	$default_email_body .= '{sitename}'."\n";
123 123
 
124
-	return apply_filters( 'give_default_donation_receipt_email', $default_email_body );
124
+	return apply_filters('give_default_donation_receipt_email', $default_email_body);
125 125
 }
126 126
 
127 127
 /**
@@ -134,22 +134,22 @@  discard block
 block discarded – undo
134 134
  *
135 135
  * @return array $email_names
136 136
  */
137
-function give_get_email_names( $user_info, $payment = false ) {
137
+function give_get_email_names($user_info, $payment = false) {
138 138
 	$email_names = array();
139 139
 
140
-	if ( is_a( $payment, 'Give_Payment' ) ) {
140
+	if (is_a($payment, 'Give_Payment')) {
141 141
 
142
-		if ( $payment->user_id > 0 ) {
142
+		if ($payment->user_id > 0) {
143 143
 
144
-			$user_data               = get_userdata( $payment->user_id );
144
+			$user_data               = get_userdata($payment->user_id);
145 145
 			$email_names['name']     = $payment->first_name;
146
-			$email_names['fullname'] = trim( $payment->first_name . ' ' . $payment->last_name );
146
+			$email_names['fullname'] = trim($payment->first_name.' '.$payment->last_name);
147 147
 			$email_names['username'] = $user_data->user_login;
148 148
 
149
-		} elseif ( ! empty( $payment->first_name ) ) {
149
+		} elseif ( ! empty($payment->first_name)) {
150 150
 
151 151
 			$email_names['name']     = $payment->first_name;
152
-			$email_names['fullname'] = trim( $payment->first_name . ' ' . $payment->last_name );
152
+			$email_names['fullname'] = trim($payment->first_name.' '.$payment->last_name);
153 153
 			$email_names['username'] = $payment->first_name;
154 154
 
155 155
 		} else {
@@ -161,29 +161,29 @@  discard block
 block discarded – undo
161 161
 	} else {
162 162
 
163 163
 		// Support for old serialized data.
164
-		if ( is_serialized( $user_info ) ) {
164
+		if (is_serialized($user_info)) {
165 165
 
166 166
 			// Security check.
167
-			preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches );
168
-			if ( ! empty( $matches ) ) {
167
+			preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches);
168
+			if ( ! empty($matches)) {
169 169
 				return array(
170 170
 					'name'     => '',
171 171
 					'fullname' => '',
172 172
 					'username' => '',
173 173
 				);
174 174
 			} else {
175
-				$user_info = maybe_unserialize( $user_info );
175
+				$user_info = maybe_unserialize($user_info);
176 176
 			}
177 177
 		}
178 178
 
179
-		if ( isset( $user_info['id'] ) && $user_info['id'] > 0 && isset( $user_info['first_name'] ) ) {
180
-			$user_data               = get_userdata( $user_info['id'] );
179
+		if (isset($user_info['id']) && $user_info['id'] > 0 && isset($user_info['first_name'])) {
180
+			$user_data               = get_userdata($user_info['id']);
181 181
 			$email_names['name']     = $user_info['first_name'];
182
-			$email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name'];
182
+			$email_names['fullname'] = $user_info['first_name'].' '.$user_info['last_name'];
183 183
 			$email_names['username'] = $user_data->user_login;
184
-		} elseif ( isset( $user_info['first_name'] ) ) {
184
+		} elseif (isset($user_info['first_name'])) {
185 185
 			$email_names['name']     = $user_info['first_name'];
186
-			$email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name'];
186
+			$email_names['fullname'] = $user_info['first_name'].' '.$user_info['last_name'];
187 187
 			$email_names['username'] = $user_info['first_name'];
188 188
 		} else {
189 189
 			$email_names['name']     = $user_info['email'];
@@ -192,13 +192,13 @@  discard block
 block discarded – undo
192 192
 	} // End if().
193 193
 
194 194
 	// Set title prefix to name, if non empty.
195
-	if ( ! empty( $user_info['title'] ) && ! empty( $user_info['last_name'] ) ) {
196
-		$email_names['name'] = give_get_donor_name_with_title_prefixes( $user_info['title'], $user_info['last_name'] );
195
+	if ( ! empty($user_info['title']) && ! empty($user_info['last_name'])) {
196
+		$email_names['name'] = give_get_donor_name_with_title_prefixes($user_info['title'], $user_info['last_name']);
197 197
 	}
198 198
 
199 199
 	// Set title prefix to fullname, if non empty.
200
-	if ( ! empty( $user_info['title'] ) && ! empty( $email_names['fullname'] ) ) {
201
-		$email_names['fullname'] = give_get_donor_name_with_title_prefixes( $user_info['title'], $email_names['fullname'] );
200
+	if ( ! empty($user_info['title']) && ! empty($email_names['fullname'])) {
201
+		$email_names['fullname'] = give_get_donor_name_with_title_prefixes($user_info['title'], $email_names['fullname']);
202 202
 	}
203 203
 
204 204
 	return $email_names;
@@ -212,37 +212,37 @@  discard block
 block discarded – undo
212 212
  *
213 213
  * @since 1.8.14
214 214
  */
215
-function give_admin_email_user_donor_disconnection( $user_id, $donor_id ) {
215
+function give_admin_email_user_donor_disconnection($user_id, $donor_id) {
216 216
 
217
-	$user_id  = absint( $user_id );
218
-	$donor_id = absint( $donor_id );
217
+	$user_id  = absint($user_id);
218
+	$donor_id = absint($donor_id);
219 219
 
220 220
 	// Bail Out, if user id doesn't exists.
221
-	if ( empty( $user_id ) ) {
221
+	if (empty($user_id)) {
222 222
 		return;
223 223
 	}
224 224
 
225 225
 	// Bail Out, if donor id doesn't exists.
226
-	if ( empty( $donor_id ) ) {
226
+	if (empty($donor_id)) {
227 227
 		return;
228 228
 	}
229 229
 
230
-	$from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) );
230
+	$from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES));
231 231
 
232
-	$from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) );
232
+	$from_email = give_get_option('from_email', get_bloginfo('admin_email'));
233 233
 
234 234
 	/* translators: %s: payment id */
235
-	$subject = __( 'Attention: User tries to login whose Donor profile is disconnected!', 'give' );
235
+	$subject = __('Attention: User tries to login whose Donor profile is disconnected!', 'give');
236 236
 
237 237
 	/**
238 238
 	 * Filters the Donor-User Disconnection notification subject.
239 239
 	 *
240 240
 	 * @since 1.8.14
241 241
 	 */
242
-	$subject = apply_filters( 'give_admin_donor_user_disconnection_notification_subject', wp_strip_all_tags( $subject ) );
242
+	$subject = apply_filters('give_admin_donor_user_disconnection_notification_subject', wp_strip_all_tags($subject));
243 243
 
244
-	$headers = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n";
245
-	$headers .= "Reply-To: " . $from_email . "\r\n";
244
+	$headers = "From: ".stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8'))." <$from_email>\r\n";
245
+	$headers .= "Reply-To: ".$from_email."\r\n";
246 246
 	$headers .= "Content-Type: text/html; charset=utf-8\r\n";
247 247
 
248 248
 	/**
@@ -250,25 +250,25 @@  discard block
 block discarded – undo
250 250
 	 *
251 251
 	 * @since 1.8.14
252 252
 	 */
253
-	$headers = apply_filters( 'give_admin_donor_user_disconnection_notification_headers', $headers );
253
+	$headers = apply_filters('give_admin_donor_user_disconnection_notification_headers', $headers);
254 254
 
255
-	$message = __( 'Hi Admin,', 'give' ) . "\n\n";
256
-	$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";
257
-	$message .= __( 'Do you want to reconnect User and Donor profile again?', 'give' ) . "\n\n";
255
+	$message = __('Hi Admin,', 'give')."\n\n";
256
+	$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";
257
+	$message .= __('Do you want to reconnect User and Donor profile again?', 'give')."\n\n";
258 258
 	$message .= sprintf(
259 259
 		'<a href="%1$s">%2$s</a>',
260
-		esc_url( admin_url() . 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor_id . '&user_id=' . $user_id . '&give-messages[]=reconnect-user' ),
261
-		__( 'Reconnect User', 'give' ) . "\n\n"
260
+		esc_url(admin_url().'edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor_id.'&user_id='.$user_id.'&give-messages[]=reconnect-user'),
261
+		__('Reconnect User', 'give')."\n\n"
262 262
 	);
263
-	$message .= __( 'Thank you,', 'give' ) . "\n\n";
264
-	$message .= '{sitename}' . "\n";
263
+	$message .= __('Thank you,', 'give')."\n\n";
264
+	$message .= '{sitename}'."\n";
265 265
 
266 266
 	$emails = Give()->emails;
267
-	$emails->__set( 'from_name', $from_name );
268
-	$emails->__set( 'from_email', $from_email );
269
-	$emails->__set( 'headers', $headers );
270
-	$emails->__set( 'heading', __( 'User - Donor Profile Disconnection', 'give' ) );
267
+	$emails->__set('from_name', $from_name);
268
+	$emails->__set('from_email', $from_email);
269
+	$emails->__set('headers', $headers);
270
+	$emails->__set('heading', __('User - Donor Profile Disconnection', 'give'));
271 271
 
272
-	$emails->send( give_get_admin_notice_emails(), $subject, give_do_email_tags( $message ) );
272
+	$emails->send(give_get_admin_notice_emails(), $subject, give_do_email_tags($message));
273 273
 
274 274
 }
Please login to merge, or discard this patch.
includes/filters.php 1 patch
Spacing   +54 added lines, -56 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -26,34 +26,34 @@  discard block
 block discarded – undo
26 26
  *
27 27
  * @return void
28 28
  */
29
-function give_set_settings_with_disable_prefix( $old_settings, $settings ) {
29
+function give_set_settings_with_disable_prefix($old_settings, $settings) {
30 30
 	// Bailout.
31
-	if ( ! function_exists( 'give_v18_renamed_core_settings' ) ) {
31
+	if ( ! function_exists('give_v18_renamed_core_settings')) {
32 32
 		return;
33 33
 	}
34 34
 
35 35
 	// Get old setting names.
36
-	$old_settings   = array_flip( give_v18_renamed_core_settings() );
36
+	$old_settings   = array_flip(give_v18_renamed_core_settings());
37 37
 	$update_setting = false;
38 38
 
39
-	foreach ( $settings as $key => $value ) {
39
+	foreach ($settings as $key => $value) {
40 40
 
41 41
 		// Check 1. Check if new option is really updated or not.
42 42
 		// Check 2. Continue if key is not renamed.
43
-		if ( ! isset( $old_settings[ $key ] ) ) {
43
+		if ( ! isset($old_settings[$key])) {
44 44
 			continue;
45 45
 		}
46 46
 
47 47
 		// Set old setting.
48
-		$settings[ $old_settings[ $key ] ] = 'on';
48
+		$settings[$old_settings[$key]] = 'on';
49 49
 
50 50
 		// Do not need to set old setting if new setting is not set.
51 51
 		if (
52
-			( give_is_setting_enabled( $value ) && ( false !== strpos( $old_settings[ $key ], 'disable_' ) ) )
53
-			|| ( ! give_is_setting_enabled( $value ) && ( false !== strpos( $old_settings[ $key ], 'enable_' ) ) )
52
+			(give_is_setting_enabled($value) && (false !== strpos($old_settings[$key], 'disable_')))
53
+			|| ( ! give_is_setting_enabled($value) && (false !== strpos($old_settings[$key], 'enable_')))
54 54
 
55 55
 		) {
56
-			unset( $settings[ $old_settings[ $key ] ] );
56
+			unset($settings[$old_settings[$key]]);
57 57
 		}
58 58
 
59 59
 		// Tell bot to update setting.
@@ -61,12 +61,12 @@  discard block
 block discarded – undo
61 61
 	}
62 62
 
63 63
 	// Update setting if any old setting set.
64
-	if ( $update_setting ) {
65
-		update_option( 'give_settings', $settings, false );
64
+	if ($update_setting) {
65
+		update_option('give_settings', $settings, false);
66 66
 	}
67 67
 }
68 68
 
69
-add_action( 'update_option_give_settings', 'give_set_settings_with_disable_prefix', 10, 2 );
69
+add_action('update_option_give_settings', 'give_set_settings_with_disable_prefix', 10, 2);
70 70
 
71 71
 /**
72 72
  * Check spam through Akismet.
@@ -80,45 +80,45 @@  discard block
 block discarded – undo
80 80
  *
81 81
  * @return bool|mixed
82 82
  */
83
-function give_akismet( $spam ) {
83
+function give_akismet($spam) {
84 84
 
85 85
 	// Bail out, If spam.
86
-	if ( $spam ) {
86
+	if ($spam) {
87 87
 		return $spam;
88 88
 	}
89 89
 
90 90
 	// Bail out, if Akismet key not exist.
91
-	if ( ! give_check_akismet_key() ) {
91
+	if ( ! give_check_akismet_key()) {
92 92
 		return false;
93 93
 	}
94 94
 
95 95
 	// Build args array.
96 96
 	$args = array();
97 97
 
98
-	$args['comment_author']       = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : '';
99
-	$args['comment_author_email'] = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false;
100
-	$args['blog']                 = get_option( 'home' );
98
+	$args['comment_author']       = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : '';
99
+	$args['comment_author_email'] = isset($_POST['give_email']) ? $_POST['give_email'] : false;
100
+	$args['blog']                 = get_option('home');
101 101
 	$args['blog_lang']            = get_locale();
102
-	$args['blog_charset']         = get_option( 'blog_charset' );
102
+	$args['blog_charset']         = get_option('blog_charset');
103 103
 	$args['user_ip']              = $_SERVER['REMOTE_ADDR'];
104 104
 	$args['user_agent']           = $_SERVER['HTTP_USER_AGENT'];
105 105
 	$args['referrer']             = $_SERVER['HTTP_REFERER'];
106 106
 	$args['comment_type']         = 'contact-form';
107 107
 
108
-	$ignore = array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' );
108
+	$ignore = array('HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW');
109 109
 
110
-	foreach ( $_SERVER as $key => $value ) {
111
-		if ( ! in_array( $key, (array) $ignore ) ) {
110
+	foreach ($_SERVER as $key => $value) {
111
+		if ( ! in_array($key, (array) $ignore)) {
112 112
 			$args["$key"] = $value;
113 113
 		}
114 114
 	}
115 115
 
116 116
 	// It will return Akismet spam detect API response.
117
-	return give_akismet_spam_check( $args );
117
+	return give_akismet_spam_check($args);
118 118
 
119 119
 }
120 120
 
121
-add_filter( 'give_spam', 'give_akismet' );
121
+add_filter('give_spam', 'give_akismet');
122 122
 
123 123
 /**
124 124
  * Check Akismet API Key.
@@ -128,11 +128,11 @@  discard block
 block discarded – undo
128 128
  * @return bool
129 129
  */
130 130
 function give_check_akismet_key() {
131
-	if ( is_callable( array( 'Akismet', 'get_api_key' ) ) ) { // Akismet v3.0+
131
+	if (is_callable(array('Akismet', 'get_api_key'))) { // Akismet v3.0+
132 132
 		return (bool) Akismet::get_api_key();
133 133
 	}
134 134
 
135
-	if ( function_exists( 'akismet_get_key' ) ) {
135
+	if (function_exists('akismet_get_key')) {
136 136
 		return (bool) akismet_get_key();
137 137
 	}
138 138
 
@@ -148,26 +148,26 @@  discard block
 block discarded – undo
148 148
  *
149 149
  * @return bool|mixed
150 150
  */
151
-function give_akismet_spam_check( $args ) {
151
+function give_akismet_spam_check($args) {
152 152
 	global $akismet_api_host, $akismet_api_port;
153 153
 
154 154
 	$spam         = false;
155
-	$query_string = http_build_query( $args );
155
+	$query_string = http_build_query($args);
156 156
 
157
-	if ( is_callable( array( 'Akismet', 'http_post' ) ) ) { // Akismet v3.0+
158
-		$response = Akismet::http_post( $query_string, 'comment-check' );
157
+	if (is_callable(array('Akismet', 'http_post'))) { // Akismet v3.0+
158
+		$response = Akismet::http_post($query_string, 'comment-check');
159 159
 	} else {
160
-		$response = akismet_http_post( $query_string, $akismet_api_host,
161
-			'/1.1/comment-check', $akismet_api_port );
160
+		$response = akismet_http_post($query_string, $akismet_api_host,
161
+			'/1.1/comment-check', $akismet_api_port);
162 162
 	}
163 163
 
164 164
 	// It's spam if response status is true.
165
-	if ( 'true' === $response[1] ) {
165
+	if ('true' === $response[1]) {
166 166
 		$spam = true;
167 167
 	}
168 168
 
169 169
 	// Allow developer to modified Akismet spam detection response.
170
-	return apply_filters( 'give_akismet_spam_check', $spam, $args );
170
+	return apply_filters('give_akismet_spam_check', $spam, $args);
171 171
 }
172 172
 
173 173
 /**
@@ -180,15 +180,15 @@  discard block
 block discarded – undo
180 180
  *
181 181
  * @return array
182 182
  */
183
-function give_bc_v1817_iranian_currency_code( $currencies ) {
184
-	if ( ! give_has_upgrade_completed( 'v1817_update_donation_iranian_currency_code' ) ) {
183
+function give_bc_v1817_iranian_currency_code($currencies) {
184
+	if ( ! give_has_upgrade_completed('v1817_update_donation_iranian_currency_code')) {
185 185
 		$currencies['RIAL'] = $currencies['IRR'];
186 186
 	}
187 187
 
188 188
 	return $currencies;
189 189
 }
190 190
 
191
-add_filter( 'give_currencies', 'give_bc_v1817_iranian_currency_code', 0 );
191
+add_filter('give_currencies', 'give_bc_v1817_iranian_currency_code', 0);
192 192
 
193 193
 
194 194
 /**
@@ -202,25 +202,23 @@  discard block
 block discarded – undo
202 202
  *
203 203
  * @return string
204 204
  */
205
-function give_format_price_for_right_to_left_supported_currency( $formatted_amount, $currency_args, $price ) {
206
-	if ( ! give_is_right_to_left_supported_currency( $currency_args['currency_code'] ) ) {
205
+function give_format_price_for_right_to_left_supported_currency($formatted_amount, $currency_args, $price) {
206
+	if ( ! give_is_right_to_left_supported_currency($currency_args['currency_code'])) {
207 207
 		return $formatted_amount;
208 208
 	}
209 209
 
210 210
 	$formatted_amount = (
211 211
 	'before' === (string) $currency_args['position'] ?
212
-		'&#x202B;' . $price . $currency_args['symbol'] . '&#x202C;' :
213
-		'&#x202A;' . $price . $currency_args['symbol'] . '&#x202C;'
212
+		'&#x202B;'.$price.$currency_args['symbol'].'&#x202C;' : '&#x202A;'.$price.$currency_args['symbol'].'&#x202C;'
214 213
 	);
215 214
 
216 215
 	$formatted_amount = $currency_args['decode_currency'] ?
217
-		html_entity_decode( $formatted_amount, ENT_COMPAT, 'UTF-8' ) :
218
-		$formatted_amount;
216
+		html_entity_decode($formatted_amount, ENT_COMPAT, 'UTF-8') : $formatted_amount;
219 217
 
220 218
 	return $formatted_amount;
221 219
 }
222 220
 
223
-add_filter( 'give_currency_filter', 'give_format_price_for_right_to_left_supported_currency', 10, 3 );
221
+add_filter('give_currency_filter', 'give_format_price_for_right_to_left_supported_currency', 10, 3);
224 222
 
225 223
 /**
226 224
  * Validate active gateway value before returning result.
@@ -231,31 +229,31 @@  discard block
 block discarded – undo
231 229
  *
232 230
  * @return array
233 231
  */
234
-function __give_validate_active_gateways( $value ) {
235
-	$gateways = array_keys( give_get_payment_gateways() );
236
-	$active_gateways = is_array( $value ) ? array_keys( $value ) : array();
232
+function __give_validate_active_gateways($value) {
233
+	$gateways = array_keys(give_get_payment_gateways());
234
+	$active_gateways = is_array($value) ? array_keys($value) : array();
237 235
 
238 236
 	// Remove deactivated payment gateways.
239
-	if( ! empty( $active_gateways ) ) {
240
-		foreach ( $active_gateways as $index => $gateway_id ) {
241
-			if( ! in_array( $gateway_id, $gateways ) ) {
242
-				unset( $value[$gateway_id] );
237
+	if ( ! empty($active_gateways)) {
238
+		foreach ($active_gateways as $index => $gateway_id) {
239
+			if ( ! in_array($gateway_id, $gateways)) {
240
+				unset($value[$gateway_id]);
243 241
 			}
244 242
 		}
245 243
 	}
246 244
 
247
-	if ( empty( $value ) ) {
245
+	if (empty($value)) {
248 246
 		/**
249 247
 		 * Filter the default active gateway
250 248
 		 *
251 249
 		 * @since 2.1.0
252 250
 		 */
253
-		$value = apply_filters( 'give_default_active_gateways', array(
251
+		$value = apply_filters('give_default_active_gateways', array(
254 252
 			'manual' => 1,
255
-		) );
253
+		));
256 254
 	}
257 255
 
258 256
 	return $value;
259 257
 }
260 258
 
261
-add_filter( 'give_get_option_gateways', '__give_validate_active_gateways', 10, 1 );
259
+add_filter('give_get_option_gateways', '__give_validate_active_gateways', 10, 1);
Please login to merge, or discard this patch.
includes/class-give-db-sessions.php 1 patch
Spacing   +18 added lines, -18 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
 
@@ -54,8 +54,8 @@  discard block
 block discarded – undo
54 54
 		// Set cache group id.
55 55
 		$current_blog_id        = get_current_blog_id();
56 56
 		$this->incrementer_name = "give-cache-incrementer-sessions-{$current_blog_id}";
57
-		$incrementer_value      = wp_cache_get( $this->incrementer_name );
58
-		$incrementer_value      = ! empty( $incrementer_value ) ? $incrementer_value : microtime( true );
57
+		$incrementer_value      = wp_cache_get($this->incrementer_name);
58
+		$incrementer_value      = ! empty($incrementer_value) ? $incrementer_value : microtime(true);
59 59
 		$this->cache_group      = "{$this->cache_group}_{$current_blog_id}_{$incrementer_value}";
60 60
 
61 61
 		$this->register_table();
@@ -101,10 +101,10 @@  discard block
 block discarded – undo
101 101
   				UNIQUE KEY session_id (session_id)
102 102
 			) {$charset_collate};";
103 103
 
104
-		require_once ABSPATH . 'wp-admin/includes/upgrade.php';
105
-		dbDelta( $sql );
104
+		require_once ABSPATH.'wp-admin/includes/upgrade.php';
105
+		dbDelta($sql);
106 106
 
107
-		update_option( $this->table_name . '_db_version', $this->version, false );
107
+		update_option($this->table_name.'_db_version', $this->version, false);
108 108
 	}
109 109
 
110 110
 
@@ -118,14 +118,14 @@  discard block
 block discarded – undo
118 118
 	 *
119 119
 	 * @return mixed
120 120
 	 */
121
-	public function get_session( $donor_id, $default = false ) {
121
+	public function get_session($donor_id, $default = false) {
122 122
 		global $wpdb;
123 123
 
124
-		if ( defined( 'WP_SETUP_CONFIG' ) ) {
124
+		if (defined('WP_SETUP_CONFIG')) {
125 125
 			return false;
126 126
 		}
127 127
 
128
-		if ( ! ( $value = wp_cache_get( $donor_id, $this->cache_group ) ) ) { // @codingStandardsIgnoreLine
128
+		if ( ! ($value = wp_cache_get($donor_id, $this->cache_group))) { // @codingStandardsIgnoreLine
129 129
 
130 130
 			// @codingStandardsIgnoreStart
131 131
 			$value = $wpdb->get_var(
@@ -140,14 +140,14 @@  discard block
 block discarded – undo
140 140
 			);
141 141
 			// @codingStandardsIgnoreEnd
142 142
 
143
-			if ( is_null( $value ) ) {
143
+			if (is_null($value)) {
144 144
 				$value = $default;
145 145
 			}
146 146
 
147
-			wp_cache_add( $donor_id, $value, $this->cache_group );
147
+			wp_cache_add($donor_id, $value, $this->cache_group);
148 148
 		}
149 149
 
150
-		return maybe_unserialize( $value );
150
+		return maybe_unserialize($value);
151 151
 	}
152 152
 
153 153
 	/**
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 	 * @param string $donor_id  Donor ID.
157 157
 	 * @param int    $timestamp Timestamp to expire the cookie.
158 158
 	 */
159
-	public function update_session_timestamp( $donor_id, $timestamp ) {
159
+	public function update_session_timestamp($donor_id, $timestamp) {
160 160
 		global $wpdb;
161 161
 
162 162
 		// @codingStandardsIgnoreStart.
@@ -183,10 +183,10 @@  discard block
 block discarded – undo
183 183
 	 *
184 184
 	 * @param int $donor_id Customer ID.
185 185
 	 */
186
-	public function delete_session( $donor_id ) {
186
+	public function delete_session($donor_id) {
187 187
 		global $wpdb;
188 188
 
189
-		wp_cache_delete( $donor_id, $this->cache_group );
189
+		wp_cache_delete($donor_id, $this->cache_group);
190 190
 
191 191
 		// @codingStandardsIgnoreStart
192 192
 		$wpdb->delete(
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 	public function delete_expired_sessions() {
210 210
 		global $wpdb;
211 211
 
212
-		wp_cache_set( $this->incrementer_name, microtime( true ) );
212
+		wp_cache_set($this->incrementer_name, microtime(true));
213 213
 
214 214
 		// @codingStandardsIgnoreStart
215 215
 		$wpdb->query(
@@ -232,10 +232,10 @@  discard block
 block discarded – undo
232 232
 	 * @param array  $data       Data.
233 233
 	 * @param array  $format     Array for data format of each key:value in data.
234 234
 	 */
235
-	public function __replace( $table_name, $data, $format = null ) {
235
+	public function __replace($table_name, $data, $format = null) {
236 236
 		global $wpdb;
237 237
 
238
-		wp_cache_set( $data['session_key'], $data['session_value'], $this->cache_group, $data['session_expiry'] - time() );
238
+		wp_cache_set($data['session_key'], $data['session_value'], $this->cache_group, $data['session_expiry'] - time());
239 239
 
240 240
 
241 241
 		// @codingStandardsIgnoreStart
Please login to merge, or discard this patch.
includes/class-give-session.php 1 patch
Spacing   +67 added lines, -67 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
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	 * @return Give_Session
136 136
 	 */
137 137
 	public static function get_instance() {
138
-		if ( null === static::$instance ) {
138
+		if (null === static::$instance) {
139 139
 			self::$instance = new static();
140 140
 			self::$instance->__setup();
141 141
 		}
@@ -150,25 +150,25 @@  discard block
 block discarded – undo
150 150
 	 * @access public
151 151
 	 */
152 152
 	private function __setup() {  // @codingStandardsIgnoreLine
153
-		$this->exp_option = give_get_option( 'session_lifetime' );
154
-		$this->exp_option = ! empty( $this->exp_option )
153
+		$this->exp_option = give_get_option('session_lifetime');
154
+		$this->exp_option = ! empty($this->exp_option)
155 155
 			? $this->exp_option
156 156
 			: 30 * 60 * 24; // Default expiration time is 12 hours
157 157
 
158 158
 		$this->set_cookie_name();
159
-		$this->cookie_name = $this->get_cookie_name( 'session' );
159
+		$this->cookie_name = $this->get_cookie_name('session');
160 160
 		$cookie            = $this->get_session_cookie();
161 161
 
162
-		if ( ! empty( $cookie ) ) {
162
+		if ( ! empty($cookie)) {
163 163
 			$this->donor_id           = $cookie[0];
164 164
 			$this->session_expiration = $cookie[1];
165 165
 			$this->session_expiring   = $cookie[2];
166 166
 			$this->has_cookie         = true;
167 167
 
168 168
 			// Update session if its close to expiring.
169
-			if ( time() > $this->session_expiring ) {
169
+			if (time() > $this->session_expiring) {
170 170
 				$this->set_expiration_time();
171
-				Give()->session_db->update_session_timestamp( $this->donor_id, $this->session_expiration );
171
+				Give()->session_db->update_session_timestamp($this->donor_id, $this->session_expiration);
172 172
 			}
173 173
 
174 174
 			// Load session.
@@ -178,17 +178,17 @@  discard block
 block discarded – undo
178 178
 			$this->generate_donor_id();
179 179
 		}
180 180
 
181
-		add_action( 'give_process_donation_after_validation', array( $this, 'maybe_start_session' ) );
181
+		add_action('give_process_donation_after_validation', array($this, 'maybe_start_session'));
182 182
 
183
-		add_action( 'shutdown', array( $this, 'save_data' ), 20 );
184
-		add_action( 'wp_logout', array( $this, 'destroy_session' ) );
183
+		add_action('shutdown', array($this, 'save_data'), 20);
184
+		add_action('wp_logout', array($this, 'destroy_session'));
185 185
 
186
-		if ( ! is_user_logged_in() ) {
187
-			add_filter( 'nonce_user_logged_out', array( $this, '__nonce_user_logged_out' ) );
186
+		if ( ! is_user_logged_in()) {
187
+			add_filter('nonce_user_logged_out', array($this, '__nonce_user_logged_out'));
188 188
 		}
189 189
 
190 190
 		// Remove old sessions.
191
-		Give_Cron::add_daily_event( array( $this, '__cleanup_sessions' ) );
191
+		Give_Cron::add_daily_event(array($this, '__cleanup_sessions'));
192 192
 	}
193 193
 
194 194
 	/**
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 	 * @return array
201 201
 	 */
202 202
 	public function get_session_data() {
203
-		return $this->has_session() ? (array) Give()->session_db->get_session( $this->donor_id, array() ) : array();
203
+		return $this->has_session() ? (array) Give()->session_db->get_session($this->donor_id, array()) : array();
204 204
 	}
205 205
 
206 206
 
@@ -214,27 +214,27 @@  discard block
 block discarded – undo
214 214
 	 */
215 215
 	public function get_session_cookie() {
216 216
 		$session      = array();
217
-		$cookie_value = isset( $_COOKIE[ $this->cookie_name ] ) ? give_clean( $_COOKIE[ $this->cookie_name ] ) : false; // @codingStandardsIgnoreLine.
217
+		$cookie_value = isset($_COOKIE[$this->cookie_name]) ? give_clean($_COOKIE[$this->cookie_name]) : false; // @codingStandardsIgnoreLine.
218 218
 
219
-		if ( empty( $cookie_value ) || ! is_string( $cookie_value ) ) {
219
+		if (empty($cookie_value) || ! is_string($cookie_value)) {
220 220
 			return $session;
221 221
 		}
222 222
 
223
-		list( $donor_id, $session_expiration, $session_expiring, $cookie_hash ) = explode( '||', $cookie_value );
223
+		list($donor_id, $session_expiration, $session_expiring, $cookie_hash) = explode('||', $cookie_value);
224 224
 
225
-		if ( empty( $donor_id ) ) {
225
+		if (empty($donor_id)) {
226 226
 			return $session;
227 227
 		}
228 228
 
229 229
 		// Validate hash.
230
-		$to_hash = $donor_id . '|' . $session_expiration;
231
-		$hash    = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) );
230
+		$to_hash = $donor_id.'|'.$session_expiration;
231
+		$hash    = hash_hmac('md5', $to_hash, wp_hash($to_hash));
232 232
 
233
-		if ( empty( $cookie_hash ) || ! hash_equals( $hash, $cookie_hash ) ) {
233
+		if (empty($cookie_hash) || ! hash_equals($hash, $cookie_hash)) {
234 234
 			return $session;
235 235
 		}
236 236
 
237
-		return array( $donor_id, $session_expiration, $session_expiring, $cookie_hash );
237
+		return array($donor_id, $session_expiration, $session_expiring, $cookie_hash);
238 238
 	}
239 239
 
240 240
 
@@ -259,8 +259,8 @@  discard block
 block discarded – undo
259 259
 	 * @return string Cookie name.
260 260
 	 */
261 261
 	private function set_cookie_name() {
262
-		$this->cookie_name       = apply_filters( 'give_session_cookie', 'wp_give_session_' . COOKIEHASH );
263
-		$this->nonce_cookie_name = 'wp_give_session_reset_nonce_' . COOKIEHASH;
262
+		$this->cookie_name       = apply_filters('give_session_cookie', 'wp_give_session_'.COOKIEHASH);
263
+		$this->nonce_cookie_name = 'wp_give_session_reset_nonce_'.COOKIEHASH;
264 264
 	}
265 265
 
266 266
 	/**
@@ -276,10 +276,10 @@  discard block
 block discarded – undo
276 276
 	 *
277 277
 	 * @return string|array      Session variable.
278 278
 	 */
279
-	public function get( $key, $default = false ) {
280
-		$key = sanitize_key( $key );
279
+	public function get($key, $default = false) {
280
+		$key = sanitize_key($key);
281 281
 
282
-		return isset( $this->session[ $key ] ) ? maybe_unserialize( $this->session[ $key ] ) : $default;
282
+		return isset($this->session[$key]) ? maybe_unserialize($this->session[$key]) : $default;
283 283
 	}
284 284
 
285 285
 	/**
@@ -293,13 +293,13 @@  discard block
 block discarded – undo
293 293
 	 *
294 294
 	 * @return string        Session variable.
295 295
 	 */
296
-	public function set( $key, $value ) {
297
-		if ( $value !== $this->get( $key ) ) {
298
-			$this->session[ sanitize_key( $key ) ] = maybe_serialize( $value );
296
+	public function set($key, $value) {
297
+		if ($value !== $this->get($key)) {
298
+			$this->session[sanitize_key($key)] = maybe_serialize($value);
299 299
 			$this->session_data_changed            = true;
300 300
 		}
301 301
 
302
-		return $this->session[ $key ];
302
+		return $this->session[$key];
303 303
 	}
304 304
 
305 305
 	/**
@@ -313,17 +313,17 @@  discard block
 block discarded – undo
313 313
 	 *
314 314
 	 * @param bool $set Flag to check if set cookie or not.
315 315
 	 */
316
-	public function set_session_cookies( $set ) {
317
-		if ( $set ) {
316
+	public function set_session_cookies($set) {
317
+		if ($set) {
318 318
 			$this->set_expiration_time();
319 319
 
320
-			$to_hash          = $this->donor_id . '|' . $this->session_expiration;
321
-			$cookie_hash      = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) );
322
-			$cookie_value     = $this->donor_id . '||' . $this->session_expiration . '||' . $this->session_expiring . '||' . $cookie_hash;
320
+			$to_hash          = $this->donor_id.'|'.$this->session_expiration;
321
+			$cookie_hash      = hash_hmac('md5', $to_hash, wp_hash($to_hash));
322
+			$cookie_value     = $this->donor_id.'||'.$this->session_expiration.'||'.$this->session_expiring.'||'.$cookie_hash;
323 323
 			$this->has_cookie = true;
324 324
 
325
-			give_setcookie( $this->cookie_name, $cookie_value, $this->session_expiration, apply_filters( 'give_session_use_secure_cookie', false ) );
326
-			give_setcookie( $this->nonce_cookie_name, '1', $this->session_expiration, apply_filters( 'give_session_use_secure_cookie', false ) );
325
+			give_setcookie($this->cookie_name, $cookie_value, $this->session_expiration, apply_filters('give_session_use_secure_cookie', false));
326
+			give_setcookie($this->nonce_cookie_name, '1', $this->session_expiration, apply_filters('give_session_use_secure_cookie', false));
327 327
 		}
328 328
 	}
329 329
 
@@ -338,8 +338,8 @@  discard block
 block discarded – undo
338 338
 	 * @return int
339 339
 	 */
340 340
 	public function set_expiration_time() {
341
-		$this->session_expiring   = time() + intval( apply_filters( 'give_session_expiring', ( $this->exp_option - 3600 ) ) ); // Default 11 Hours.
342
-		$this->session_expiration = time() + intval( apply_filters( 'give_session_expiration', $this->exp_option ) ); // Default 12 Hours.
341
+		$this->session_expiring   = time() + intval(apply_filters('give_session_expiring', ($this->exp_option - 3600))); // Default 11 Hours.
342
+		$this->session_expiration = time() + intval(apply_filters('give_session_expiration', $this->exp_option)); // Default 12 Hours.
343 343
 
344 344
 		return $this->session_expiration;
345 345
 	}
@@ -371,10 +371,10 @@  discard block
 block discarded – undo
371 371
 	public function maybe_start_session() {
372 372
 		if (
373 373
 			! headers_sent()
374
-			&& empty( $this->session )
374
+			&& empty($this->session)
375 375
 			&& ! $this->has_cookie
376 376
 		) {
377
-			$this->set_session_cookies( true );
377
+			$this->set_session_cookies(true);
378 378
 		}
379 379
 	}
380 380
 
@@ -387,10 +387,10 @@  discard block
 block discarded – undo
387 387
 	 * @access public
388 388
 	 */
389 389
 	public function generate_donor_id() {
390
-		require_once ABSPATH . 'wp-includes/class-phpass.php';
390
+		require_once ABSPATH.'wp-includes/class-phpass.php';
391 391
 
392
-		$hasher         = new PasswordHash( 8, false );
393
-		$this->donor_id = md5( $hasher->get_random_bytes( 32 ) );
392
+		$hasher         = new PasswordHash(8, false);
393
+		$this->donor_id = md5($hasher->get_random_bytes(32));
394 394
 	}
395 395
 
396 396
 	/**
@@ -401,14 +401,14 @@  discard block
 block discarded – undo
401 401
 	 */
402 402
 	public function save_data() {
403 403
 		// Dirty if something changed - prevents saving nothing new.
404
-		if ( $this->session_data_changed && $this->has_session() ) {
404
+		if ($this->session_data_changed && $this->has_session()) {
405 405
 			global $wpdb;
406 406
 
407 407
 			Give()->session_db->__replace(
408 408
 				Give()->session_db->table_name,
409 409
 				array(
410 410
 					'session_key'    => $this->donor_id,
411
-					'session_value'  => maybe_serialize( $this->session ),
411
+					'session_value'  => maybe_serialize($this->session),
412 412
 					'session_expiry' => $this->session_expiration,
413 413
 				),
414 414
 				array(
@@ -429,10 +429,10 @@  discard block
 block discarded – undo
429 429
 	 * @access public
430 430
 	 */
431 431
 	public function destroy_session() {
432
-		give_setcookie( $this->cookie_name, '', time() - YEAR_IN_SECONDS, apply_filters( 'give_session_use_secure_cookie', false ) );
433
-		give_setcookie( $this->nonce_cookie_name, '', time() - YEAR_IN_SECONDS, apply_filters( 'give_session_use_secure_cookie', false ) );
432
+		give_setcookie($this->cookie_name, '', time() - YEAR_IN_SECONDS, apply_filters('give_session_use_secure_cookie', false));
433
+		give_setcookie($this->nonce_cookie_name, '', time() - YEAR_IN_SECONDS, apply_filters('give_session_use_secure_cookie', false));
434 434
 
435
-		Give()->session_db->delete_session( $this->donor_id );
435
+		Give()->session_db->delete_session($this->donor_id);
436 436
 
437 437
 		$this->session              = array();
438 438
 		$this->session_data_changed = false;
@@ -448,10 +448,10 @@  discard block
 block discarded – undo
448 448
 	 *
449 449
 	 * @return bool
450 450
 	 */
451
-	public function is_delete_nonce_cookie(){
451
+	public function is_delete_nonce_cookie() {
452 452
 		$value = false;
453 453
 
454
-		if ( Give()->session->has_session() ) {
454
+		if (Give()->session->has_session()) {
455 455
 			$value = true;
456 456
 		}
457 457
 
@@ -468,10 +468,10 @@  discard block
 block discarded – undo
468 468
 	 *
469 469
 	 * @return string Cookie name
470 470
 	 */
471
-	public function get_cookie_name( $type = '' ) {
471
+	public function get_cookie_name($type = '') {
472 472
 		$name = '';
473 473
 
474
-		switch ( $type ) {
474
+		switch ($type) {
475 475
 			case 'nonce':
476 476
 				$name = $this->nonce_cookie_name;
477 477
 				break;
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 	 *
496 496
 	 * @return string
497 497
 	 */
498
-	public function __nonce_user_logged_out( $uid ) {
498
+	public function __nonce_user_logged_out($uid) {
499 499
 		return $this->has_session() && $this->donor_id ? $this->donor_id : $uid;
500 500
 	}
501 501
 
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
 	 */
542 542
 	public function set_expiration_variant_time() {
543 543
 
544
-		return ( ! empty( $this->exp_option ) ? ( intval( $this->exp_option ) - 3600 ) : 30 * 60 * 23 );
544
+		return ( ! empty($this->exp_option) ? (intval($this->exp_option) - 3600) : 30 * 60 * 23);
545 545
 	}
546 546
 
547 547
 	/**
@@ -558,9 +558,9 @@  discard block
 block discarded – undo
558 558
 	public function use_php_sessions() {
559 559
 		$ret = false;
560 560
 
561
-		give_doing_it_wrong( __FUNCTION__, __( 'We are using database session logic instead of PHP session', 'give' ), '2.2.0' );
561
+		give_doing_it_wrong(__FUNCTION__, __('We are using database session logic instead of PHP session', 'give'), '2.2.0');
562 562
 
563
-		return (bool) apply_filters( 'give_use_php_sessions', $ret );
563
+		return (bool) apply_filters('give_use_php_sessions', $ret);
564 564
 	}
565 565
 
566 566
 	/**
@@ -578,10 +578,10 @@  discard block
 block discarded – undo
578 578
 
579 579
 		$start_session = true;
580 580
 
581
-		give_doing_it_wrong( __FUNCTION__, __( 'We are using database session logic instead of PHP session', 'give' ), '2.2.0' );
581
+		give_doing_it_wrong(__FUNCTION__, __('We are using database session logic instead of PHP session', 'give'), '2.2.0');
582 582
 
583 583
 
584
-		if ( ! empty( $_SERVER['REQUEST_URI'] ) ) {  // @codingStandardsIgnoreLine
584
+		if ( ! empty($_SERVER['REQUEST_URI'])) {  // @codingStandardsIgnoreLine
585 585
 
586 586
 			$blacklist = apply_filters(
587 587
 				'give_session_start_uri_blacklist', array(
@@ -594,19 +594,19 @@  discard block
 block discarded – undo
594 594
 					'comments/feed/',
595 595
 				)
596 596
 			);
597
-			$uri       = ltrim( $_SERVER['REQUEST_URI'], '/' ); // // @codingStandardsIgnoreLine
598
-			$uri       = untrailingslashit( $uri );
599
-			if ( in_array( $uri, $blacklist, true ) ) {
597
+			$uri       = ltrim($_SERVER['REQUEST_URI'], '/'); // // @codingStandardsIgnoreLine
598
+			$uri       = untrailingslashit($uri);
599
+			if (in_array($uri, $blacklist, true)) {
600 600
 				$start_session = false;
601 601
 			}
602
-			if ( false !== strpos( $uri, 'feed=' ) ) {
602
+			if (false !== strpos($uri, 'feed=')) {
603 603
 				$start_session = false;
604 604
 			}
605
-			if ( is_admin() ) {
605
+			if (is_admin()) {
606 606
 				$start_session = false;
607 607
 			}
608 608
 		}
609 609
 
610
-		return apply_filters( 'give_start_session', $start_session );
610
+		return apply_filters('give_start_session', $start_session);
611 611
 	}
612 612
 }
Please login to merge, or discard this patch.
includes/class-give-db-logs.php 1 patch
Spacing   +71 added lines, -73 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
 		/* @var WPDB $wpdb */
36 36
 		global $wpdb;
37 37
 
38
-		$this->table_name  = $wpdb->prefix . 'give_logs';
38
+		$this->table_name  = $wpdb->prefix.'give_logs';
39 39
 		$this->primary_key = 'ID';
40 40
 		$this->version     = '1.0';
41 41
 
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
 	 * @return array  Default column values.
75 75
 	 */
76 76
 	public function get_column_defaults() {
77
-		$log_create_date     = current_time( 'mysql', 0 );
78
-		$log_create_date_gmt = get_gmt_from_date( $log_create_date );
77
+		$log_create_date     = current_time('mysql', 0);
78
+		$log_create_date_gmt = get_gmt_from_date($log_create_date);
79 79
 
80 80
 		return array(
81 81
 			'ID'           => 0,
@@ -98,39 +98,39 @@  discard block
 block discarded – undo
98 98
 	 *
99 99
 	 * @return bool|int
100 100
 	 */
101
-	public function add( $data = array() ) {
101
+	public function add($data = array()) {
102 102
 		// Valid table columns.
103
-		$table_columns = array_keys( $this->get_columns() );
103
+		$table_columns = array_keys($this->get_columns());
104 104
 
105 105
 		// Filter data.
106
-		foreach ( $data as $table_column => $column_data ) {
107
-			if ( ! in_array( $table_column, $table_columns ) ) {
108
-				unset( $data[ $table_column ] );
106
+		foreach ($data as $table_column => $column_data) {
107
+			if ( ! in_array($table_column, $table_columns)) {
108
+				unset($data[$table_column]);
109 109
 			}
110 110
 		}
111 111
 
112 112
 		// Set default values.
113
-		$current_log_data = wp_parse_args( $data, $this->get_column_defaults() );
113
+		$current_log_data = wp_parse_args($data, $this->get_column_defaults());
114 114
 
115 115
 		// Log parent should be an int.
116
-		$current_log_data['log_parent'] = absint( $current_log_data['log_parent'] );
116
+		$current_log_data['log_parent'] = absint($current_log_data['log_parent']);
117 117
 
118 118
 		// Get log.
119
-		$existing_log = $this->get_log_by( $current_log_data['ID'] );
119
+		$existing_log = $this->get_log_by($current_log_data['ID']);
120 120
 
121 121
 		// Update an existing log.
122
-		if ( $existing_log ) {
122
+		if ($existing_log) {
123 123
 
124 124
 			// Create new log data from existing and new log data.
125
-			$current_log_data = array_merge( $current_log_data, $existing_log );
125
+			$current_log_data = array_merge($current_log_data, $existing_log);
126 126
 
127 127
 			// Update log data.
128
-			$this->update( $current_log_data['ID'], $current_log_data );
128
+			$this->update($current_log_data['ID'], $current_log_data);
129 129
 
130 130
 			$log_id = $current_log_data['ID'];
131 131
 
132 132
 		} else {
133
-			$log_id = $this->insert( $current_log_data, 'log' );
133
+			$log_id = $this->insert($current_log_data, 'log');
134 134
 		}
135 135
 
136 136
 		return $log_id;
@@ -148,20 +148,20 @@  discard block
 block discarded – undo
148 148
 	 *
149 149
 	 * @return bool|null|array
150 150
 	 */
151
-	public function get_log_by( $log_id = 0, $by = 'id' ) {
151
+	public function get_log_by($log_id = 0, $by = 'id') {
152 152
 		/* @var WPDB $wpdb */
153 153
 		global $wpdb;
154 154
 		$log = null;
155 155
 
156 156
 		// Make sure $log_id is int.
157
-		$log_id = absint( $log_id );
157
+		$log_id = absint($log_id);
158 158
 
159 159
 		// Bailout.
160
-		if ( empty( $log_id ) ) {
160
+		if (empty($log_id)) {
161 161
 			return null;
162 162
 		}
163 163
 
164
-		switch ( $by ) {
164
+		switch ($by) {
165 165
 			case 'id':
166 166
 				$log = $wpdb->get_row(
167 167
 					$wpdb->prepare(
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 				break;
174 174
 
175 175
 			default:
176
-				$log = apply_filters( "give_get_log_by_{$by}", $log, $log_id );
176
+				$log = apply_filters("give_get_log_by_{$by}", $log, $log_id);
177 177
 		}
178 178
 
179 179
 		return $log;
@@ -189,14 +189,14 @@  discard block
 block discarded – undo
189 189
 	 *
190 190
 	 * @return mixed
191 191
 	 */
192
-	public function get_logs( $args = array() ) {
192
+	public function get_logs($args = array()) {
193 193
 		global $wpdb;
194
-		$sql_query = $this->get_sql( $args );
194
+		$sql_query = $this->get_sql($args);
195 195
 
196 196
 		// Get log.
197
-		if ( ! ( $logs = Give_Cache::get( 'give_logs', true, $sql_query ) ) ) {
198
-			$logs = $wpdb->get_results( $sql_query );
199
-			Give_Cache::set( 'give_logs', $logs, 3600, true, $sql_query );
197
+		if ( ! ($logs = Give_Cache::get('give_logs', true, $sql_query))) {
198
+			$logs = $wpdb->get_results($sql_query);
199
+			Give_Cache::set('give_logs', $logs, 3600, true, $sql_query);
200 200
 		}
201 201
 
202 202
 		return $logs;
@@ -213,21 +213,21 @@  discard block
 block discarded – undo
213 213
 	 *
214 214
 	 * @return int
215 215
 	 */
216
-	public function count( $args = array() ) {
216
+	public function count($args = array()) {
217 217
 		/* @var WPDB $wpdb */
218 218
 		global $wpdb;
219 219
 		$args['number'] = - 1;
220 220
 		$args['fields'] = 'ID';
221 221
 		$args['count']  = true;
222 222
 
223
-		$sql_query = $this->get_sql( $args );
223
+		$sql_query = $this->get_sql($args);
224 224
 
225
-		if ( ! ( $count = Give_Cache::get( 'give_logs_count', true, $sql_query ) ) ) {
226
-			$count = $wpdb->get_var( $sql_query );
227
-			Give_Cache::set( 'give_logs_count', $count, 3600, true, $args );
225
+		if ( ! ($count = Give_Cache::get('give_logs_count', true, $sql_query))) {
226
+			$count = $wpdb->get_var($sql_query);
227
+			Give_Cache::set('give_logs_count', $count, 3600, true, $args);
228 228
 		}
229 229
 
230
-		return absint( $count );
230
+		return absint($count);
231 231
 	}
232 232
 
233 233
 	/**
@@ -253,10 +253,10 @@  discard block
 block discarded – undo
253 253
         PRIMARY KEY  (ID)
254 254
         ) {$charset_collate};";
255 255
 
256
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
257
-		dbDelta( $sql );
256
+		require_once(ABSPATH.'wp-admin/includes/upgrade.php');
257
+		dbDelta($sql);
258 258
 
259
-		update_option( $this->table_name . '_db_version', $this->version, false );
259
+		update_option($this->table_name.'_db_version', $this->version, false);
260 260
 	}
261 261
 
262 262
 
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 	 *
271 271
 	 * @return string
272 272
 	 */
273
-	public function get_sql( $args = array() ) {
273
+	public function get_sql($args = array()) {
274 274
 		/* @var WPDB $wpdb */
275 275
 		global $wpdb;
276 276
 
@@ -284,12 +284,12 @@  discard block
 block discarded – undo
284 284
 			'count'   => false,
285 285
 		);
286 286
 
287
-		$args = wp_parse_args( $args, $defaults );
287
+		$args = wp_parse_args($args, $defaults);
288 288
 
289 289
 		// validate params.
290
-		$this->validate_params( $args );
290
+		$this->validate_params($args);
291 291
 
292
-		if ( $args['number'] < 1 ) {
292
+		if ($args['number'] < 1) {
293 293
 			$args['number'] = 99999999999;
294 294
 		}
295 295
 
@@ -297,78 +297,78 @@  discard block
 block discarded – undo
297 297
 		$where = '';
298 298
 
299 299
 		// Get sql query for meta.
300
-		if ( ! empty( $args['meta_query'] ) ) {
301
-			$meta_query_object = new WP_Meta_Query( $args['meta_query'] );
302
-			$meta_query        = $meta_query_object->get_sql( 'log', $this->table_name, 'id' );
303
-			$where             = implode( '', $meta_query );
300
+		if ( ! empty($args['meta_query'])) {
301
+			$meta_query_object = new WP_Meta_Query($args['meta_query']);
302
+			$meta_query        = $meta_query_object->get_sql('log', $this->table_name, 'id');
303
+			$where             = implode('', $meta_query);
304 304
 		}
305 305
 
306 306
 		$where .= ' WHERE 1=1 ';
307 307
 
308 308
 		// Set offset.
309
-		if ( empty( $args['offset'] ) && ( 0 < $args['paged'] ) ) {
310
-			$args['offset'] = $args['number'] * ( $args['paged'] - 1 );
309
+		if (empty($args['offset']) && (0 < $args['paged'])) {
310
+			$args['offset'] = $args['number'] * ($args['paged'] - 1);
311 311
 		}
312 312
 
313 313
 		// Set fields.
314 314
 		$fields = "{$this->table_name}.*";
315
-		if ( is_string( $args['fields'] ) && ( 'all' !== $args['fields'] ) ) {
315
+		if (is_string($args['fields']) && ('all' !== $args['fields'])) {
316 316
 			$fields = "{$this->table_name}.{$args['fields']}";
317 317
 		}
318 318
 
319 319
 		// Set count.
320
-		if ( $args['count'] ) {
320
+		if ($args['count']) {
321 321
 			$fields = "COUNT({$fields})";
322 322
 		}
323 323
 
324 324
 		// Specific logs.
325
-		if ( ! empty( $args['ID'] ) ) {
325
+		if ( ! empty($args['ID'])) {
326 326
 
327
-			if ( ! is_array( $args['ID'] ) ) {
328
-				$args['ID'] = explode( ',', $args['ID'] );
327
+			if ( ! is_array($args['ID'])) {
328
+				$args['ID'] = explode(',', $args['ID']);
329 329
 			}
330
-			$log_ids = implode( ',', array_map( 'intval', $args['ID'] ) );
330
+			$log_ids = implode(',', array_map('intval', $args['ID']));
331 331
 
332 332
 			$where .= " AND {$this->table_name}.ID IN( {$log_ids} ) ";
333 333
 		}
334 334
 
335 335
 		// Logs created for a specific date or in a date range
336
-		if ( ! empty( $args['date_query'] ) ) {
337
-			$date_query_object = new WP_Date_Query( $args['date_query'], "{$this->table_name}.log_date" );
338
-			$where             .= $date_query_object->get_sql();
336
+		if ( ! empty($args['date_query'])) {
337
+			$date_query_object = new WP_Date_Query($args['date_query'], "{$this->table_name}.log_date");
338
+			$where .= $date_query_object->get_sql();
339 339
 		}
340 340
 
341 341
 		// Logs create for specific parent.
342
-		if ( ! empty( $args['log_parent'] ) ) {
343
-			if ( ! is_array( $args['log_parent'] ) ) {
344
-				$args['log_parent'] = explode( ',', $args['log_parent'] );
342
+		if ( ! empty($args['log_parent'])) {
343
+			if ( ! is_array($args['log_parent'])) {
344
+				$args['log_parent'] = explode(',', $args['log_parent']);
345 345
 			}
346
-			$parent_ids = implode( ',', array_map( 'intval', $args['log_parent'] ) );
346
+			$parent_ids = implode(',', array_map('intval', $args['log_parent']));
347 347
 
348 348
 			$where .= " AND {$this->table_name}.log_parent IN( {$parent_ids} ) ";
349 349
 		}
350 350
 
351 351
 		// Logs create for specific type.
352 352
 		// is_array check is for backward compatibility.
353
-		if ( ! empty( $args['log_type'] ) && ! is_array( $args['log_type'] ) ) {
354
-			if ( ! is_array( $args['log_type'] ) ) {
355
-				$args['log_type'] = explode( ',', $args['log_type'] );
353
+		if ( ! empty($args['log_type']) && ! is_array($args['log_type'])) {
354
+			if ( ! is_array($args['log_type'])) {
355
+				$args['log_type'] = explode(',', $args['log_type']);
356 356
 			}
357 357
 
358
-			$log_types = implode( '\',\'', array_map( 'trim', $args['log_type'] ) );
358
+			$log_types = implode('\',\'', array_map('trim', $args['log_type']));
359 359
 
360 360
 			$where .= " AND {$this->table_name}.log_type IN( '{$log_types}' ) ";
361 361
 		}
362 362
 
363
-		$args['orderby'] = ! array_key_exists( $args['orderby'], $this->get_columns() ) ? 'log_date' : $args['orderby'];
363
+		$args['orderby'] = ! array_key_exists($args['orderby'], $this->get_columns()) ? 'log_date' : $args['orderby'];
364 364
 
365
-		$args['orderby'] = esc_sql( $args['orderby'] );
366
-		$args['order']   = esc_sql( $args['order'] );
365
+		$args['orderby'] = esc_sql($args['orderby']);
366
+		$args['order']   = esc_sql($args['order']);
367 367
 
368 368
 		return $wpdb->prepare(
369 369
 			"SELECT {$fields} FROM {$this->table_name} {$where} ORDER BY {$this->table_name}.{$args['orderby']} {$args['order']} LIMIT %d,%d;",
370
-			absint( $args['offset'] ),
371
-			absint( $args['number'] )
370
+			absint($args['offset']),
371
+			absint($args['number'])
372 372
 		);
373 373
 	}
374 374
 
@@ -383,13 +383,11 @@  discard block
 block discarded – undo
383 383
 	 *
384 384
 	 * @return mixed
385 385
 	 */
386
-	private function validate_params( &$args ) {
386
+	private function validate_params(&$args) {
387 387
 		// fields params
388 388
 		$args['fields'] = 'ids' === $args['fields'] ?
389
-			'ID' :
390
-			$args['fields'];
391
-		$args['fields'] = array_key_exists( $args['fields'], $this->get_columns() ) ?
392
-			$args['fields'] :
393
-			'all';
389
+			'ID' : $args['fields'];
390
+		$args['fields'] = array_key_exists($args['fields'], $this->get_columns()) ?
391
+			$args['fields'] : 'all';
394 392
 	}
395 393
 }
Please login to merge, or discard this patch.
includes/user-functions.php 1 patch
Spacing   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly.
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -30,54 +30,54 @@  discard block
 block discarded – undo
30 30
  *
31 31
  * @return bool|array List of all user donations.
32 32
  */
33
-function give_get_users_donations( $user = 0, $number = 20, $pagination = false, $status = 'complete' ) {
33
+function give_get_users_donations($user = 0, $number = 20, $pagination = false, $status = 'complete') {
34 34
 
35
-	if ( empty( $user ) ) {
35
+	if (empty($user)) {
36 36
 		$user = get_current_user_id();
37 37
 	}
38 38
 
39
-	if ( 0 === $user && ! Give()->email_access->token_exists ) {
39
+	if (0 === $user && ! Give()->email_access->token_exists) {
40 40
 		return false;
41 41
 	}
42 42
 
43
-	$status = ( 'complete' === $status ) ? 'publish' : $status;
43
+	$status = ('complete' === $status) ? 'publish' : $status;
44 44
 	$paged = 1;
45 45
 
46
-	if ( $pagination ) {
47
-		if ( get_query_var( 'paged' ) ) {
48
-			$paged = get_query_var( 'paged' );
49
-		} elseif ( get_query_var( 'page' ) ) {
50
-			$paged = get_query_var( 'page' );
46
+	if ($pagination) {
47
+		if (get_query_var('paged')) {
48
+			$paged = get_query_var('paged');
49
+		} elseif (get_query_var('page')) {
50
+			$paged = get_query_var('page');
51 51
 		}
52 52
 	}
53 53
 
54
-	$args = apply_filters( 'give_get_users_donations_args', array(
54
+	$args = apply_filters('give_get_users_donations_args', array(
55 55
 		'user'    => $user,
56 56
 		'number'  => $number,
57 57
 		'status'  => $status,
58 58
 		'orderby' => 'date',
59
-	) );
59
+	));
60 60
 
61
-	if ( $pagination ) {
61
+	if ($pagination) {
62 62
 		$args['page'] = $paged;
63 63
 	} else {
64 64
 		$args['nopaging'] = true;
65 65
 	}
66 66
 
67
-	$by_user_id = is_numeric( $user ) ? true : false;
68
-	$donor   = new Give_Donor( $user, $by_user_id );
67
+	$by_user_id = is_numeric($user) ? true : false;
68
+	$donor = new Give_Donor($user, $by_user_id);
69 69
 
70
-	if ( ! empty( $donor->payment_ids ) ) {
70
+	if ( ! empty($donor->payment_ids)) {
71 71
 
72
-		unset( $args['user'] );
73
-		$args['post__in'] = array_map( 'absint', explode( ',', $donor->payment_ids ) );
72
+		unset($args['user']);
73
+		$args['post__in'] = array_map('absint', explode(',', $donor->payment_ids));
74 74
 
75 75
 	}
76 76
 
77
-	$donations = give_get_payments( apply_filters( 'give_get_users_donations_args', $args ) );
77
+	$donations = give_get_payments(apply_filters('give_get_users_donations_args', $args));
78 78
 
79 79
 	// No donations.
80
-	if ( ! $donations ) {
80
+	if ( ! $donations) {
81 81
 		return false;
82 82
 	}
83 83
 
@@ -96,65 +96,65 @@  discard block
 block discarded – undo
96 96
  *
97 97
  * @return bool|object List of unique forms donated by user
98 98
  */
99
-function give_get_users_completed_donations( $user = 0, $status = 'complete' ) {
100
-	if ( empty( $user ) ) {
99
+function give_get_users_completed_donations($user = 0, $status = 'complete') {
100
+	if (empty($user)) {
101 101
 		$user = get_current_user_id();
102 102
 	}
103 103
 
104
-	if ( empty( $user ) ) {
104
+	if (empty($user)) {
105 105
 		return false;
106 106
 	}
107 107
 
108
-	$by_user_id = is_numeric( $user ) ? true : false;
108
+	$by_user_id = is_numeric($user) ? true : false;
109 109
 
110
-	$donor = new Give_Donor( $user, $by_user_id );
110
+	$donor = new Give_Donor($user, $by_user_id);
111 111
 
112
-	if ( empty( $donor->payment_ids ) ) {
112
+	if (empty($donor->payment_ids)) {
113 113
 		return false;
114 114
 	}
115 115
 
116 116
 	// Get all the items donated.
117
-	$payment_ids    = array_reverse( explode( ',', $donor->payment_ids ) );
118
-	$limit_payments = apply_filters( 'give_users_completed_donations_payments', 50 );
119
-	if ( ! empty( $limit_payments ) ) {
120
-		$payment_ids = array_slice( $payment_ids, 0, $limit_payments );
117
+	$payment_ids    = array_reverse(explode(',', $donor->payment_ids));
118
+	$limit_payments = apply_filters('give_users_completed_donations_payments', 50);
119
+	if ( ! empty($limit_payments)) {
120
+		$payment_ids = array_slice($payment_ids, 0, $limit_payments);
121 121
 	}
122 122
 	$donation_data = array();
123
-	foreach ( $payment_ids as $payment_id ) {
124
-		$donation_data[] = give_get_payment_meta( $payment_id );
123
+	foreach ($payment_ids as $payment_id) {
124
+		$donation_data[] = give_get_payment_meta($payment_id);
125 125
 	}
126 126
 
127
-	if ( empty( $donation_data ) ) {
127
+	if (empty($donation_data)) {
128 128
 		return false;
129 129
 	}
130 130
 
131 131
 	// Grab only the post ids "form_id" of the forms donated on this order.
132 132
 	$completed_donations_ids = array();
133
-	foreach ( $donation_data as $donation_meta ) {
134
-		$completed_donations_ids[] = isset( $donation_meta['form_id'] ) ? $donation_meta['form_id'] : '';
133
+	foreach ($donation_data as $donation_meta) {
134
+		$completed_donations_ids[] = isset($donation_meta['form_id']) ? $donation_meta['form_id'] : '';
135 135
 	}
136 136
 
137
-	if ( empty( $completed_donations_ids ) ) {
137
+	if (empty($completed_donations_ids)) {
138 138
 		return false;
139 139
 	}
140 140
 
141 141
 	// Only include each donation once.
142
-	$form_ids = array_unique( $completed_donations_ids );
142
+	$form_ids = array_unique($completed_donations_ids);
143 143
 
144 144
 	// Make sure we still have some products and a first item.
145
-	if ( empty( $form_ids ) || ! isset( $form_ids[0] ) ) {
145
+	if (empty($form_ids) || ! isset($form_ids[0])) {
146 146
 		return false;
147 147
 	}
148 148
 
149
-	$post_type = get_post_type( $form_ids[0] );
149
+	$post_type = get_post_type($form_ids[0]);
150 150
 
151
-	$args = apply_filters( 'give_get_users_completed_donations_args', array(
151
+	$args = apply_filters('give_get_users_completed_donations_args', array(
152 152
 		'include'        => $form_ids,
153 153
 		'post_type'      => $post_type,
154
-		'posts_per_page' => - 1,
155
-	) );
154
+		'posts_per_page' => -1,
155
+	));
156 156
 
157
-	return apply_filters( 'give_users_completed_donations_list', get_posts( $args ) );
157
+	return apply_filters('give_users_completed_donations_list', get_posts($args));
158 158
 }
159 159
 
160 160
 
@@ -170,12 +170,12 @@  discard block
 block discarded – undo
170 170
  *
171 171
  * @return bool True if has donated, false other wise.
172 172
  */
173
-function give_has_donations( $user_id = null ) {
174
-	if ( empty( $user_id ) ) {
173
+function give_has_donations($user_id = null) {
174
+	if (empty($user_id)) {
175 175
 		$user_id = get_current_user_id();
176 176
 	}
177 177
 
178
-	if ( give_get_users_donations( $user_id, 1 ) ) {
178
+	if (give_get_users_donations($user_id, 1)) {
179 179
 		return true; // User has at least one donation.
180 180
 	}
181 181
 
@@ -196,23 +196,23 @@  discard block
 block discarded – undo
196 196
  *
197 197
  * @return array
198 198
  */
199
-function give_get_donation_stats_by_user( $user = '' ) {
199
+function give_get_donation_stats_by_user($user = '') {
200 200
 
201 201
 	$field = '';
202 202
 
203
-	if ( is_email( $user ) ) {
203
+	if (is_email($user)) {
204 204
 		$field = 'email';
205
-	} elseif ( is_numeric( $user ) ) {
205
+	} elseif (is_numeric($user)) {
206 206
 		$field = 'user_id';
207 207
 	}
208 208
 
209
-	$stats    = array();
210
-	$donor = Give()->donors->get_donor_by( $field, $user );
209
+	$stats = array();
210
+	$donor = Give()->donors->get_donor_by($field, $user);
211 211
 
212
-	if ( $donor ) {
213
-		$donor = new Give_Donor( $donor->id );
214
-		$stats['purchases']   = absint( $donor->purchase_count );
215
-		$stats['total_spent'] = give_maybe_sanitize_amount( $donor->get_total_donation_amount() );
212
+	if ($donor) {
213
+		$donor = new Give_Donor($donor->id);
214
+		$stats['purchases']   = absint($donor->purchase_count);
215
+		$stats['total_spent'] = give_maybe_sanitize_amount($donor->get_total_donation_amount());
216 216
 	}
217 217
 
218 218
 	/**
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 	 *
221 221
 	 * @since 1.7
222 222
 	 */
223
-	$stats = (array) apply_filters( 'give_donation_stats_by_user', $stats, $user );
223
+	$stats = (array) apply_filters('give_donation_stats_by_user', $stats, $user);
224 224
 
225 225
 	return $stats;
226 226
 }
@@ -238,21 +238,21 @@  discard block
 block discarded – undo
238 238
  *
239 239
  * @return int The total number of donations.
240 240
  */
241
-function give_count_donations_of_donor( $user = null ) {
241
+function give_count_donations_of_donor($user = null) {
242 242
 
243 243
 	// Logged in?
244
-	if ( empty( $user ) ) {
244
+	if (empty($user)) {
245 245
 		$user = get_current_user_id();
246 246
 	}
247 247
 
248 248
 	// Email access?
249
-	if ( empty( $user ) && Give()->email_access->token_email ) {
249
+	if (empty($user) && Give()->email_access->token_email) {
250 250
 		$user = Give()->email_access->token_email;
251 251
 	}
252 252
 
253
-	$stats = ! empty( $user ) ? give_get_donation_stats_by_user( $user ) : false;
253
+	$stats = ! empty($user) ? give_get_donation_stats_by_user($user) : false;
254 254
 
255
-	return isset( $stats['purchases'] ) ? $stats['purchases'] : 0;
255
+	return isset($stats['purchases']) ? $stats['purchases'] : 0;
256 256
 }
257 257
 
258 258
 /**
@@ -265,9 +265,9 @@  discard block
 block discarded – undo
265 265
  *
266 266
  * @return float The total amount the user has spent
267 267
  */
268
-function give_donation_total_of_user( $user = null ) {
268
+function give_donation_total_of_user($user = null) {
269 269
 
270
-	$stats = give_get_donation_stats_by_user( $user );
270
+	$stats = give_get_donation_stats_by_user($user);
271 271
 
272 272
 	return $stats['total_spent'];
273 273
 }
@@ -283,40 +283,40 @@  discard block
 block discarded – undo
283 283
  *
284 284
  * @return bool
285 285
  */
286
-function give_validate_username( $username, $form_id = 0 ) {
286
+function give_validate_username($username, $form_id = 0) {
287 287
 	$valid = true;
288 288
 
289 289
 	// Validate username.
290
-	if ( ! empty( $username ) ) {
290
+	if ( ! empty($username)) {
291 291
 
292 292
 		// Sanitize username.
293
-		$sanitized_user_name = sanitize_user( $username, false );
293
+		$sanitized_user_name = sanitize_user($username, false);
294 294
 
295 295
 		// We have an user name, check if it already exists.
296
-		if ( username_exists( $username ) ) {
296
+		if (username_exists($username)) {
297 297
 			// Username already registered.
298
-			give_set_error( 'username_unavailable', __( 'Username already taken.', 'give' ) );
298
+			give_set_error('username_unavailable', __('Username already taken.', 'give'));
299 299
 			$valid = false;
300 300
 
301 301
 			// Check if it's valid.
302
-		} elseif ( $sanitized_user_name !== $username ) {
302
+		} elseif ($sanitized_user_name !== $username) {
303 303
 			// Invalid username.
304
-			if ( is_multisite() ) {
305
-				give_set_error( 'username_invalid', __( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ) );
304
+			if (is_multisite()) {
305
+				give_set_error('username_invalid', __('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give'));
306 306
 				$valid = false;
307 307
 			} else {
308
-				give_set_error( 'username_invalid', __( 'Invalid username.', 'give' ) );
308
+				give_set_error('username_invalid', __('Invalid username.', 'give'));
309 309
 				$valid = false;
310 310
 			}
311 311
 		}
312 312
 	} else {
313 313
 		// Username is empty.
314
-		give_set_error( 'username_empty', __( 'Enter a username.', 'give' ) );
314
+		give_set_error('username_empty', __('Enter a username.', 'give'));
315 315
 		$valid = false;
316 316
 
317 317
 		// Check if guest checkout is disable for form.
318
-		if ( $form_id && give_logged_in_only( $form_id ) ) {
319
-			give_set_error( 'registration_required', __( 'You must register or login to complete your donation.', 'give' ) );
318
+		if ($form_id && give_logged_in_only($form_id)) {
319
+			give_set_error('registration_required', __('You must register or login to complete your donation.', 'give'));
320 320
 			$valid = false;
321 321
 		}
322 322
 	}
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 	 *
331 331
 	 * @since 1.8
332 332
 	 */
333
-	$valid = (bool) apply_filters( 'give_validate_username', $valid, $username, $form_id );
333
+	$valid = (bool) apply_filters('give_validate_username', $valid, $username, $form_id);
334 334
 
335 335
 	return $valid;
336 336
 }
@@ -346,30 +346,30 @@  discard block
 block discarded – undo
346 346
  *
347 347
  * @return bool
348 348
  */
349
-function give_validate_user_email( $email, $registering_new_user = false ) {
349
+function give_validate_user_email($email, $registering_new_user = false) {
350 350
 	$valid = true;
351 351
 
352
-	if ( empty( $email ) ) {
352
+	if (empty($email)) {
353 353
 		// No email.
354
-		give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) );
354
+		give_set_error('email_empty', __('Enter an email.', 'give'));
355 355
 		$valid = false;
356 356
 
357
-	} elseif ( email_exists( $email ) ) {
357
+	} elseif (email_exists($email)) {
358 358
 		// Email already exists.
359
-		give_set_error( 'email_exists', __( 'Email already exists.', 'give' ) );
359
+		give_set_error('email_exists', __('Email already exists.', 'give'));
360 360
 		$valid = false;
361 361
 
362
-	} elseif ( ! is_email( $email ) ) {
362
+	} elseif ( ! is_email($email)) {
363 363
 		// Validate email.
364
-		give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) );
364
+		give_set_error('email_invalid', __('Invalid email.', 'give'));
365 365
 		$valid = false;
366 366
 
367
-	} elseif ( $registering_new_user ) {
367
+	} elseif ($registering_new_user) {
368 368
 
369 369
 		// If donor email is not primary.
370
-		if ( ! email_exists( $email ) && give_donor_email_exists( $email ) && give_is_additional_email( $email ) ) {
370
+		if ( ! email_exists($email) && give_donor_email_exists($email) && give_is_additional_email($email)) {
371 371
 			// Check if email exists.
372
-			give_set_error( 'email_used', __( 'The email address provided is already active for another user.', 'give' ) );
372
+			give_set_error('email_used', __('The email address provided is already active for another user.', 'give'));
373 373
 			$valid = false;
374 374
 		}
375 375
 	}
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 	 *
384 384
 	 * @since 1.8
385 385
 	 */
386
-	$valid = (bool) apply_filters( 'give_validate_user_email', $valid, $email, $registering_new_user );
386
+	$valid = (bool) apply_filters('give_validate_user_email', $valid, $email, $registering_new_user);
387 387
 
388 388
 	return $valid;
389 389
 }
@@ -399,34 +399,34 @@  discard block
 block discarded – undo
399 399
  *
400 400
  * @return bool
401 401
  */
402
-function give_validate_user_password( $password = '', $confirm_password = '', $registering_new_user = false ) {
402
+function give_validate_user_password($password = '', $confirm_password = '', $registering_new_user = false) {
403 403
 	$valid = true;
404 404
 
405 405
 	// Passwords Validation For New Donors Only.
406
-	if ( $registering_new_user ) {
406
+	if ($registering_new_user) {
407 407
 		// Password or confirmation missing.
408
-		if ( ! $password ) {
408
+		if ( ! $password) {
409 409
 			// The password is invalid.
410
-			give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) );
410
+			give_set_error('password_empty', __('Enter a password.', 'give'));
411 411
 			$valid = false;
412
-		} elseif ( ! $confirm_password ) {
412
+		} elseif ( ! $confirm_password) {
413 413
 			// Confirmation password is invalid.
414
-			give_set_error( 'confirmation_empty', __( 'Enter the password confirmation.', 'give' ) );
414
+			give_set_error('confirmation_empty', __('Enter the password confirmation.', 'give'));
415 415
 			$valid = false;
416 416
 		}
417 417
 	}
418 418
 	// Passwords Validation For New Donors as well as Existing Donors.
419
-	if ( $password || $confirm_password ) {
420
-		if ( strlen( $password ) < 6 || strlen( $confirm_password ) < 6 ) {
419
+	if ($password || $confirm_password) {
420
+		if (strlen($password) < 6 || strlen($confirm_password) < 6) {
421 421
 			// Seems Weak Password.
422
-			give_set_error( 'password_weak', __( 'Passwords should have at least 6 characters.', 'give' ) );
422
+			give_set_error('password_weak', __('Passwords should have at least 6 characters.', 'give'));
423 423
 			$valid = false;
424 424
 		}
425
-		if ( $password && $confirm_password ) {
425
+		if ($password && $confirm_password) {
426 426
 			// Verify confirmation matches.
427
-			if ( $password !== $confirm_password ) {
427
+			if ($password !== $confirm_password) {
428 428
 				// Passwords do not match.
429
-				give_set_error( 'password_mismatch', __( 'Passwords you entered do not match. Please try again.', 'give' ) );
429
+				give_set_error('password_mismatch', __('Passwords you entered do not match. Please try again.', 'give'));
430 430
 				$valid = false;
431 431
 			}
432 432
 		}
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
 	 *
443 443
 	 * @since 1.8
444 444
 	 */
445
-	$valid = (bool) apply_filters( 'give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user );
445
+	$valid = (bool) apply_filters('give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user);
446 446
 
447 447
 	return $valid;
448 448
 }
@@ -470,8 +470,8 @@  discard block
 block discarded – undo
470 470
  *
471 471
  * @return array The donor's address, if any
472 472
  */
473
-function give_get_donor_address( $donor_id = null, $args = array() ) {
474
-	if ( empty( $donor_id ) ) {
473
+function give_get_donor_address($donor_id = null, $args = array()) {
474
+	if (empty($donor_id)) {
475 475
 		$donor_id = get_current_user_id();
476 476
 	}
477 477
 
@@ -493,33 +493,33 @@  discard block
 block discarded – undo
493 493
 
494 494
 
495 495
 	// Backward compatibility for user id param.
496
-	$by_user_id = get_user_by( 'id', $donor_id ) ? true : false;
496
+	$by_user_id = get_user_by('id', $donor_id) ? true : false;
497 497
 
498 498
 	// Backward compatibility.
499
-	if ( ! give_has_upgrade_completed( 'v20_upgrades_user_address' ) && $by_user_id ) {
499
+	if ( ! give_has_upgrade_completed('v20_upgrades_user_address') && $by_user_id) {
500 500
 		return wp_parse_args(
501
-			(array) get_user_meta( $donor_id, '_give_user_address', true ),
501
+			(array) get_user_meta($donor_id, '_give_user_address', true),
502 502
 			$default_address
503 503
 		);
504 504
 	}
505 505
 
506
-	$donor = new Give_Donor( $donor_id, $by_user_id );
506
+	$donor = new Give_Donor($donor_id, $by_user_id);
507 507
 
508 508
 	if (
509 509
 		! $donor->id ||
510
-		empty( $donor->address ) ||
511
-		! array_key_exists( $args['address_type'], $donor->address )
510
+		empty($donor->address) ||
511
+		! array_key_exists($args['address_type'], $donor->address)
512 512
 	) {
513 513
 		return $default_address;
514 514
 	}
515 515
 
516
-	switch ( true ) {
517
-		case is_string( end( $donor->address[ $args['address_type'] ] ) ):
518
-			$address = wp_parse_args( $donor->address[ $args['address_type'] ], $default_address );
516
+	switch (true) {
517
+		case is_string(end($donor->address[$args['address_type']])):
518
+			$address = wp_parse_args($donor->address[$args['address_type']], $default_address);
519 519
 			break;
520 520
 
521
-		case is_array( end( $donor->address[ $args['address_type'] ] ) ):
522
-			$address = wp_parse_args( array_shift( $donor->address[ $args['address_type'] ] ), $default_address );
521
+		case is_array(end($donor->address[$args['address_type']])):
522
+			$address = wp_parse_args(array_shift($donor->address[$args['address_type']]), $default_address);
523 523
 			break;
524 524
 	}
525 525
 
@@ -539,19 +539,19 @@  discard block
 block discarded – undo
539 539
  *
540 540
  * @return void
541 541
  */
542
-function give_new_user_notification( $donation_id = 0, $donation_data = array() ) {
542
+function give_new_user_notification($donation_id = 0, $donation_data = array()) {
543 543
 	// Bailout.
544 544
 	if (
545
-		empty( $donation_id )
546
-		|| empty( $donation_data )
547
-		|| ! isset( $_POST['give_create_account'] )
548
-		|| 'on' !== give_clean( $_POST['give_create_account'] )
545
+		empty($donation_id)
546
+		|| empty($donation_data)
547
+		|| ! isset($_POST['give_create_account'])
548
+		|| 'on' !== give_clean($_POST['give_create_account'])
549 549
 	) {
550 550
 		return;
551 551
 	}
552 552
 
553 553
 	// For backward compatibility
554
-	$user = get_user_by( 'ID', $donation_data['user_info']['id'] );
554
+	$user = get_user_by('ID', $donation_data['user_info']['id']);
555 555
 
556 556
 	$donation_data['user_info'] = array_merge(
557 557
 		$donation_data['user_info'],
@@ -564,11 +564,11 @@  discard block
 block discarded – undo
564 564
 		)
565 565
 	);
566 566
 
567
-	do_action( 'give_new-donor-register_email_notification', $donation_data['user_info']['id'], $donation_data['user_info'], $donation_id );
568
-	do_action( 'give_donor-register_email_notification', $donation_data['user_info']['id'], $donation_data['user_info'], $donation_id );
567
+	do_action('give_new-donor-register_email_notification', $donation_data['user_info']['id'], $donation_data['user_info'], $donation_id);
568
+	do_action('give_donor-register_email_notification', $donation_data['user_info']['id'], $donation_data['user_info'], $donation_id);
569 569
 }
570 570
 
571
-add_action( 'give_insert_payment', 'give_new_user_notification', 10, 2 );
571
+add_action('give_insert_payment', 'give_new_user_notification', 10, 2);
572 572
 
573 573
 
574 574
 /**
@@ -584,37 +584,37 @@  discard block
 block discarded – undo
584 584
  *
585 585
  * @return string
586 586
  */
587
-function give_get_donor_name_by( $id = 0, $from = 'donation' ) {
587
+function give_get_donor_name_by($id = 0, $from = 'donation') {
588 588
 
589 589
 	// ID shouldn't be empty.
590
-	if ( empty( $id ) ) {
590
+	if (empty($id)) {
591 591
 		return '';
592 592
 	}
593 593
 
594 594
 	$name         = '';
595 595
 	$title_prefix = '';
596 596
 
597
-	switch ( $from ) {
597
+	switch ($from) {
598 598
 
599 599
 		case 'donation':
600
-			$title_prefix  = give_get_meta( $id, '_give_payment_donor_title_prefix', true );
601
-			$first_name    = give_get_meta( $id, '_give_donor_billing_first_name', true );
602
-			$last_name     = give_get_meta( $id, '_give_donor_billing_last_name', true );
600
+			$title_prefix  = give_get_meta($id, '_give_payment_donor_title_prefix', true);
601
+			$first_name    = give_get_meta($id, '_give_donor_billing_first_name', true);
602
+			$last_name     = give_get_meta($id, '_give_donor_billing_last_name', true);
603 603
 
604 604
 			$name = "{$first_name} {$last_name}";
605 605
 
606 606
 			break;
607 607
 
608 608
 		case 'donor':
609
-			$name         = Give()->donors->get_column( 'name', $id );
610
-			$title_prefix = Give()->donor_meta->get_meta( $id, '_give_donor_title_prefix', true );
609
+			$name         = Give()->donors->get_column('name', $id);
610
+			$title_prefix = Give()->donor_meta->get_meta($id, '_give_donor_title_prefix', true);
611 611
 
612 612
 			break;
613 613
 
614 614
 	}
615 615
 
616 616
 	// If title prefix is set then prepend it to name.
617
-	$name = give_get_donor_name_with_title_prefixes( $title_prefix, $name );
617
+	$name = give_get_donor_name_with_title_prefixes($title_prefix, $name);
618 618
 
619 619
 	return $name;
620 620
 
@@ -629,8 +629,8 @@  discard block
 block discarded – undo
629 629
  *
630 630
  * @return boolean  The user's ID on success, and false on failure.
631 631
  */
632
-function give_donor_email_exists( $email ) {
633
-	if ( Give()->donors->get_donor_by( 'email', $email ) ) {
632
+function give_donor_email_exists($email) {
633
+	if (Give()->donors->get_donor_by('email', $email)) {
634 634
 		return true;
635 635
 	}
636 636
 	return false;
@@ -645,14 +645,14 @@  discard block
 block discarded – undo
645 645
  *
646 646
  * @return bool
647 647
  */
648
-function give_is_additional_email( $email ) {
648
+function give_is_additional_email($email) {
649 649
 	global $wpdb;
650 650
 
651 651
 	$meta_table = Give()->donor_meta->table_name;
652 652
 	$meta_type  = Give()->donor_meta->meta_type;
653
-	$donor_id   = $wpdb->get_var( $wpdb->prepare( "SELECT {$meta_type}_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $email ) );
653
+	$donor_id   = $wpdb->get_var($wpdb->prepare("SELECT {$meta_type}_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $email));
654 654
 
655
-	if ( empty( $donor_id ) ) {
655
+	if (empty($donor_id)) {
656 656
 		return false;
657 657
 	}
658 658
 
Please login to merge, or discard this patch.
includes/price-functions.php 1 patch
Spacing   +21 added lines, -21 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,13 +23,13 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * @return bool true if has variable prices, false otherwise
25 25
  */
26
-function give_has_variable_prices( $form_id = 0 ) {
26
+function give_has_variable_prices($form_id = 0) {
27 27
 
28
-	if ( empty( $form_id ) ) {
28
+	if (empty($form_id)) {
29 29
 		return false;
30 30
 	}
31 31
 
32
-	$form = new Give_Donate_Form( $form_id );
32
+	$form = new Give_Donate_Form($form_id);
33 33
 
34 34
 	return $form->has_variable_prices();
35 35
 }
@@ -44,13 +44,13 @@  discard block
 block discarded – undo
44 44
  *
45 45
  * @return array|bool Variable prices
46 46
  */
47
-function give_get_variable_prices( $form_id = 0 ) {
47
+function give_get_variable_prices($form_id = 0) {
48 48
 
49
-	if ( empty( $form_id ) ) {
49
+	if (empty($form_id)) {
50 50
 		return false;
51 51
 	}
52 52
 
53
-	$form = new Give_Donate_Form( $form_id );
53
+	$form = new Give_Donate_Form($form_id);
54 54
 
55 55
 	return $form->prices;
56 56
 
@@ -65,13 +65,13 @@  discard block
 block discarded – undo
65 65
  *
66 66
  * @return array Variable prices
67 67
  */
68
-function give_get_variable_price_ids( $form_id = 0 ) {
69
-	if( ! ( $prices = give_get_variable_prices( $form_id ) ) ) {
68
+function give_get_variable_price_ids($form_id = 0) {
69
+	if ( ! ($prices = give_get_variable_prices($form_id))) {
70 70
 		return array();
71 71
 	}
72 72
 
73 73
 	$price_ids = array();
74
-	foreach ( $prices as $price ){
74
+	foreach ($prices as $price) {
75 75
 		$price_ids[] = $price['_give_id']['level_id'];
76 76
 	}
77 77
 
@@ -89,12 +89,12 @@  discard block
 block discarded – undo
89 89
  *
90 90
  * @return string $default_price
91 91
  */
92
-function give_get_default_multilevel_amount( $form_id ) {
92
+function give_get_default_multilevel_amount($form_id) {
93 93
 	$default_price = '1.00';
94 94
 
95 95
 	// Get default level price data.
96
-	$default_level = give_form_get_default_level( $form_id );
97
-	$default_price = isset( $default_level['_give_amount'] ) ? $default_level['_give_amount'] : $default_price;
96
+	$default_level = give_form_get_default_level($form_id);
97
+	$default_price = isset($default_level['_give_amount']) ? $default_level['_give_amount'] : $default_price;
98 98
 
99 99
 	return $default_price;
100 100
 }
@@ -110,19 +110,19 @@  discard block
 block discarded – undo
110 110
  * @return string $default_price
111 111
  * @since      1.0
112 112
  */
113
-function give_get_default_form_amount( $form_id ) {
113
+function give_get_default_form_amount($form_id) {
114 114
 
115
-	if ( give_has_variable_prices( $form_id ) ) {
115
+	if (give_has_variable_prices($form_id)) {
116 116
 
117
-		$default_amount = give_get_default_multilevel_amount( $form_id );
117
+		$default_amount = give_get_default_multilevel_amount($form_id);
118 118
 
119 119
 	} else {
120 120
 
121
-		$default_amount = give_get_meta( $form_id, '_give_set_price', true );
121
+		$default_amount = give_get_meta($form_id, '_give_set_price', true);
122 122
 
123 123
 	}
124 124
 
125
-	return apply_filters( 'give_default_form_amount', $default_amount, $form_id );
125
+	return apply_filters('give_default_form_amount', $default_amount, $form_id);
126 126
 
127 127
 }
128 128
 
@@ -140,13 +140,13 @@  discard block
 block discarded – undo
140 140
  *
141 141
  * @return bool
142 142
  */
143
-function give_is_custom_price_mode( $form_id = 0 ) {
143
+function give_is_custom_price_mode($form_id = 0) {
144 144
 
145
-	if ( empty( $form_id ) ) {
145
+	if (empty($form_id)) {
146 146
 		return false;
147 147
 	}
148 148
 
149
-	$form = new Give_Donate_Form( $form_id );
149
+	$form = new Give_Donate_Form($form_id);
150 150
 
151 151
 	return $form->is_custom_price_mode();
152 152
 }
Please login to merge, or discard this patch.