Test Failed
Push — master ( f5256c...25a383 )
by Devin
07:02
created
includes/admin/donors/donor-actions.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
  *
22 22
  * @since 1.0
23 23
  *
24
- * @return array|bool $output Response messages
24
+ * @return false|null $output Response messages
25 25
  */
26 26
 function give_edit_donor( $args ) {
27 27
 
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
  *
435 435
  * @since  1.7
436 436
  *
437
- * @return bool|null
437
+ * @return false|null
438 438
  */
439 439
 function give_remove_donor_email() {
440 440
 	if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
  *
479 479
  * @since  1.7
480 480
  *
481
- * @return bool|null
481
+ * @return false|null
482 482
  */
483 483
 function give_set_donor_primary_email() {
484 484
 	if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
Please login to merge, or discard this patch.
Spacing   +174 added lines, -174 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,37 +23,37 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * @return array|bool $output Response messages
25 25
  */
26
-function give_edit_donor( $args ) {
26
+function give_edit_donor($args) {
27 27
 
28
-	$donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' );
28
+	$donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments');
29 29
 
30
-	if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) {
31
-		wp_die( esc_html__( 'You do not have permission to edit this donor.', 'give' ), esc_html__( 'Error', 'give' ), array(
30
+	if ( ! is_admin() || ! current_user_can($donor_edit_role)) {
31
+		wp_die(esc_html__('You do not have permission to edit this donor.', 'give'), esc_html__('Error', 'give'), array(
32 32
 			'response' => 403,
33
-		) );
33
+		));
34 34
 	}
35 35
 
36
-	if ( empty( $args ) ) {
36
+	if (empty($args)) {
37 37
 		return false;
38 38
 	}
39 39
 
40 40
 	// Sanitize Data.
41
-	$args = give_clean( $args );
41
+	$args = give_clean($args);
42 42
 
43 43
 	// Verify Nonce.
44
-	if ( ! wp_verify_nonce( $args['_wpnonce'], 'edit-donor' ) ) {
45
-		wp_die( esc_html__( 'Cheatin’ uh?', 'give' ), esc_html__( 'Error', 'give' ), array(
44
+	if ( ! wp_verify_nonce($args['_wpnonce'], 'edit-donor')) {
45
+		wp_die(esc_html__('Cheatin’ uh?', 'give'), esc_html__('Error', 'give'), array(
46 46
 			'response' => 400,
47
-		) );
47
+		));
48 48
 	}
49 49
 
50 50
 	$donor_info = $args['donor_info'];
51
-	$donor_id   = intval( $donor_info['id'] );
51
+	$donor_id   = intval($donor_info['id']);
52 52
 
53
-	$donor = new Give_Donor( $donor_id );
53
+	$donor = new Give_Donor($donor_id);
54 54
 
55 55
 	// Bailout, if donor id doesn't exists.
56
-	if ( empty( $donor->id ) ) {
56
+	if (empty($donor->id)) {
57 57
 		return false;
58 58
 	}
59 59
 
@@ -69,30 +69,30 @@  discard block
 block discarded – undo
69 69
 		'country' => '',
70 70
 	);
71 71
 
72
-	$donor_info = wp_parse_args( $donor_info, $defaults );
72
+	$donor_info = wp_parse_args($donor_info, $defaults);
73 73
 
74
-	if ( (int) $donor_info['user_id'] !== (int) $donor->user_id ) {
74
+	if ((int) $donor_info['user_id'] !== (int) $donor->user_id) {
75 75
 
76 76
 		// Make sure we don't already have this user attached to a donor.
77
-		if ( ! empty( $donor_info['user_id'] ) && false !== Give()->donors->get_donor_by( 'user_id', $donor_info['user_id'] ) ) {
77
+		if ( ! empty($donor_info['user_id']) && false !== Give()->donors->get_donor_by('user_id', $donor_info['user_id'])) {
78 78
 			give_set_error(
79 79
 				'give-invalid-donor-user_id',
80 80
 				sprintf(
81 81
 					/* translators: %d User ID */
82
-					__( 'The User ID #%d is already associated with a different donor.', 'give' ),
82
+					__('The User ID #%d is already associated with a different donor.', 'give'),
83 83
 					$donor_info['user_id']
84 84
 				)
85 85
 			);
86 86
 		}
87 87
 
88 88
 		// Make sure it's actually a user.
89
-		$user = get_user_by( 'id', $donor_info['user_id'] );
90
-		if ( ! empty( $donor_info['user_id'] ) && false === $user ) {
89
+		$user = get_user_by('id', $donor_info['user_id']);
90
+		if ( ! empty($donor_info['user_id']) && false === $user) {
91 91
 			give_set_error(
92 92
 				'give-invalid-user_id',
93 93
 				sprintf(
94 94
 					/* translators: %d User ID */
95
-					__( 'The User ID #%d does not exist. Please assign an existing user.', 'give' ),
95
+					__('The User ID #%d does not exist. Please assign an existing user.', 'give'),
96 96
 					$donor_info['user_id']
97 97
 				)
98 98
 			);
@@ -100,29 +100,29 @@  discard block
 block discarded – undo
100 100
 	}
101 101
 
102 102
 	// Bailout, if errors are present.
103
-	if ( give_get_errors() ) {
103
+	if (give_get_errors()) {
104 104
 		return false;
105 105
 	}
106 106
 
107
-	$donor->update_meta( '_give_anonymous_donor', absint( $args['give_anonymous_donor'] ) );
107
+	$donor->update_meta('_give_anonymous_donor', absint($args['give_anonymous_donor']));
108 108
 
109 109
 	// Save company name in when admin update donor company name from dashboard.
110
-	$donor->update_meta( '_give_donor_company', sanitize_text_field( $args['give_donor_company'] ) );
110
+	$donor->update_meta('_give_donor_company', sanitize_text_field($args['give_donor_company']));
111 111
 
112 112
 	// If First name of donor is empty, then fetch the current first name of donor.
113
-	if ( empty( $donor_info['first_name'] ) ) {
113
+	if (empty($donor_info['first_name'])) {
114 114
 		$donor_info['first_name'] = $donor->get_first_name();
115 115
 	}
116 116
 
117 117
 	// Sanitize the inputs.
118 118
 	$donor_data               = array();
119
-	$donor_data['name']       = trim( "{$donor_info['first_name']} {$donor_info['last_name']}" );
119
+	$donor_data['name']       = trim("{$donor_info['first_name']} {$donor_info['last_name']}");
120 120
 	$donor_data['first_name'] = $donor_info['first_name'];
121 121
 	$donor_data['last_name']  = $donor_info['last_name'];
122 122
 	$donor_data['title']      = $donor_info['title'];
123 123
 	$donor_data['user_id']    = $donor_info['user_id'];
124 124
 
125
-	$donor_data = apply_filters( 'give_edit_donor_info', $donor_data, $donor_id );
125
+	$donor_data = apply_filters('give_edit_donor_info', $donor_data, $donor_id);
126 126
 
127 127
 	/**
128 128
 	 * Filter the address
@@ -131,21 +131,21 @@  discard block
 block discarded – undo
131 131
 	 *
132 132
 	 * @since 1.0
133 133
 	 */
134
-	$address = apply_filters( 'give_edit_donor_address', array(), $donor_id );
134
+	$address = apply_filters('give_edit_donor_address', array(), $donor_id);
135 135
 
136
-	$donor_data = give_clean( $donor_data );
137
-	$address    = give_clean( $address );
136
+	$donor_data = give_clean($donor_data);
137
+	$address    = give_clean($address);
138 138
 
139
-	$output = give_connect_user_donor_profile( $donor, $donor_data, $address );
139
+	$output = give_connect_user_donor_profile($donor, $donor_data, $address);
140 140
 
141
-	if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
142
-		header( 'Content-Type: application/json' );
143
-		echo wp_json_encode( $output );
141
+	if (defined('DOING_AJAX') && DOING_AJAX) {
142
+		header('Content-Type: application/json');
143
+		echo wp_json_encode($output);
144 144
 		wp_die();
145 145
 	}
146 146
 
147
-	if ( $output['success'] ) {
148
-		wp_safe_redirect( add_query_arg(
147
+	if ($output['success']) {
148
+		wp_safe_redirect(add_query_arg(
149 149
 			array(
150 150
 				'post_type'       => 'give_forms',
151 151
 				'page'            => 'give-donors',
@@ -153,15 +153,15 @@  discard block
 block discarded – undo
153 153
 				'id'              => $donor_id,
154 154
 				'give-messages[]' => 'profile-updated'
155 155
 			),
156
-			esc_url( admin_url( 'edit.php' ) )
157
-		) );
156
+			esc_url(admin_url('edit.php'))
157
+		));
158 158
 	}
159 159
 
160 160
 	exit;
161 161
 
162 162
 }
163 163
 
164
-add_action( 'give_edit-donor', 'give_edit_donor', 10, 1 );
164
+add_action('give_edit-donor', 'give_edit_donor', 10, 1);
165 165
 
166 166
 /**
167 167
  * Save a donor note.
@@ -172,40 +172,40 @@  discard block
 block discarded – undo
172 172
  *
173 173
  * @return int The Note ID that was saved, or 0 if nothing was saved.
174 174
  */
175
-function give_donor_save_note( $args ) {
175
+function give_donor_save_note($args) {
176 176
 
177
-	$donor_view_role = apply_filters( 'give_view_donors_role', 'view_give_reports' );
177
+	$donor_view_role = apply_filters('give_view_donors_role', 'view_give_reports');
178 178
 
179
-	if ( ! is_admin() || ! current_user_can( $donor_view_role ) ) {
180
-		wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array(
179
+	if ( ! is_admin() || ! current_user_can($donor_view_role)) {
180
+		wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array(
181 181
 			'response' => 403,
182
-		) );
182
+		));
183 183
 	}
184 184
 
185
-	if ( empty( $args ) ) {
185
+	if (empty($args)) {
186 186
 		return false;
187 187
 	}
188 188
 
189
-	$donor_note = trim( give_clean( $args['donor_note'] ) );
189
+	$donor_note = trim(give_clean($args['donor_note']));
190 190
 	$donor_id   = (int) $args['customer_id'];
191 191
 	$nonce      = $args['add_donor_note_nonce'];
192 192
 
193
-	if ( ! wp_verify_nonce( $nonce, 'add-donor-note' ) ) {
194
-		wp_die( __( 'Cheatin’ uh?', 'give' ), __( 'Error', 'give' ), array(
193
+	if ( ! wp_verify_nonce($nonce, 'add-donor-note')) {
194
+		wp_die(__('Cheatin’ uh?', 'give'), __('Error', 'give'), array(
195 195
 			'response' => 400,
196
-		) );
196
+		));
197 197
 	}
198 198
 
199
-	if ( empty( $donor_note ) ) {
200
-		give_set_error( 'empty-donor-note', __( 'A note is required.', 'give' ) );
199
+	if (empty($donor_note)) {
200
+		give_set_error('empty-donor-note', __('A note is required.', 'give'));
201 201
 	}
202 202
 
203
-	if ( give_get_errors() ) {
203
+	if (give_get_errors()) {
204 204
 		return false;
205 205
 	}
206 206
 
207
-	$donor    = new Give_Donor( $donor_id );
208
-	$new_note = $donor->add_note( $donor_note );
207
+	$donor    = new Give_Donor($donor_id);
208
+	$new_note = $donor->add_note($donor_note);
209 209
 
210 210
 	/**
211 211
 	 * Fires before inserting donor note.
@@ -215,22 +215,22 @@  discard block
 block discarded – undo
215 215
 	 *
216 216
 	 * @since 1.0
217 217
 	 */
218
-	do_action( 'give_pre_insert_donor_note', $donor_id, $new_note );
218
+	do_action('give_pre_insert_donor_note', $donor_id, $new_note);
219 219
 
220
-	if ( ! empty( $new_note ) && ! empty( $donor->id ) ) {
220
+	if ( ! empty($new_note) && ! empty($donor->id)) {
221 221
 
222 222
 		ob_start();
223 223
 		?>
224 224
 		<div class="donor-note-wrapper dashboard-comment-wrap comment-item">
225 225
 			<span class="note-content-wrap">
226
-				<?php echo stripslashes( $new_note ); ?>
226
+				<?php echo stripslashes($new_note); ?>
227 227
 			</span>
228 228
 		</div>
229 229
 		<?php
230 230
 		$output = ob_get_contents();
231 231
 		ob_end_clean();
232 232
 
233
-		if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
233
+		if (defined('DOING_AJAX') && DOING_AJAX) {
234 234
 			echo $output;
235 235
 			exit;
236 236
 		}
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 
244 244
 }
245 245
 
246
-add_action( 'give_add-donor-note', 'give_donor_save_note', 10, 1 );
246
+add_action('give_add-donor-note', 'give_donor_save_note', 10, 1);
247 247
 
248 248
 
249 249
 /**
@@ -255,17 +255,17 @@  discard block
 block discarded – undo
255 255
  *
256 256
  * @return bool|array If the disconnect was successful.
257 257
  */
258
-function give_disconnect_donor_user_id( $args ) {
258
+function give_disconnect_donor_user_id($args) {
259 259
 
260
-	$donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' );
260
+	$donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments');
261 261
 
262
-	if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) {
263
-		wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array(
262
+	if ( ! is_admin() || ! current_user_can($donor_edit_role)) {
263
+		wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array(
264 264
 			'response' => 403,
265
-		) );
265
+		));
266 266
 	}
267 267
 
268
-	if ( empty( $args ) ) {
268
+	if (empty($args)) {
269 269
 		return false;
270 270
 	}
271 271
 
@@ -273,14 +273,14 @@  discard block
 block discarded – undo
273 273
 
274 274
 	$nonce = $args['_wpnonce'];
275 275
 
276
-	if ( ! wp_verify_nonce( $nonce, 'edit-donor' ) ) {
277
-		wp_die( __( 'Cheatin&#8217; uh?', 'give' ), __( 'Error', 'give' ), array(
276
+	if ( ! wp_verify_nonce($nonce, 'edit-donor')) {
277
+		wp_die(__('Cheatin&#8217; uh?', 'give'), __('Error', 'give'), array(
278 278
 			'response' => 400,
279
-		) );
279
+		));
280 280
 	}
281 281
 
282
-	$donor = new Give_Donor( $donor_id );
283
-	if ( empty( $donor->id ) ) {
282
+	$donor = new Give_Donor($donor_id);
283
+	if (empty($donor->id)) {
284 284
 		return false;
285 285
 	}
286 286
 
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 	 *
295 295
 	 * @since 1.0
296 296
 	 */
297
-	do_action( 'give_pre_donor_disconnect_user_id', $donor_id, $user_id );
297
+	do_action('give_pre_donor_disconnect_user_id', $donor_id, $user_id);
298 298
 
299 299
 	$output     = array();
300 300
 	$donor_args = array(
@@ -303,19 +303,19 @@  discard block
 block discarded – undo
303 303
 
304 304
 
305 305
 	$output['success'] = true;
306
-	if ( ! $donor->update( $donor_args ) ) {
307
-		update_user_meta( $user_id, '_give_is_donor_disconnected', true );
308
-		update_user_meta( $user_id, '_give_disconnected_donor_id', $donor->id );
309
-		$donor->update_meta( '_give_disconnected_user_id', $user_id );
306
+	if ( ! $donor->update($donor_args)) {
307
+		update_user_meta($user_id, '_give_is_donor_disconnected', true);
308
+		update_user_meta($user_id, '_give_disconnected_donor_id', $donor->id);
309
+		$donor->update_meta('_give_disconnected_user_id', $user_id);
310 310
 
311 311
 		$output['success'] = true;
312 312
 
313 313
 	} else {
314 314
 		$output['success'] = false;
315
-		give_set_error( 'give-disconnect-user-fail', __( 'Failed to disconnect user from donor.', 'give' ) );
315
+		give_set_error('give-disconnect-user-fail', __('Failed to disconnect user from donor.', 'give'));
316 316
 	}
317 317
 
318
-	$output['redirect'] = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' ) . $donor_id;
318
+	$output['redirect'] = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id=').$donor_id;
319 319
 
320 320
 	/**
321 321
 	 * Fires after disconnecting user ID from a donor.
@@ -324,11 +324,11 @@  discard block
 block discarded – undo
324 324
 	 *
325 325
 	 * @since 1.0
326 326
 	 */
327
-	do_action( 'give_post_donor_disconnect_user_id', $donor_id );
327
+	do_action('give_post_donor_disconnect_user_id', $donor_id);
328 328
 
329
-	if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
330
-		header( 'Content-Type: application/json' );
331
-		echo json_encode( $output );
329
+	if (defined('DOING_AJAX') && DOING_AJAX) {
330
+		header('Content-Type: application/json');
331
+		echo json_encode($output);
332 332
 		wp_die();
333 333
 	}
334 334
 
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 
337 337
 }
338 338
 
339
-add_action( 'give_disconnect-userid', 'give_disconnect_donor_user_id', 10, 1 );
339
+add_action('give_disconnect-userid', 'give_disconnect_donor_user_id', 10, 1);
340 340
 
341 341
 /**
342 342
  * Add an email address to the donor from within the admin and log a donor note.
@@ -347,86 +347,86 @@  discard block
 block discarded – undo
347 347
  *
348 348
  * @return mixed If DOING_AJAX echos out JSON, otherwise returns array of success (bool) and message (string).
349 349
  */
350
-function give_add_donor_email( $args ) {
350
+function give_add_donor_email($args) {
351 351
 
352 352
 	$donor_id = '';
353
-	$donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' );
353
+	$donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments');
354 354
 
355
-	if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) {
356
-		wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array(
355
+	if ( ! is_admin() || ! current_user_can($donor_edit_role)) {
356
+		wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array(
357 357
 			'response' => 403,
358
-		) );
358
+		));
359 359
 	}
360 360
 
361 361
 	$output = array();
362
-	if ( empty( $args ) || empty( $args['email'] ) || empty( $args['customer_id'] ) ) {
362
+	if (empty($args) || empty($args['email']) || empty($args['customer_id'])) {
363 363
 		$output['success'] = false;
364
-		if ( empty( $args['email'] ) ) {
365
-			$output['message'] = __( 'Email address is required.', 'give' );
366
-		} elseif ( empty( $args['customer_id'] ) ) {
367
-			$output['message'] = __( 'Donor ID is required.', 'give' );
364
+		if (empty($args['email'])) {
365
+			$output['message'] = __('Email address is required.', 'give');
366
+		} elseif (empty($args['customer_id'])) {
367
+			$output['message'] = __('Donor ID is required.', 'give');
368 368
 		} else {
369
-			$output['message'] = __( 'An error has occurred. Please try again.', 'give' );
369
+			$output['message'] = __('An error has occurred. Please try again.', 'give');
370 370
 		}
371
-	} elseif ( ! wp_verify_nonce( $args['_wpnonce'], 'give_add_donor_email' ) ) {
371
+	} elseif ( ! wp_verify_nonce($args['_wpnonce'], 'give_add_donor_email')) {
372 372
 		$output = array(
373 373
 			'success' => false,
374
-			'message' => __( 'Nonce verification failed.', 'give' ),
374
+			'message' => __('Nonce verification failed.', 'give'),
375 375
 		);
376
-	} elseif ( ! is_email( $args['email'] ) ) {
376
+	} elseif ( ! is_email($args['email'])) {
377 377
 		$output = array(
378 378
 			'success' => false,
379
-			'message' => __( 'Invalid email.', 'give' ),
379
+			'message' => __('Invalid email.', 'give'),
380 380
 		);
381 381
 	} else {
382
-		$email    = sanitize_email( $args['email'] );
382
+		$email    = sanitize_email($args['email']);
383 383
 		$donor_id = (int) $args['customer_id'];
384 384
 		$primary  = 'true' === $args['primary'] ? true : false;
385
-		$donor    = new Give_Donor( $donor_id );
386
-		if ( false === $donor->add_email( $email, $primary ) ) {
387
-			if ( in_array( $email, $donor->emails ) ) {
385
+		$donor    = new Give_Donor($donor_id);
386
+		if (false === $donor->add_email($email, $primary)) {
387
+			if (in_array($email, $donor->emails)) {
388 388
 				$output = array(
389 389
 					'success' => false,
390
-					'message' => __( 'Email already associated with this donor.', 'give' ),
390
+					'message' => __('Email already associated with this donor.', 'give'),
391 391
 				);
392 392
 			} else {
393 393
 				$output = array(
394 394
 					'success' => false,
395
-					'message' => __( 'Email address is already associated with another donor.', 'give' ),
395
+					'message' => __('Email address is already associated with another donor.', 'give'),
396 396
 				);
397 397
 			}
398 398
 		} else {
399
-			$redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor_id . '&give-messages[]=email-added' );
399
+			$redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor_id.'&give-messages[]=email-added');
400 400
 			$output   = array(
401 401
 				'success'  => true,
402
-				'message'  => __( 'Email successfully added to donor.', 'give' ),
402
+				'message'  => __('Email successfully added to donor.', 'give'),
403 403
 				'redirect' => $redirect,
404 404
 			);
405 405
 
406 406
 			$user       = wp_get_current_user();
407
-			$user_login = ! empty( $user->user_login ) ? $user->user_login : __( 'System', 'give' );
408
-			$donor_note = sprintf( __( 'Email address %1$s added by %2$s', 'give' ), $email, $user_login );
409
-			$donor->add_note( $donor_note );
407
+			$user_login = ! empty($user->user_login) ? $user->user_login : __('System', 'give');
408
+			$donor_note = sprintf(__('Email address %1$s added by %2$s', 'give'), $email, $user_login);
409
+			$donor->add_note($donor_note);
410 410
 
411
-			if ( $primary ) {
412
-				$donor_note = sprintf( __( 'Email address %1$s set as primary by %2$s', 'give' ), $email, $user_login );
413
-				$donor->add_note( $donor_note );
411
+			if ($primary) {
412
+				$donor_note = sprintf(__('Email address %1$s set as primary by %2$s', 'give'), $email, $user_login);
413
+				$donor->add_note($donor_note);
414 414
 			}
415 415
 		}
416 416
 	} // End if().
417 417
 
418
-	do_action( 'give_post_add_donor_email', $donor_id, $args );
418
+	do_action('give_post_add_donor_email', $donor_id, $args);
419 419
 
420
-	if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
421
-		header( 'Content-Type: application/json' );
422
-		echo json_encode( $output );
420
+	if (defined('DOING_AJAX') && DOING_AJAX) {
421
+		header('Content-Type: application/json');
422
+		echo json_encode($output);
423 423
 		wp_die();
424 424
 	}
425 425
 
426 426
 	return $output;
427 427
 }
428 428
 
429
-add_action( 'give_add_donor_email', 'give_add_donor_email', 10, 1 );
429
+add_action('give_add_donor_email', 'give_add_donor_email', 10, 1);
430 430
 
431 431
 
432 432
 /**
@@ -437,39 +437,39 @@  discard block
 block discarded – undo
437 437
  * @return bool|null
438 438
  */
439 439
 function give_remove_donor_email() {
440
-	if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
440
+	if (empty($_GET['id']) || ! is_numeric($_GET['id'])) {
441 441
 		return false;
442 442
 	}
443
-	if ( empty( $_GET['email'] ) || ! is_email( $_GET['email'] ) ) {
443
+	if (empty($_GET['email']) || ! is_email($_GET['email'])) {
444 444
 		return false;
445 445
 	}
446
-	if ( empty( $_GET['_wpnonce'] ) ) {
446
+	if (empty($_GET['_wpnonce'])) {
447 447
 		return false;
448 448
 	}
449 449
 
450 450
 	$nonce = $_GET['_wpnonce'];
451
-	if ( ! wp_verify_nonce( $nonce, 'give-remove-donor-email' ) ) {
452
-		wp_die( __( 'Nonce verification failed', 'give' ), __( 'Error', 'give' ), array(
451
+	if ( ! wp_verify_nonce($nonce, 'give-remove-donor-email')) {
452
+		wp_die(__('Nonce verification failed', 'give'), __('Error', 'give'), array(
453 453
 			'response' => 403,
454
-		) );
454
+		));
455 455
 	}
456 456
 
457
-	$donor = new Give_Donor( $_GET['id'] );
458
-	if ( $donor->remove_email( $_GET['email'] ) ) {
459
-		$url        = add_query_arg( 'give-messages[]', 'email-removed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) );
457
+	$donor = new Give_Donor($_GET['id']);
458
+	if ($donor->remove_email($_GET['email'])) {
459
+		$url        = add_query_arg('give-messages[]', 'email-removed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id));
460 460
 		$user       = wp_get_current_user();
461
-		$user_login = ! empty( $user->user_login ) ? $user->user_login : __( 'System', 'give' );
462
-		$donor_note = sprintf( __( 'Email address %1$s removed by %2$s', 'give' ), $_GET['email'], $user_login );
463
-		$donor->add_note( $donor_note );
461
+		$user_login = ! empty($user->user_login) ? $user->user_login : __('System', 'give');
462
+		$donor_note = sprintf(__('Email address %1$s removed by %2$s', 'give'), $_GET['email'], $user_login);
463
+		$donor->add_note($donor_note);
464 464
 	} else {
465
-		$url = add_query_arg( 'give-messages[]', 'email-remove-failed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) );
465
+		$url = add_query_arg('give-messages[]', 'email-remove-failed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id));
466 466
 	}
467 467
 
468
-	wp_safe_redirect( $url );
468
+	wp_safe_redirect($url);
469 469
 	exit;
470 470
 }
471 471
 
472
-add_action( 'give_remove_donor_email', 'give_remove_donor_email', 10 );
472
+add_action('give_remove_donor_email', 'give_remove_donor_email', 10);
473 473
 
474 474
 
475 475
 /**
@@ -481,44 +481,44 @@  discard block
 block discarded – undo
481 481
  * @return bool|null
482 482
  */
483 483
 function give_set_donor_primary_email() {
484
-	if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
484
+	if (empty($_GET['id']) || ! is_numeric($_GET['id'])) {
485 485
 		return false;
486 486
 	}
487 487
 
488
-	if ( empty( $_GET['email'] ) || ! is_email( $_GET['email'] ) ) {
488
+	if (empty($_GET['email']) || ! is_email($_GET['email'])) {
489 489
 		return false;
490 490
 	}
491 491
 
492
-	if ( empty( $_GET['_wpnonce'] ) ) {
492
+	if (empty($_GET['_wpnonce'])) {
493 493
 		return false;
494 494
 	}
495 495
 
496 496
 	$nonce = $_GET['_wpnonce'];
497 497
 
498
-	if ( ! wp_verify_nonce( $nonce, 'give-set-donor-primary-email' ) ) {
499
-		wp_die( __( 'Nonce verification failed', 'give' ), __( 'Error', 'give' ), array(
498
+	if ( ! wp_verify_nonce($nonce, 'give-set-donor-primary-email')) {
499
+		wp_die(__('Nonce verification failed', 'give'), __('Error', 'give'), array(
500 500
 			'response' => 403,
501
-		) );
501
+		));
502 502
 	}
503 503
 
504
-	$donor = new Give_Donor( $_GET['id'] );
504
+	$donor = new Give_Donor($_GET['id']);
505 505
 
506
-	if ( $donor->set_primary_email( $_GET['email'] ) ) {
507
-		$url        = add_query_arg( 'give-messages[]', 'primary-email-updated', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) );
506
+	if ($donor->set_primary_email($_GET['email'])) {
507
+		$url        = add_query_arg('give-messages[]', 'primary-email-updated', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id));
508 508
 		$user       = wp_get_current_user();
509
-		$user_login = ! empty( $user->user_login ) ? $user->user_login : __( 'System', 'give' );
510
-		$donor_note = sprintf( __( 'Email address %1$s set as primary by %2$s', 'give' ), $_GET['email'], $user_login );
509
+		$user_login = ! empty($user->user_login) ? $user->user_login : __('System', 'give');
510
+		$donor_note = sprintf(__('Email address %1$s set as primary by %2$s', 'give'), $_GET['email'], $user_login);
511 511
 
512
-		$donor->add_note( $donor_note );
512
+		$donor->add_note($donor_note);
513 513
 	} else {
514
-		$url = add_query_arg( 'give-messages[]', 'primary-email-failed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) );
514
+		$url = add_query_arg('give-messages[]', 'primary-email-failed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id));
515 515
 	}
516 516
 
517
-	wp_safe_redirect( $url );
517
+	wp_safe_redirect($url);
518 518
 	exit;
519 519
 }
520 520
 
521
-add_action( 'give_set_donor_primary_email', 'give_set_donor_primary_email', 10 );
521
+add_action('give_set_donor_primary_email', 'give_set_donor_primary_email', 10);
522 522
 
523 523
 
524 524
 /**
@@ -528,15 +528,15 @@  discard block
 block discarded – undo
528 528
  *
529 529
  * @since 2.2
530 530
  */
531
-function give_process_donor_deletion( $args ) {
531
+function give_process_donor_deletion($args) {
532 532
 
533
-	$donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' );
533
+	$donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments');
534 534
 
535 535
 	// Verify user capabilities to proceed for deleting donor.
536
-	if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) {
536
+	if ( ! is_admin() || ! current_user_can($donor_edit_role)) {
537 537
 		wp_die(
538
-			esc_html__( 'You do not have permission to delete donors.', 'give' ),
539
-			esc_html__( 'Error', 'give' ),
538
+			esc_html__('You do not have permission to delete donors.', 'give'),
539
+			esc_html__('Error', 'give'),
540 540
 			array(
541 541
 				'response' => 403,
542 542
 			)
@@ -544,32 +544,32 @@  discard block
 block discarded – undo
544 544
 	}
545 545
 
546 546
 	$nonce_action = '';
547
-	if ( 'delete_bulk_donor' === $args['give_action'] ) {
547
+	if ('delete_bulk_donor' === $args['give_action']) {
548 548
 		$nonce_action = 'bulk-donors';
549
-	} elseif ( 'delete_donor' === $args['give_action'] ) {
549
+	} elseif ('delete_donor' === $args['give_action']) {
550 550
 		$nonce_action = 'give-delete-donor';
551 551
 	}
552 552
 
553 553
 	// Verify Nonce for deleting bulk donors.
554
-	give_validate_nonce( $args['_wpnonce'], $nonce_action );
554
+	give_validate_nonce($args['_wpnonce'], $nonce_action);
555 555
 
556 556
 	$redirect_args            = array();
557
-	$donor_ids                = ( isset( $args['donor'] ) && is_array( $args['donor'] ) ) ? $args['donor'] : array( $args['donor_id'] );
558
-	$redirect_args['order']   = ! empty( $args['order'] ) ? $args['order'] : 'DESC';
559
-	$redirect_args['orderby'] = ! empty( $args['orderby'] ) ? $args['orderby'] : 'ID';
560
-	$redirect_args['s']       = ! empty( $args['s'] ) ? $args['s'] : '';
561
-	$delete_donor             = ! empty( $args['give-donor-delete-confirm'] ) ? give_is_setting_enabled( $args['give-donor-delete-confirm'] ) : false;
562
-	$delete_donation          = ! empty( $args['give-donor-delete-records'] ) ? give_is_setting_enabled( $args['give-donor-delete-records'] ) : false;
557
+	$donor_ids                = (isset($args['donor']) && is_array($args['donor'])) ? $args['donor'] : array($args['donor_id']);
558
+	$redirect_args['order']   = ! empty($args['order']) ? $args['order'] : 'DESC';
559
+	$redirect_args['orderby'] = ! empty($args['orderby']) ? $args['orderby'] : 'ID';
560
+	$redirect_args['s']       = ! empty($args['s']) ? $args['s'] : '';
561
+	$delete_donor             = ! empty($args['give-donor-delete-confirm']) ? give_is_setting_enabled($args['give-donor-delete-confirm']) : false;
562
+	$delete_donation          = ! empty($args['give-donor-delete-records']) ? give_is_setting_enabled($args['give-donor-delete-records']) : false;
563 563
 
564
-	if ( count( $donor_ids ) > 0 ) {
564
+	if (count($donor_ids) > 0) {
565 565
 
566 566
 		// Loop through the selected donors to delete.
567
-		foreach ( $donor_ids as $donor_id ) {
567
+		foreach ($donor_ids as $donor_id) {
568 568
 
569
-			$donor = new Give_Donor( $donor_id );
569
+			$donor = new Give_Donor($donor_id);
570 570
 
571 571
 			// Proceed only if valid donor id is provided.
572
-			if ( $donor->id > 0 ) {
572
+			if ($donor->id > 0) {
573 573
 
574 574
 				/**
575 575
 				 * Fires before deleting donor.
@@ -580,19 +580,19 @@  discard block
 block discarded – undo
580 580
 				 *
581 581
 				 * @since 1.0
582 582
 				 */
583
-				do_action( 'give_pre_delete_donor', $donor->id, $delete_donor, $delete_donation );
583
+				do_action('give_pre_delete_donor', $donor->id, $delete_donor, $delete_donation);
584 584
 
585 585
 				// Proceed only, if user confirmed whether they need to delete the donor.
586
-				if ( $delete_donor ) {
586
+				if ($delete_donor) {
587 587
 
588 588
 					// Delete donor and linked donations.
589
-					$donor_delete_status = give_delete_donor_and_related_donation( $donor, array(
589
+					$donor_delete_status = give_delete_donor_and_related_donation($donor, array(
590 590
 						'delete_donation' => $delete_donation,
591
-					) );
591
+					));
592 592
 
593
-					if ( 1 === $donor_delete_status ) {
593
+					if (1 === $donor_delete_status) {
594 594
 						$redirect_args['give-messages[]'] = 'donor-deleted';
595
-					} elseif ( 2 === $donor_delete_status ) {
595
+					} elseif (2 === $donor_delete_status) {
596 596
 						$redirect_args['give-messages[]'] = 'donor-donations-deleted';
597 597
 					}
598 598
 				} else {
@@ -608,12 +608,12 @@  discard block
 block discarded – undo
608 608
 
609 609
 	$redirect_url = add_query_arg(
610 610
 		$redirect_args,
611
-		admin_url( 'edit.php?post_type=give_forms&page=give-donors' )
611
+		admin_url('edit.php?post_type=give_forms&page=give-donors')
612 612
 	);
613 613
 
614
-	wp_safe_redirect( $redirect_url );
614
+	wp_safe_redirect($redirect_url);
615 615
 	give_die();
616 616
 
617 617
 }
618
-add_action( 'give_delete_donor', 'give_process_donor_deletion' );
619
-add_action( 'give_delete_bulk_donor', 'give_process_donor_deletion' );
618
+add_action('give_delete_donor', 'give_process_donor_deletion');
619
+add_action('give_delete_bulk_donor', 'give_process_donor_deletion');
Please login to merge, or discard this patch.
includes/admin/donors/donor-functions.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -162,7 +162,7 @@
 block discarded – undo
162 162
 /**
163 163
  * This function is used to delete donor and related donation without redirection.
164 164
  *
165
- * @param int|Give_Donor $donor Donor ID or List of Donor IDs.
165
+ * @param Give_Donor $donor Donor ID or List of Donor IDs.
166 166
  * @param array          $args  List of arguments to handle donor and related donation deletion process.
167 167
  *
168 168
  * @type bool delete_donation Delete donor linked donations if set to true. Default is false.
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 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,7 +23,7 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * @return array        The altered list of views.
25 25
  */
26
-function give_register_default_donor_views( $views ) {
26
+function give_register_default_donor_views($views) {
27 27
 
28 28
 	$default_views = array(
29 29
 		'overview' => 'give_donor_view',
@@ -31,11 +31,11 @@  discard block
 block discarded – undo
31 31
 		'notes'    => 'give_donor_notes_view',
32 32
 	);
33 33
 
34
-	return array_merge( $views, $default_views );
34
+	return array_merge($views, $default_views);
35 35
 
36 36
 }
37 37
 
38
-add_filter( 'give_donor_views', 'give_register_default_donor_views', 1, 1 );
38
+add_filter('give_donor_views', 'give_register_default_donor_views', 1, 1);
39 39
 
40 40
 /**
41 41
  * Register a tab for the single donor view.
@@ -46,23 +46,23 @@  discard block
 block discarded – undo
46 46
  *
47 47
  * @return array       The altered list of tabs
48 48
  */
49
-function give_register_default_donor_tabs( $tabs ) {
49
+function give_register_default_donor_tabs($tabs) {
50 50
 
51 51
 	$default_tabs = array(
52 52
 		'overview' => array(
53 53
 			'dashicon' => 'dashicons-admin-users',
54
-			'title'    => __( 'Donor Profile', 'give' ),
54
+			'title'    => __('Donor Profile', 'give'),
55 55
 		),
56 56
 		'notes'    => array(
57 57
 			'dashicon' => 'dashicons-admin-comments',
58
-			'title'    => __( 'Donor Notes', 'give' ),
58
+			'title'    => __('Donor Notes', 'give'),
59 59
 		),
60 60
 	);
61 61
 
62
-	return array_merge( $tabs, $default_tabs );
62
+	return array_merge($tabs, $default_tabs);
63 63
 }
64 64
 
65
-add_filter( 'give_donor_tabs', 'give_register_default_donor_tabs', 1, 1 );
65
+add_filter('give_donor_tabs', 'give_register_default_donor_tabs', 1, 1);
66 66
 
67 67
 /**
68 68
  * Register the Delete icon as late as possible so it's at the bottom.
@@ -73,17 +73,17 @@  discard block
 block discarded – undo
73 73
  *
74 74
  * @return array       The altered list of tabs, with 'delete' at the bottom.
75 75
  */
76
-function give_register_delete_donor_tab( $tabs ) {
76
+function give_register_delete_donor_tab($tabs) {
77 77
 
78 78
 	$tabs['delete'] = array(
79 79
 		'dashicon' => 'dashicons-trash',
80
-		'title'    => __( 'Delete Donor', 'give' ),
80
+		'title'    => __('Delete Donor', 'give'),
81 81
 	);
82 82
 
83 83
 	return $tabs;
84 84
 }
85 85
 
86
-add_filter( 'give_donor_tabs', 'give_register_delete_donor_tab', PHP_INT_MAX, 1 );
86
+add_filter('give_donor_tabs', 'give_register_delete_donor_tab', PHP_INT_MAX, 1);
87 87
 
88 88
 /**
89 89
  * Connect and Reconnect Donor with User profile.
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
  *
99 99
  * @return array
100 100
  */
101
-function give_connect_user_donor_profile( $donor, $donor_data, $address ) {
101
+function give_connect_user_donor_profile($donor, $donor_data, $address) {
102 102
 
103 103
 	$donor_id         = $donor->id;
104 104
 	$previous_user_id = $donor->user_id;
@@ -112,32 +112,32 @@  discard block
 block discarded – undo
112 112
 	 *
113 113
 	 * @since 1.0
114 114
 	 */
115
-	do_action( 'give_pre_edit_donor', $donor_id, $donor_data, $address );
115
+	do_action('give_pre_edit_donor', $donor_id, $donor_data, $address);
116 116
 
117 117
 	$output = array();
118 118
 
119
-	if ( $donor->update( $donor_data ) ) {
119
+	if ($donor->update($donor_data)) {
120 120
 
121 121
 		// Create and Update Donor First Name and Last Name in Meta Fields.
122
-		$donor->update_meta( '_give_donor_first_name', $donor_data['first_name'] );
123
-		$donor->update_meta( '_give_donor_last_name', $donor_data['last_name'] );
124
-		$donor->update_meta( '_give_donor_title_prefix', $donor_data['title'] );
122
+		$donor->update_meta('_give_donor_first_name', $donor_data['first_name']);
123
+		$donor->update_meta('_give_donor_last_name', $donor_data['last_name']);
124
+		$donor->update_meta('_give_donor_title_prefix', $donor_data['title']);
125 125
 
126 126
 		// Fetch disconnected user id, if exists.
127
-		$disconnected_user_id = $donor->get_meta( '_give_disconnected_user_id', true );
127
+		$disconnected_user_id = $donor->get_meta('_give_disconnected_user_id', true);
128 128
 
129 129
 		// Flag User and Donor Disconnection.
130
-		delete_user_meta( $disconnected_user_id, '_give_is_donor_disconnected' );
130
+		delete_user_meta($disconnected_user_id, '_give_is_donor_disconnected');
131 131
 
132 132
 		// Check whether the disconnected user id and the reconnected user id are same or not.
133 133
 		// If both are same then delete user id store in donor meta.
134
-		if ( $donor_data['user_id'] === $disconnected_user_id ) {
135
-			delete_user_meta( $disconnected_user_id, '_give_disconnected_donor_id' );
136
-			$donor->delete_meta( '_give_disconnected_user_id' );
134
+		if ($donor_data['user_id'] === $disconnected_user_id) {
135
+			delete_user_meta($disconnected_user_id, '_give_disconnected_donor_id');
136
+			$donor->delete_meta('_give_disconnected_user_id');
137 137
 		}
138 138
 
139 139
 		$output['success']       = true;
140
-		$donor_data              = array_merge( $donor_data, $address );
140
+		$donor_data              = array_merge($donor_data, $address);
141 141
 		$output['customer_info'] = $donor_data;
142 142
 
143 143
 	} else {
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 	 *
155 155
 	 * @since 1.0
156 156
 	 */
157
-	do_action( 'give_post_edit_donor', $donor_id, $donor_data );
157
+	do_action('give_post_edit_donor', $donor_id, $donor_data);
158 158
 
159 159
 	return $output;
160 160
 }
@@ -171,39 +171,39 @@  discard block
 block discarded – undo
171 171
  *
172 172
  * @return int
173 173
  */
174
-function give_delete_donor_and_related_donation( $donor, $args = array() ) {
174
+function give_delete_donor_and_related_donation($donor, $args = array()) {
175 175
 
176 176
 	// Default Arguments.
177 177
 	$default_args = array(
178 178
 		'delete_donation' => false,
179 179
 	);
180 180
 
181
-	$args = wp_parse_args( $args, $default_args );
181
+	$args = wp_parse_args($args, $default_args);
182 182
 
183 183
 	// If $donor not an instance of Give_Donor then create one.
184
-	if ( ! $donor instanceof Give_Donor ) {
185
-		$donor = new Give_Donor( $donor );
184
+	if ( ! $donor instanceof Give_Donor) {
185
+		$donor = new Give_Donor($donor);
186 186
 	}
187 187
 
188
-	if ( $donor->id > 0 ) {
188
+	if ($donor->id > 0) {
189 189
 
190 190
 		// Delete Donor.
191
-		$donor_deleted = Give()->donors->delete( $donor->id );
191
+		$donor_deleted = Give()->donors->delete($donor->id);
192 192
 
193 193
 		// Fetch linked donations of a particular donor.
194
-		$donation_ids  = explode( ',', $donor->payment_ids );
194
+		$donation_ids  = explode(',', $donor->payment_ids);
195 195
 
196 196
 		// Proceed to delete related donation, if user opted and donor is deleted successfully.
197
-		if ( $donor_deleted && $args['delete_donation'] ) {
198
-			foreach ( $donation_ids as $donation_id ) {
199
-				give_delete_donation( $donation_id );
197
+		if ($donor_deleted && $args['delete_donation']) {
198
+			foreach ($donation_ids as $donation_id) {
199
+				give_delete_donation($donation_id);
200 200
 			}
201 201
 
202 202
 			return 2; // Donor and linked Donations deleted.
203 203
 
204 204
 		} else {
205
-			foreach ( $donation_ids as $donation_id ) {
206
-				give_update_payment_meta( $donation_id, '_give_payment_donor_id', 0 );
205
+			foreach ($donation_ids as $donation_id) {
206
+				give_update_payment_meta($donation_id, '_give_payment_donor_id', 0);
207 207
 			}
208 208
 		}
209 209
 
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-delete-import-donors.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -290,7 +290,7 @@
 block discarded – undo
290 290
 	 *
291 291
 	 * @since 1.8.12
292 292
 	 *
293
-	 * @return int
293
+	 * @return double
294 294
 	 */
295 295
 	public function get_percentage_complete() {
296 296
 		return ceil( ( 100 * $this->step_completed ) / $this->total_step );
Please login to merge, or discard this patch.
Spacing   +116 added lines, -116 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly.
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
 	 *
135 135
 	 * @param int $_step Steps.
136 136
 	 */
137
-	public function __construct( $_step = 1 ) {
138
-		parent::__construct( $_step );
137
+	public function __construct($_step = 1) {
138
+		parent::__construct($_step);
139 139
 
140 140
 		$this->is_writable = true;
141 141
 	}
@@ -154,38 +154,38 @@  discard block
 block discarded – undo
154 154
 		$donor_ids    = array();
155 155
 
156 156
 		// Check if the ajax request if running for the first time.
157
-		if ( 1 === (int) $this->step ) {
157
+		if (1 === (int) $this->step) {
158 158
 
159 159
 			// Delete all the form ids.
160
-			$this->delete_option( $this->form_key );
160
+			$this->delete_option($this->form_key);
161 161
 
162 162
 			// Delete all the donation ids.
163
-			$this->delete_option( $this->donation_key );
163
+			$this->delete_option($this->donation_key);
164 164
 
165 165
 			// Delete all the donor ids.
166
-			$this->delete_option( $this->donor_key );
166
+			$this->delete_option($this->donor_key);
167 167
 
168 168
 			// Delete all the step and set to 'count' which if the first step in the process of deleting the donors.
169
-			$this->update_option( $this->step_key, 'count' );
169
+			$this->update_option($this->step_key, 'count');
170 170
 
171 171
 			// Delete tha page count of the step.
172
-			$this->update_option( $this->step_on_key, '0' );
172
+			$this->update_option($this->step_on_key, '0');
173 173
 		} else {
174 174
 
175 175
 			// Get the old donors list.
176
-			$donor_ids = $this->get_option( $this->donor_key );
176
+			$donor_ids = $this->get_option($this->donor_key);
177 177
 
178 178
 			// Get the old donation list.
179
-			$donation_ids = $this->get_option( $this->donation_key );
179
+			$donation_ids = $this->get_option($this->donation_key);
180 180
 		}
181 181
 
182 182
 		// Get the step and check for it if it's on the first step( 'count' ) or not.
183 183
 		$step = (int) $this->get_step();
184
-		if ( 1 === $step ) {
184
+		if (1 === $step) {
185 185
 			/**
186 186
 			 * Will add or update the donation and donor data by running wp query.
187 187
 			 */
188
-			$this->count( $step, $donation_ids, $donor_ids );
188
+			$this->count($step, $donation_ids, $donor_ids);
189 189
 		}
190 190
 	}
191 191
 
@@ -196,18 +196,18 @@  discard block
 block discarded – undo
196 196
 	 * @param array  $donation_ids Contain the list of all the donation id's that has being add before this.
197 197
 	 * @param array  $donor_ids    Contain the list of all the donors id's that has being add before this.
198 198
 	 */
199
-	private function count( $step, $donation_ids = array(), $donor_ids = array() ) {
199
+	private function count($step, $donation_ids = array(), $donor_ids = array()) {
200 200
 
201 201
 		// Get the Page count by default it's zero.
202 202
 		$paged = (int) $this->get_step_page();
203 203
 
204 204
 		// Increased the page count by one.
205
-		++ $paged;
205
+		++$paged;
206 206
 
207 207
 		/**
208 208
 		 * Filter add to alter the argument before the wp quest run
209 209
 		 */
210
-		$args = apply_filters( 'give_tools_reset_stats_total_args', array(
210
+		$args = apply_filters('give_tools_reset_stats_total_args', array(
211 211
 			'post_type'      => 'give_payment',
212 212
 			'post_status'    => 'any',
213 213
 			'posts_per_page' => $this->per_step,
@@ -215,41 +215,41 @@  discard block
 block discarded – undo
215 215
 			'meta_key'       => '_give_payment_import',
216 216
 			'meta_value_num' => 1,
217 217
 			'meta_compare'   => '=',
218
-		) );
218
+		));
219 219
 
220 220
 		// Reset the post data.
221 221
 		wp_reset_postdata();
222 222
 
223 223
 		// Getting the new donation.
224
-		$donation_posts = new WP_Query( $args );
224
+		$donation_posts = new WP_Query($args);
225 225
 
226 226
 		// The Loop.
227
-		if ( $donation_posts->have_posts() ) {
228
-			while ( $donation_posts->have_posts() ) {
227
+		if ($donation_posts->have_posts()) {
228
+			while ($donation_posts->have_posts()) {
229 229
 				$add_author = true;
230 230
 				$donation_posts->the_post();
231 231
 				global $post;
232 232
 				// Add the donation id in side the array.
233 233
 				$donation_ids[] = $post->ID;
234 234
 
235
-				$donor_id = (int) give_get_meta( $post->ID, '_give_payment_customer_id', true );
236
-				if ( ! empty( $donor_id ) ) {
237
-					$donor = new Give_Donor( $donor_id );
238
-					if ( ! empty( $donor->id ) ) {
239
-						if ( empty( $donor->user_id ) && ! empty( $donor->payment_ids ) ) {
235
+				$donor_id = (int) give_get_meta($post->ID, '_give_payment_customer_id', true);
236
+				if ( ! empty($donor_id)) {
237
+					$donor = new Give_Donor($donor_id);
238
+					if ( ! empty($donor->id)) {
239
+						if (empty($donor->user_id) && ! empty($donor->payment_ids)) {
240 240
 							$add_author = false;
241
-							$count      = (int) count( $donor->payment_ids );
242
-							if ( 1 === $count ) {
243
-								give_delete_donor_and_related_donation( $donor );
241
+							$count      = (int) count($donor->payment_ids);
242
+							if (1 === $count) {
243
+								give_delete_donor_and_related_donation($donor);
244 244
 							} else {
245
-								$donor->remove_payment( $post->ID );
245
+								$donor->remove_payment($post->ID);
246 246
 								$donor->decrease_donation_count();
247 247
 							}
248 248
 						}
249 249
 					}
250 250
 				}
251 251
 
252
-				if ( ! empty( $add_author ) ) {
252
+				if ( ! empty($add_author)) {
253 253
 					// Add the donor id in side the array.
254 254
 					$donor_ids[] = (int) $post->post_author;
255 255
 				}
@@ -263,24 +263,24 @@  discard block
 block discarded – undo
263 263
 		$max_num_pages = (int) $donation_posts->max_num_pages;
264 264
 
265 265
 		// Check current page is less then max number of page or not.
266
-		if ( $paged < $max_num_pages ) {
266
+		if ($paged < $max_num_pages) {
267 267
 
268 268
 			// Update the current page variable for the next step.
269
-			$this->update_option( $this->step_on_key, $paged );
269
+			$this->update_option($this->step_on_key, $paged);
270 270
 
271 271
 			// Calculating percentage.
272 272
 			$page_remain          = $max_num_pages - $paged;
273
-			$this->total_step     = (int) $max_num_pages + ( $total_donation / $this->per_step ) + ( ( $page_remain * 2 ) * count( $donor_ids ) );
273
+			$this->total_step     = (int) $max_num_pages + ($total_donation / $this->per_step) + (($page_remain * 2) * count($donor_ids));
274 274
 			$this->step_completed = $paged;
275 275
 		} else {
276
-			$donation_ids_count = count( $donor_ids );
277
-			$this->update_option( $this->step_key, 'donation' );
278
-			$this->update_option( $this->step_on_key, '0' );
276
+			$donation_ids_count = count($donor_ids);
277
+			$this->update_option($this->step_key, 'donation');
278
+			$this->update_option($this->step_on_key, '0');
279 279
 		}
280 280
 
281
-		$donor_ids = array_unique( $donor_ids );
282
-		$this->update_option( $this->donor_key, $donor_ids );
283
-		$this->update_option( $this->donation_key, $donation_ids );
281
+		$donor_ids = array_unique($donor_ids);
282
+		$this->update_option($this->donor_key, $donor_ids);
283
+		$this->update_option($this->donation_key, $donation_ids);
284 284
 
285 285
 		wp_reset_postdata();
286 286
 	}
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 	 * @return int
294 294
 	 */
295 295
 	public function get_percentage_complete() {
296
-		return ceil( ( 100 * $this->step_completed ) / $this->total_step );
296
+		return ceil((100 * $this->step_completed) / $this->total_step);
297 297
 	}
298 298
 
299 299
 	/**
@@ -303,10 +303,10 @@  discard block
 block discarded – undo
303 303
 	 */
304 304
 	public function process_step() {
305 305
 
306
-		if ( ! $this->can_export() ) {
306
+		if ( ! $this->can_export()) {
307 307
 			wp_die(
308
-				esc_html__( 'You do not have permission to delete Import transactions.', 'give' ),
309
-				esc_html__( 'Error', 'give' ),
308
+				esc_html__('You do not have permission to delete Import transactions.', 'give'),
309
+				esc_html__('Error', 'give'),
310 310
 				array(
311 311
 					'response' => 403,
312 312
 				)
@@ -315,18 +315,18 @@  discard block
 block discarded – undo
315 315
 
316 316
 		$had_data = $this->get_data();
317 317
 
318
-		if ( $had_data ) {
318
+		if ($had_data) {
319 319
 			$this->done = false;
320 320
 
321 321
 			return true;
322 322
 		} else {
323
-			update_option( 'give_earnings_total', give_get_total_earnings( true ), false );
324
-			Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) );
323
+			update_option('give_earnings_total', give_get_total_earnings(true), false);
324
+			Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats'));
325 325
 
326
-			$this->delete_option( $this->donation_key );
326
+			$this->delete_option($this->donation_key);
327 327
 
328 328
 			$this->done    = true;
329
-			$this->message = __( 'Imported donor and transactions successfully deleted.', 'give' );
329
+			$this->message = __('Imported donor and transactions successfully deleted.', 'give');
330 330
 
331 331
 			return false;
332 332
 		}
@@ -344,12 +344,12 @@  discard block
 block discarded – undo
344 344
 	public function get_data() {
345 345
 
346 346
 		// Get the donation id's.
347
-		$donation_ids = $this->get_option( $this->donation_key );
347
+		$donation_ids = $this->get_option($this->donation_key);
348 348
 
349 349
 		/**
350 350
 		 * Return false id not Import donation is found.
351 351
 		 */
352
-		if ( empty( $donation_ids ) ) {
352
+		if (empty($donation_ids)) {
353 353
 			$this->is_empty   = true;
354 354
 			$this->total_step = 1;
355 355
 
@@ -360,110 +360,110 @@  discard block
 block discarded – undo
360 360
 		$step = (int) $this->get_step();
361 361
 
362 362
 		// Get the donor ids.
363
-		$donor_ids = $this->get_option( $this->donor_key );
363
+		$donor_ids = $this->get_option($this->donor_key);
364 364
 
365 365
 		// Delete all the imported donations.
366
-		if ( 2 === $step ) {
366
+		if (2 === $step) {
367 367
 			$pass_to_donor = false;
368 368
 			$page          = (int) $this->get_step_page();
369
-			$page ++;
370
-			$count = count( $donation_ids );
369
+			$page++;
370
+			$count = count($donation_ids);
371 371
 
372
-			$this->total_step     = ( ( count( $donation_ids ) / $this->per_step ) * 2 ) + count( $donor_ids );
372
+			$this->total_step     = ((count($donation_ids) / $this->per_step) * 2) + count($donor_ids);
373 373
 			$this->step_completed = $page;
374 374
 
375
-			if ( $count > $this->per_step ) {
375
+			if ($count > $this->per_step) {
376 376
 
377
-				$this->update_option( $this->step_on_key, $page );
378
-				$donation_ids = $this->get_delete_ids( $donation_ids, $page );
379
-				$current_page = (int) ceil( $count / $this->per_step );
377
+				$this->update_option($this->step_on_key, $page);
378
+				$donation_ids = $this->get_delete_ids($donation_ids, $page);
379
+				$current_page = (int) ceil($count / $this->per_step);
380 380
 
381
-				if ( $page === $current_page ) {
381
+				if ($page === $current_page) {
382 382
 					$pass_to_donor = true;
383 383
 				}
384 384
 			} else {
385 385
 				$pass_to_donor = true;
386 386
 			}
387 387
 
388
-			if ( true === $pass_to_donor ) {
389
-				$this->update_option( $this->step_key, 'donor' );
390
-				$this->update_option( $this->step_on_key, '0' );
388
+			if (true === $pass_to_donor) {
389
+				$this->update_option($this->step_key, 'donor');
390
+				$this->update_option($this->step_on_key, '0');
391 391
 			}
392 392
 
393 393
 			// Get the old form list.
394
-			$form_ids = (array) $this->get_option( $this->form_key );
394
+			$form_ids = (array) $this->get_option($this->form_key);
395 395
 
396
-			foreach ( $donation_ids as $item ) {
397
-				$form_ids[] = give_get_meta( $item, '_give_payment_form_id', true );
396
+			foreach ($donation_ids as $item) {
397
+				$form_ids[] = give_get_meta($item, '_give_payment_form_id', true);
398 398
 
399 399
 				// Delete the main payment.
400
-				give_delete_donation( absint( $item ) );
400
+				give_delete_donation(absint($item));
401 401
 			}
402 402
 
403 403
 			// Update the new form list.
404
-			$this->update_option( $this->form_key, $form_ids );
404
+			$this->update_option($this->form_key, $form_ids);
405 405
 		} // End if().
406 406
 
407 407
 		// Delete all the donors.
408
-		if ( 3 === $step ) {
408
+		if (3 === $step) {
409 409
 
410 410
 			// Get the old form list.
411
-			$form_ids = (array) $this->get_option( $this->form_key );
412
-			if ( ! empty( $form_ids ) ) {
413
-				$form_ids = array_unique( $form_ids );
414
-				foreach ( $form_ids as $form_id ) {
415
-					give_recount_form_income_donation( (int) $form_id );
411
+			$form_ids = (array) $this->get_option($this->form_key);
412
+			if ( ! empty($form_ids)) {
413
+				$form_ids = array_unique($form_ids);
414
+				foreach ($form_ids as $form_id) {
415
+					give_recount_form_income_donation((int) $form_id);
416 416
 				}
417 417
 			}
418 418
 			// update the new form list.
419
-			$this->update_option( $this->form_key, array() );
419
+			$this->update_option($this->form_key, array());
420 420
 
421 421
 			$page  = (int) $this->get_step_page();
422
-			$count = count( $donor_ids );
422
+			$count = count($donor_ids);
423 423
 
424
-			$this->total_step     = ( ( count( $donation_ids ) / $this->per_step ) * 2 ) + count( $donor_ids );
425
-			$this->step_completed = $page + ( count( $donation_ids ) / $this->per_step );
424
+			$this->total_step     = ((count($donation_ids) / $this->per_step) * 2) + count($donor_ids);
425
+			$this->step_completed = $page + (count($donation_ids) / $this->per_step);
426 426
 
427
-			if ( ! empty( $donor_ids[ $page ] ) ) {
428
-				$args = apply_filters( 'give_tools_reset_stats_total_args', array(
427
+			if ( ! empty($donor_ids[$page])) {
428
+				$args = apply_filters('give_tools_reset_stats_total_args', array(
429 429
 					'post_status'    => 'any',
430 430
 					'posts_per_page' => 1,
431
-					'author'         => $donor_ids[ $page ],
432
-				) );
431
+					'author'         => $donor_ids[$page],
432
+				));
433 433
 
434 434
 				$donations = array();
435
-				$payments  = new Give_Payments_Query( $args );
435
+				$payments  = new Give_Payments_Query($args);
436 436
 				$payments  = $payments->get_payments();
437
-				if ( empty( $payments ) ) {
438
-					Give()->donors->delete_by_user_id( $donor_ids[ $page ] );
437
+				if (empty($payments)) {
438
+					Give()->donors->delete_by_user_id($donor_ids[$page]);
439 439
 
440 440
 					/**
441 441
 					 * If Checked then delete WP user.
442 442
 					 *
443 443
 					 * @since 1.8.14
444 444
 					 */
445
-					$delete_import_donors = isset( $_REQUEST['delete-import-donors'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['delete-import-donors'] ) ) : '';
445
+					$delete_import_donors = isset($_REQUEST['delete-import-donors']) ? sanitize_text_field(wp_unslash($_REQUEST['delete-import-donors'])) : '';
446 446
 
447
-					if ( 'on' === (string) $delete_import_donors ) {
448
-						wp_delete_user( $donor_ids[ $page ] );
447
+					if ('on' === (string) $delete_import_donors) {
448
+						wp_delete_user($donor_ids[$page]);
449 449
 					}
450 450
 				} else {
451
-					foreach ( $payments as $payment ) {
451
+					foreach ($payments as $payment) {
452 452
 						$donations[] = $payment->ID;
453 453
 					}
454 454
 
455
-					$donor          = new Give_Donor( $donor_ids[ $page ], true );
455
+					$donor          = new Give_Donor($donor_ids[$page], true);
456 456
 					$data_to_update = array(
457
-						'purchase_count' => count( $donations ),
458
-						'payment_ids'    => implode( ',', $donations ),
457
+						'purchase_count' => count($donations),
458
+						'payment_ids'    => implode(',', $donations),
459 459
 					);
460
-					$donor->update( $data_to_update );
460
+					$donor->update($data_to_update);
461 461
 				}
462 462
 			} // End if().
463 463
 
464
-			$page ++;
465
-			$this->update_option( $this->step_on_key, $page );
466
-			if ( $count === $page ) {
464
+			$page++;
465
+			$this->update_option($this->step_on_key, $page);
466
+			if ($count === $page) {
467 467
 				$this->is_empty = false;
468 468
 
469 469
 				return false;
@@ -483,24 +483,24 @@  discard block
 block discarded – undo
483 483
 	 *
484 484
 	 * @return mixed
485 485
 	 */
486
-	public function get_delete_ids( $donation_ids, $page ) {
487
-		$index            = $page --;
488
-		$count            = count( $donation_ids );
486
+	public function get_delete_ids($donation_ids, $page) {
487
+		$index            = $page--;
488
+		$count            = count($donation_ids);
489 489
 		$temp             = 0;
490 490
 		$current_page     = 0;
491 491
 		$post_delete      = $this->per_step;
492 492
 		$page_donation_id = array();
493 493
 
494
-		foreach ( $donation_ids as $item ) {
495
-			$temp ++;
496
-			$page_donation_id[ $current_page ][] = $item;
497
-			if ( $temp === $post_delete ) {
498
-				$current_page ++;
494
+		foreach ($donation_ids as $item) {
495
+			$temp++;
496
+			$page_donation_id[$current_page][] = $item;
497
+			if ($temp === $post_delete) {
498
+				$current_page++;
499 499
 				$temp = 0;
500 500
 			}
501 501
 		}
502 502
 
503
-		return $page_donation_id[ $page ];
503
+		return $page_donation_id[$page];
504 504
 	}
505 505
 
506 506
 	/**
@@ -513,8 +513,8 @@  discard block
 block discarded – undo
513 513
 	 *
514 514
 	 * @return mixed Returns the data from the database
515 515
 	 */
516
-	public function get_option( $key, $default_value = false ) {
517
-		return get_option( $key, $default_value );
516
+	public function get_option($key, $default_value = false) {
517
+		return get_option($key, $default_value);
518 518
 	}
519 519
 
520 520
 	/**
@@ -527,8 +527,8 @@  discard block
 block discarded – undo
527 527
 	 *
528 528
 	 * @return void
529 529
 	 */
530
-	public function update_option( $key, $value ) {
531
-		update_option( $key, $value, false );
530
+	public function update_option($key, $value) {
531
+		update_option($key, $value, false);
532 532
 	}
533 533
 
534 534
 	/**
@@ -540,8 +540,8 @@  discard block
 block discarded – undo
540 540
 	 *
541 541
 	 * @return void
542 542
 	 */
543
-	public function delete_option( $key ) {
544
-		delete_option( $key );
543
+	public function delete_option($key) {
544
+		delete_option($key);
545 545
 	}
546 546
 
547 547
 	/**
@@ -552,12 +552,12 @@  discard block
 block discarded – undo
552 552
 	 * @return int|string
553 553
 	 */
554 554
 	private function get_step() {
555
-		$step_key = (string) $this->get_option( $this->step_key, false );
556
-		if ( 'count' === $step_key ) {
555
+		$step_key = (string) $this->get_option($this->step_key, false);
556
+		if ('count' === $step_key) {
557 557
 			return 1;
558
-		} elseif ( 'donation' === $step_key ) {
558
+		} elseif ('donation' === $step_key) {
559 559
 			return 2;
560
-		} elseif ( 'donor' === $step_key ) {
560
+		} elseif ('donor' === $step_key) {
561 561
 			return 3;
562 562
 		} else {
563 563
 			return $step_key;
@@ -568,6 +568,6 @@  discard block
 block discarded – undo
568 568
 	 * Get the current $page value in the ajax.
569 569
 	 */
570 570
 	private function get_step_page() {
571
-		return $this->get_option( $this->step_on_key, false );
571
+		return $this->get_option($this->step_on_key, false);
572 572
 	}
573 573
 }
Please login to merge, or discard this patch.
includes/class-give-comment.php 2 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 	 * @param int        $comment_id
446 446
 	 * @param WP_Comment $comment
447 447
 	 *
448
-	 * @return mixed
448
+	 * @return string
449 449
 	 */
450 450
 	public function __get_comment_author( $author, $comment_id, $comment ) {
451 451
 		if ( in_array( $comment->comment_type, $this->comment_types ) ) {
@@ -468,6 +468,7 @@  discard block
 block discarded – undo
468 468
 	 * @access public
469 469
 	 *
470 470
 	 * @param array @comment_types
471
+	 * @param string[] $comment_types
471 472
 	 *
472 473
 	 * @return array
473 474
 	 */
Please login to merge, or discard this patch.
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	 * @return Give_Comment
47 47
 	 */
48 48
 	public static function get_instance() {
49
-		if ( null === static::$instance ) {
49
+		if (null === static::$instance) {
50 50
 			self::$instance = new static();
51 51
 			self::$instance->init();
52 52
 		}
@@ -68,14 +68,14 @@  discard block
 block discarded – undo
68 68
 		 */
69 69
 		$this->comment_types = apply_filters(
70 70
 			'give_comment_type',
71
-			self::get_comment_types( array( 'payment', 'donor' ) )
71
+			self::get_comment_types(array('payment', 'donor'))
72 72
 		);
73 73
 
74
-		add_action( 'pre_get_comments', array( $this, 'hide_comments' ), 10 );
75
-		add_filter( 'comments_clauses', array( $this, 'hide_comments_pre_wp_41' ), 10, 1 );
76
-		add_filter( 'comment_feed_where', array( $this, 'hide_comments_from_feeds' ), 10, 1 );
77
-		add_filter( 'wp_count_comments', array( $this, 'remove_comments_from_comment_counts' ), 10, 2 );
78
-		add_filter( 'get_comment_author', array( $this, '__get_comment_author' ), 10, 3 );
74
+		add_action('pre_get_comments', array($this, 'hide_comments'), 10);
75
+		add_filter('comments_clauses', array($this, 'hide_comments_pre_wp_41'), 10, 1);
76
+		add_filter('comment_feed_where', array($this, 'hide_comments_from_feeds'), 10, 1);
77
+		add_filter('wp_count_comments', array($this, 'remove_comments_from_comment_counts'), 10, 2);
78
+		add_filter('get_comment_author', array($this, '__get_comment_author'), 10, 3);
79 79
 	}
80 80
 
81 81
 	/**
@@ -91,13 +91,13 @@  discard block
 block discarded – undo
91 91
 	 *
92 92
 	 * @return int|WP_Error
93 93
 	 */
94
-	public static function add( $id, $note, $comment_type, $comment_args = array() ) {
94
+	public static function add($id, $note, $comment_type, $comment_args = array()) {
95 95
 		// Bailout
96
-		if ( empty( $id ) || empty( $note ) || empty( $comment_type ) ) {
97
-			return new WP_Error( 'give_invalid_required_param', __( 'This comment has invalid ID or comment text or cooment type', 'give' ) );
96
+		if (empty($id) || empty($note) || empty($comment_type)) {
97
+			return new WP_Error('give_invalid_required_param', __('This comment has invalid ID or comment text or cooment type', 'give'));
98 98
 		}
99 99
 
100
-		$is_existing_comment = array_key_exists( 'comment_ID', $comment_args ) && ! empty( $comment_args['comment_ID'] );
100
+		$is_existing_comment = array_key_exists('comment_ID', $comment_args) && ! empty($comment_args['comment_ID']);
101 101
 		$action_type         = $is_existing_comment ? 'update' : 'insert';
102 102
 
103 103
 		/**
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 		 *
109 109
 		 * @since 1.0
110 110
 		 */
111
-		do_action( "give_pre_{$action_type}_{$comment_type}_note", $id, $note );
111
+		do_action("give_pre_{$action_type}_{$comment_type}_note", $id, $note);
112 112
 
113 113
 		$comment_args = wp_parse_args(
114 114
 			$comment_args,
@@ -116,8 +116,8 @@  discard block
 block discarded – undo
116 116
 				'comment_post_ID'      => $id,
117 117
 				'comment_content'      => $note,
118 118
 				'user_id'              => is_admin() ? get_current_user_id() : 0,
119
-				'comment_date'         => current_time( 'mysql' ),
120
-				'comment_date_gmt'     => current_time( 'mysql', 1 ),
119
+				'comment_date'         => current_time('mysql'),
120
+				'comment_date_gmt'     => current_time('mysql', 1),
121 121
 				'comment_approved'     => 1,
122 122
 				'comment_parent'       => 0,
123 123
 				'comment_author'       => '',
@@ -131,24 +131,24 @@  discard block
 block discarded – undo
131 131
 
132 132
 
133 133
 		// Check comment max length.
134
-		$error = wp_check_comment_data_max_lengths( $comment_args );
135
-		if( is_wp_error( $error ) ) {
134
+		$error = wp_check_comment_data_max_lengths($comment_args);
135
+		if (is_wp_error($error)) {
136 136
 			return $error;
137 137
 		}
138 138
 
139 139
 		// Remove moderation emails when comment posted.
140
-		remove_action( 'comment_post', 'wp_new_comment_notify_moderator' );
141
-		remove_action( 'comment_post', 'wp_new_comment_notify_postauthor' );
140
+		remove_action('comment_post', 'wp_new_comment_notify_moderator');
141
+		remove_action('comment_post', 'wp_new_comment_notify_postauthor');
142 142
 
143 143
 		$comment_id = $is_existing_comment
144
-			? wp_update_comment( $comment_args )
145
-			: wp_new_comment( $comment_args, true );
144
+			? wp_update_comment($comment_args)
145
+			: wp_new_comment($comment_args, true);
146 146
 
147 147
 		// Add moderation emails when comment posted.
148
-		add_action( 'comment_post', 'wp_new_comment_notify_moderator' );
149
-		add_action( 'comment_post', 'wp_new_comment_notify_postauthor' );
148
+		add_action('comment_post', 'wp_new_comment_notify_moderator');
149
+		add_action('comment_post', 'wp_new_comment_notify_postauthor');
150 150
 
151
-		update_comment_meta( $comment_id, "_give_{$comment_type}_id", $id );
151
+		update_comment_meta($comment_id, "_give_{$comment_type}_id", $id);
152 152
 
153 153
 		/**
154 154
 		 * Fires after payment|donor comment inserted/updated.
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 		 *
160 160
 		 * @since 1.0
161 161
 		 */
162
-		do_action( "give_{$action_type}_{$comment_type}_note", $comment_id, $id, $note );
162
+		do_action("give_{$action_type}_{$comment_type}_note", $comment_id, $id, $note);
163 163
 
164 164
 		return $comment_id;
165 165
 	}
@@ -179,11 +179,11 @@  discard block
 block discarded – undo
179 179
 	 *
180 180
 	 * @return bool True on success, false otherwise.
181 181
 	 */
182
-	public static function delete( $comment_id, $id, $comment_type ) {
182
+	public static function delete($comment_id, $id, $comment_type) {
183 183
 		$ret = false;
184 184
 
185 185
 		// Bailout
186
-		if ( empty( $id ) || empty( $comment_id ) || empty( $comment_type ) ) {
186
+		if (empty($id) || empty($comment_id) || empty($comment_type)) {
187 187
 			return $ret;
188 188
 		}
189 189
 
@@ -195,9 +195,9 @@  discard block
 block discarded – undo
195 195
 		 *
196 196
 		 * @since 1.0
197 197
 		 */
198
-		do_action( "give_pre_delete_{$comment_type}_note", $comment_id, $id );
198
+		do_action("give_pre_delete_{$comment_type}_note", $comment_id, $id);
199 199
 
200
-		$ret = wp_delete_comment( $comment_id, true );
200
+		$ret = wp_delete_comment($comment_id, true);
201 201
 
202 202
 		/**
203 203
 		 * Fires after donation note deleted.
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 		 *
209 209
 		 * @since 1.0
210 210
 		 */
211
-		do_action( "give_post_delete_{$comment_type}_note", $comment_id, $id, $ret );
211
+		do_action("give_post_delete_{$comment_type}_note", $comment_id, $id, $ret);
212 212
 
213 213
 		return $ret;
214 214
 	}
@@ -227,25 +227,25 @@  discard block
 block discarded – undo
227 227
 	 *
228 228
 	 * @return array
229 229
 	 */
230
-	public static function get( $id, $comment_type, $comment_args = array(), $search = '' ) {
230
+	public static function get($id, $comment_type, $comment_args = array(), $search = '') {
231 231
 		$comments = array();
232 232
 
233 233
 		// Set default meta_query value.
234
-		if ( ! isset( $comment_args['meta_query'] ) ) {
234
+		if ( ! isset($comment_args['meta_query'])) {
235 235
 			$comment_args['meta_query'] = array();
236 236
 		}
237 237
 
238 238
 		// Bailout
239
-		if ( empty( $id ) || empty( $comment_type ) ) {
239
+		if (empty($id) || empty($comment_type)) {
240 240
 			return $comments;
241 241
 		}
242 242
 
243
-		remove_action( 'pre_get_comments', array( self::$instance, 'hide_comments' ), 10 );
244
-		remove_filter( 'comments_clauses', array( self::$instance, 'hide_comments_pre_wp_41' ), 10 );
243
+		remove_action('pre_get_comments', array(self::$instance, 'hide_comments'), 10);
244
+		remove_filter('comments_clauses', array(self::$instance, 'hide_comments_pre_wp_41'), 10);
245 245
 
246
-		switch ( $comment_type ) {
246
+		switch ($comment_type) {
247 247
 			case 'payment':
248
-				$comment_args['meta_query'] = ! empty( $comment_args['meta_query'] )
248
+				$comment_args['meta_query'] = ! empty($comment_args['meta_query'])
249 249
 					? $comment_args['meta_query']
250 250
 					: array(
251 251
 						array(
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 						)
255 255
 					);
256 256
 
257
-				$comments = get_comments( wp_parse_args(
257
+				$comments = get_comments(wp_parse_args(
258 258
 					$comment_args,
259 259
 					array(
260 260
 						'post_id' => $id,
@@ -262,11 +262,11 @@  discard block
 block discarded – undo
262 262
 						'search'  => $search,
263 263
 						'type'    => 'give_payment_note'
264 264
 					)
265
-				) );
265
+				));
266 266
 				break;
267 267
 
268 268
 			case 'donor':
269
-				$comment_args['meta_query'] = ! empty( $comment_args['meta_query'] )
269
+				$comment_args['meta_query'] = ! empty($comment_args['meta_query'])
270 270
 					? $comment_args['meta_query']
271 271
 					: array(
272 272
 						array(
@@ -275,19 +275,19 @@  discard block
 block discarded – undo
275 275
 						)
276 276
 					);
277 277
 
278
-				$comments = get_comments( wp_parse_args(
278
+				$comments = get_comments(wp_parse_args(
279 279
 					$comment_args,
280 280
 					array(
281 281
 						'order'  => 'ASC',
282 282
 						'search' => $search,
283 283
 						'type'   => 'give_donor_note'
284 284
 					)
285
-				) );
285
+				));
286 286
 				break;
287 287
 		}
288 288
 
289
-		add_action( 'pre_get_comments', array( self::$instance, 'hide_comments' ), 10, 1 );
290
-		add_filter( 'comments_clauses', array( self::$instance, 'hide_comments_pre_wp_41' ), 10, 1 );
289
+		add_action('pre_get_comments', array(self::$instance, 'hide_comments'), 10, 1);
290
+		add_filter('comments_clauses', array(self::$instance, 'hide_comments_pre_wp_41'), 10, 1);
291 291
 
292 292
 		return $comments;
293 293
 	}
@@ -303,14 +303,14 @@  discard block
 block discarded – undo
303 303
 	 *
304 304
 	 * @return void
305 305
 	 */
306
-	public function hide_comments( $query ) {
307
-		if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '>=' ) ) {
308
-			$types = isset( $query->query_vars['type__not_in'] ) ? $query->query_vars['type__not_in'] : array();
309
-			if ( ! is_array( $types ) ) {
310
-				$types = array( $types );
306
+	public function hide_comments($query) {
307
+		if (version_compare(floatval(get_bloginfo('version')), '4.1', '>=')) {
308
+			$types = isset($query->query_vars['type__not_in']) ? $query->query_vars['type__not_in'] : array();
309
+			if ( ! is_array($types)) {
310
+				$types = array($types);
311 311
 			}
312 312
 
313
-			$types = array_filter( array_merge( $types, $this->comment_types ) );
313
+			$types = array_filter(array_merge($types, $this->comment_types));
314 314
 
315 315
 			$query->query_vars['type__not_in'] = $types;
316 316
 		}
@@ -326,9 +326,9 @@  discard block
 block discarded – undo
326 326
 	 *
327 327
 	 * @return array $clauses Updated comment clauses.
328 328
 	 */
329
-	public function hide_comments_pre_wp_41( $clauses ) {
330
-		if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '<' ) ) {
331
-			foreach ( $this->comment_types as $comment_type ) {
329
+	public function hide_comments_pre_wp_41($clauses) {
330
+		if (version_compare(floatval(get_bloginfo('version')), '4.1', '<')) {
331
+			foreach ($this->comment_types as $comment_type) {
332 332
 				$clauses['where'] .= " AND comment_type != \"{$comment_type}\"";
333 333
 			}
334 334
 		}
@@ -346,11 +346,11 @@  discard block
 block discarded – undo
346 346
 	 *
347 347
 	 * @return string $where
348 348
 	 */
349
-	public function hide_comments_from_feeds( $where ) {
349
+	public function hide_comments_from_feeds($where) {
350 350
 		global $wpdb;
351 351
 
352
-		foreach ( $this->comment_types as $comment_type ) {
353
-			$where .= $wpdb->prepare( ' AND comment_type!=%s', $comment_type );
352
+		foreach ($this->comment_types as $comment_type) {
353
+			$where .= $wpdb->prepare(' AND comment_type!=%s', $comment_type);
354 354
 		}
355 355
 
356 356
 		return $where;
@@ -367,30 +367,30 @@  discard block
 block discarded – undo
367 367
 	 *
368 368
 	 * @return array|object Array of comment counts.
369 369
 	 */
370
-	public function remove_comments_from_comment_counts( $stats, $post_id ) {
370
+	public function remove_comments_from_comment_counts($stats, $post_id) {
371 371
 		global $wpdb;
372 372
 
373 373
 		$post_id = (int) $post_id;
374 374
 
375
-		if ( apply_filters( 'give_count_payment_notes_in_comments', false ) ) {
375
+		if (apply_filters('give_count_payment_notes_in_comments', false)) {
376 376
 			return $stats;
377 377
 		}
378 378
 
379
-		$stats = Give_Cache::get_group( "comments-{$post_id}", 'counts' );
379
+		$stats = Give_Cache::get_group("comments-{$post_id}", 'counts');
380 380
 
381 381
 		// Return result from cache.
382
-		if ( ! is_null( $stats ) ) {
382
+		if ( ! is_null($stats)) {
383 383
 			return $stats;
384 384
 		}
385 385
 
386 386
 		$where = 'WHERE';
387 387
 
388
-		foreach ( $this->comment_types as $index => $comment_type ) {
389
-			$where .= ( $index ? ' AND ' : ' ' ) . "comment_type != \"{$comment_type}\"";
388
+		foreach ($this->comment_types as $index => $comment_type) {
389
+			$where .= ($index ? ' AND ' : ' ')."comment_type != \"{$comment_type}\"";
390 390
 		}
391 391
 
392
-		if ( $post_id > 0 ) {
393
-			$where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id );
392
+		if ($post_id > 0) {
393
+			$where .= $wpdb->prepare(' AND comment_post_ID = %d', $post_id);
394 394
 		}
395 395
 
396 396
 		$count = $wpdb->get_results(
@@ -411,26 +411,26 @@  discard block
 block discarded – undo
411 411
 			'post-trashed' => 'post-trashed',
412 412
 		);
413 413
 
414
-		foreach ( (array) $count as $row ) {
414
+		foreach ((array) $count as $row) {
415 415
 			// Don't count post-trashed toward totals.
416
-			if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) {
416
+			if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) {
417 417
 				$total += $row['num_comments'];
418 418
 			}
419
-			if ( isset( $approved[ $row['comment_approved'] ] ) ) {
420
-				$stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments'];
419
+			if (isset($approved[$row['comment_approved']])) {
420
+				$stats[$approved[$row['comment_approved']]] = $row['num_comments'];
421 421
 			}
422 422
 		}
423 423
 
424 424
 		$stats['total_comments'] = $stats['all'] = $total;
425
-		foreach ( $approved as $key ) {
426
-			if ( empty( $stats[ $key ] ) ) {
427
-				$stats[ $key ] = 0;
425
+		foreach ($approved as $key) {
426
+			if (empty($stats[$key])) {
427
+				$stats[$key] = 0;
428 428
 			}
429 429
 		}
430 430
 
431 431
 		$stats = (object) $stats;
432 432
 
433
-		Give_Cache::set_group( "comments-{$post_id}", $stats, 'counts' );
433
+		Give_Cache::set_group("comments-{$post_id}", $stats, 'counts');
434 434
 
435 435
 		return $stats;
436 436
 	}
@@ -447,12 +447,12 @@  discard block
 block discarded – undo
447 447
 	 *
448 448
 	 * @return mixed
449 449
 	 */
450
-	public function __get_comment_author( $author, $comment_id, $comment ) {
451
-		if ( in_array( $comment->comment_type, $this->comment_types ) ) {
452
-			switch ( $comment->comment_type ) {
450
+	public function __get_comment_author($author, $comment_id, $comment) {
451
+		if (in_array($comment->comment_type, $this->comment_types)) {
452
+			switch ($comment->comment_type) {
453 453
 				case 'give_payment_note':
454
-					if ( get_comment_meta( $comment_id, '_give_donor_id', true ) ) {
455
-						$author = give_get_donor_name_by( $comment->comment_post_ID );
454
+					if (get_comment_meta($comment_id, '_give_donor_id', true)) {
455
+						$author = give_get_donor_name_by($comment->comment_post_ID);
456 456
 					}
457 457
 			}
458 458
 		}
@@ -471,9 +471,9 @@  discard block
 block discarded – undo
471 471
 	 *
472 472
 	 * @return array
473 473
 	 */
474
-	public static function get_comment_types( $comment_types ) {
474
+	public static function get_comment_types($comment_types) {
475 475
 		$_comment_types = array();
476
-		foreach ( $comment_types as $comment_type ) {
476
+		foreach ($comment_types as $comment_type) {
477 477
 			$_comment_types[] = "give_{$comment_type}_note";
478 478
 		}
479 479
 
Please login to merge, or discard this patch.
includes/class-give-db-meta.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 	/**
280 280
 	 * Rename query clauses for new meta table
281 281
 	 *
282
-	 * @param $clause
282
+	 * @param string $clause
283 283
 	 * @param $filter
284 284
 	 *
285 285
 	 * @return mixed
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
 	 * @since  2.0.4
516 516
 	 * @access public
517 517
 	 *
518
-	 * @return string
518
+	 * @return boolean
519 519
 	 */
520 520
 	public function get_meta_type() {
521 521
 		return $this->meta_type;
Please login to merge, or discard this patch.
Spacing   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -77,40 +77,40 @@  discard block
 block discarded – undo
77 77
 		parent::__construct();
78 78
 
79 79
 		// Bailout.
80
-		if ( empty( $this->supports ) || ! $this->is_custom_meta_table_active() ) {
80
+		if (empty($this->supports) || ! $this->is_custom_meta_table_active()) {
81 81
 			return;
82 82
 		}
83 83
 
84
-		if ( in_array( 'add_post_metadata', $this->supports ) ) {
85
-			add_filter( 'add_post_metadata', array( $this, '__add_meta' ), 0, 5 );
84
+		if (in_array('add_post_metadata', $this->supports)) {
85
+			add_filter('add_post_metadata', array($this, '__add_meta'), 0, 5);
86 86
 		}
87 87
 
88
-		if ( in_array( 'get_post_metadata', $this->supports ) ) {
89
-			add_filter( 'get_post_metadata', array( $this, '__get_meta' ), 10, 4 );
88
+		if (in_array('get_post_metadata', $this->supports)) {
89
+			add_filter('get_post_metadata', array($this, '__get_meta'), 10, 4);
90 90
 		}
91 91
 
92
-		if ( in_array( 'update_post_metadata', $this->supports ) ) {
93
-			add_filter( 'update_post_metadata', array( $this, '__update_meta' ), 0, 5 );
92
+		if (in_array('update_post_metadata', $this->supports)) {
93
+			add_filter('update_post_metadata', array($this, '__update_meta'), 0, 5);
94 94
 		}
95 95
 
96
-		if ( in_array( 'delete_post_metadata', $this->supports ) ) {
97
-			add_filter( 'delete_post_metadata', array( $this, '__delete_meta' ), 0, 5 );
96
+		if (in_array('delete_post_metadata', $this->supports)) {
97
+			add_filter('delete_post_metadata', array($this, '__delete_meta'), 0, 5);
98 98
 		}
99 99
 
100
-		if ( in_array( 'posts_where', $this->supports ) ) {
101
-			add_filter( 'posts_where', array( $this, '__rename_meta_table_name_in_query' ), 99999, 2 );
100
+		if (in_array('posts_where', $this->supports)) {
101
+			add_filter('posts_where', array($this, '__rename_meta_table_name_in_query'), 99999, 2);
102 102
 		}
103 103
 
104
-		if ( in_array( 'posts_join', $this->supports ) ) {
105
-			add_filter( 'posts_join', array( $this, '__rename_meta_table_name_in_query' ), 99999, 2 );
104
+		if (in_array('posts_join', $this->supports)) {
105
+			add_filter('posts_join', array($this, '__rename_meta_table_name_in_query'), 99999, 2);
106 106
 		}
107 107
 
108
-		if ( in_array( 'posts_groupby', $this->supports ) ) {
109
-			add_filter( 'posts_groupby', array( $this, '__rename_meta_table_name_in_query' ), 99999, 2 );
108
+		if (in_array('posts_groupby', $this->supports)) {
109
+			add_filter('posts_groupby', array($this, '__rename_meta_table_name_in_query'), 99999, 2);
110 110
 		}
111 111
 
112
-		if ( in_array( 'posts_orderby', $this->supports ) ) {
113
-			add_filter( 'posts_orderby', array( $this, '__rename_meta_table_name_in_query' ), 99999, 2 );
112
+		if (in_array('posts_orderby', $this->supports)) {
113
+			add_filter('posts_orderby', array($this, '__rename_meta_table_name_in_query'), 99999, 2);
114 114
 		}
115 115
 	}
116 116
 
@@ -128,16 +128,16 @@  discard block
 block discarded – undo
128 128
 	 * @return  mixed                 Will be an array if $single is false. Will be value of meta data field if $single
129 129
 	 *                                is true.
130 130
 	 */
131
-	public function get_meta( $id = 0, $meta_key = '', $single = false ) {
132
-		$id = $this->sanitize_id( $id );
131
+	public function get_meta($id = 0, $meta_key = '', $single = false) {
132
+		$id = $this->sanitize_id($id);
133 133
 
134 134
 		// Bailout.
135
-		if ( ! $this->is_valid_post_type( $id ) ) {
135
+		if ( ! $this->is_valid_post_type($id)) {
136 136
 			return $this->check;
137 137
 		}
138 138
 
139
-		if ( $this->raw_result ) {
140
-			if ( ! ( $value = get_metadata( $this->meta_type, $id, $meta_key, false ) ) ) {
139
+		if ($this->raw_result) {
140
+			if ( ! ($value = get_metadata($this->meta_type, $id, $meta_key, false))) {
141 141
 				$value = '';
142 142
 			}
143 143
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 			$this->raw_result = false;
146 146
 
147 147
 		} else {
148
-			$value = get_metadata( $this->meta_type, $id, $meta_key, $single );
148
+			$value = get_metadata($this->meta_type, $id, $meta_key, $single);
149 149
 		}
150 150
 
151 151
 		return $value;
@@ -167,18 +167,18 @@  discard block
 block discarded – undo
167 167
 	 *
168 168
 	 * @return  int|bool                  False for failure. True for success.
169 169
 	 */
170
-	public function add_meta( $id = 0, $meta_key = '', $meta_value, $unique = false ) {
171
-		$id = $this->sanitize_id( $id );
170
+	public function add_meta($id = 0, $meta_key = '', $meta_value, $unique = false) {
171
+		$id = $this->sanitize_id($id);
172 172
 
173 173
 		// Bailout.
174
-		if ( ! $this->is_valid_post_type( $id ) ) {
174
+		if ( ! $this->is_valid_post_type($id)) {
175 175
 			return $this->check;
176 176
 		}
177 177
 
178
-		$meta_id = add_metadata( $this->meta_type, $id, $meta_key, $meta_value, $unique );
178
+		$meta_id = add_metadata($this->meta_type, $id, $meta_key, $meta_value, $unique);
179 179
 
180
-		if ( $meta_id ) {
181
-			$this->delete_cache( $id );
180
+		if ($meta_id) {
181
+			$this->delete_cache($id);
182 182
 		}
183 183
 
184 184
 		return $meta_id;
@@ -204,18 +204,18 @@  discard block
 block discarded – undo
204 204
 	 *
205 205
 	 * @return  int|bool                  False on failure, true if success.
206 206
 	 */
207
-	public function update_meta( $id = 0, $meta_key = '', $meta_value, $prev_value = '' ) {
208
-		$id = $this->sanitize_id( $id );
207
+	public function update_meta($id = 0, $meta_key = '', $meta_value, $prev_value = '') {
208
+		$id = $this->sanitize_id($id);
209 209
 
210 210
 		// Bailout.
211
-		if ( ! $this->is_valid_post_type( $id ) ) {
211
+		if ( ! $this->is_valid_post_type($id)) {
212 212
 			return $this->check;
213 213
 		}
214 214
 
215
-		$meta_id = update_metadata( $this->meta_type, $id, $meta_key, $meta_value, $prev_value );
215
+		$meta_id = update_metadata($this->meta_type, $id, $meta_key, $meta_value, $prev_value);
216 216
 
217
-		if ( $meta_id ) {
218
-			$this->delete_cache( $id );
217
+		if ($meta_id) {
218
+			$this->delete_cache($id);
219 219
 		}
220 220
 
221 221
 		return $meta_id;
@@ -238,18 +238,18 @@  discard block
 block discarded – undo
238 238
 	 *
239 239
 	 * @return  bool                  False for failure. True for success.
240 240
 	 */
241
-	public function delete_meta( $id = 0, $meta_key = '', $meta_value = '', $delete_all = '' ) {
242
-		$id = $this->sanitize_id( $id );
241
+	public function delete_meta($id = 0, $meta_key = '', $meta_value = '', $delete_all = '') {
242
+		$id = $this->sanitize_id($id);
243 243
 
244 244
 		// Bailout.
245
-		if ( ! $this->is_valid_post_type( $id ) ) {
245
+		if ( ! $this->is_valid_post_type($id)) {
246 246
 			return $this->check;
247 247
 		}
248 248
 
249
-		$is_meta_deleted = delete_metadata( $this->meta_type, $id, $meta_key, $meta_value, $delete_all );
249
+		$is_meta_deleted = delete_metadata($this->meta_type, $id, $meta_key, $meta_value, $delete_all);
250 250
 
251
-		if ( $is_meta_deleted ) {
252
-			$this->delete_cache( $id );
251
+		if ($is_meta_deleted) {
252
+			$this->delete_cache($id);
253 253
 		}
254 254
 
255 255
 		return $is_meta_deleted;
@@ -266,10 +266,10 @@  discard block
 block discarded – undo
266 266
 	 *
267 267
 	 * @return string
268 268
 	 */
269
-	public function __rename_meta_table_name_in_query( $clause, $wp_query ) {
269
+	public function __rename_meta_table_name_in_query($clause, $wp_query) {
270 270
 		// Add new table to sql query.
271
-		if ( $this->is_post_type_query( $wp_query ) && ! empty( $wp_query->meta_query->queries ) ) {
272
-			$clause = $this->__rename_meta_table_name( $clause, current_filter() );
271
+		if ($this->is_post_type_query($wp_query) && ! empty($wp_query->meta_query->queries)) {
272
+			$clause = $this->__rename_meta_table_name($clause, current_filter());
273 273
 		}
274 274
 
275 275
 		return $clause;
@@ -284,42 +284,42 @@  discard block
 block discarded – undo
284 284
 	 *
285 285
 	 * @return mixed
286 286
 	 */
287
-	public function __rename_meta_table_name( $clause, $filter ) {
287
+	public function __rename_meta_table_name($clause, $filter) {
288 288
 		global $wpdb;
289 289
 
290
-		$clause = str_replace( "{$wpdb->postmeta}.post_id", "{$this->table_name}.{$this->meta_type}_id", $clause );
291
-		$clause = str_replace( $wpdb->postmeta, $this->table_name, $clause );
290
+		$clause = str_replace("{$wpdb->postmeta}.post_id", "{$this->table_name}.{$this->meta_type}_id", $clause);
291
+		$clause = str_replace($wpdb->postmeta, $this->table_name, $clause);
292 292
 
293
-		switch ( $filter ) {
293
+		switch ($filter) {
294 294
 			case 'posts_join':
295
-				$joins = array( 'INNER JOIN', 'LEFT JOIN' );
295
+				$joins = array('INNER JOIN', 'LEFT JOIN');
296 296
 
297
-				foreach ( $joins as $join ) {
298
-					if ( false !== strpos( $clause, $join ) ) {
299
-						$clause = explode( $join, $clause );
297
+				foreach ($joins as $join) {
298
+					if (false !== strpos($clause, $join)) {
299
+						$clause = explode($join, $clause);
300 300
 
301
-						foreach ( $clause as $key => $clause_part ) {
302
-							if ( empty( $clause_part ) ) {
301
+						foreach ($clause as $key => $clause_part) {
302
+							if (empty($clause_part)) {
303 303
 								continue;
304 304
 							}
305 305
 
306
-							preg_match( '/' . $wpdb->prefix . 'give_' . $this->meta_type . 'meta AS (.*) ON/', $clause_part, $alias_table_name );
306
+							preg_match('/'.$wpdb->prefix.'give_'.$this->meta_type.'meta AS (.*) ON/', $clause_part, $alias_table_name);
307 307
 
308
-							if ( isset( $alias_table_name[1] ) ) {
309
-								$clause[ $key ] = str_replace( "{$alias_table_name[1]}.post_id", "{$alias_table_name[1]}.{$this->meta_type}_id", $clause_part );
308
+							if (isset($alias_table_name[1])) {
309
+								$clause[$key] = str_replace("{$alias_table_name[1]}.post_id", "{$alias_table_name[1]}.{$this->meta_type}_id", $clause_part);
310 310
 							}
311 311
 						}
312 312
 
313
-						$clause = implode( "{$join} ", $clause );
313
+						$clause = implode("{$join} ", $clause);
314 314
 					}
315 315
 				}
316 316
 				break;
317 317
 
318 318
 			case 'posts_where':
319
-				$clause = str_replace( array( 'mt2.post_id', 'mt1.post_id' ), array(
319
+				$clause = str_replace(array('mt2.post_id', 'mt1.post_id'), array(
320 320
 					"mt2.{$this->meta_type}_id",
321 321
 					"mt1.{$this->meta_type}_id"
322
-				), $clause );
322
+				), $clause);
323 323
 				break;
324 324
 		}
325 325
 
@@ -337,19 +337,19 @@  discard block
 block discarded – undo
337 337
 	 *
338 338
 	 * @return bool
339 339
 	 */
340
-	protected function is_post_type_query( $wp_query ) {
340
+	protected function is_post_type_query($wp_query) {
341 341
 		$status = false;
342 342
 
343 343
 		// Check if it is payment query.
344
-		if ( ! empty( $wp_query->query['post_type'] ) ) {
344
+		if ( ! empty($wp_query->query['post_type'])) {
345 345
 			if (
346
-				is_string( $wp_query->query['post_type'] ) &&
346
+				is_string($wp_query->query['post_type']) &&
347 347
 				$this->post_type === $wp_query->query['post_type']
348 348
 			) {
349 349
 				$status = true;
350 350
 			} elseif (
351
-				is_array( $wp_query->query['post_type'] ) &&
352
-				in_array( $this->post_type, $wp_query->query['post_type'] )
351
+				is_array($wp_query->query['post_type']) &&
352
+				in_array($this->post_type, $wp_query->query['post_type'])
353 353
 			) {
354 354
 				$status = true;
355 355
 			}
@@ -368,8 +368,8 @@  discard block
 block discarded – undo
368 368
 	 *
369 369
 	 * @return bool
370 370
 	 */
371
-	protected function is_valid_post_type( $ID ) {
372
-		return $ID && ( $this->post_type === get_post_type( $ID ) );
371
+	protected function is_valid_post_type($ID) {
372
+		return $ID && ($this->post_type === get_post_type($ID));
373 373
 	}
374 374
 
375 375
 	/**
@@ -395,8 +395,8 @@  discard block
 block discarded – undo
395 395
 	 *
396 396
 	 * @return void
397 397
 	 */
398
-	private function delete_cache( $id, $meta_type = '' ) {
399
-		$meta_type = empty( $meta_type ) ? $this->meta_type : $meta_type;
398
+	private function delete_cache($id, $meta_type = '') {
399
+		$meta_type = empty($meta_type) ? $this->meta_type : $meta_type;
400 400
 
401 401
 		$group = array(
402 402
 			'payment'  => 'give-donations', // Backward compatibility
@@ -405,8 +405,8 @@  discard block
 block discarded – undo
405 405
 			'customer' => 'give-donors', // Backward compatibility for pre upgrade in 2.0
406 406
 		);
407 407
 
408
-		if ( array_key_exists( $meta_type, $group ) ) {
409
-			Give_Cache::delete_group( $id, $group[ $meta_type ] );
408
+		if (array_key_exists($meta_type, $group)) {
409
+			Give_Cache::delete_group($id, $group[$meta_type]);
410 410
 		}
411 411
 	}
412 412
 
@@ -421,8 +421,8 @@  discard block
 block discarded – undo
421 421
 	 *
422 422
 	 * @return mixed
423 423
 	 */
424
-	public function __call( $name, $arguments ) {
425
-		switch ( $name ) {
424
+	public function __call($name, $arguments) {
425
+		switch ($name) {
426 426
 			case '__add_meta':
427 427
 				$this->check = $arguments[0];
428 428
 				$id          = $arguments[1];
@@ -431,11 +431,11 @@  discard block
 block discarded – undo
431 431
 				$unique      = $arguments[4];
432 432
 
433 433
 				// Bailout.
434
-				if ( ! $this->is_valid_post_type( $id ) ) {
434
+				if ( ! $this->is_valid_post_type($id)) {
435 435
 					return $this->check;
436 436
 				}
437 437
 
438
-				return $this->add_meta( $id, $meta_key, $meta_value, $unique );
438
+				return $this->add_meta($id, $meta_key, $meta_value, $unique);
439 439
 
440 440
 			case '__get_meta':
441 441
 				$this->check = $arguments[0];
@@ -444,13 +444,13 @@  discard block
 block discarded – undo
444 444
 				$single      = $arguments[3];
445 445
 
446 446
 				// Bailout.
447
-				if ( ! $this->is_valid_post_type( $id ) ) {
447
+				if ( ! $this->is_valid_post_type($id)) {
448 448
 					return $this->check;
449 449
 				}
450 450
 
451 451
 				$this->raw_result = true;
452 452
 
453
-				return $this->get_meta( $id, $meta_key, $single );
453
+				return $this->get_meta($id, $meta_key, $single);
454 454
 
455 455
 			case '__update_meta':
456 456
 				$this->check = $arguments[0];
@@ -459,11 +459,11 @@  discard block
 block discarded – undo
459 459
 				$meta_value  = $arguments[3];
460 460
 
461 461
 				// Bailout.
462
-				if ( ! $this->is_valid_post_type( $id ) ) {
462
+				if ( ! $this->is_valid_post_type($id)) {
463 463
 					return $this->check;
464 464
 				}
465 465
 
466
-				return $this->update_meta( $id, $meta_key, $meta_value );
466
+				return $this->update_meta($id, $meta_key, $meta_value);
467 467
 
468 468
 			case '__delete_meta':
469 469
 				$this->check = $arguments[0];
@@ -473,11 +473,11 @@  discard block
 block discarded – undo
473 473
 				$delete_all  = $arguments[3];
474 474
 
475 475
 				// Bailout.
476
-				if ( ! $this->is_valid_post_type( $id ) ) {
476
+				if ( ! $this->is_valid_post_type($id)) {
477 477
 					return $this->check;
478 478
 				}
479 479
 
480
-				return $this->delete_meta( $id, $meta_key, $meta_value, $delete_all );
480
+				return $this->delete_meta($id, $meta_key, $meta_value, $delete_all);
481 481
 		}
482 482
 	}
483 483
 
@@ -502,10 +502,10 @@  discard block
 block discarded – undo
502 502
 			KEY meta_key (meta_key({$this->min_index_length}))
503 503
 			) {$charset_collate};";
504 504
 
505
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
506
-		dbDelta( $sql );
505
+		require_once(ABSPATH.'wp-admin/includes/upgrade.php');
506
+		dbDelta($sql);
507 507
 
508
-		update_option( $this->table_name . '_db_version', $this->version, false );
508
+		update_option($this->table_name.'_db_version', $this->version, false);
509 509
 	}
510 510
 
511 511
 
@@ -531,12 +531,12 @@  discard block
 block discarded – undo
531 531
 	 *
532 532
 	 * @return  bool  False for failure. True for success.
533 533
 	 */
534
-	public function delete_all_meta( $id = 0 ) {
534
+	public function delete_all_meta($id = 0) {
535 535
 		global $wpdb;
536
-		$status = $wpdb->delete( $this->table_name, array( "{$this->meta_type}_id" => $id ), array( '%d' ) );
536
+		$status = $wpdb->delete($this->table_name, array("{$this->meta_type}_id" => $id), array('%d'));
537 537
 
538
-		if ( $status ) {
539
-			$this->delete_cache( $id, $this->meta_type );
538
+		if ($status) {
539
+			$this->delete_cache($id, $this->meta_type);
540 540
 		}
541 541
 
542 542
 		return $status;
Please login to merge, or discard this patch.
includes/class-give-donor.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1052,7 +1052,7 @@
 block discarded – undo
1052 1052
 	 * @access public
1053 1053
 	 *
1054 1054
 	 * @param  string $meta_key   Metadata name. Default is empty.
1055
-	 * @param  mixed  $meta_value Optional. Metadata value. Default is empty.
1055
+	 * @param  string  $meta_value Optional. Metadata value. Default is empty.
1056 1056
 	 *
1057 1057
 	 * @return bool               False for failure. True for success.
1058 1058
 	 */
Please login to merge, or discard this patch.
Spacing   +273 added lines, -273 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
 
@@ -149,29 +149,29 @@  discard block
 block discarded – undo
149 149
 	 * @param int|bool $_id_or_email
150 150
 	 * @param bool     $by_user_id
151 151
 	 */
152
-	public function __construct( $_id_or_email = false, $by_user_id = false ) {
152
+	public function __construct($_id_or_email = false, $by_user_id = false) {
153 153
 
154 154
 		$this->db = Give()->donors;
155 155
 
156
-		if ( false === $_id_or_email || ( is_numeric( $_id_or_email ) && (int) $_id_or_email !== absint( $_id_or_email ) ) ) {
156
+		if (false === $_id_or_email || (is_numeric($_id_or_email) && (int) $_id_or_email !== absint($_id_or_email))) {
157 157
 			return false;
158 158
 		}
159 159
 
160
-		$by_user_id = is_bool( $by_user_id ) ? $by_user_id : false;
160
+		$by_user_id = is_bool($by_user_id) ? $by_user_id : false;
161 161
 
162
-		if ( is_numeric( $_id_or_email ) ) {
162
+		if (is_numeric($_id_or_email)) {
163 163
 			$field = $by_user_id ? 'user_id' : 'id';
164 164
 		} else {
165 165
 			$field = 'email';
166 166
 		}
167 167
 
168
-		$donor = $this->db->get_donor_by( $field, $_id_or_email );
168
+		$donor = $this->db->get_donor_by($field, $_id_or_email);
169 169
 
170
-		if ( empty( $donor ) || ! is_object( $donor ) ) {
170
+		if (empty($donor) || ! is_object($donor)) {
171 171
 			return false;
172 172
 		}
173 173
 
174
-		$this->setup_donor( $donor );
174
+		$this->setup_donor($donor);
175 175
 
176 176
 	}
177 177
 
@@ -187,19 +187,19 @@  discard block
 block discarded – undo
187 187
 	 *
188 188
 	 * @return bool             If the setup was successful or not.
189 189
 	 */
190
-	private function setup_donor( $donor ) {
190
+	private function setup_donor($donor) {
191 191
 
192
-		if ( ! is_object( $donor ) ) {
192
+		if ( ! is_object($donor)) {
193 193
 			return false;
194 194
 		}
195 195
 
196 196
 		// Get cached donors.
197
-		$donor_vars = Give_Cache::get_group( $donor->id, 'give-donors' );
197
+		$donor_vars = Give_Cache::get_group($donor->id, 'give-donors');
198 198
 
199
-		if ( is_null( $donor_vars ) ) {
200
-			foreach ( $donor as $key => $value ) {
199
+		if (is_null($donor_vars)) {
200
+			foreach ($donor as $key => $value) {
201 201
 
202
-				switch ( $key ) {
202
+				switch ($key) {
203 203
 
204 204
 					case 'notes':
205 205
 						$this->$key = $this->get_notes();
@@ -213,20 +213,20 @@  discard block
 block discarded – undo
213 213
 			}
214 214
 
215 215
 			// Get donor's all email including primary email.
216
-			$this->emails = (array) $this->get_meta( 'additional_email', false );
217
-			$this->emails = array( 'primary' => $this->email ) + $this->emails;
216
+			$this->emails = (array) $this->get_meta('additional_email', false);
217
+			$this->emails = array('primary' => $this->email) + $this->emails;
218 218
 
219 219
 			$this->setup_address();
220 220
 
221
-			Give_Cache::set_group( $donor->id, get_object_vars( $this ), 'give-donors' );
221
+			Give_Cache::set_group($donor->id, get_object_vars($this), 'give-donors');
222 222
 		} else {
223
-			foreach ( $donor_vars as $donor_var => $value ) {
223
+			foreach ($donor_vars as $donor_var => $value) {
224 224
 				$this->$donor_var = $value;
225 225
 			}
226 226
 		}
227 227
 
228 228
 		// Donor ID and email are the only things that are necessary, make sure they exist.
229
-		if ( ! empty( $this->id ) && ! empty( $this->email ) ) {
229
+		if ( ! empty($this->id) && ! empty($this->email)) {
230 230
 			return true;
231 231
 		}
232 232
 
@@ -245,25 +245,25 @@  discard block
 block discarded – undo
245 245
 		global $wpdb;
246 246
 		$meta_type = Give()->donor_meta->meta_type;
247 247
 
248
-		$addresses = $wpdb->get_results( $wpdb->prepare( "
248
+		$addresses = $wpdb->get_results($wpdb->prepare("
249 249
 				SELECT meta_key, meta_value FROM {$wpdb->donormeta}
250 250
 				WHERE meta_key
251 251
 				LIKE '%%%s%%'
252 252
 				AND {$meta_type}_id=%d
253
-				", 'give_donor_address', $this->id ), ARRAY_N );
253
+				", 'give_donor_address', $this->id), ARRAY_N);
254 254
 
255
-		if ( empty( $addresses ) ) {
255
+		if (empty($addresses)) {
256 256
 			return $this->address;
257 257
 		}
258 258
 
259
-		foreach ( $addresses as $address ) {
260
-			$address[0] = str_replace( '_give_donor_address_', '', $address[0] );
261
-			$address[0] = explode( '_', $address[0] );
259
+		foreach ($addresses as $address) {
260
+			$address[0] = str_replace('_give_donor_address_', '', $address[0]);
261
+			$address[0] = explode('_', $address[0]);
262 262
 
263
-			if ( 3 === count( $address[0] ) ) {
264
-				$this->address[ $address[0][0] ][ $address[0][2] ][ $address[0][1] ] = $address[1];
263
+			if (3 === count($address[0])) {
264
+				$this->address[$address[0][0]][$address[0][2]][$address[0][1]] = $address[1];
265 265
 			} else {
266
-				$this->address[ $address[0][0] ][ $address[0][1] ] = $address[1];
266
+				$this->address[$address[0][0]][$address[0][1]] = $address[1];
267 267
 			}
268 268
 		}
269 269
 	}
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 	 *
280 280
 	 * @return array The donor's address, if any
281 281
 	 */
282
-	public function get_donor_address( $args = array() ) {
282
+	public function get_donor_address($args = array()) {
283 283
 		$args = wp_parse_args(
284 284
 			$args,
285 285
 			array(
@@ -297,24 +297,24 @@  discard block
 block discarded – undo
297 297
 		);
298 298
 
299 299
 		// Backward compatibility.
300
-		if ( ! give_has_upgrade_completed( 'v20_upgrades_user_address' ) ) {
300
+		if ( ! give_has_upgrade_completed('v20_upgrades_user_address')) {
301 301
 
302 302
 			// Backward compatibility for user id param.
303
-			return wp_parse_args( (array) get_user_meta( $this->user_id, '_give_user_address', true ), $default_address );
303
+			return wp_parse_args((array) get_user_meta($this->user_id, '_give_user_address', true), $default_address);
304 304
 
305 305
 		}
306 306
 
307
-		if ( ! $this->id || empty( $this->address ) || ! array_key_exists( $args['address_type'], $this->address ) ) {
307
+		if ( ! $this->id || empty($this->address) || ! array_key_exists($args['address_type'], $this->address)) {
308 308
 			return $default_address;
309 309
 		}
310 310
 
311
-		switch ( true ) {
312
-			case is_string( end( $this->address[ $args['address_type'] ] ) ):
313
-				$address = wp_parse_args( $this->address[ $args['address_type'] ], $default_address );
311
+		switch (true) {
312
+			case is_string(end($this->address[$args['address_type']])):
313
+				$address = wp_parse_args($this->address[$args['address_type']], $default_address);
314 314
 				break;
315 315
 
316
-			case is_array( end( $this->address[ $args['address_type'] ] ) ):
317
-				$address = wp_parse_args( array_shift( $this->address[ $args['address_type'] ] ), $default_address );
316
+			case is_array(end($this->address[$args['address_type']])):
317
+				$address = wp_parse_args(array_shift($this->address[$args['address_type']]), $default_address);
318 318
 				break;
319 319
 		}
320 320
 
@@ -331,16 +331,16 @@  discard block
 block discarded – undo
331 331
 	 *
332 332
 	 * @return mixed|\WP_Error
333 333
 	 */
334
-	public function __get( $key ) {
334
+	public function __get($key) {
335 335
 
336
-		if ( method_exists( $this, 'get_' . $key ) ) {
336
+		if (method_exists($this, 'get_'.$key)) {
337 337
 
338
-			return call_user_func( array( $this, 'get_' . $key ) );
338
+			return call_user_func(array($this, 'get_'.$key));
339 339
 
340 340
 		} else {
341 341
 
342 342
 			/* translators: %s: property key */
343
-			return new WP_Error( 'give-donor-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) );
343
+			return new WP_Error('give-donor-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key));
344 344
 
345 345
 		}
346 346
 
@@ -356,9 +356,9 @@  discard block
 block discarded – undo
356 356
 	 *
357 357
 	 * @return bool|int    False if not a valid creation, donor ID if user is found or valid creation.
358 358
 	 */
359
-	public function create( $data = array() ) {
359
+	public function create($data = array()) {
360 360
 
361
-		if ( $this->id != 0 || empty( $data ) ) {
361
+		if ($this->id != 0 || empty($data)) {
362 362
 			return false;
363 363
 		}
364 364
 
@@ -366,15 +366,15 @@  discard block
 block discarded – undo
366 366
 			'payment_ids' => '',
367 367
 		);
368 368
 
369
-		$args = wp_parse_args( $data, $defaults );
370
-		$args = $this->sanitize_columns( $args );
369
+		$args = wp_parse_args($data, $defaults);
370
+		$args = $this->sanitize_columns($args);
371 371
 
372
-		if ( empty( $args['email'] ) || ! is_email( $args['email'] ) ) {
372
+		if (empty($args['email']) || ! is_email($args['email'])) {
373 373
 			return false;
374 374
 		}
375 375
 
376
-		if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) {
377
-			$args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) );
376
+		if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) {
377
+			$args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids'])));
378 378
 		}
379 379
 
380 380
 		/**
@@ -384,18 +384,18 @@  discard block
 block discarded – undo
384 384
 		 *
385 385
 		 * @param array $args Donor attributes.
386 386
 		 */
387
-		do_action( 'give_donor_pre_create', $args );
387
+		do_action('give_donor_pre_create', $args);
388 388
 
389 389
 		$created = false;
390 390
 
391 391
 		// The DB class 'add' implies an update if the donor being asked to be created already exists
392
-		if ( $this->db->add( $data ) ) {
392
+		if ($this->db->add($data)) {
393 393
 
394 394
 			// We've successfully added/updated the donor, reset the class vars with the new data
395
-			$donor = $this->db->get_donor_by( 'email', $args['email'] );
395
+			$donor = $this->db->get_donor_by('email', $args['email']);
396 396
 
397 397
 			// Setup the donor data with the values from DB
398
-			$this->setup_donor( $donor );
398
+			$this->setup_donor($donor);
399 399
 
400 400
 			$created = $this->id;
401 401
 		}
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
 		 * @param bool|int $created False if not a valid creation, donor ID if user is found or valid creation.
409 409
 		 * @param array    $args    Customer attributes.
410 410
 		 */
411
-		do_action( 'give_donor_post_create', $created, $args );
411
+		do_action('give_donor_post_create', $created, $args);
412 412
 
413 413
 		return $created;
414 414
 
@@ -424,13 +424,13 @@  discard block
 block discarded – undo
424 424
 	 *
425 425
 	 * @return bool        If the update was successful or not.
426 426
 	 */
427
-	public function update( $data = array() ) {
427
+	public function update($data = array()) {
428 428
 
429
-		if ( empty( $data ) ) {
429
+		if (empty($data)) {
430 430
 			return false;
431 431
 		}
432 432
 
433
-		$data = $this->sanitize_columns( $data );
433
+		$data = $this->sanitize_columns($data);
434 434
 
435 435
 		/**
436 436
 		 * Fires before updating donors.
@@ -440,15 +440,15 @@  discard block
 block discarded – undo
440 440
 		 * @param int   $donor_id Donor id.
441 441
 		 * @param array $data     Donor attributes.
442 442
 		 */
443
-		do_action( 'give_donor_pre_update', $this->id, $data );
443
+		do_action('give_donor_pre_update', $this->id, $data);
444 444
 
445 445
 		$updated = false;
446 446
 
447
-		if ( $this->db->update( $this->id, $data ) ) {
447
+		if ($this->db->update($this->id, $data)) {
448 448
 
449
-			$donor = $this->db->get_donor_by( 'id', $this->id );
449
+			$donor = $this->db->get_donor_by('id', $this->id);
450 450
 
451
-			$this->setup_donor( $donor );
451
+			$this->setup_donor($donor);
452 452
 
453 453
 			$updated = true;
454 454
 		}
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
 		 * @param int   $donor_id Donor id.
463 463
 		 * @param array $data     Donor attributes.
464 464
 		 */
465
-		do_action( 'give_donor_post_update', $updated, $this->id, $data );
465
+		do_action('give_donor_post_update', $updated, $this->id, $data);
466 466
 
467 467
 		return $updated;
468 468
 	}
@@ -480,27 +480,27 @@  discard block
 block discarded – undo
480 480
 	 *
481 481
 	 * @return bool            If the attachment was successfully.
482 482
 	 */
483
-	public function attach_payment( $payment_id = 0, $update_stats = true ) {
483
+	public function attach_payment($payment_id = 0, $update_stats = true) {
484 484
 
485
-		if ( empty( $payment_id ) ) {
485
+		if (empty($payment_id)) {
486 486
 			return false;
487 487
 		}
488 488
 
489
-		if ( empty( $this->payment_ids ) ) {
489
+		if (empty($this->payment_ids)) {
490 490
 
491 491
 			$new_payment_ids = $payment_id;
492 492
 
493 493
 		} else {
494 494
 
495
-			$payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) );
495
+			$payment_ids = array_map('absint', explode(',', $this->payment_ids));
496 496
 
497
-			if ( in_array( $payment_id, $payment_ids ) ) {
497
+			if (in_array($payment_id, $payment_ids)) {
498 498
 				$update_stats = false;
499 499
 			}
500 500
 
501 501
 			$payment_ids[] = $payment_id;
502 502
 
503
-			$new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) );
503
+			$new_payment_ids = implode(',', array_unique(array_values($payment_ids)));
504 504
 
505 505
 		}
506 506
 
@@ -512,20 +512,20 @@  discard block
 block discarded – undo
512 512
 		 * @param int $payment_id Payment id.
513 513
 		 * @param int $donor_id   Donor id.
514 514
 		 */
515
-		do_action( 'give_donor_pre_attach_payment', $payment_id, $this->id );
515
+		do_action('give_donor_pre_attach_payment', $payment_id, $this->id);
516 516
 
517
-		$payment_added = $this->update( array( 'payment_ids' => $new_payment_ids ) );
517
+		$payment_added = $this->update(array('payment_ids' => $new_payment_ids));
518 518
 
519
-		if ( $payment_added ) {
519
+		if ($payment_added) {
520 520
 
521 521
 			$this->payment_ids = $new_payment_ids;
522 522
 
523 523
 			// We added this payment successfully, increment the stats
524
-			if ( $update_stats ) {
525
-				$payment_amount = give_donation_amount( $payment_id, array( 'type' => 'stats' ) );
524
+			if ($update_stats) {
525
+				$payment_amount = give_donation_amount($payment_id, array('type' => 'stats'));
526 526
 
527
-				if ( ! empty( $payment_amount ) ) {
528
-					$this->increase_value( $payment_amount );
527
+				if ( ! empty($payment_amount)) {
528
+					$this->increase_value($payment_amount);
529 529
 				}
530 530
 
531 531
 				$this->increase_purchase_count();
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
 		 * @param int  $payment_id    Payment id.
542 542
 		 * @param int  $donor_id      Donor id.
543 543
 		 */
544
-		do_action( 'give_donor_post_attach_payment', $payment_added, $payment_id, $this->id );
544
+		do_action('give_donor_post_attach_payment', $payment_added, $payment_id, $this->id);
545 545
 
546 546
 		return $payment_added;
547 547
 	}
@@ -559,33 +559,33 @@  discard block
 block discarded – undo
559 559
 	 *
560 560
 	 * @return boolean               If the removal was successful.
561 561
 	 */
562
-	public function remove_payment( $payment_id = 0, $update_stats = true ) {
562
+	public function remove_payment($payment_id = 0, $update_stats = true) {
563 563
 
564
-		if ( empty( $payment_id ) ) {
564
+		if (empty($payment_id)) {
565 565
 			return false;
566 566
 		}
567 567
 
568
-		$payment = new Give_Payment( $payment_id );
568
+		$payment = new Give_Payment($payment_id);
569 569
 
570
-		if ( 'publish' !== $payment->status && 'revoked' !== $payment->status ) {
570
+		if ('publish' !== $payment->status && 'revoked' !== $payment->status) {
571 571
 			$update_stats = false;
572 572
 		}
573 573
 
574 574
 		$new_payment_ids = '';
575 575
 
576
-		if ( ! empty( $this->payment_ids ) ) {
576
+		if ( ! empty($this->payment_ids)) {
577 577
 
578
-			$payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) );
578
+			$payment_ids = array_map('absint', explode(',', $this->payment_ids));
579 579
 
580
-			$pos = array_search( $payment_id, $payment_ids );
581
-			if ( false === $pos ) {
580
+			$pos = array_search($payment_id, $payment_ids);
581
+			if (false === $pos) {
582 582
 				return false;
583 583
 			}
584 584
 
585
-			unset( $payment_ids[ $pos ] );
586
-			$payment_ids = array_filter( $payment_ids );
585
+			unset($payment_ids[$pos]);
586
+			$payment_ids = array_filter($payment_ids);
587 587
 
588
-			$new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) );
588
+			$new_payment_ids = implode(',', array_unique(array_values($payment_ids)));
589 589
 
590 590
 		}
591 591
 
@@ -597,20 +597,20 @@  discard block
 block discarded – undo
597 597
 		 * @param int $payment_id Payment id.
598 598
 		 * @param int $donor_id   Customer id.
599 599
 		 */
600
-		do_action( 'give_donor_pre_remove_payment', $payment_id, $this->id );
600
+		do_action('give_donor_pre_remove_payment', $payment_id, $this->id);
601 601
 
602
-		$payment_removed = $this->update( array( 'payment_ids' => $new_payment_ids ) );
602
+		$payment_removed = $this->update(array('payment_ids' => $new_payment_ids));
603 603
 
604
-		if ( $payment_removed ) {
604
+		if ($payment_removed) {
605 605
 
606 606
 			$this->payment_ids = $new_payment_ids;
607 607
 
608
-			if ( $update_stats ) {
608
+			if ($update_stats) {
609 609
 				// We removed this payment successfully, decrement the stats
610
-				$payment_amount = give_donation_amount( $payment_id );
610
+				$payment_amount = give_donation_amount($payment_id);
611 611
 
612
-				if ( ! empty( $payment_amount ) ) {
613
-					$this->decrease_value( $payment_amount );
612
+				if ( ! empty($payment_amount)) {
613
+					$this->decrease_value($payment_amount);
614 614
 				}
615 615
 
616 616
 				$this->decrease_donation_count();
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
 		 * @param int  $payment_id      Payment id.
627 627
 		 * @param int  $donor_id        Donor id.
628 628
 		 */
629
-		do_action( 'give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id );
629
+		do_action('give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id);
630 630
 
631 631
 		return $payment_removed;
632 632
 
@@ -642,10 +642,10 @@  discard block
 block discarded – undo
642 642
 	 *
643 643
 	 * @return int        The donation count.
644 644
 	 */
645
-	public function increase_purchase_count( $count = 1 ) {
645
+	public function increase_purchase_count($count = 1) {
646 646
 
647 647
 		// Make sure it's numeric and not negative.
648
-		if ( ! is_numeric( $count ) || $count != absint( $count ) ) {
648
+		if ( ! is_numeric($count) || $count != absint($count)) {
649 649
 			return false;
650 650
 		}
651 651
 
@@ -659,9 +659,9 @@  discard block
 block discarded – undo
659 659
 		 * @param int $count    The number to increase by.
660 660
 		 * @param int $donor_id Donor id.
661 661
 		 */
662
-		do_action( 'give_donor_pre_increase_donation_count', $count, $this->id );
662
+		do_action('give_donor_pre_increase_donation_count', $count, $this->id);
663 663
 
664
-		if ( $this->update( array( 'purchase_count' => $new_total ) ) ) {
664
+		if ($this->update(array('purchase_count' => $new_total))) {
665 665
 			$this->purchase_count = $new_total;
666 666
 		}
667 667
 
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
 		 * @param int $count          The number increased by.
675 675
 		 * @param int $donor_id       Donor id.
676 676
 		 */
677
-		do_action( 'give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id );
677
+		do_action('give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id);
678 678
 
679 679
 		return $this->purchase_count;
680 680
 	}
@@ -689,16 +689,16 @@  discard block
 block discarded – undo
689 689
 	 *
690 690
 	 * @return mixed      If successful, the new count, otherwise false.
691 691
 	 */
692
-	public function decrease_donation_count( $count = 1 ) {
692
+	public function decrease_donation_count($count = 1) {
693 693
 
694 694
 		// Make sure it's numeric and not negative
695
-		if ( ! is_numeric( $count ) || $count != absint( $count ) ) {
695
+		if ( ! is_numeric($count) || $count != absint($count)) {
696 696
 			return false;
697 697
 		}
698 698
 
699 699
 		$new_total = (int) $this->purchase_count - (int) $count;
700 700
 
701
-		if ( $new_total < 0 ) {
701
+		if ($new_total < 0) {
702 702
 			$new_total = 0;
703 703
 		}
704 704
 
@@ -710,9 +710,9 @@  discard block
 block discarded – undo
710 710
 		 * @param int $count    The number to decrease by.
711 711
 		 * @param int $donor_id Customer id.
712 712
 		 */
713
-		do_action( 'give_donor_pre_decrease_donation_count', $count, $this->id );
713
+		do_action('give_donor_pre_decrease_donation_count', $count, $this->id);
714 714
 
715
-		if ( $this->update( array( 'purchase_count' => $new_total ) ) ) {
715
+		if ($this->update(array('purchase_count' => $new_total))) {
716 716
 			$this->purchase_count = $new_total;
717 717
 		}
718 718
 
@@ -725,7 +725,7 @@  discard block
 block discarded – undo
725 725
 		 * @param int $count          The number decreased by.
726 726
 		 * @param int $donor_id       Donor id.
727 727
 		 */
728
-		do_action( 'give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id );
728
+		do_action('give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id);
729 729
 
730 730
 		return $this->purchase_count;
731 731
 	}
@@ -740,9 +740,9 @@  discard block
 block discarded – undo
740 740
 	 *
741 741
 	 * @return mixed        If successful, the new value, otherwise false.
742 742
 	 */
743
-	public function increase_value( $value = 0.00 ) {
743
+	public function increase_value($value = 0.00) {
744 744
 
745
-		$new_value = floatval( $this->purchase_value ) + $value;
745
+		$new_value = floatval($this->purchase_value) + $value;
746 746
 
747 747
 		/**
748 748
 		 * Fires before increasing donor lifetime value.
@@ -752,9 +752,9 @@  discard block
 block discarded – undo
752 752
 		 * @param float $value    The value to increase by.
753 753
 		 * @param int   $donor_id Customer id.
754 754
 		 */
755
-		do_action( 'give_donor_pre_increase_value', $value, $this->id );
755
+		do_action('give_donor_pre_increase_value', $value, $this->id);
756 756
 
757
-		if ( $this->update( array( 'purchase_value' => $new_value ) ) ) {
757
+		if ($this->update(array('purchase_value' => $new_value))) {
758 758
 			$this->purchase_value = $new_value;
759 759
 		}
760 760
 
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
 		 * @param float $value          The value increased by.
768 768
 		 * @param int   $donor_id       Donor id.
769 769
 		 */
770
-		do_action( 'give_donor_post_increase_value', $this->purchase_value, $value, $this->id );
770
+		do_action('give_donor_post_increase_value', $this->purchase_value, $value, $this->id);
771 771
 
772 772
 		return $this->purchase_value;
773 773
 	}
@@ -782,11 +782,11 @@  discard block
 block discarded – undo
782 782
 	 *
783 783
 	 * @return mixed        If successful, the new value, otherwise false.
784 784
 	 */
785
-	public function decrease_value( $value = 0.00 ) {
785
+	public function decrease_value($value = 0.00) {
786 786
 
787
-		$new_value = floatval( $this->purchase_value ) - $value;
787
+		$new_value = floatval($this->purchase_value) - $value;
788 788
 
789
-		if ( $new_value < 0 ) {
789
+		if ($new_value < 0) {
790 790
 			$new_value = 0.00;
791 791
 		}
792 792
 
@@ -798,9 +798,9 @@  discard block
 block discarded – undo
798 798
 		 * @param float $value    The value to decrease by.
799 799
 		 * @param int   $donor_id Donor id.
800 800
 		 */
801
-		do_action( 'give_donor_pre_decrease_value', $value, $this->id );
801
+		do_action('give_donor_pre_decrease_value', $value, $this->id);
802 802
 
803
-		if ( $this->update( array( 'purchase_value' => $new_value ) ) ) {
803
+		if ($this->update(array('purchase_value' => $new_value))) {
804 804
 			$this->purchase_value = $new_value;
805 805
 		}
806 806
 
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
 		 * @param float $value          The value decreased by.
814 814
 		 * @param int   $donor_id       Donor id.
815 815
 		 */
816
-		do_action( 'give_donor_post_decrease_value', $this->purchase_value, $value, $this->id );
816
+		do_action('give_donor_post_decrease_value', $this->purchase_value, $value, $this->id);
817 817
 
818 818
 		return $this->purchase_value;
819 819
 	}
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
 	 *
834 834
 	 * @return mixed              If successful, the new donation stat value, otherwise false.
835 835
 	 */
836
-	public function update_donation_value( $curr_amount, $new_amount ) {
836
+	public function update_donation_value($curr_amount, $new_amount) {
837 837
 		/**
838 838
 		 * Payment total difference value can be:
839 839
 		 *  zero   (in case amount not change)
@@ -843,15 +843,15 @@  discard block
 block discarded – undo
843 843
 		$payment_total_diff = $new_amount - $curr_amount;
844 844
 
845 845
 		// We do not need to update donation stat if donation did not change.
846
-		if ( ! $payment_total_diff ) {
846
+		if ( ! $payment_total_diff) {
847 847
 			return false;
848 848
 		}
849 849
 
850
-		if ( $payment_total_diff > 0 ) {
851
-			$this->increase_value( $payment_total_diff );
850
+		if ($payment_total_diff > 0) {
851
+			$this->increase_value($payment_total_diff);
852 852
 		} else {
853 853
 			// Pass payment total difference as +ve value to decrease amount from user lifetime stat.
854
-			$this->decrease_value( - $payment_total_diff );
854
+			$this->decrease_value( -$payment_total_diff );
855 855
 		}
856 856
 
857 857
 		return $this->purchase_value;
@@ -868,15 +868,15 @@  discard block
 block discarded – undo
868 868
 	 *
869 869
 	 * @return array       The notes requested.
870 870
 	 */
871
-	public function get_notes( $length = 20, $paged = 1 ) {
871
+	public function get_notes($length = 20, $paged = 1) {
872 872
 
873
-		$length = is_numeric( $length ) ? $length : 20;
874
-		$offset = is_numeric( $paged ) && $paged != 1 ? ( ( absint( $paged ) - 1 ) * $length ) : 0;
873
+		$length = is_numeric($length) ? $length : 20;
874
+		$offset = is_numeric($paged) && $paged != 1 ? ((absint($paged) - 1) * $length) : 0;
875 875
 
876 876
 		$all_notes   = $this->get_raw_notes();
877
-		$notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) );
877
+		$notes_array = array_reverse(array_filter(explode("\n\n", $all_notes)));
878 878
 
879
-		$desired_notes = array_slice( $notes_array, $offset, $length );
879
+		$desired_notes = array_slice($notes_array, $offset, $length);
880 880
 
881 881
 		return $desired_notes;
882 882
 
@@ -893,9 +893,9 @@  discard block
 block discarded – undo
893 893
 	public function get_notes_count() {
894 894
 
895 895
 		$all_notes   = $this->get_raw_notes();
896
-		$notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) );
896
+		$notes_array = array_reverse(array_filter(explode("\n\n", $all_notes)));
897 897
 
898
-		return count( $notes_array );
898
+		return count($notes_array);
899 899
 
900 900
 	}
901 901
 
@@ -908,7 +908,7 @@  discard block
 block discarded – undo
908 908
 	 *
909 909
 	 * @return string|float
910 910
 	 */
911
-	public function get_total_donation_amount( $args = array() ) {
911
+	public function get_total_donation_amount($args = array()) {
912 912
 
913 913
 		/**
914 914
 		 * Filter total donation amount.
@@ -919,7 +919,7 @@  discard block
 block discarded – undo
919 919
 		 * @param integer      $donor_id       Donor ID.
920 920
 		 * @param array        $args           Pass additional data.
921 921
 		 */
922
-		return apply_filters( 'give_get_total_donation_amount', $this->purchase_value, $this->id, $args );
922
+		return apply_filters('give_get_total_donation_amount', $this->purchase_value, $this->id, $args);
923 923
 	}
924 924
 
925 925
 	/**
@@ -932,22 +932,22 @@  discard block
 block discarded – undo
932 932
 	 *
933 933
 	 * @return string|boolean The new note if added successfully, false otherwise.
934 934
 	 */
935
-	public function add_note( $note = '' ) {
935
+	public function add_note($note = '') {
936 936
 
937
-		$note = trim( $note );
938
-		if ( empty( $note ) ) {
937
+		$note = trim($note);
938
+		if (empty($note)) {
939 939
 			return false;
940 940
 		}
941 941
 
942 942
 		$notes = $this->get_raw_notes();
943 943
 
944
-		if ( empty( $notes ) ) {
944
+		if (empty($notes)) {
945 945
 			$notes = '';
946 946
 		}
947 947
 
948
-		$note_string = date_i18n( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $note;
949
-		$new_note    = apply_filters( 'give_customer_add_note_string', $note_string );
950
-		$notes       .= "\n\n" . $new_note;
948
+		$note_string = date_i18n('F j, Y H:i:s', current_time('timestamp')).' - '.$note;
949
+		$new_note    = apply_filters('give_customer_add_note_string', $note_string);
950
+		$notes .= "\n\n".$new_note;
951 951
 
952 952
 		/**
953 953
 		 * Fires before donor note is added.
@@ -957,11 +957,11 @@  discard block
 block discarded – undo
957 957
 		 * @param string $new_note New note to add.
958 958
 		 * @param int    $donor_id Donor id.
959 959
 		 */
960
-		do_action( 'give_donor_pre_add_note', $new_note, $this->id );
960
+		do_action('give_donor_pre_add_note', $new_note, $this->id);
961 961
 
962
-		$updated = $this->update( array( 'notes' => $notes ) );
962
+		$updated = $this->update(array('notes' => $notes));
963 963
 
964
-		if ( $updated ) {
964
+		if ($updated) {
965 965
 			$this->notes = $this->get_notes();
966 966
 		}
967 967
 
@@ -974,7 +974,7 @@  discard block
 block discarded – undo
974 974
 		 * @param string $new_note    New note added.
975 975
 		 * @param int    $donor_id    Donor id.
976 976
 		 */
977
-		do_action( 'give_donor_post_add_note', $this->notes, $new_note, $this->id );
977
+		do_action('give_donor_post_add_note', $this->notes, $new_note, $this->id);
978 978
 
979 979
 		// Return the formatted note, so we can test, as well as update any displays
980 980
 		return $new_note;
@@ -991,7 +991,7 @@  discard block
 block discarded – undo
991 991
 	 */
992 992
 	private function get_raw_notes() {
993 993
 
994
-		$all_notes = $this->db->get_column( 'notes', $this->id );
994
+		$all_notes = $this->db->get_column('notes', $this->id);
995 995
 
996 996
 		return $all_notes;
997 997
 
@@ -1009,8 +1009,8 @@  discard block
 block discarded – undo
1009 1009
 	 * @return mixed            Will be an array if $single is false. Will be value of meta data field if $single is
1010 1010
 	 *                          true.
1011 1011
 	 */
1012
-	public function get_meta( $meta_key = '', $single = true ) {
1013
-		return Give()->donor_meta->get_meta( $this->id, $meta_key, $single );
1012
+	public function get_meta($meta_key = '', $single = true) {
1013
+		return Give()->donor_meta->get_meta($this->id, $meta_key, $single);
1014 1014
 	}
1015 1015
 
1016 1016
 	/**
@@ -1025,8 +1025,8 @@  discard block
 block discarded – undo
1025 1025
 	 *
1026 1026
 	 * @return bool               False for failure. True for success.
1027 1027
 	 */
1028
-	public function add_meta( $meta_key = '', $meta_value, $unique = false ) {
1029
-		return Give()->donor_meta->add_meta( $this->id, $meta_key, $meta_value, $unique );
1028
+	public function add_meta($meta_key = '', $meta_value, $unique = false) {
1029
+		return Give()->donor_meta->add_meta($this->id, $meta_key, $meta_value, $unique);
1030 1030
 	}
1031 1031
 
1032 1032
 	/**
@@ -1041,8 +1041,8 @@  discard block
 block discarded – undo
1041 1041
 	 *
1042 1042
 	 * @return bool               False on failure, true if success.
1043 1043
 	 */
1044
-	public function update_meta( $meta_key = '', $meta_value, $prev_value = '' ) {
1045
-		return Give()->donor_meta->update_meta( $this->id, $meta_key, $meta_value, $prev_value );
1044
+	public function update_meta($meta_key = '', $meta_value, $prev_value = '') {
1045
+		return Give()->donor_meta->update_meta($this->id, $meta_key, $meta_value, $prev_value);
1046 1046
 	}
1047 1047
 
1048 1048
 	/**
@@ -1056,8 +1056,8 @@  discard block
 block discarded – undo
1056 1056
 	 *
1057 1057
 	 * @return bool               False for failure. True for success.
1058 1058
 	 */
1059
-	public function delete_meta( $meta_key = '', $meta_value = '' ) {
1060
-		return Give()->donor_meta->delete_meta( $this->id, $meta_key, $meta_value );
1059
+	public function delete_meta($meta_key = '', $meta_value = '') {
1060
+		return Give()->donor_meta->delete_meta($this->id, $meta_key, $meta_value);
1061 1061
 	}
1062 1062
 
1063 1063
 	/**
@@ -1070,51 +1070,51 @@  discard block
 block discarded – undo
1070 1070
 	 *
1071 1071
 	 * @return array       The sanitized data, based off column defaults.
1072 1072
 	 */
1073
-	private function sanitize_columns( $data ) {
1073
+	private function sanitize_columns($data) {
1074 1074
 
1075 1075
 		$columns        = $this->db->get_columns();
1076 1076
 		$default_values = $this->db->get_column_defaults();
1077 1077
 
1078
-		foreach ( $columns as $key => $type ) {
1078
+		foreach ($columns as $key => $type) {
1079 1079
 
1080 1080
 			// Only sanitize data that we were provided
1081
-			if ( ! array_key_exists( $key, $data ) ) {
1081
+			if ( ! array_key_exists($key, $data)) {
1082 1082
 				continue;
1083 1083
 			}
1084 1084
 
1085
-			switch ( $type ) {
1085
+			switch ($type) {
1086 1086
 
1087 1087
 				case '%s':
1088
-					if ( 'email' == $key ) {
1089
-						$data[ $key ] = sanitize_email( $data[ $key ] );
1090
-					} elseif ( 'notes' == $key ) {
1091
-						$data[ $key ] = strip_tags( $data[ $key ] );
1088
+					if ('email' == $key) {
1089
+						$data[$key] = sanitize_email($data[$key]);
1090
+					} elseif ('notes' == $key) {
1091
+						$data[$key] = strip_tags($data[$key]);
1092 1092
 					} else {
1093
-						$data[ $key ] = sanitize_text_field( $data[ $key ] );
1093
+						$data[$key] = sanitize_text_field($data[$key]);
1094 1094
 					}
1095 1095
 					break;
1096 1096
 
1097 1097
 				case '%d':
1098
-					if ( ! is_numeric( $data[ $key ] ) || (int) $data[ $key ] !== absint( $data[ $key ] ) ) {
1099
-						$data[ $key ] = $default_values[ $key ];
1098
+					if ( ! is_numeric($data[$key]) || (int) $data[$key] !== absint($data[$key])) {
1099
+						$data[$key] = $default_values[$key];
1100 1100
 					} else {
1101
-						$data[ $key ] = absint( $data[ $key ] );
1101
+						$data[$key] = absint($data[$key]);
1102 1102
 					}
1103 1103
 					break;
1104 1104
 
1105 1105
 				case '%f':
1106 1106
 					// Convert what was given to a float
1107
-					$value = floatval( $data[ $key ] );
1107
+					$value = floatval($data[$key]);
1108 1108
 
1109
-					if ( ! is_float( $value ) ) {
1110
-						$data[ $key ] = $default_values[ $key ];
1109
+					if ( ! is_float($value)) {
1110
+						$data[$key] = $default_values[$key];
1111 1111
 					} else {
1112
-						$data[ $key ] = $value;
1112
+						$data[$key] = $value;
1113 1113
 					}
1114 1114
 					break;
1115 1115
 
1116 1116
 				default:
1117
-					$data[ $key ] = sanitize_text_field( $data[ $key ] );
1117
+					$data[$key] = sanitize_text_field($data[$key]);
1118 1118
 					break;
1119 1119
 
1120 1120
 			}
@@ -1134,33 +1134,33 @@  discard block
 block discarded – undo
1134 1134
 	 *
1135 1135
 	 * @return bool            If the email was added successfully
1136 1136
 	 */
1137
-	public function add_email( $email = '', $primary = false ) {
1138
-		if ( ! is_email( $email ) ) {
1137
+	public function add_email($email = '', $primary = false) {
1138
+		if ( ! is_email($email)) {
1139 1139
 			return false;
1140 1140
 		}
1141
-		$existing = new Give_Donor( $email );
1141
+		$existing = new Give_Donor($email);
1142 1142
 
1143
-		if ( $existing->id > 0 ) {
1143
+		if ($existing->id > 0) {
1144 1144
 			// Email address already belongs to another donor
1145 1145
 			return false;
1146 1146
 		}
1147 1147
 
1148
-		if ( email_exists( $email ) ) {
1149
-			$user = get_user_by( 'email', $email );
1150
-			if ( $user->ID != $this->user_id ) {
1148
+		if (email_exists($email)) {
1149
+			$user = get_user_by('email', $email);
1150
+			if ($user->ID != $this->user_id) {
1151 1151
 				return false;
1152 1152
 			}
1153 1153
 		}
1154 1154
 
1155
-		do_action( 'give_donor_pre_add_email', $email, $this->id, $this );
1155
+		do_action('give_donor_pre_add_email', $email, $this->id, $this);
1156 1156
 
1157 1157
 		// Add is used to ensure duplicate emails are not added
1158
-		$ret = (bool) $this->add_meta( 'additional_email', $email );
1158
+		$ret = (bool) $this->add_meta('additional_email', $email);
1159 1159
 
1160
-		do_action( 'give_donor_post_add_email', $email, $this->id, $this );
1160
+		do_action('give_donor_post_add_email', $email, $this->id, $this);
1161 1161
 
1162
-		if ( $ret && true === $primary ) {
1163
-			$this->set_primary_email( $email );
1162
+		if ($ret && true === $primary) {
1163
+			$this->set_primary_email($email);
1164 1164
 		}
1165 1165
 
1166 1166
 		return $ret;
@@ -1176,16 +1176,16 @@  discard block
 block discarded – undo
1176 1176
 	 *
1177 1177
 	 * @return bool          If the email was removed successfully.
1178 1178
 	 */
1179
-	public function remove_email( $email = '' ) {
1180
-		if ( ! is_email( $email ) ) {
1179
+	public function remove_email($email = '') {
1180
+		if ( ! is_email($email)) {
1181 1181
 			return false;
1182 1182
 		}
1183 1183
 
1184
-		do_action( 'give_donor_pre_remove_email', $email, $this->id, $this );
1184
+		do_action('give_donor_pre_remove_email', $email, $this->id, $this);
1185 1185
 
1186
-		$ret = (bool) $this->delete_meta( 'additional_email', $email );
1186
+		$ret = (bool) $this->delete_meta('additional_email', $email);
1187 1187
 
1188
-		do_action( 'give_donor_post_remove_email', $email, $this->id, $this );
1188
+		do_action('give_donor_post_remove_email', $email, $this->id, $this);
1189 1189
 
1190 1190
 		return $ret;
1191 1191
 	}
@@ -1202,16 +1202,16 @@  discard block
 block discarded – undo
1202 1202
 	 *
1203 1203
 	 * @return bool                      If the email was set as primary successfully.
1204 1204
 	 */
1205
-	public function set_primary_email( $new_primary_email = '' ) {
1206
-		if ( ! is_email( $new_primary_email ) ) {
1205
+	public function set_primary_email($new_primary_email = '') {
1206
+		if ( ! is_email($new_primary_email)) {
1207 1207
 			return false;
1208 1208
 		}
1209 1209
 
1210
-		do_action( 'give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this );
1210
+		do_action('give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this);
1211 1211
 
1212
-		$existing = new Give_Donor( $new_primary_email );
1212
+		$existing = new Give_Donor($new_primary_email);
1213 1213
 
1214
-		if ( $existing->id > 0 && (int) $existing->id !== (int) $this->id ) {
1214
+		if ($existing->id > 0 && (int) $existing->id !== (int) $this->id) {
1215 1215
 			// This email belongs to another donor.
1216 1216
 			return false;
1217 1217
 		}
@@ -1219,21 +1219,21 @@  discard block
 block discarded – undo
1219 1219
 		$old_email = $this->email;
1220 1220
 
1221 1221
 		// Update donor record with new email.
1222
-		$update = $this->update( array( 'email' => $new_primary_email ) );
1222
+		$update = $this->update(array('email' => $new_primary_email));
1223 1223
 
1224 1224
 		// Remove new primary from list of additional emails.
1225
-		$remove = $this->remove_email( $new_primary_email );
1225
+		$remove = $this->remove_email($new_primary_email);
1226 1226
 
1227 1227
 		// Add old email to additional emails list.
1228
-		$add = $this->add_email( $old_email );
1228
+		$add = $this->add_email($old_email);
1229 1229
 
1230 1230
 		$ret = $update && $remove && $add;
1231 1231
 
1232
-		if ( $ret ) {
1232
+		if ($ret) {
1233 1233
 			$this->email = $new_primary_email;
1234 1234
 		}
1235 1235
 
1236
-		do_action( 'give_donor_post_set_primary_email', $new_primary_email, $this->id, $this );
1236
+		do_action('give_donor_post_set_primary_email', $new_primary_email, $this->id, $this);
1237 1237
 
1238 1238
 		return $ret;
1239 1239
 	}
@@ -1248,17 +1248,17 @@  discard block
 block discarded – undo
1248 1248
 	 *
1249 1249
 	 * @return bool
1250 1250
 	 */
1251
-	private function is_valid_address( $address ) {
1251
+	private function is_valid_address($address) {
1252 1252
 		$is_valid_address = true;
1253 1253
 
1254 1254
 		// Address ready to process even if only one value set.
1255
-		foreach ( $address as $address_type => $value ) {
1255
+		foreach ($address as $address_type => $value) {
1256 1256
 			// @todo: Handle state field validation on basis of country.
1257
-			if ( in_array( $address_type, array( 'line2', 'state' ) ) ) {
1257
+			if (in_array($address_type, array('line2', 'state'))) {
1258 1258
 				continue;
1259 1259
 			}
1260 1260
 
1261
-			if ( empty( $value ) ) {
1261
+			if (empty($value)) {
1262 1262
 				$is_valid_address = false;
1263 1263
 				break;
1264 1264
 			}
@@ -1285,57 +1285,57 @@  discard block
 block discarded – undo
1285 1285
 	 *
1286 1286
 	 * @return bool
1287 1287
 	 */
1288
-	public function add_address( $address_type, $address ) {
1288
+	public function add_address($address_type, $address) {
1289 1289
 		// Bailout.
1290
-		if ( empty( $address_type ) || ! $this->is_valid_address( $address ) || ! $this->id ) {
1290
+		if (empty($address_type) || ! $this->is_valid_address($address) || ! $this->id) {
1291 1291
 			return false;
1292 1292
 		}
1293 1293
 
1294 1294
 		// Check if multiple address exist or not and set params.
1295 1295
 		$multi_address_id = null;
1296
-		if ( $is_multi_address = ( false !== strpos( $address_type, '[]' ) ) ) {
1297
-			$address_type = $is_multi_address ? str_replace( '[]', '', $address_type ) : $address_type;
1298
-		} elseif ( $is_multi_address = ( false !== strpos( $address_type, '_' ) ) ) {
1299
-			$multi_address_id = $is_multi_address ? array_pop( explode( '_', $address_type ) ) : $address_type;
1296
+		if ($is_multi_address = (false !== strpos($address_type, '[]'))) {
1297
+			$address_type = $is_multi_address ? str_replace('[]', '', $address_type) : $address_type;
1298
+		} elseif ($is_multi_address = (false !== strpos($address_type, '_'))) {
1299
+			$multi_address_id = $is_multi_address ? array_pop(explode('_', $address_type)) : $address_type;
1300 1300
 
1301
-			$address_type = $is_multi_address ? array_shift( explode( '_', $address_type ) ) : $address_type;
1301
+			$address_type = $is_multi_address ? array_shift(explode('_', $address_type)) : $address_type;
1302 1302
 		}
1303 1303
 
1304 1304
 		// Bailout: do not save duplicate orders
1305
-		if ( $this->does_address_exist( $address_type, $address ) ) {
1305
+		if ($this->does_address_exist($address_type, $address)) {
1306 1306
 			return false;
1307 1307
 		}
1308 1308
 
1309 1309
 		// Set default address.
1310
-		$address = wp_parse_args( $address, array(
1310
+		$address = wp_parse_args($address, array(
1311 1311
 			'line1'   => '',
1312 1312
 			'line2'   => '',
1313 1313
 			'city'    => '',
1314 1314
 			'state'   => '',
1315 1315
 			'country' => '',
1316 1316
 			'zip'     => '',
1317
-		) );
1317
+		));
1318 1318
 
1319 1319
 		// Set meta key prefix.
1320 1320
 		global $wpdb;
1321 1321
 		$meta_key_prefix = "_give_donor_address_{$address_type}_{address_name}";
1322 1322
 		$meta_type       = Give()->donor_meta->meta_type;
1323 1323
 
1324
-		if ( $is_multi_address ) {
1325
-			if ( is_null( $multi_address_id ) ) {
1324
+		if ($is_multi_address) {
1325
+			if (is_null($multi_address_id)) {
1326 1326
 				// Get latest address key to set multi address id.
1327
-				$multi_address_id = $wpdb->get_var( $wpdb->prepare( "
1327
+				$multi_address_id = $wpdb->get_var($wpdb->prepare("
1328 1328
 						SELECT meta_key FROM {$wpdb->donormeta}
1329 1329
 						WHERE meta_key
1330 1330
 						LIKE '%%%s%%'
1331 1331
 						AND {$meta_type}_id=%d
1332 1332
 						ORDER BY meta_id DESC
1333 1333
 						LIMIT 1
1334
-						", "_give_donor_address_{$address_type}_line1", $this->id ) );
1334
+						", "_give_donor_address_{$address_type}_line1", $this->id));
1335 1335
 
1336
-				if ( ! empty( $multi_address_id ) ) {
1337
-					$multi_address_id = absint( substr( strrchr( $multi_address_id, '_' ), 1 ) );
1338
-					$multi_address_id ++;
1336
+				if ( ! empty($multi_address_id)) {
1337
+					$multi_address_id = absint(substr(strrchr($multi_address_id, '_'), 1));
1338
+					$multi_address_id++;
1339 1339
 				} else {
1340 1340
 					$multi_address_id = 0;
1341 1341
 				}
@@ -1345,9 +1345,9 @@  discard block
 block discarded – undo
1345 1345
 		}
1346 1346
 
1347 1347
 		// Save donor address.
1348
-		foreach ( $address as $type => $value ) {
1349
-			$meta_key = str_replace( '{address_name}', $type, $meta_key_prefix );
1350
-			Give()->donor_meta->update_meta( $this->id, $meta_key, $value );
1348
+		foreach ($address as $type => $value) {
1349
+			$meta_key = str_replace('{address_name}', $type, $meta_key_prefix);
1350
+			Give()->donor_meta->update_meta($this->id, $meta_key, $value);
1351 1351
 		}
1352 1352
 
1353 1353
 		$this->setup_address();
@@ -1366,31 +1366,31 @@  discard block
 block discarded – undo
1366 1366
 	 *
1367 1367
 	 * @return bool
1368 1368
 	 */
1369
-	public function remove_address( $address_id ) {
1369
+	public function remove_address($address_id) {
1370 1370
 		global $wpdb;
1371 1371
 
1372 1372
 		// Get address type.
1373
-		$is_multi_address = false !== strpos( $address_id, '_' ) ? true : false;
1373
+		$is_multi_address = false !== strpos($address_id, '_') ? true : false;
1374 1374
 
1375
-		$address_type = false !== strpos( $address_id, '_' ) ? array_shift( explode( '_', $address_id ) ) : $address_id;
1375
+		$address_type = false !== strpos($address_id, '_') ? array_shift(explode('_', $address_id)) : $address_id;
1376 1376
 
1377
-		$address_count = false !== strpos( $address_id, '_' ) ? array_pop( explode( '_', $address_id ) ) : null;
1377
+		$address_count = false !== strpos($address_id, '_') ? array_pop(explode('_', $address_id)) : null;
1378 1378
 
1379 1379
 		// Set meta key prefix.
1380 1380
 		$meta_key_prefix = "_give_donor_address_{$address_type}_%";
1381
-		if ( $is_multi_address && is_numeric( $address_count ) ) {
1381
+		if ($is_multi_address && is_numeric($address_count)) {
1382 1382
 			$meta_key_prefix .= "_{$address_count}";
1383 1383
 		}
1384 1384
 
1385 1385
 		$meta_type = Give()->donor_meta->meta_type;
1386 1386
 
1387 1387
 		// Process query.
1388
-		$row_affected = $wpdb->query( $wpdb->prepare( "
1388
+		$row_affected = $wpdb->query($wpdb->prepare("
1389 1389
 				DELETE FROM {$wpdb->donormeta}
1390 1390
 				WHERE meta_key
1391 1391
 				LIKE '%s'
1392 1392
 				AND {$meta_type}_id=%d
1393
-				", $meta_key_prefix, $this->id ) );
1393
+				", $meta_key_prefix, $this->id));
1394 1394
 
1395 1395
 		$this->setup_address();
1396 1396
 
@@ -1409,39 +1409,39 @@  discard block
 block discarded – undo
1409 1409
 	 *
1410 1410
 	 * @return bool
1411 1411
 	 */
1412
-	public function update_address( $address_id, $address ) {
1412
+	public function update_address($address_id, $address) {
1413 1413
 		global $wpdb;
1414 1414
 
1415 1415
 		// Get address type.
1416
-		$is_multi_address = false !== strpos( $address_id, '_' ) ? true : false;
1416
+		$is_multi_address = false !== strpos($address_id, '_') ? true : false;
1417 1417
 
1418
-		$address_type = false !== strpos( $address_id, '_' ) ? array_shift( explode( '_', $address_id ) ) : $address_id;
1418
+		$address_type = false !== strpos($address_id, '_') ? array_shift(explode('_', $address_id)) : $address_id;
1419 1419
 
1420
-		$address_count = false !== strpos( $address_id, '_' ) ? array_pop( explode( '_', $address_id ) ) : null;
1420
+		$address_count = false !== strpos($address_id, '_') ? array_pop(explode('_', $address_id)) : null;
1421 1421
 
1422 1422
 		// Set meta key prefix.
1423 1423
 		$meta_key_prefix = "_give_donor_address_{$address_type}_%";
1424
-		if ( $is_multi_address && is_numeric( $address_count ) ) {
1424
+		if ($is_multi_address && is_numeric($address_count)) {
1425 1425
 			$meta_key_prefix .= "_{$address_count}";
1426 1426
 		}
1427 1427
 
1428 1428
 		$meta_type = Give()->donor_meta->meta_type;
1429 1429
 
1430 1430
 		// Process query.
1431
-		$row_affected = $wpdb->get_results( $wpdb->prepare( "
1431
+		$row_affected = $wpdb->get_results($wpdb->prepare("
1432 1432
 				SELECT meta_key FROM {$wpdb->donormeta}
1433 1433
 				WHERE meta_key
1434 1434
 				LIKE '%s'
1435 1435
 				AND {$meta_type}_id=%d
1436
-				", $meta_key_prefix, $this->id ) );
1436
+				", $meta_key_prefix, $this->id));
1437 1437
 
1438 1438
 		// Return result.
1439
-		if ( ! count( $row_affected ) ) {
1439
+		if ( ! count($row_affected)) {
1440 1440
 			return false;
1441 1441
 		}
1442 1442
 
1443 1443
 		// Update address.
1444
-		if ( ! $this->add_address( $address_id, $address ) ) {
1444
+		if ( ! $this->add_address($address_id, $address)) {
1445 1445
 			return false;
1446 1446
 		}
1447 1447
 
@@ -1460,39 +1460,39 @@  discard block
 block discarded – undo
1460 1460
 	 *
1461 1461
 	 * @return bool|null
1462 1462
 	 */
1463
-	public function does_address_exist( $current_address_type, $current_address ) {
1463
+	public function does_address_exist($current_address_type, $current_address) {
1464 1464
 		$status = false;
1465 1465
 
1466 1466
 		// Bailout.
1467
-		if ( empty( $current_address_type ) || empty( $current_address ) ) {
1467
+		if (empty($current_address_type) || empty($current_address)) {
1468 1468
 			return null;
1469 1469
 		}
1470 1470
 
1471 1471
 		// Bailout.
1472
-		if ( empty( $this->address ) || empty( $this->address[ $current_address_type ] ) ) {
1472
+		if (empty($this->address) || empty($this->address[$current_address_type])) {
1473 1473
 			return $status;
1474 1474
 		}
1475 1475
 
1476 1476
 		// Get address.
1477
-		$address = $this->address[ $current_address_type ];
1477
+		$address = $this->address[$current_address_type];
1478 1478
 
1479
-		switch ( true ) {
1479
+		switch (true) {
1480 1480
 
1481 1481
 			// Single address.
1482
-			case is_string( end( $address ) ) :
1483
-				$status = $this->is_address_match( $current_address, $address );
1482
+			case is_string(end($address)) :
1483
+				$status = $this->is_address_match($current_address, $address);
1484 1484
 				break;
1485 1485
 
1486 1486
 			// Multi address.
1487
-			case is_array( end( $address ) ):
1487
+			case is_array(end($address)):
1488 1488
 				// Compare address.
1489
-				foreach ( $address as $saved_address ) {
1490
-					if ( empty( $saved_address ) ) {
1489
+				foreach ($address as $saved_address) {
1490
+					if (empty($saved_address)) {
1491 1491
 						continue;
1492 1492
 					}
1493 1493
 
1494 1494
 					// Exit loop immediately if address exist.
1495
-					if ( $status = $this->is_address_match( $current_address, $saved_address ) ) {
1495
+					if ($status = $this->is_address_match($current_address, $saved_address)) {
1496 1496
 						break;
1497 1497
 					}
1498 1498
 				}
@@ -1513,10 +1513,10 @@  discard block
 block discarded – undo
1513 1513
 	 *
1514 1514
 	 * @return bool
1515 1515
 	 */
1516
-	private function is_address_match( $address_1, $address_2 ) {
1517
-		$result = array_diff( $address_1, $address_2 );
1516
+	private function is_address_match($address_1, $address_2) {
1517
+		$result = array_diff($address_1, $address_2);
1518 1518
 
1519
-		return empty( $result );
1519
+		return empty($result);
1520 1520
 	}
1521 1521
 
1522 1522
 	/**
@@ -1527,23 +1527,23 @@  discard block
 block discarded – undo
1527 1527
 	 * @since   2.0
1528 1528
 	 * @return  object
1529 1529
 	 */
1530
-	public function split_donor_name( $id ) {
1530
+	public function split_donor_name($id) {
1531 1531
 		$first_name = $last_name = '';
1532
-		$donor      = new Give_Donor( $id );
1532
+		$donor      = new Give_Donor($id);
1533 1533
 
1534
-		$split_donor_name = explode( ' ', $donor->name, 2 );
1534
+		$split_donor_name = explode(' ', $donor->name, 2);
1535 1535
 
1536 1536
 		// Check for existence of first name after split of donor name.
1537
-		if ( is_array( $split_donor_name ) && ! empty( $split_donor_name[0] ) ) {
1537
+		if (is_array($split_donor_name) && ! empty($split_donor_name[0])) {
1538 1538
 			$first_name = $split_donor_name[0];
1539 1539
 		}
1540 1540
 
1541 1541
 		// Check for existence of last name after split of donor name.
1542
-		if ( is_array( $split_donor_name ) && ! empty( $split_donor_name[1] ) ) {
1542
+		if (is_array($split_donor_name) && ! empty($split_donor_name[1])) {
1543 1543
 			$last_name = $split_donor_name[1];
1544 1544
 		}
1545 1545
 
1546
-		return (object) array( 'first_name' => $first_name, 'last_name' => $last_name );
1546
+		return (object) array('first_name' => $first_name, 'last_name' => $last_name);
1547 1547
 	}
1548 1548
 
1549 1549
 	/**
@@ -1553,9 +1553,9 @@  discard block
 block discarded – undo
1553 1553
 	 * @return  string
1554 1554
 	 */
1555 1555
 	public function get_first_name() {
1556
-		$first_name = $this->get_meta( '_give_donor_first_name' );
1557
-		if ( ! $first_name ) {
1558
-			$first_name = $this->split_donor_name( $this->id )->first_name;
1556
+		$first_name = $this->get_meta('_give_donor_first_name');
1557
+		if ( ! $first_name) {
1558
+			$first_name = $this->split_donor_name($this->id)->first_name;
1559 1559
 		}
1560 1560
 
1561 1561
 		return $first_name;
@@ -1568,15 +1568,15 @@  discard block
 block discarded – undo
1568 1568
 	 * @return  string
1569 1569
 	 */
1570 1570
 	public function get_last_name() {
1571
-		$first_name = $this->get_meta( '_give_donor_first_name' );
1572
-		$last_name  = $this->get_meta( '_give_donor_last_name' );
1571
+		$first_name = $this->get_meta('_give_donor_first_name');
1572
+		$last_name  = $this->get_meta('_give_donor_last_name');
1573 1573
 
1574 1574
 		// This condition will prevent unnecessary splitting of donor name to fetch last name.
1575
-		if ( ! $first_name && ! $last_name ) {
1576
-			$last_name = $this->split_donor_name( $this->id )->last_name;
1575
+		if ( ! $first_name && ! $last_name) {
1576
+			$last_name = $this->split_donor_name($this->id)->last_name;
1577 1577
 		}
1578 1578
 
1579
-		return ( $last_name ) ? $last_name : '';
1579
+		return ($last_name) ? $last_name : '';
1580 1580
 	}
1581 1581
 
1582 1582
 	/**
@@ -1587,7 +1587,7 @@  discard block
 block discarded – undo
1587 1587
 	 * @return  string $company_name Donor Company Name
1588 1588
 	 */
1589 1589
 	public function get_company_name() {
1590
-		$company_name = $this->get_meta( '_give_donor_company' );
1590
+		$company_name = $this->get_meta('_give_donor_company');
1591 1591
 
1592 1592
 		return $company_name;
1593 1593
 	}
@@ -1601,9 +1601,9 @@  discard block
 block discarded – undo
1601 1601
 	 */
1602 1602
 	public function get_last_donation() {
1603 1603
 
1604
-		$payments = array_unique( array_values( explode( ',', $this->payment_ids ) ) );
1604
+		$payments = array_unique(array_values(explode(',', $this->payment_ids)));
1605 1605
 
1606
-		return end( $payments );
1606
+		return end($payments);
1607 1607
 
1608 1608
 	}
1609 1609
 
@@ -1616,18 +1616,18 @@  discard block
 block discarded – undo
1616 1616
 	 *
1617 1617
 	 * @return string The date of the last donation.
1618 1618
 	 */
1619
-	public function get_last_donation_date( $formatted = false ) {
1619
+	public function get_last_donation_date($formatted = false) {
1620 1620
 		$completed_data = '';
1621 1621
 
1622 1622
 		// Return if donation id is invalid.
1623
-		if( ! ( $last_donation = absint( $this->get_last_donation() ) ) ) {
1623
+		if ( ! ($last_donation = absint($this->get_last_donation()))) {
1624 1624
 			return $completed_data;
1625 1625
 		}
1626 1626
 
1627
-		$completed_data = give_get_payment_completed_date( $last_donation );
1627
+		$completed_data = give_get_payment_completed_date($last_donation);
1628 1628
 
1629
-		if ( $formatted ) {
1630
-			return date_i18n( give_date_format(), strtotime( $completed_data ) );
1629
+		if ($formatted) {
1630
+			return date_i18n(give_date_format(), strtotime($completed_data));
1631 1631
 		}
1632 1632
 
1633 1633
 		return $completed_data;
@@ -1643,10 +1643,10 @@  discard block
 block discarded – undo
1643 1643
 	 */
1644 1644
 	public function get_donor_initals() {
1645 1645
 
1646
-		$first_name_initial = mb_substr( $this->get_first_name(), 0, 1, 'utf-8' );
1647
-		$last_name_initial  = mb_substr( $this->get_last_name(), 0, 1, 'utf-8' );
1646
+		$first_name_initial = mb_substr($this->get_first_name(), 0, 1, 'utf-8');
1647
+		$last_name_initial  = mb_substr($this->get_last_name(), 0, 1, 'utf-8');
1648 1648
 
1649
-		return apply_filters( 'get_donor_initals', $first_name_initial . $last_name_initial );
1649
+		return apply_filters('get_donor_initals', $first_name_initial.$last_name_initial);
1650 1650
 
1651 1651
 	}
1652 1652
 
Please login to merge, or discard this patch.
includes/donors/frontend-donor-functions.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@
 block discarded – undo
46 46
  *
47 47
  * @since 2.2.0
48 48
  *
49
- * @param string|int $id_or_email
49
+ * @param string $id_or_email
50 50
  *
51 51
  * @return bool
52 52
  */
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -21,15 +21,15 @@  discard block
 block discarded – undo
21 21
  *
22 22
  * @return string HTML output.
23 23
  */
24
-function give_get_donor_avatar( $donor, $size = 60 ) {
24
+function give_get_donor_avatar($donor, $size = 60) {
25 25
 	ob_start();
26 26
 	?>
27 27
 	<div class="give-donor__image">
28 28
 		<?php
29 29
 		// Check if gravatar exists.
30
-		if ( give_validate_gravatar( $donor->email ) ) {
30
+		if (give_validate_gravatar($donor->email)) {
31 31
 			// Return avatar.
32
-			echo get_avatar( $donor->email, $size );
32
+			echo get_avatar($donor->email, $size);
33 33
 		} else {
34 34
 			// No gravatar = output initials.
35 35
 			echo $donor->get_donor_initals();
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	</div>
38 38
 	<?php
39 39
 
40
-	return apply_filters( 'give_get_donor_avatar', ob_get_clean() );
40
+	return apply_filters('give_get_donor_avatar', ob_get_clean());
41 41
 
42 42
 }
43 43
 
@@ -50,51 +50,51 @@  discard block
 block discarded – undo
50 50
  *
51 51
  * @return bool
52 52
  */
53
-function give_validate_gravatar( $id_or_email ) {
53
+function give_validate_gravatar($id_or_email) {
54 54
 
55 55
 	//id or email code borrowed from wp-includes/pluggable.php
56 56
 	$email = '';
57
-	if ( is_numeric( $id_or_email ) ) {
57
+	if (is_numeric($id_or_email)) {
58 58
 		$id   = (int) $id_or_email;
59
-		$user = get_userdata( $id );
60
-		if ( $user ) {
59
+		$user = get_userdata($id);
60
+		if ($user) {
61 61
 			$email = $user->user_email;
62 62
 		}
63
-	} elseif ( is_object( $id_or_email ) ) {
63
+	} elseif (is_object($id_or_email)) {
64 64
 		// No avatar for pingbacks or trackbacks
65
-		$allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) );
66
-		if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) ) {
65
+		$allowed_comment_types = apply_filters('get_avatar_comment_types', array('comment'));
66
+		if ( ! empty($id_or_email->comment_type) && ! in_array($id_or_email->comment_type, (array) $allowed_comment_types)) {
67 67
 			return false;
68 68
 		}
69 69
 
70
-		if ( ! empty( $id_or_email->user_id ) ) {
70
+		if ( ! empty($id_or_email->user_id)) {
71 71
 			$id   = (int) $id_or_email->user_id;
72
-			$user = get_userdata( $id );
73
-			if ( $user ) {
72
+			$user = get_userdata($id);
73
+			if ($user) {
74 74
 				$email = $user->user_email;
75 75
 			}
76
-		} elseif ( ! empty( $id_or_email->comment_author_email ) ) {
76
+		} elseif ( ! empty($id_or_email->comment_author_email)) {
77 77
 			$email = $id_or_email->comment_author_email;
78 78
 		}
79 79
 	} else {
80 80
 		$email = $id_or_email;
81 81
 	}
82 82
 
83
-	$hashkey = md5( strtolower( trim( $email ) ) );
84
-	$uri     = 'http://www.gravatar.com/avatar/' . $hashkey . '?d=404';
83
+	$hashkey = md5(strtolower(trim($email)));
84
+	$uri     = 'http://www.gravatar.com/avatar/'.$hashkey.'?d=404';
85 85
 
86
-	$data = wp_cache_get( $hashkey );
87
-	if ( false === $data ) {
88
-		$response = wp_remote_head( $uri );
89
-		if ( is_wp_error( $response ) ) {
86
+	$data = wp_cache_get($hashkey);
87
+	if (false === $data) {
88
+		$response = wp_remote_head($uri);
89
+		if (is_wp_error($response)) {
90 90
 			$data = 'not200';
91 91
 		} else {
92 92
 			$data = $response['response']['code'];
93 93
 		}
94
-		wp_cache_set( $hashkey, $data, $group = '', $expire = 60 * 5 );
94
+		wp_cache_set($hashkey, $data, $group = '', $expire = 60 * 5);
95 95
 
96 96
 	}
97
-	if ( $data == '200' ) {
97
+	if ($data == '200') {
98 98
 		return true;
99 99
 	} else {
100 100
 		return false;
@@ -114,18 +114,18 @@  discard block
 block discarded – undo
114 114
  *
115 115
  * @return int The new note ID
116 116
  */
117
-function give_insert_donor_donation_comment( $donation_id, $donor, $note, $comment_args = array() ) {
117
+function give_insert_donor_donation_comment($donation_id, $donor, $note, $comment_args = array()) {
118 118
 	$comment_args = wp_parse_args(
119 119
 		$comment_args,
120 120
 		array(
121 121
 			'comment_approved' => 0,
122
-			'comment_parent'   => give_get_payment_form_id( $donation_id )
122
+			'comment_parent'   => give_get_payment_form_id($donation_id)
123 123
 		)
124 124
 	);
125 125
 
126
-	$comment_id = Give_Comment::add( $donation_id, $note, 'payment', $comment_args );
126
+	$comment_id = Give_Comment::add($donation_id, $note, 'payment', $comment_args);
127 127
 
128
-	update_comment_meta( $comment_id, '_give_donor_id', $donor );
128
+	update_comment_meta($comment_id, '_give_donor_id', $donor);
129 129
 
130 130
 	return $comment_id;
131 131
 }
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
  *
145 145
  * @return WP_Comment|array
146 146
  */
147
-function give_get_donor_donation_comment( $donation_id, $donor_id, $search = '' ) {
147
+function give_get_donor_donation_comment($donation_id, $donor_id, $search = '') {
148 148
 	$comments = Give_Comment::get(
149 149
 		$donation_id,
150 150
 		'payment',
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 		$search
161 161
 	);
162 162
 
163
-	return ( ! empty( $comments ) ? current( $comments ) : array() );
163
+	return ( ! empty($comments) ? current($comments) : array());
164 164
 }
165 165
 
166 166
 /**
@@ -176,9 +176,9 @@  discard block
 block discarded – undo
176 176
  *
177 177
  * @return int
178 178
  */
179
-function give_get_donor_donation_comment_id( $donation_id, $donor_id, $search = '' ) {
179
+function give_get_donor_donation_comment_id($donation_id, $donor_id, $search = '') {
180 180
 	/* @var WP_Comment|array $comment */
181
-	$comment    = give_get_donor_donation_comment( $donation_id, $donor_id, $search );
181
+	$comment    = give_get_donor_donation_comment($donation_id, $donor_id, $search);
182 182
 	$comment_id = $comment instanceof WP_Comment ? $comment->comment_ID : 0;
183 183
 
184 184
 	return $comment_id;
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
  *
198 198
  * @return array
199 199
  */
200
-function give_get_donor_donation_comments( $donor_id, $comment_args = array(), $search = '' ) {
200
+function give_get_donor_donation_comments($donor_id, $comment_args = array(), $search = '') {
201 201
 	$comments = Give_Comment::get(
202 202
 		$donor_id,
203 203
 		'payment',
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 		$search
206 206
 	);
207 207
 
208
-	return ( ! empty( $comments ) ? $comments : array() );
208
+	return ( ! empty($comments) ? $comments : array());
209 209
 }
210 210
 
211 211
 
@@ -219,19 +219,19 @@  discard block
 block discarded – undo
219 219
  *
220 220
  * @return string
221 221
  */
222
-function give_get_donor_donation_comment_html( $comment, $payment_id = 0 ) {
222
+function give_get_donor_donation_comment_html($comment, $payment_id = 0) {
223 223
 
224
-	if ( is_numeric( $comment ) ) {
225
-		$comment = get_comment( $comment );
224
+	if (is_numeric($comment)) {
225
+		$comment = get_comment($comment);
226 226
 	}
227 227
 
228
-	$date_format = give_date_format() . ', ' . get_option( 'time_format' );
228
+	$date_format = give_date_format().', '.get_option('time_format');
229 229
 
230 230
 	$comment_html = sprintf(
231 231
 		'<div class="give-payment-note" id="give-payment-note-%s"><p><strong>%s</strong>&nbsp;&ndash;&nbsp;<span style="color:#aaa;font-style:italic;">%s</span><br/>%s</p></div>',
232 232
 		$comment->comment_ID,
233
-		get_comment_author( $comment->comment_ID ),
234
-		date_i18n( $date_format, strtotime( $comment->comment_date ) ),
233
+		get_comment_author($comment->comment_ID),
234
+		date_i18n($date_format, strtotime($comment->comment_date)),
235 235
 		$comment->comment_content
236 236
 	);
237 237
 
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
  *
251 251
  * @return WP_Comment/array
252 252
  */
253
-function give_get_donor_latest_comment( $donor_id, $form_id = 0 ) {
253
+function give_get_donor_latest_comment($donor_id, $form_id = 0) {
254 254
 	$comment_args = array(
255 255
 		'post_id'    => 0,
256 256
 		'orderby'    => 'comment_ID',
@@ -270,11 +270,11 @@  discard block
 block discarded – undo
270 270
 	);
271 271
 
272 272
 	// Get donor donation comment for specific form.
273
-	if ( $form_id ) {
273
+	if ($form_id) {
274 274
 		$comment_args['parent'] = $form_id;
275 275
 	}
276 276
 
277
-	$comment = current( give_get_donor_donation_comments( $donor_id, $comment_args ) );
277
+	$comment = current(give_get_donor_donation_comments($donor_id, $comment_args));
278 278
 
279 279
 	return $comment;
280 280
 }
Please login to merge, or discard this patch.
includes/forms/functions.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
  *
156 156
  * Used to redirect a user back to the donation form if there are errors present.
157 157
  *
158
- * @param array|string $args
158
+ * @param string $args
159 159
  *
160 160
  * @access public
161 161
  * @since  1.0
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
  * @since  1.0
302 302
  * @since  1.8.16 Add security check
303 303
  *
304
- * @return bool
304
+ * @return false|null
305 305
  */
306 306
 function give_listen_for_failed_payments() {
307 307
 
@@ -1292,7 +1292,7 @@  discard block
 block discarded – undo
1292 1292
  * @since 2.2.0
1293 1293
  *
1294 1294
  * @param array|integer   $price_or_level_id Price level data.
1295
- * @param boolean|integer $form_id           Donation Form ID.
1295
+ * @param integer $form_id           Donation Form ID.
1296 1296
  *
1297 1297
  * @return boolean
1298 1298
  */
Please login to merge, or discard this patch.
Spacing   +264 added lines, -266 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,14 +23,14 @@  discard block
 block discarded – undo
23 23
 
24 24
 	global $typenow;
25 25
 
26
-	if ( $typenow != 'give_forms' ) {
26
+	if ($typenow != 'give_forms') {
27 27
 		return true;
28 28
 	}
29 29
 
30 30
 	return false;
31 31
 }
32 32
 
33
-add_filter( 'give_shortcode_button_condition', 'give_shortcode_button_condition' );
33
+add_filter('give_shortcode_button_condition', 'give_shortcode_button_condition');
34 34
 
35 35
 
36 36
 /**
@@ -40,11 +40,11 @@  discard block
 block discarded – undo
40 40
  *
41 41
  * @return int|false
42 42
  */
43
-function get_form_id_from_args( $args ) {
43
+function get_form_id_from_args($args) {
44 44
 
45
-	if ( isset( $args['form_id'] ) && $args['form_id'] != 0 ) {
45
+	if (isset($args['form_id']) && $args['form_id'] != 0) {
46 46
 
47
-		return intval( $args['form_id'] );
47
+		return intval($args['form_id']);
48 48
 	}
49 49
 
50 50
 	return false;
@@ -59,23 +59,23 @@  discard block
 block discarded – undo
59 59
  *
60 60
  * @return bool
61 61
  */
62
-function give_is_float_labels_enabled( $args ) {
62
+function give_is_float_labels_enabled($args) {
63 63
 
64 64
 	$float_labels = '';
65 65
 
66
-	if ( ! empty( $args['float_labels'] ) ) {
66
+	if ( ! empty($args['float_labels'])) {
67 67
 		$float_labels = $args['float_labels'];
68 68
 	}
69 69
 
70
-	if ( empty( $float_labels ) ) {
71
-		$float_labels = give_get_meta( $args['form_id'], '_give_form_floating_labels', true );
70
+	if (empty($float_labels)) {
71
+		$float_labels = give_get_meta($args['form_id'], '_give_form_floating_labels', true);
72 72
 	}
73 73
 
74
-	if ( empty( $float_labels ) || ( 'global' === $float_labels ) ) {
75
-		$float_labels = give_get_option( 'floatlabels', 'disabled' );
74
+	if (empty($float_labels) || ('global' === $float_labels)) {
75
+		$float_labels = give_get_option('floatlabels', 'disabled');
76 76
 	}
77 77
 
78
-	return give_is_setting_enabled( $float_labels );
78
+	return give_is_setting_enabled($float_labels);
79 79
 }
80 80
 
81 81
 /**
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 
92 92
 	$can_checkout = true;
93 93
 
94
-	return (bool) apply_filters( 'give_can_checkout', $can_checkout );
94
+	return (bool) apply_filters('give_can_checkout', $can_checkout);
95 95
 }
96 96
 
97 97
 /**
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
 function give_get_success_page_uri() {
106 106
 	$give_options = give_get_settings();
107 107
 
108
-	$success_page = isset( $give_options['success_page'] ) ? get_permalink( absint( $give_options['success_page'] ) ) : get_bloginfo( 'url' );
108
+	$success_page = isset($give_options['success_page']) ? get_permalink(absint($give_options['success_page'])) : get_bloginfo('url');
109 109
 
110
-	return apply_filters( 'give_get_success_page_uri', $success_page );
110
+	return apply_filters('give_get_success_page_uri', $success_page);
111 111
 }
112 112
 
113 113
 /**
@@ -119,9 +119,9 @@  discard block
 block discarded – undo
119 119
  */
120 120
 function give_is_success_page() {
121 121
 	$give_options    = give_get_settings();
122
-	$is_success_page = isset( $give_options['success_page'] ) ? is_page( $give_options['success_page'] ) : false;
122
+	$is_success_page = isset($give_options['success_page']) ? is_page($give_options['success_page']) : false;
123 123
 
124
-	return apply_filters( 'give_is_success_page', $is_success_page );
124
+	return apply_filters('give_is_success_page', $is_success_page);
125 125
 }
126 126
 
127 127
 /**
@@ -135,17 +135,17 @@  discard block
 block discarded – undo
135 135
  * @since       1.0
136 136
  * @return      void
137 137
  */
138
-function give_send_to_success_page( $query_string = null ) {
138
+function give_send_to_success_page($query_string = null) {
139 139
 
140 140
 	$redirect = give_get_success_page_uri();
141 141
 
142
-	if ( $query_string ) {
142
+	if ($query_string) {
143 143
 		$redirect .= $query_string;
144 144
 	}
145 145
 
146
-	$gateway = isset( $_REQUEST['give-gateway'] ) ? $_REQUEST['give-gateway'] : '';
146
+	$gateway = isset($_REQUEST['give-gateway']) ? $_REQUEST['give-gateway'] : '';
147 147
 
148
-	wp_redirect( apply_filters( 'give_success_page_redirect', $redirect, $gateway, $query_string ) );
148
+	wp_redirect(apply_filters('give_success_page_redirect', $redirect, $gateway, $query_string));
149 149
 	give_die();
150 150
 }
151 151
 
@@ -161,19 +161,19 @@  discard block
 block discarded – undo
161 161
  * @since  1.0
162 162
  * @return Void
163 163
  */
164
-function give_send_back_to_checkout( $args = array() ) {
164
+function give_send_back_to_checkout($args = array()) {
165 165
 
166
-	$url     = isset( $_POST['give-current-url'] ) ? sanitize_text_field( $_POST['give-current-url'] ) : '';
166
+	$url     = isset($_POST['give-current-url']) ? sanitize_text_field($_POST['give-current-url']) : '';
167 167
 	$form_id = 0;
168 168
 
169 169
 	// Set the form_id.
170
-	if ( isset( $_POST['give-form-id'] ) ) {
171
-		$form_id = sanitize_text_field( $_POST['give-form-id'] );
170
+	if (isset($_POST['give-form-id'])) {
171
+		$form_id = sanitize_text_field($_POST['give-form-id']);
172 172
 	}
173 173
 
174 174
 	// Need a URL to continue. If none, redirect back to single form.
175
-	if ( empty( $url ) ) {
176
-		wp_safe_redirect( get_permalink( $form_id ) );
175
+	if (empty($url)) {
176
+		wp_safe_redirect(get_permalink($form_id));
177 177
 		give_die();
178 178
 	}
179 179
 
@@ -182,41 +182,41 @@  discard block
 block discarded – undo
182 182
 	);
183 183
 
184 184
 	// Set the $level_id.
185
-	if ( isset( $_POST['give-price-id'] ) ) {
186
-		$defaults['level-id'] = sanitize_text_field( $_POST['give-price-id'] );
185
+	if (isset($_POST['give-price-id'])) {
186
+		$defaults['level-id'] = sanitize_text_field($_POST['give-price-id']);
187 187
 	}
188 188
 
189 189
 	// Check for backward compatibility.
190
-	if ( is_string( $args ) ) {
191
-		$args = str_replace( '?', '', $args );
190
+	if (is_string($args)) {
191
+		$args = str_replace('?', '', $args);
192 192
 	}
193 193
 
194
-	$args = wp_parse_args( $args, $defaults );
194
+	$args = wp_parse_args($args, $defaults);
195 195
 
196 196
 	// Merge URL query with $args to maintain third-party URL parameters after redirect.
197
-	$url_data = wp_parse_url( $url );
197
+	$url_data = wp_parse_url($url);
198 198
 
199 199
 	// Check if an array to prevent notices before parsing.
200
-	if ( isset( $url_data['query'] ) && ! empty( $url_data['query'] ) ) {
201
-		parse_str( $url_data['query'], $query );
200
+	if (isset($url_data['query']) && ! empty($url_data['query'])) {
201
+		parse_str($url_data['query'], $query);
202 202
 
203 203
 		// Precaution: don't allow any CC info.
204
-		unset( $query['card_number'] );
205
-		unset( $query['card_cvc'] );
204
+		unset($query['card_number']);
205
+		unset($query['card_cvc']);
206 206
 
207 207
 	} else {
208 208
 		// No $url_data so pass empty array.
209 209
 		$query = array();
210 210
 	}
211 211
 
212
-	$new_query        = array_merge( $args, $query );
213
-	$new_query_string = http_build_query( $new_query );
212
+	$new_query        = array_merge($args, $query);
213
+	$new_query_string = http_build_query($new_query);
214 214
 
215 215
 	// Assemble URL parts.
216
-	$redirect = home_url( '/' . $url_data['path'] . '?' . $new_query_string . '#give-form-' . $form_id . '-wrap' );
216
+	$redirect = home_url('/'.$url_data['path'].'?'.$new_query_string.'#give-form-'.$form_id.'-wrap');
217 217
 
218 218
 	// Redirect them.
219
-	wp_safe_redirect( apply_filters( 'give_send_back_to_checkout', $redirect, $args ) );
219
+	wp_safe_redirect(apply_filters('give_send_back_to_checkout', $redirect, $args));
220 220
 	give_die();
221 221
 
222 222
 }
@@ -232,16 +232,16 @@  discard block
 block discarded – undo
232 232
  * @since       1.0
233 233
  * @return      string
234 234
  */
235
-function give_get_success_page_url( $query_string = null ) {
235
+function give_get_success_page_url($query_string = null) {
236 236
 
237
-	$success_page = give_get_option( 'success_page', 0 );
238
-	$success_page = get_permalink( $success_page );
237
+	$success_page = give_get_option('success_page', 0);
238
+	$success_page = get_permalink($success_page);
239 239
 
240
-	if ( $query_string ) {
240
+	if ($query_string) {
241 241
 		$success_page .= $query_string;
242 242
 	}
243 243
 
244
-	return apply_filters( 'give_success_page_url', $success_page );
244
+	return apply_filters('give_success_page_url', $success_page);
245 245
 
246 246
 }
247 247
 
@@ -254,32 +254,31 @@  discard block
 block discarded – undo
254 254
  *
255 255
  * @return mixed Full URL to the Failed Donation Page, if present, home page if it doesn't exist.
256 256
  */
257
-function give_get_failed_transaction_uri( $extras = false ) {
257
+function give_get_failed_transaction_uri($extras = false) {
258 258
 	$give_options = give_get_settings();
259 259
 
260 260
 	// Remove question mark.
261
-	if ( 0 === strpos( $extras, '?' ) ) {
262
-		$extras = substr( $extras, 1 );
261
+	if (0 === strpos($extras, '?')) {
262
+		$extras = substr($extras, 1);
263 263
 	}
264 264
 
265
-	$extras_args = wp_parse_args( $extras );
265
+	$extras_args = wp_parse_args($extras);
266 266
 
267 267
 	// Set nonce if payment id exist in extra params.
268
-	if ( array_key_exists( 'payment-id', $extras_args ) ) {
269
-		$extras_args['_wpnonce'] = wp_create_nonce( "give-failed-donation-{$extras_args['payment-id']}" );
270
-		$extras                  = http_build_query( $extras_args );
268
+	if (array_key_exists('payment-id', $extras_args)) {
269
+		$extras_args['_wpnonce'] = wp_create_nonce("give-failed-donation-{$extras_args['payment-id']}");
270
+		$extras                  = http_build_query($extras_args);
271 271
 	}
272 272
 
273
-	$uri = ! empty( $give_options['failure_page'] ) ?
274
-		trailingslashit( get_permalink( $give_options['failure_page'] ) ) :
275
-		home_url();
273
+	$uri = ! empty($give_options['failure_page']) ?
274
+		trailingslashit(get_permalink($give_options['failure_page'])) : home_url();
276 275
 
277 276
 
278
-	if ( $extras ) {
277
+	if ($extras) {
279 278
 		$uri .= "?{$extras}";
280 279
 	}
281 280
 
282
-	return apply_filters( 'give_get_failed_transaction_uri', $uri );
281
+	return apply_filters('give_get_failed_transaction_uri', $uri);
283 282
 }
284 283
 
285 284
 /**
@@ -290,9 +289,9 @@  discard block
 block discarded – undo
290 289
  */
291 290
 function give_is_failed_transaction_page() {
292 291
 	$give_options = give_get_settings();
293
-	$ret          = isset( $give_options['failure_page'] ) ? is_page( $give_options['failure_page'] ) : false;
292
+	$ret          = isset($give_options['failure_page']) ? is_page($give_options['failure_page']) : false;
294 293
 
295
-	return apply_filters( 'give_is_failure_page', $ret );
294
+	return apply_filters('give_is_failure_page', $ret);
296 295
 }
297 296
 
298 297
 /**
@@ -305,25 +304,25 @@  discard block
 block discarded – undo
305 304
  */
306 305
 function give_listen_for_failed_payments() {
307 306
 
308
-	$failed_page = give_get_option( 'failure_page', 0 );
309
-	$payment_id  = ! empty( $_GET['payment-id'] ) ? absint( $_GET['payment-id'] ) : 0;
310
-	$nonce       = ! empty( $_GET['_wpnonce'] ) ? give_clean( $_GET['_wpnonce'] ) : false;
307
+	$failed_page = give_get_option('failure_page', 0);
308
+	$payment_id  = ! empty($_GET['payment-id']) ? absint($_GET['payment-id']) : 0;
309
+	$nonce       = ! empty($_GET['_wpnonce']) ? give_clean($_GET['_wpnonce']) : false;
311 310
 
312 311
 	// Bailout.
313
-	if ( ! $failed_page || ! is_page( $failed_page ) || ! $payment_id || ! $nonce ) {
312
+	if ( ! $failed_page || ! is_page($failed_page) || ! $payment_id || ! $nonce) {
314 313
 		return false;
315 314
 	}
316 315
 
317 316
 	// Security check.
318
-	if ( ! wp_verify_nonce( $nonce, "give-failed-donation-{$payment_id}" ) ) {
319
-		wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ) );
317
+	if ( ! wp_verify_nonce($nonce, "give-failed-donation-{$payment_id}")) {
318
+		wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'));
320 319
 	}
321 320
 
322 321
 	// Set payment status to failure
323
-	give_update_payment_status( $payment_id, 'failed' );
322
+	give_update_payment_status($payment_id, 'failed');
324 323
 }
325 324
 
326
-add_action( 'template_redirect', 'give_listen_for_failed_payments' );
325
+add_action('template_redirect', 'give_listen_for_failed_payments');
327 326
 
328 327
 /**
329 328
  * Retrieve the Donation History page URI
@@ -336,9 +335,9 @@  discard block
 block discarded – undo
336 335
 function give_get_history_page_uri() {
337 336
 	$give_options = give_get_settings();
338 337
 
339
-	$history_page = isset( $give_options['history_page'] ) ? get_permalink( absint( $give_options['history_page'] ) ) : get_bloginfo( 'url' );
338
+	$history_page = isset($give_options['history_page']) ? get_permalink(absint($give_options['history_page'])) : get_bloginfo('url');
340 339
 
341
-	return apply_filters( 'give_get_history_page_uri', $history_page );
340
+	return apply_filters('give_get_history_page_uri', $history_page);
342 341
 }
343 342
 
344 343
 /**
@@ -351,11 +350,11 @@  discard block
 block discarded – undo
351 350
  * @since       1.0
352 351
  * @return      bool
353 352
  */
354
-function give_field_is_required( $field = '', $form_id ) {
353
+function give_field_is_required($field = '', $form_id) {
355 354
 
356
-	$required_fields = give_get_required_fields( $form_id );
355
+	$required_fields = give_get_required_fields($form_id);
357 356
 
358
-	return array_key_exists( $field, $required_fields );
357
+	return array_key_exists($field, $required_fields);
359 358
 }
360 359
 
361 360
 /**
@@ -372,12 +371,12 @@  discard block
 block discarded – undo
372 371
  *
373 372
  * @return void
374 373
  */
375
-function give_record_donation_in_log( $give_form_id = 0, $payment_id, $price_id = false, $donation_date = null ) {
374
+function give_record_donation_in_log($give_form_id = 0, $payment_id, $price_id = false, $donation_date = null) {
376 375
 	$log_data = array(
377 376
 		'log_parent'   => $payment_id,
378 377
 		'log_type'     => 'sale',
379
-		'log_date'     => isset( $donation_date ) ? $donation_date : null,
380
-		'log_date_gmt' => isset( $donation_date ) ? $donation_date : null,
378
+		'log_date'     => isset($donation_date) ? $donation_date : null,
379
+		'log_date_gmt' => isset($donation_date) ? $donation_date : null,
381 380
 	);
382 381
 
383 382
 	$log_meta = array(
@@ -385,7 +384,7 @@  discard block
 block discarded – undo
385 384
 		'price_id' => (int) $price_id,
386 385
 	);
387 386
 
388
-	Give()->logs->insert_log( $log_data, $log_meta );
387
+	Give()->logs->insert_log($log_data, $log_meta);
389 388
 }
390 389
 
391 390
 
@@ -399,13 +398,13 @@  discard block
 block discarded – undo
399 398
  *
400 399
  * @return bool|int
401 400
  */
402
-function give_increase_donation_count( $form_id = 0, $quantity = 1 ) {
401
+function give_increase_donation_count($form_id = 0, $quantity = 1) {
403 402
 	$quantity = (int) $quantity;
404 403
 
405 404
 	/** @var \Give_Donate_Form $form */
406
-	$form = new Give_Donate_Form( $form_id );
405
+	$form = new Give_Donate_Form($form_id);
407 406
 
408
-	return $form->increase_sales( $quantity );
407
+	return $form->increase_sales($quantity);
409 408
 }
410 409
 
411 410
 /**
@@ -418,13 +417,13 @@  discard block
 block discarded – undo
418 417
  *
419 418
  * @return bool|int
420 419
  */
421
-function give_decrease_donation_count( $form_id = 0, $quantity = 1 ) {
420
+function give_decrease_donation_count($form_id = 0, $quantity = 1) {
422 421
 	$quantity = (int) $quantity;
423 422
 
424 423
 	/** @var \Give_Donate_Form $form */
425
-	$form = new Give_Donate_Form( $form_id );
424
+	$form = new Give_Donate_Form($form_id);
426 425
 
427
-	return $form->decrease_sales( $quantity );
426
+	return $form->decrease_sales($quantity);
428 427
 }
429 428
 
430 429
 /**
@@ -440,11 +439,11 @@  discard block
 block discarded – undo
440 439
  *
441 440
  * @return bool|int
442 441
  */
443
-function give_increase_earnings( $give_form_id = 0, $amount, $payment_id = 0 ) {
442
+function give_increase_earnings($give_form_id = 0, $amount, $payment_id = 0) {
444 443
 	/** @var \Give_Donate_Form $form */
445
-	$form = new Give_Donate_Form( $give_form_id );
444
+	$form = new Give_Donate_Form($give_form_id);
446 445
 
447
-	return $form->increase_earnings( $amount, $payment_id );
446
+	return $form->increase_earnings($amount, $payment_id);
448 447
 }
449 448
 
450 449
 /**
@@ -462,11 +461,11 @@  discard block
 block discarded – undo
462 461
  *
463 462
  * @return bool|int
464 463
  */
465
-function give_decrease_form_earnings( $form_id = 0, $amount, $payment_id = 0 ) {
464
+function give_decrease_form_earnings($form_id = 0, $amount, $payment_id = 0) {
466 465
 	/** @var \Give_Donate_Form $form */
467
-	$form = new Give_Donate_Form( $form_id );
466
+	$form = new Give_Donate_Form($form_id);
468 467
 
469
-	return $form->decrease_earnings( $amount, $payment_id );
468
+	return $form->decrease_earnings($amount, $payment_id);
470 469
 }
471 470
 
472 471
 
@@ -479,15 +478,15 @@  discard block
 block discarded – undo
479 478
  *
480 479
  * @return int $earnings Earnings for a certain form
481 480
  */
482
-function give_get_form_earnings_stats( $form_id = 0 ) {
483
-	$give_form = new Give_Donate_Form( $form_id );
481
+function give_get_form_earnings_stats($form_id = 0) {
482
+	$give_form = new Give_Donate_Form($form_id);
484 483
 
485 484
 	/**
486 485
 	 * Filter the form earnings
487 486
 	 *
488 487
 	 * @since 1.8.17
489 488
 	 */
490
-	return apply_filters( 'give_get_form_earnings_stats', $give_form->earnings, $form_id, $give_form );
489
+	return apply_filters('give_get_form_earnings_stats', $give_form->earnings, $form_id, $give_form);
491 490
 }
492 491
 
493 492
 
@@ -500,8 +499,8 @@  discard block
 block discarded – undo
500 499
  *
501 500
  * @return int $sales Amount of sales for a certain form
502 501
  */
503
-function give_get_form_sales_stats( $give_form_id = 0 ) {
504
-	$give_form = new Give_Donate_Form( $give_form_id );
502
+function give_get_form_sales_stats($give_form_id = 0) {
503
+	$give_form = new Give_Donate_Form($give_form_id);
505 504
 
506 505
 	return $give_form->sales;
507 506
 }
@@ -516,16 +515,16 @@  discard block
 block discarded – undo
516 515
  *
517 516
  * @return float $sales Average monthly sales
518 517
  */
519
-function give_get_average_monthly_form_sales( $form_id = 0 ) {
520
-	$sales        = give_get_form_sales_stats( $form_id );
521
-	$release_date = get_post_field( 'post_date', $form_id );
518
+function give_get_average_monthly_form_sales($form_id = 0) {
519
+	$sales        = give_get_form_sales_stats($form_id);
520
+	$release_date = get_post_field('post_date', $form_id);
522 521
 
523
-	$diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) );
522
+	$diff = abs(current_time('timestamp') - strtotime($release_date));
524 523
 
525
-	$months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication
524
+	$months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication
526 525
 
527
-	if ( $months > 0 ) {
528
-		$sales = ( $sales / $months );
526
+	if ($months > 0) {
527
+		$sales = ($sales / $months);
529 528
 	}
530 529
 
531 530
 	return $sales;
@@ -541,16 +540,16 @@  discard block
 block discarded – undo
541 540
  *
542 541
  * @return float $earnings Average monthly earnings
543 542
  */
544
-function give_get_average_monthly_form_earnings( $form_id = 0 ) {
545
-	$earnings     = give_get_form_earnings_stats( $form_id );
546
-	$release_date = get_post_field( 'post_date', $form_id );
543
+function give_get_average_monthly_form_earnings($form_id = 0) {
544
+	$earnings     = give_get_form_earnings_stats($form_id);
545
+	$release_date = get_post_field('post_date', $form_id);
547 546
 
548
-	$diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) );
547
+	$diff = abs(current_time('timestamp') - strtotime($release_date));
549 548
 
550
-	$months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication
549
+	$months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication
551 550
 
552
-	if ( $months > 0 ) {
553
-		$earnings = ( $earnings / $months );
551
+	if ($months > 0) {
552
+		$earnings = ($earnings / $months);
554 553
 	}
555 554
 
556 555
 	return $earnings < 0 ? 0 : $earnings;
@@ -571,34 +570,34 @@  discard block
 block discarded – undo
571 570
  *
572 571
  * @return string $price_name Name of the price option
573 572
  */
574
-function give_get_price_option_name( $form_id = 0, $price_id = 0, $payment_id = 0, $use_fallback = true ) {
573
+function give_get_price_option_name($form_id = 0, $price_id = 0, $payment_id = 0, $use_fallback = true) {
575 574
 
576
-	$prices     = give_get_variable_prices( $form_id );
575
+	$prices     = give_get_variable_prices($form_id);
577 576
 	$price_name = '';
578 577
 
579
-	if ( false === $prices ) {
578
+	if (false === $prices) {
580 579
 		return $price_name;
581 580
 	}
582 581
 
583
-	foreach ( $prices as $price ) {
582
+	foreach ($prices as $price) {
584 583
 
585
-		if ( intval( $price['_give_id']['level_id'] ) === intval( $price_id ) ) {
584
+		if (intval($price['_give_id']['level_id']) === intval($price_id)) {
586 585
 
587
-			$price_text     = isset( $price['_give_text'] ) ? $price['_give_text'] : '';
586
+			$price_text     = isset($price['_give_text']) ? $price['_give_text'] : '';
588 587
 			$price_fallback = $use_fallback ?
589 588
 				give_currency_filter(
590 589
 					give_format_amount(
591 590
 						$price['_give_amount'],
592
-						array( 'sanitize' => false )
591
+						array('sanitize' => false)
593 592
 					),
594
-					array( 'decode_currency' => true )
593
+					array('decode_currency' => true)
595 594
 				) : '';
596
-			$price_name     = ! empty( $price_text ) ? $price_text : $price_fallback;
595
+			$price_name = ! empty($price_text) ? $price_text : $price_fallback;
597 596
 
598 597
 		}
599 598
 	}
600 599
 
601
-	return apply_filters( 'give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id );
600
+	return apply_filters('give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id);
602 601
 }
603 602
 
604 603
 
@@ -612,25 +611,25 @@  discard block
 block discarded – undo
612 611
  *
613 612
  * @return string $range A fully formatted price range
614 613
  */
615
-function give_price_range( $form_id = 0, $formatted = true ) {
616
-	$low        = give_get_lowest_price_option( $form_id );
617
-	$high       = give_get_highest_price_option( $form_id );
618
-	$order_type = ! empty( $_REQUEST['order'] ) ? $_REQUEST['order'] : 'asc';
614
+function give_price_range($form_id = 0, $formatted = true) {
615
+	$low        = give_get_lowest_price_option($form_id);
616
+	$high       = give_get_highest_price_option($form_id);
617
+	$order_type = ! empty($_REQUEST['order']) ? $_REQUEST['order'] : 'asc';
619 618
 
620 619
 	$range = sprintf(
621 620
 		'<span class="give_price_range_%1$s">%2$s</span><span class="give_price_range_sep">&nbsp;&ndash;&nbsp;</span><span class="give_price_range_%3$s">%4$s</span>',
622 621
 		'asc' === $order_type ? 'low' : 'high',
623
-		'asc' === $order_type ? give_currency_filter( give_format_amount( $low, array( 'sanitize' => false ) ) ) : give_currency_filter( give_format_amount( $high, array( 'sanitize' => false ) ) ),
622
+		'asc' === $order_type ? give_currency_filter(give_format_amount($low, array('sanitize' => false))) : give_currency_filter(give_format_amount($high, array('sanitize' => false))),
624 623
 		'asc' === $order_type ? 'high' : 'low',
625
-		'asc' === $order_type ? give_currency_filter( give_format_amount( $high, array( 'sanitize' => false ) ) ) : give_currency_filter( give_format_amount( $low, array( 'sanitize' => false ) ) )
624
+		'asc' === $order_type ? give_currency_filter(give_format_amount($high, array('sanitize' => false))) : give_currency_filter(give_format_amount($low, array('sanitize' => false)))
626 625
 
627 626
 	);
628 627
 
629
-	if ( ! $formatted ) {
630
-		$range = wp_strip_all_tags( $range );
628
+	if ( ! $formatted) {
629
+		$range = wp_strip_all_tags($range);
631 630
 	}
632 631
 
633
-	return apply_filters( 'give_price_range', $range, $form_id, $low, $high );
632
+	return apply_filters('give_price_range', $range, $form_id, $low, $high);
634 633
 }
635 634
 
636 635
 
@@ -645,35 +644,35 @@  discard block
 block discarded – undo
645 644
  *
646 645
  * @return int ID of the lowest price
647 646
  */
648
-function give_get_lowest_price_id( $form_id = 0 ) {
647
+function give_get_lowest_price_id($form_id = 0) {
649 648
 
650
-	if ( empty( $form_id ) ) {
649
+	if (empty($form_id)) {
651 650
 		$form_id = get_the_ID();
652 651
 	}
653 652
 
654
-	if ( ! give_has_variable_prices( $form_id ) ) {
655
-		return give_get_form_price( $form_id );
653
+	if ( ! give_has_variable_prices($form_id)) {
654
+		return give_get_form_price($form_id);
656 655
 	}
657 656
 
658
-	$prices = give_get_variable_prices( $form_id );
657
+	$prices = give_get_variable_prices($form_id);
659 658
 
660 659
 	$min = $min_id = 0;
661 660
 
662
-	if ( ! empty( $prices ) ) {
661
+	if ( ! empty($prices)) {
663 662
 
664
-		foreach ( $prices as $key => $price ) {
663
+		foreach ($prices as $key => $price) {
665 664
 
666
-			if ( empty( $price['_give_amount'] ) ) {
665
+			if (empty($price['_give_amount'])) {
667 666
 				continue;
668 667
 			}
669 668
 
670
-			if ( ! isset( $min ) ) {
669
+			if ( ! isset($min)) {
671 670
 				$min = $price['_give_amount'];
672 671
 			} else {
673
-				$min = min( $min, $price['_give_amount'] );
672
+				$min = min($min, $price['_give_amount']);
674 673
 			}
675 674
 
676
-			if ( $price['_give_amount'] == $min ) {
675
+			if ($price['_give_amount'] == $min) {
677 676
 				$min_id = $price['_give_id']['level_id'];
678 677
 			}
679 678
 		}
@@ -691,22 +690,22 @@  discard block
 block discarded – undo
691 690
  *
692 691
  * @return float Amount of the lowest price
693 692
  */
694
-function give_get_lowest_price_option( $form_id = 0 ) {
695
-	if ( empty( $form_id ) ) {
693
+function give_get_lowest_price_option($form_id = 0) {
694
+	if (empty($form_id)) {
696 695
 		$form_id = get_the_ID();
697 696
 	}
698 697
 
699
-	if ( ! give_has_variable_prices( $form_id ) ) {
700
-		return give_get_form_price( $form_id );
698
+	if ( ! give_has_variable_prices($form_id)) {
699
+		return give_get_form_price($form_id);
701 700
 	}
702 701
 
703
-	if ( ! ( $low = get_post_meta( $form_id, '_give_levels_minimum_amount', true ) ) ) {
702
+	if ( ! ($low = get_post_meta($form_id, '_give_levels_minimum_amount', true))) {
704 703
 		// Backward compatibility.
705
-		$prices = wp_list_pluck( give_get_variable_prices( $form_id ), '_give_amount' );
706
-		$low    = ! empty( $prices ) ? min( $prices ) : 0;
704
+		$prices = wp_list_pluck(give_get_variable_prices($form_id), '_give_amount');
705
+		$low    = ! empty($prices) ? min($prices) : 0;
707 706
 	}
708 707
 
709
-	return give_maybe_sanitize_amount( $low );
708
+	return give_maybe_sanitize_amount($low);
710 709
 }
711 710
 
712 711
 /**
@@ -718,23 +717,23 @@  discard block
 block discarded – undo
718 717
  *
719 718
  * @return float Amount of the highest price
720 719
  */
721
-function give_get_highest_price_option( $form_id = 0 ) {
720
+function give_get_highest_price_option($form_id = 0) {
722 721
 
723
-	if ( empty( $form_id ) ) {
722
+	if (empty($form_id)) {
724 723
 		$form_id = get_the_ID();
725 724
 	}
726 725
 
727
-	if ( ! give_has_variable_prices( $form_id ) ) {
728
-		return give_get_form_price( $form_id );
726
+	if ( ! give_has_variable_prices($form_id)) {
727
+		return give_get_form_price($form_id);
729 728
 	}
730 729
 
731
-	if ( ! ( $high = get_post_meta( $form_id, '_give_levels_maximum_amount', true ) ) ) {
730
+	if ( ! ($high = get_post_meta($form_id, '_give_levels_maximum_amount', true))) {
732 731
 		// Backward compatibility.
733
-		$prices = wp_list_pluck( give_get_variable_prices( $form_id ), '_give_amount' );
734
-		$high   = ! empty( $prices ) ? max( $prices ) : 0;
732
+		$prices = wp_list_pluck(give_get_variable_prices($form_id), '_give_amount');
733
+		$high   = ! empty($prices) ? max($prices) : 0;
735 734
 	}
736 735
 
737
-	return give_maybe_sanitize_amount( $high );
736
+	return give_maybe_sanitize_amount($high);
738 737
 }
739 738
 
740 739
 /**
@@ -746,15 +745,15 @@  discard block
 block discarded – undo
746 745
  *
747 746
  * @return mixed string|int Price of the form
748 747
  */
749
-function give_get_form_price( $form_id = 0 ) {
748
+function give_get_form_price($form_id = 0) {
750 749
 
751
-	if ( empty( $form_id ) ) {
750
+	if (empty($form_id)) {
752 751
 		return false;
753 752
 	}
754 753
 
755
-	$form = new Give_Donate_Form( $form_id );
754
+	$form = new Give_Donate_Form($form_id);
756 755
 
757
-	return $form->__get( 'price' );
756
+	return $form->__get('price');
758 757
 }
759 758
 
760 759
 /**
@@ -766,13 +765,13 @@  discard block
 block discarded – undo
766 765
  *
767 766
  * @return mixed string|int Minimum price of the form
768 767
  */
769
-function give_get_form_minimum_price( $form_id = 0 ) {
768
+function give_get_form_minimum_price($form_id = 0) {
770 769
 
771
-	if ( empty( $form_id ) ) {
770
+	if (empty($form_id)) {
772 771
 		return false;
773 772
 	}
774 773
 
775
-	$form = new Give_Donate_Form( $form_id );
774
+	$form = new Give_Donate_Form($form_id);
776 775
 
777 776
 	return $form->get_minimum_price();
778 777
 
@@ -787,13 +786,13 @@  discard block
 block discarded – undo
787 786
  *
788 787
  * @return bool|float
789 788
  */
790
-function give_get_form_maximum_price( $form_id = 0 ) {
789
+function give_get_form_maximum_price($form_id = 0) {
791 790
 
792
-	if ( empty( $form_id ) ) {
791
+	if (empty($form_id)) {
793 792
 		return false;
794 793
 	}
795 794
 
796
-	$form = new Give_Donate_Form( $form_id );
795
+	$form = new Give_Donate_Form($form_id);
797 796
 
798 797
 	return $form->get_maximum_price();
799 798
 }
@@ -809,48 +808,48 @@  discard block
 block discarded – undo
809 808
  *
810 809
  * @return int $formatted_price
811 810
  */
812
-function give_price( $form_id = 0, $echo = true, $price_id = false ) {
811
+function give_price($form_id = 0, $echo = true, $price_id = false) {
813 812
 	$price = 0;
814 813
 
815
-	if ( empty( $form_id ) ) {
814
+	if (empty($form_id)) {
816 815
 		$form_id = get_the_ID();
817 816
 	}
818 817
 
819
-	if ( give_has_variable_prices( $form_id ) ) {
818
+	if (give_has_variable_prices($form_id)) {
820 819
 
821
-		$prices = give_get_variable_prices( $form_id );
820
+		$prices = give_get_variable_prices($form_id);
822 821
 
823
-		if ( false !== $price_id ) {
822
+		if (false !== $price_id) {
824 823
 
825 824
 			// loop through multi-prices to see which is default
826
-			foreach ( $prices as $price ) {
825
+			foreach ($prices as $price) {
827 826
 				// this is the default price
828
-				if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) {
827
+				if (isset($price['_give_default']) && $price['_give_default'] === 'default') {
829 828
 					$price = (float) $price['_give_amount'];
830 829
 				};
831 830
 			}
832 831
 		} else {
833 832
 
834
-			$price = give_get_lowest_price_option( $form_id );
833
+			$price = give_get_lowest_price_option($form_id);
835 834
 		}
836 835
 	} else {
837 836
 
838
-		$price = give_get_form_price( $form_id );
837
+		$price = give_get_form_price($form_id);
839 838
 	}
840 839
 
841
-	$price           = apply_filters( 'give_form_price', give_maybe_sanitize_amount( $price ), $form_id );
842
-	$formatted_price = '<span class="give_price" id="give_price_' . $form_id . '">' . $price . '</span>';
843
-	$formatted_price = apply_filters( 'give_form_price_after_html', $formatted_price, $form_id, $price );
840
+	$price           = apply_filters('give_form_price', give_maybe_sanitize_amount($price), $form_id);
841
+	$formatted_price = '<span class="give_price" id="give_price_'.$form_id.'">'.$price.'</span>';
842
+	$formatted_price = apply_filters('give_form_price_after_html', $formatted_price, $form_id, $price);
844 843
 
845
-	if ( $echo ) {
844
+	if ($echo) {
846 845
 		echo $formatted_price;
847 846
 	} else {
848 847
 		return $formatted_price;
849 848
 	}
850 849
 }
851 850
 
852
-add_filter( 'give_form_price', 'give_format_amount', 10 );
853
-add_filter( 'give_form_price', 'give_currency_filter', 20 );
851
+add_filter('give_form_price', 'give_format_amount', 10);
852
+add_filter('give_form_price', 'give_currency_filter', 20);
854 853
 
855 854
 
856 855
 /**
@@ -863,19 +862,19 @@  discard block
 block discarded – undo
863 862
  *
864 863
  * @return float $amount Amount of the price option
865 864
  */
866
-function give_get_price_option_amount( $form_id = 0, $price_id = 0 ) {
867
-	$prices = give_get_variable_prices( $form_id );
865
+function give_get_price_option_amount($form_id = 0, $price_id = 0) {
866
+	$prices = give_get_variable_prices($form_id);
868 867
 
869 868
 	$amount = 0.00;
870 869
 
871
-	foreach ( $prices as $price ) {
872
-		if ( isset( $price['_give_id']['level_id'] ) && $price['_give_id']['level_id'] == $price_id ) {
873
-			$amount = isset( $price['_give_amount'] ) ? $price['_give_amount'] : 0.00;
870
+	foreach ($prices as $price) {
871
+		if (isset($price['_give_id']['level_id']) && $price['_give_id']['level_id'] == $price_id) {
872
+			$amount = isset($price['_give_amount']) ? $price['_give_amount'] : 0.00;
874 873
 			break;
875 874
 		};
876 875
 	}
877 876
 
878
-	return apply_filters( 'give_get_price_option_amount', give_maybe_sanitize_amount( $amount ), $form_id, $price_id );
877
+	return apply_filters('give_get_price_option_amount', give_maybe_sanitize_amount($amount), $form_id, $price_id);
879 878
 }
880 879
 
881 880
 /**
@@ -887,13 +886,13 @@  discard block
 block discarded – undo
887 886
  *
888 887
  * @return mixed string|int Goal of the form
889 888
  */
890
-function give_get_form_goal( $form_id = 0 ) {
889
+function give_get_form_goal($form_id = 0) {
891 890
 
892
-	if ( empty( $form_id ) ) {
891
+	if (empty($form_id)) {
893 892
 		return false;
894 893
 	}
895 894
 
896
-	$form = new Give_Donate_Form( $form_id );
895
+	$form = new Give_Donate_Form($form_id);
897 896
 
898 897
 	return $form->goal;
899 898
 
@@ -908,13 +907,13 @@  discard block
 block discarded – undo
908 907
  *
909 908
  * @return mixed string|int Goal of the form
910 909
  */
911
-function give_get_form_goal_format( $form_id = 0 ) {
910
+function give_get_form_goal_format($form_id = 0) {
912 911
 
913
-	if ( empty( $form_id ) ) {
912
+	if (empty($form_id)) {
914 913
 		return false;
915 914
 	}
916 915
 
917
-	return give_get_meta( $form_id, '_give_goal_format', true );
916
+	return give_get_meta($form_id, '_give_goal_format', true);
918 917
 
919 918
 }
920 919
 
@@ -928,19 +927,19 @@  discard block
 block discarded – undo
928 927
  *
929 928
  * @return string $formatted_goal
930 929
  */
931
-function give_goal( $form_id = 0, $echo = true ) {
930
+function give_goal($form_id = 0, $echo = true) {
932 931
 
933
-	if ( empty( $form_id ) ) {
932
+	if (empty($form_id)) {
934 933
 		$form_id = get_the_ID();
935 934
 	}
936 935
 
937
-	$goal        = give_get_form_goal( $form_id );
938
-	$goal_format = give_get_form_goal_format( $form_id );
936
+	$goal        = give_get_form_goal($form_id);
937
+	$goal_format = give_get_form_goal_format($form_id);
939 938
 
940
-	if ( 'donation' === $goal_format ) {
939
+	if ('donation' === $goal_format) {
941 940
 		$goal = "{$goal} donations";
942 941
 	} else {
943
-		$goal = apply_filters( 'give_form_goal', give_maybe_sanitize_amount( $goal ), $form_id );
942
+		$goal = apply_filters('give_form_goal', give_maybe_sanitize_amount($goal), $form_id);
944 943
 	}
945 944
 
946 945
 	$formatted_goal = sprintf(
@@ -948,17 +947,17 @@  discard block
 block discarded – undo
948 947
 		$form_id,
949 948
 		$goal
950 949
 	);
951
-	$formatted_goal = apply_filters( 'give_form_price_after_html', $formatted_goal, $form_id, $goal );
950
+	$formatted_goal = apply_filters('give_form_price_after_html', $formatted_goal, $form_id, $goal);
952 951
 
953
-	if ( $echo ) {
952
+	if ($echo) {
954 953
 		echo $formatted_goal;
955 954
 	} else {
956 955
 		return $formatted_goal;
957 956
 	}
958 957
 }
959 958
 
960
-add_filter( 'give_form_goal', 'give_format_amount', 10 );
961
-add_filter( 'give_form_goal', 'give_currency_filter', 20 );
959
+add_filter('give_form_goal', 'give_format_amount', 10);
960
+add_filter('give_form_goal', 'give_currency_filter', 20);
962 961
 
963 962
 
964 963
 /**
@@ -970,15 +969,15 @@  discard block
 block discarded – undo
970 969
  *
971 970
  * @return bool  $ret Whether or not the logged_in_only setting is set
972 971
  */
973
-function give_logged_in_only( $form_id ) {
972
+function give_logged_in_only($form_id) {
974 973
 	// If _give_logged_in_only is set to enable then guest can donate from that specific form.
975 974
 	// Otherwise it is member only donation form.
976
-	$val = give_get_meta( $form_id, '_give_logged_in_only', true );
977
-	$val = ! empty( $val ) ? $val : 'enabled';
975
+	$val = give_get_meta($form_id, '_give_logged_in_only', true);
976
+	$val = ! empty($val) ? $val : 'enabled';
978 977
 
979
-	$ret = ! give_is_setting_enabled( $val );
978
+	$ret = ! give_is_setting_enabled($val);
980 979
 
981
-	return (bool) apply_filters( 'give_logged_in_only', $ret, $form_id );
980
+	return (bool) apply_filters('give_logged_in_only', $ret, $form_id);
982 981
 }
983 982
 
984 983
 
@@ -991,11 +990,11 @@  discard block
 block discarded – undo
991 990
  *
992 991
  * @return string
993 992
  */
994
-function give_show_login_register_option( $form_id ) {
993
+function give_show_login_register_option($form_id) {
995 994
 
996
-	$show_register_form = give_get_meta( $form_id, '_give_show_register_form', true );
995
+	$show_register_form = give_get_meta($form_id, '_give_show_register_form', true);
997 996
 
998
-	return apply_filters( 'give_show_register_form', $show_register_form, $form_id );
997
+	return apply_filters('give_show_register_form', $show_register_form, $form_id);
999 998
 
1000 999
 }
1001 1000
 
@@ -1011,12 +1010,12 @@  discard block
 block discarded – undo
1011 1010
  *
1012 1011
  * @return array
1013 1012
  */
1014
-function _give_get_prefill_form_field_values( $form_id ) {
1013
+function _give_get_prefill_form_field_values($form_id) {
1015 1014
 	$logged_in_donor_info = array();
1016 1015
 
1017
-	if ( is_user_logged_in() ) :
1018
-		$donor_data    = get_userdata( get_current_user_id() );
1019
-		$donor         = new Give_Donor( get_current_user_id(), true );
1016
+	if (is_user_logged_in()) :
1017
+		$donor_data    = get_userdata(get_current_user_id());
1018
+		$donor         = new Give_Donor(get_current_user_id(), true);
1020 1019
 		$donor_address = $donor->get_donor_address();
1021 1020
 		$company_name  = $donor->get_company_name();
1022 1021
 
@@ -1028,7 +1027,7 @@  discard block
 block discarded – undo
1028 1027
 			'give_last'       => $donor_data->last_name,
1029 1028
 
1030 1029
 			// Title Prefix.
1031
-			'give_title'      => $donor->get_meta( '_give_donor_title_prefix', true ),
1030
+			'give_title'      => $donor->get_meta('_give_donor_title_prefix', true),
1032 1031
 
1033 1032
 			// Company name.
1034 1033
 			'company_name'    => $company_name,
@@ -1058,23 +1057,23 @@  discard block
 block discarded – undo
1058 1057
 
1059 1058
 	// Bailout: Auto fill form field values only form form which donor is donating.
1060 1059
 	if (
1061
-		empty( $_GET['form-id'] )
1060
+		empty($_GET['form-id'])
1062 1061
 		|| ! $form_id
1063
-		|| ( $form_id !== absint( $_GET['form-id'] ) )
1062
+		|| ($form_id !== absint($_GET['form-id']))
1064 1063
 	) {
1065 1064
 		return $logged_in_donor_info;
1066 1065
 	}
1067 1066
 
1068 1067
 	// Get purchase data.
1069
-	$give_purchase_data = Give()->session->get( 'give_purchase' );
1068
+	$give_purchase_data = Give()->session->get('give_purchase');
1070 1069
 
1071 1070
 	// Get donor info from form data.
1072
-	$give_donor_info_in_session = empty( $give_purchase_data['post_data'] )
1071
+	$give_donor_info_in_session = empty($give_purchase_data['post_data'])
1073 1072
 		? array()
1074 1073
 		: $give_purchase_data['post_data'];
1075 1074
 
1076 1075
 	// Output.
1077
-	return wp_parse_args( $give_donor_info_in_session, $logged_in_donor_info );
1076
+	return wp_parse_args($give_donor_info_in_session, $logged_in_donor_info);
1078 1077
 }
1079 1078
 
1080 1079
 /**
@@ -1087,13 +1086,13 @@  discard block
 block discarded – undo
1087 1086
  *
1088 1087
  * @return int
1089 1088
  */
1090
-function give_get_form_donor_count( $form_id, $args = array() ) {
1089
+function give_get_form_donor_count($form_id, $args = array()) {
1091 1090
 	global $wpdb;
1092 1091
 
1093
-	$cache_key   = Give_Cache::get_key( "form_donor_count_{$form_id}", $args, false );
1094
-	$donor_count = absint( Give_Cache::get_db_query( $cache_key ) );
1092
+	$cache_key   = Give_Cache::get_key("form_donor_count_{$form_id}", $args, false);
1093
+	$donor_count = absint(Give_Cache::get_db_query($cache_key));
1095 1094
 
1096
-	if ( $form_id && ! $donor_count ) {
1095
+	if ($form_id && ! $donor_count) {
1097 1096
 		// Set arguments.
1098 1097
 		$args = wp_parse_args(
1099 1098
 			$args,
@@ -1103,7 +1102,7 @@  discard block
 block discarded – undo
1103 1102
 		);
1104 1103
 
1105 1104
 		$donation_meta_table  = Give()->payment_meta->table_name;
1106
-		$donation_id_col_name = Give()->payment_meta->get_meta_type() . '_id';
1105
+		$donation_id_col_name = Give()->payment_meta->get_meta_type().'_id';
1107 1106
 
1108 1107
 		$distinct = $args['unique'] ? 'DISTINCT meta_value' : 'meta_value';
1109 1108
 
@@ -1128,7 +1127,7 @@  discard block
 block discarded – undo
1128 1127
 			'publish'
1129 1128
 		);
1130 1129
 
1131
-		$donor_count = absint( $wpdb->get_var( $query ) );
1130
+		$donor_count = absint($wpdb->get_var($query));
1132 1131
 	}
1133 1132
 
1134 1133
 
@@ -1137,7 +1136,7 @@  discard block
 block discarded – undo
1137 1136
 	 *
1138 1137
 	 * @since 2.1.0
1139 1138
 	 */
1140
-	$donor_count = apply_filters( 'give_get_form_donor_count', $donor_count, $form_id, $args );
1139
+	$donor_count = apply_filters('give_get_form_donor_count', $donor_count, $form_id, $args);
1141 1140
 
1142 1141
 	return $donor_count;
1143 1142
 }
@@ -1151,33 +1150,33 @@  discard block
 block discarded – undo
1151 1150
  *
1152 1151
  * @return void
1153 1152
  */
1154
-function give_set_form_closed_status( $form_id ) {
1153
+function give_set_form_closed_status($form_id) {
1155 1154
 
1156 1155
 	// Bailout.
1157
-	if ( empty( $form_id ) ) {
1156
+	if (empty($form_id)) {
1158 1157
 		return;
1159 1158
 	}
1160 1159
 
1161 1160
 	$open_form       = false;
1162
-	$is_goal_enabled = give_is_setting_enabled( give_get_meta( $form_id, '_give_goal_option', true, 'disabled' ) );
1161
+	$is_goal_enabled = give_is_setting_enabled(give_get_meta($form_id, '_give_goal_option', true, 'disabled'));
1163 1162
 
1164 1163
 	// Proceed, if the form goal is enabled.
1165
-	if ( $is_goal_enabled ) {
1164
+	if ($is_goal_enabled) {
1166 1165
 
1167
-		$close_form_when_goal_achieved = give_is_setting_enabled( give_get_meta( $form_id, '_give_close_form_when_goal_achieved', true, 'disabled' ) );
1166
+		$close_form_when_goal_achieved = give_is_setting_enabled(give_get_meta($form_id, '_give_close_form_when_goal_achieved', true, 'disabled'));
1168 1167
 
1169 1168
 		// Proceed, if close form when goal achieved option is enabled.
1170
-		if ( $close_form_when_goal_achieved ) {
1169
+		if ($close_form_when_goal_achieved) {
1171 1170
 
1172
-			$form                = new Give_Donate_Form( $form_id );
1173
-			$goal_progress_stats = give_goal_progress_stats( $form );
1171
+			$form                = new Give_Donate_Form($form_id);
1172
+			$goal_progress_stats = give_goal_progress_stats($form);
1174 1173
 
1175 1174
 			// Verify whether the form is closed or not after processing data.
1176 1175
 			$closed = $goal_progress_stats['raw_goal'] <= $goal_progress_stats['raw_actual'];
1177 1176
 
1178 1177
 			// Update form meta if verified that the form is closed.
1179
-			if ( $closed ) {
1180
-				give_update_meta( $form_id, '_give_form_status', 'closed' );
1178
+			if ($closed) {
1179
+				give_update_meta($form_id, '_give_form_status', 'closed');
1181 1180
 			} else {
1182 1181
 				$open_form = true;
1183 1182
 			}
@@ -1189,8 +1188,8 @@  discard block
 block discarded – undo
1189 1188
 	}
1190 1189
 
1191 1190
 	// If $open_form is true, then update form status to open.
1192
-	if ( $open_form ) {
1193
-		give_update_meta( $form_id, '_give_form_status', 'open' );
1191
+	if ($open_form) {
1192
+		give_update_meta($form_id, '_give_form_status', 'open');
1194 1193
 	}
1195 1194
 }
1196 1195
 
@@ -1203,32 +1202,31 @@  discard block
 block discarded – undo
1203 1202
  *
1204 1203
  * @return string
1205 1204
  */
1206
-function give_admin_form_goal_stats( $form_id ) {
1205
+function give_admin_form_goal_stats($form_id) {
1207 1206
 
1208 1207
 	$html             = '';
1209
-	$goal_stats       = give_goal_progress_stats( $form_id );
1210
-	$percent_complete = round( ( $goal_stats['raw_actual'] / $goal_stats['raw_goal'] ), 3 ) * 100;
1208
+	$goal_stats       = give_goal_progress_stats($form_id);
1209
+	$percent_complete = round(($goal_stats['raw_actual'] / $goal_stats['raw_goal']), 3) * 100;
1211 1210
 
1212 1211
 	$html .= sprintf(
1213 1212
 		'<div class="give-admin-progress-bar" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="%1$s">
1214 1213
 <span style="width:%1$s%%;"></span>
1215 1214
 </div>',
1216
-		esc_attr( $goal_stats['progress'] )
1215
+		esc_attr($goal_stats['progress'])
1217 1216
 	);
1218 1217
 
1219 1218
 	$html .= sprintf(
1220
-		( 'percentage' !== $goal_stats['format'] ) ?
1221
-			'<div class="give-goal-text"><span>%1$s</span> %2$s <a href="%3$s">%4$s</a> %5$s ' :
1222
-			'<div class="give-goal-text"><a href="%3$s">%1$s </a>',
1223
-		( 'percentage' !== $goal_stats['format'] ) ? $goal_stats['actual'] : $percent_complete . '%',
1224
-		( 'percentage' !== $goal_stats['format'] ) ? __( 'of', 'give' ) : '',
1225
-		esc_url( admin_url( "post.php?post={$form_id}&action=edit&give_tab=donation_goal_options" ) ),
1219
+		('percentage' !== $goal_stats['format']) ?
1220
+			'<div class="give-goal-text"><span>%1$s</span> %2$s <a href="%3$s">%4$s</a> %5$s ' : '<div class="give-goal-text"><a href="%3$s">%1$s </a>',
1221
+		('percentage' !== $goal_stats['format']) ? $goal_stats['actual'] : $percent_complete.'%',
1222
+		('percentage' !== $goal_stats['format']) ? __('of', 'give') : '',
1223
+		esc_url(admin_url("post.php?post={$form_id}&action=edit&give_tab=donation_goal_options")),
1226 1224
 		$goal_stats['goal'],
1227
-		( 'donors' === $goal_stats['format'] ? __( 'Donors', 'give' ) : ( 'donation' === $goal_stats['format'] ? __( 'Donations', 'give' ) : '' ) )
1225
+		('donors' === $goal_stats['format'] ? __('Donors', 'give') : ('donation' === $goal_stats['format'] ? __('Donations', 'give') : ''))
1228 1226
 	);
1229 1227
 
1230
-	if ( $goal_stats['raw_actual'] >= $goal_stats['raw_goal'] ) {
1231
-		$html .= sprintf( '<span class="give-admin-goal-achieved"><span class="dashicons dashicons-star-filled"></span> %s</span>', __( 'Goal achieved', 'give' ) );
1228
+	if ($goal_stats['raw_actual'] >= $goal_stats['raw_goal']) {
1229
+		$html .= sprintf('<span class="give-admin-goal-achieved"><span class="dashicons dashicons-star-filled"></span> %s</span>', __('Goal achieved', 'give'));
1232 1230
 	}
1233 1231
 
1234 1232
 	$html .= '</div>';
@@ -1246,11 +1244,11 @@  discard block
 block discarded – undo
1246 1244
  *
1247 1245
  * @return null | array
1248 1246
  */
1249
-function give_form_get_default_level( $form_id ) {
1247
+function give_form_get_default_level($form_id) {
1250 1248
 	$default_level = null;
1251 1249
 
1252 1250
 	// If donation form has variable prices.
1253
-	if ( give_has_variable_prices( $form_id ) ) {
1251
+	if (give_has_variable_prices($form_id)) {
1254 1252
 		/**
1255 1253
 		 * Filter the variable pricing
1256 1254
 		 *
@@ -1262,12 +1260,12 @@  discard block
 block discarded – undo
1262 1260
 		 * @param array $prices Array of variable prices.
1263 1261
 		 * @param int   $form   Form ID.
1264 1262
 		 */
1265
-		$prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id );
1263
+		$prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id);
1266 1264
 
1267 1265
 		// Go through each of the level and get the default level id.
1268
-		foreach ( $prices as $level ) {
1266
+		foreach ($prices as $level) {
1269 1267
 			if (
1270
-				isset( $level['_give_default'] )
1268
+				isset($level['_give_default'])
1271 1269
 				&& $level['_give_default'] === 'default'
1272 1270
 			) {
1273 1271
 				$default_level = $level;
@@ -1283,7 +1281,7 @@  discard block
 block discarded – undo
1283 1281
 	 * @param array   $default_level Default level price data.
1284 1282
 	 * @param integer $form_id       Donation form ID.
1285 1283
 	 */
1286
-	return apply_filters( 'give_form_get_default_level', $default_level, $form_id );
1284
+	return apply_filters('give_form_get_default_level', $default_level, $form_id);
1287 1285
 }
1288 1286
 
1289 1287
 /**
@@ -1296,21 +1294,21 @@  discard block
 block discarded – undo
1296 1294
  *
1297 1295
  * @return boolean
1298 1296
  */
1299
-function give_is_default_level_id( $price_or_level_id, $form_id = 0 ) {
1297
+function give_is_default_level_id($price_or_level_id, $form_id = 0) {
1300 1298
 	$is_default = false;
1301 1299
 
1302 1300
 	if (
1303
-		! empty( $form_id )
1304
-		&& is_numeric( $price_or_level_id )
1301
+		! empty($form_id)
1302
+		&& is_numeric($price_or_level_id)
1305 1303
 	) {
1306 1304
 		// Get default level id.
1307
-		$form_price_data = give_form_get_default_level( $form_id );
1305
+		$form_price_data = give_form_get_default_level($form_id);
1308 1306
 
1309
-		$is_default = ! is_null( $form_price_data ) && ( $price_or_level_id === absint( $form_price_data['_give_id']['level_id'] ) );
1307
+		$is_default = ! is_null($form_price_data) && ($price_or_level_id === absint($form_price_data['_give_id']['level_id']));
1310 1308
 	}
1311 1309
 
1312
-	$is_default = false === $is_default && is_array( $price_or_level_id ) ?
1313
-		( isset( $price_or_level_id['_give_default'] ) && $price_or_level_id['_give_default'] === 'default' )
1310
+	$is_default = false === $is_default && is_array($price_or_level_id) ?
1311
+		(isset($price_or_level_id['_give_default']) && $price_or_level_id['_give_default'] === 'default')
1314 1312
 		: $is_default;
1315 1313
 
1316 1314
 	/**
@@ -1321,5 +1319,5 @@  discard block
 block discarded – undo
1321 1319
 	 * @param bool          $is_default        True if it is default price level id otherwise false.
1322 1320
 	 * @param array|integer $price_or_level_id Price Data.
1323 1321
 	 */
1324
-	return apply_filters( 'give_is_default_level_id', $is_default, $price_or_level_id );
1322
+	return apply_filters('give_is_default_level_id', $is_default, $price_or_level_id);
1325 1323
 }
Please login to merge, or discard this patch.
includes/misc-functions.php 3 patches
Doc Comments   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
  *
229 229
  * @since 1.8.17
230 230
  *
231
- * @return array|string
231
+ * @return boolean
232 232
  */
233 233
 function give_get_history_session() {
234 234
 	return (bool) Give()->session->get( 'history_access' );
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
  *
706 706
  * @todo  Remove this, when WordPress Core ticket is resolved (https://core.trac.wordpress.org/ticket/16828).
707 707
  *
708
- * @return bool
708
+ * @return false|null
709 709
  */
710 710
 function give_donation_metabox_menu() {
711 711
 
@@ -983,7 +983,7 @@  discard block
 block discarded – undo
983 983
  *
984 984
  * @since 1.8
985 985
  *
986
- * @param $form_id
986
+ * @param integer $form_id
987 987
  *
988 988
  * @return bool
989 989
  */
@@ -1090,7 +1090,7 @@  discard block
 block discarded – undo
1090 1090
  * @param int    $id
1091 1091
  * @param string $meta_key
1092 1092
  * @param mixed  $meta_value
1093
- * @param mixed  $prev_value
1093
+ * @param string  $prev_value
1094 1094
  *
1095 1095
  * @return mixed
1096 1096
  */
@@ -1349,7 +1349,7 @@  discard block
 block discarded – undo
1349 1349
  * @since 1.8.13
1350 1350
  *
1351 1351
  * @param array      $list      List of objects or arrays
1352
- * @param int|string $field     Field from the object to place instead of the entire object
1352
+ * @param string $field     Field from the object to place instead of the entire object
1353 1353
  * @param int|string $index_key Optional. Field from the object to use as keys for the new array.
1354 1354
  *                              Default null.
1355 1355
  *
@@ -1779,7 +1779,7 @@  discard block
 block discarded – undo
1779 1779
  *
1780 1780
  * @since 2.1
1781 1781
  *
1782
- * @param $form_id
1782
+ * @param integer $form_id
1783 1783
  *
1784 1784
  * @return bool
1785 1785
  */
@@ -2167,7 +2167,7 @@  discard block
 block discarded – undo
2167 2167
  *
2168 2168
  * @since 2.2.0
2169 2169
  *
2170
- * @return object
2170
+ * @return Give_Donor
2171 2171
  */
2172 2172
 function give_get_name_with_title_prefixes( $donor ) {
2173 2173
 
Please login to merge, or discard this patch.
Spacing   +451 added lines, -451 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,9 +23,9 @@  discard block
 block discarded – undo
23 23
  */
24 24
 function give_is_test_mode() {
25 25
 
26
-	$ret = give_is_setting_enabled( give_get_option( 'test_mode' ) );
26
+	$ret = give_is_setting_enabled(give_get_option('test_mode'));
27 27
 
28
-	return (bool) apply_filters( 'give_is_test_mode', $ret );
28
+	return (bool) apply_filters('give_is_test_mode', $ret);
29 29
 
30 30
 }
31 31
 
@@ -39,18 +39,18 @@  discard block
 block discarded – undo
39 39
 
40 40
 	global $wp;
41 41
 
42
-	if ( get_option( 'permalink_structure' ) ) {
43
-		$base = trailingslashit( home_url( $wp->request ) );
42
+	if (get_option('permalink_structure')) {
43
+		$base = trailingslashit(home_url($wp->request));
44 44
 	} else {
45
-		$base = add_query_arg( $wp->query_string, '', trailingslashit( home_url( $wp->request ) ) );
46
-		$base = remove_query_arg( array( 'post_type', 'name' ), $base );
45
+		$base = add_query_arg($wp->query_string, '', trailingslashit(home_url($wp->request)));
46
+		$base = remove_query_arg(array('post_type', 'name'), $base);
47 47
 	}
48 48
 
49 49
 	$scheme      = is_ssl() ? 'https' : 'http';
50
-	$current_uri = set_url_scheme( $base, $scheme );
50
+	$current_uri = set_url_scheme($base, $scheme);
51 51
 
52
-	if ( is_front_page() ) {
53
-		$current_uri = home_url( '/' );
52
+	if (is_front_page()) {
53
+		$current_uri = home_url('/');
54 54
 	}
55 55
 
56 56
 	/**
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	 *
61 61
 	 * @param string $current_uri
62 62
 	 */
63
-	return apply_filters( 'give_get_current_page_url', $current_uri );
63
+	return apply_filters('give_get_current_page_url', $current_uri);
64 64
 
65 65
 }
66 66
 
@@ -82,11 +82,11 @@  discard block
 block discarded – undo
82 82
 	 */
83 83
 	$gateways = give_get_enabled_payment_gateways();
84 84
 
85
-	if ( count( $gateways ) == 1 && ! isset( $gateways['paypal'] ) && ! isset( $gateways['manual'] ) ) {
85
+	if (count($gateways) == 1 && ! isset($gateways['paypal']) && ! isset($gateways['manual'])) {
86 86
 		$ret = true;
87
-	} elseif ( count( $gateways ) == 1 ) {
87
+	} elseif (count($gateways) == 1) {
88 88
 		$ret = false;
89
-	} elseif ( count( $gateways ) == 2 && isset( $gateways['paypal'] ) && isset( $gateways['manual'] ) ) {
89
+	} elseif (count($gateways) == 2 && isset($gateways['paypal']) && isset($gateways['manual'])) {
90 90
 		$ret = false;
91 91
 	}
92 92
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 *
98 98
 	 * @param bool $ret
99 99
 	 */
100
-	return (bool) apply_filters( 'give_is_cc_verify_enabled', $ret );
100
+	return (bool) apply_filters('give_is_cc_verify_enabled', $ret);
101 101
 }
102 102
 
103 103
 /**
@@ -109,26 +109,26 @@  discard block
 block discarded – undo
109 109
 function give_get_timezone_id() {
110 110
 
111 111
 	// if site timezone string exists, return it.
112
-	if ( $timezone = get_option( 'timezone_string' ) ) {
112
+	if ($timezone = get_option('timezone_string')) {
113 113
 		return $timezone;
114 114
 	}
115 115
 
116 116
 	// get UTC offset, if it isn't set return UTC.
117
-	if ( ! ( $utc_offset = 3600 * get_option( 'gmt_offset', 0 ) ) ) {
117
+	if ( ! ($utc_offset = 3600 * get_option('gmt_offset', 0))) {
118 118
 		return 'UTC';
119 119
 	}
120 120
 
121 121
 	// attempt to guess the timezone string from the UTC offset.
122
-	$timezone = timezone_name_from_abbr( '', $utc_offset );
122
+	$timezone = timezone_name_from_abbr('', $utc_offset);
123 123
 
124 124
 	// last try, guess timezone string manually.
125
-	if ( $timezone === false ) {
125
+	if ($timezone === false) {
126 126
 
127
-		$is_dst = date( 'I' );
127
+		$is_dst = date('I');
128 128
 
129
-		foreach ( timezone_abbreviations_list() as $abbr ) {
130
-			foreach ( $abbr as $city ) {
131
-				if ( $city['dst'] == $is_dst && $city['offset'] == $utc_offset ) {
129
+		foreach (timezone_abbreviations_list() as $abbr) {
130
+			foreach ($abbr as $city) {
131
+				if ($city['dst'] == $is_dst && $city['offset'] == $utc_offset) {
132 132
 					return $city['timezone_id'];
133 133
 				}
134 134
 			}
@@ -152,13 +152,13 @@  discard block
 block discarded – undo
152 152
 
153 153
 	$ip = '127.0.0.1';
154 154
 
155
-	if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
155
+	if ( ! empty($_SERVER['HTTP_CLIENT_IP'])) {
156 156
 		// check ip from share internet
157 157
 		$ip = $_SERVER['HTTP_CLIENT_IP'];
158
-	} elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
158
+	} elseif ( ! empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
159 159
 		// to check ip is pass from proxy
160 160
 		$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
161
-	} elseif ( ! empty( $_SERVER['REMOTE_ADDR'] ) ) {
161
+	} elseif ( ! empty($_SERVER['REMOTE_ADDR'])) {
162 162
 		$ip = $_SERVER['REMOTE_ADDR'];
163 163
 	}
164 164
 
@@ -167,15 +167,15 @@  discard block
 block discarded – undo
167 167
 	 *
168 168
 	 * @since 1.0
169 169
 	 */
170
-	$ip = apply_filters( 'give_get_ip', $ip );
170
+	$ip = apply_filters('give_get_ip', $ip);
171 171
 
172 172
 	// Filter empty values.
173
-	if ( false !== strpos( $ip, ',' ) ) {
174
-		$ip = give_clean( explode( ',', $ip ) );
175
-		$ip = array_filter( $ip );
176
-		$ip = implode( ',', $ip );
173
+	if (false !== strpos($ip, ',')) {
174
+		$ip = give_clean(explode(',', $ip));
175
+		$ip = array_filter($ip);
176
+		$ip = implode(',', $ip);
177 177
 	} else {
178
-		$ip = give_clean( $ip );
178
+		$ip = give_clean($ip);
179 179
 	}
180 180
 
181 181
 	return $ip;
@@ -193,9 +193,9 @@  discard block
 block discarded – undo
193 193
  *
194 194
  * @uses  Give()->session->set()
195 195
  */
196
-function give_set_purchase_session( $purchase_data = array() ) {
197
-	Give()->session->set( 'give_purchase', $purchase_data );
198
-	Give()->session->set( 'give_email', $purchase_data['user_email'] );
196
+function give_set_purchase_session($purchase_data = array()) {
197
+	Give()->session->set('give_purchase', $purchase_data);
198
+	Give()->session->set('give_email', $purchase_data['user_email']);
199 199
 }
200 200
 
201 201
 /**
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
  * @return mixed array | false
210 210
  */
211 211
 function give_get_purchase_session() {
212
-	return Give()->session->get( 'give_purchase' );
212
+	return Give()->session->get('give_purchase');
213 213
 }
214 214
 
215 215
 /**
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
  * @return array|string
221 221
  */
222 222
 function give_get_receipt_session() {
223
-	return Give()->session->get( 'receipt_access' );
223
+	return Give()->session->get('receipt_access');
224 224
 }
225 225
 
226 226
 /**
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
  * @return array|string
232 232
  */
233 233
 function give_get_history_session() {
234
-	return (bool) Give()->session->get( 'history_access' );
234
+	return (bool) Give()->session->get('history_access');
235 235
 }
236 236
 
237 237
 /**
@@ -243,17 +243,17 @@  discard block
 block discarded – undo
243 243
  *
244 244
  * @return string By default, the name of the form. Then the price level text if any is found.
245 245
  */
246
-function give_payment_gateway_item_title( $payment_data ) {
246
+function give_payment_gateway_item_title($payment_data) {
247 247
 
248
-	$form_id   = intval( $payment_data['post_data']['give-form-id'] );
249
-	$item_name = isset( $payment_data['post_data']['give-form-title'] ) ? $payment_data['post_data']['give-form-title'] : '';
250
-	$price_id  = isset( $payment_data['post_data']['give-price-id'] ) ? $payment_data['post_data']['give-price-id'] : '';
248
+	$form_id   = intval($payment_data['post_data']['give-form-id']);
249
+	$item_name = isset($payment_data['post_data']['give-form-title']) ? $payment_data['post_data']['give-form-title'] : '';
250
+	$price_id  = isset($payment_data['post_data']['give-price-id']) ? $payment_data['post_data']['give-price-id'] : '';
251 251
 
252 252
 
253 253
 	// Verify has variable prices.
254
-	if ( give_has_variable_prices( $form_id ) && ! empty( $price_id ) ) {
254
+	if (give_has_variable_prices($form_id) && ! empty($price_id)) {
255 255
 
256
-		$item_price_level_text = give_get_price_option_name( $form_id, $price_id, 0, false );
256
+		$item_price_level_text = give_get_price_option_name($form_id, $price_id, 0, false);
257 257
 
258 258
 		/**
259 259
 		 * Output donation level text if:
@@ -261,9 +261,9 @@  discard block
 block discarded – undo
261 261
 		 * 1. It's not a custom amount
262 262
 		 * 2. The level field has actual text and isn't the amount (which is already displayed on the receipt).
263 263
 		 */
264
-		if ( 'custom' !== $price_id && ! empty( $item_price_level_text ) ) {
264
+		if ('custom' !== $price_id && ! empty($item_price_level_text)) {
265 265
 			// Matches a donation level - append level text.
266
-			$item_name .= ' - ' . $item_price_level_text;
266
+			$item_name .= ' - '.$item_price_level_text;
267 267
 		}
268 268
 	}
269 269
 
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 	 *
279 279
 	 * @return string
280 280
 	 */
281
-	return apply_filters( 'give_payment_gateway_item_title', $item_name, $form_id, $payment_data );
281
+	return apply_filters('give_payment_gateway_item_title', $item_name, $form_id, $payment_data);
282 282
 }
283 283
 
284 284
 /**
@@ -294,38 +294,38 @@  discard block
 block discarded – undo
294 294
  *
295 295
  * @return string
296 296
  */
297
-function give_payment_gateway_donation_summary( $donation_data, $name_and_email = true, $length = 255 ) {
297
+function give_payment_gateway_donation_summary($donation_data, $name_and_email = true, $length = 255) {
298 298
 
299
-	$form_id  = isset( $donation_data['post_data']['give-form-id'] ) ? $donation_data['post_data']['give-form-id'] : '';
300
-	$price_id = isset( $donation_data['post_data']['give-price-id'] ) ? $donation_data['post_data']['give-price-id'] : '';
299
+	$form_id  = isset($donation_data['post_data']['give-form-id']) ? $donation_data['post_data']['give-form-id'] : '';
300
+	$price_id = isset($donation_data['post_data']['give-price-id']) ? $donation_data['post_data']['give-price-id'] : '';
301 301
 
302 302
 	// Form title.
303
-	$summary = ( ! empty( $donation_data['post_data']['give-form-title'] ) ? $donation_data['post_data']['give-form-title'] : ( ! empty( $form_id ) ? wp_sprintf( __( 'Donation Form ID: %d', 'give' ), $form_id ) : __( 'Untitled donation form', 'give' ) ) );
303
+	$summary = ( ! empty($donation_data['post_data']['give-form-title']) ? $donation_data['post_data']['give-form-title'] : ( ! empty($form_id) ? wp_sprintf(__('Donation Form ID: %d', 'give'), $form_id) : __('Untitled donation form', 'give')));
304 304
 
305 305
 	// Form multilevel if applicable.
306
-	if ( ! empty( $price_id ) && 'custom' !== $price_id ) {
307
-		$summary .= ': ' . give_get_price_option_name( $form_id, $donation_data['post_data']['give-price-id'] );
306
+	if ( ! empty($price_id) && 'custom' !== $price_id) {
307
+		$summary .= ': '.give_get_price_option_name($form_id, $donation_data['post_data']['give-price-id']);
308 308
 	}
309 309
 
310 310
 	// Add Donor's name + email if requested.
311
-	if ( $name_and_email ) {
311
+	if ($name_and_email) {
312 312
 
313 313
 		// First name
314
-		if ( isset( $donation_data['user_info']['first_name'] ) && ! empty( $donation_data['user_info']['first_name'] ) ) {
315
-			$summary .= ' - ' . $donation_data['user_info']['first_name'];
314
+		if (isset($donation_data['user_info']['first_name']) && ! empty($donation_data['user_info']['first_name'])) {
315
+			$summary .= ' - '.$donation_data['user_info']['first_name'];
316 316
 		}
317 317
 
318
-		if ( isset( $donation_data['user_info']['last_name'] ) && ! empty( $donation_data['user_info']['last_name'] ) ) {
319
-			$summary .= ' ' . $donation_data['user_info']['last_name'];
318
+		if (isset($donation_data['user_info']['last_name']) && ! empty($donation_data['user_info']['last_name'])) {
319
+			$summary .= ' '.$donation_data['user_info']['last_name'];
320 320
 		}
321 321
 
322
-		$summary .= ' (' . $donation_data['user_email'] . ')';
322
+		$summary .= ' ('.$donation_data['user_email'].')';
323 323
 	}
324 324
 
325 325
 	// Cut the length
326
-	$summary = substr( $summary, 0, $length );
326
+	$summary = substr($summary, 0, $length);
327 327
 
328
-	return apply_filters( 'give_payment_gateway_donation_summary', $summary );
328
+	return apply_filters('give_payment_gateway_donation_summary', $summary);
329 329
 }
330 330
 
331 331
 
@@ -340,31 +340,31 @@  discard block
 block discarded – undo
340 340
 function give_get_host() {
341 341
 	$host = false;
342 342
 
343
-	if ( defined( 'WPE_APIKEY' ) ) {
343
+	if (defined('WPE_APIKEY')) {
344 344
 		$host = 'WP Engine';
345
-	} elseif ( defined( 'PAGELYBIN' ) ) {
345
+	} elseif (defined('PAGELYBIN')) {
346 346
 		$host = 'Pagely';
347
-	} elseif ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) {
347
+	} elseif (DB_HOST == 'localhost:/tmp/mysql5.sock') {
348 348
 		$host = 'ICDSoft';
349
-	} elseif ( DB_HOST == 'mysqlv5' ) {
349
+	} elseif (DB_HOST == 'mysqlv5') {
350 350
 		$host = 'NetworkSolutions';
351
-	} elseif ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) {
351
+	} elseif (strpos(DB_HOST, 'ipagemysql.com') !== false) {
352 352
 		$host = 'iPage';
353
-	} elseif ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) {
353
+	} elseif (strpos(DB_HOST, 'ipowermysql.com') !== false) {
354 354
 		$host = 'IPower';
355
-	} elseif ( strpos( DB_HOST, '.gridserver.com' ) !== false ) {
355
+	} elseif (strpos(DB_HOST, '.gridserver.com') !== false) {
356 356
 		$host = 'MediaTemple Grid';
357
-	} elseif ( strpos( DB_HOST, '.pair.com' ) !== false ) {
357
+	} elseif (strpos(DB_HOST, '.pair.com') !== false) {
358 358
 		$host = 'pair Networks';
359
-	} elseif ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) {
359
+	} elseif (strpos(DB_HOST, '.stabletransit.com') !== false) {
360 360
 		$host = 'Rackspace Cloud';
361
-	} elseif ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) {
361
+	} elseif (strpos(DB_HOST, '.sysfix.eu') !== false) {
362 362
 		$host = 'SysFix.eu Power Hosting';
363
-	} elseif ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) {
363
+	} elseif (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) {
364 364
 		$host = 'Flywheel';
365 365
 	} else {
366 366
 		// Adding a general fallback for data gathering
367
-		$host = 'DBH: ' . DB_HOST . ', SRV: ' . $_SERVER['SERVER_NAME'];
367
+		$host = 'DBH: '.DB_HOST.', SRV: '.$_SERVER['SERVER_NAME'];
368 368
 	}
369 369
 
370 370
 	return $host;
@@ -380,67 +380,67 @@  discard block
 block discarded – undo
380 380
  *
381 381
  * @return bool true if host matches, false if not
382 382
  */
383
-function give_is_host( $host = false ) {
383
+function give_is_host($host = false) {
384 384
 
385 385
 	$return = false;
386 386
 
387
-	if ( $host ) {
388
-		$host = str_replace( ' ', '', strtolower( $host ) );
387
+	if ($host) {
388
+		$host = str_replace(' ', '', strtolower($host));
389 389
 
390
-		switch ( $host ) {
390
+		switch ($host) {
391 391
 			case 'wpengine':
392
-				if ( defined( 'WPE_APIKEY' ) ) {
392
+				if (defined('WPE_APIKEY')) {
393 393
 					$return = true;
394 394
 				}
395 395
 				break;
396 396
 			case 'pagely':
397
-				if ( defined( 'PAGELYBIN' ) ) {
397
+				if (defined('PAGELYBIN')) {
398 398
 					$return = true;
399 399
 				}
400 400
 				break;
401 401
 			case 'icdsoft':
402
-				if ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) {
402
+				if (DB_HOST == 'localhost:/tmp/mysql5.sock') {
403 403
 					$return = true;
404 404
 				}
405 405
 				break;
406 406
 			case 'networksolutions':
407
-				if ( DB_HOST == 'mysqlv5' ) {
407
+				if (DB_HOST == 'mysqlv5') {
408 408
 					$return = true;
409 409
 				}
410 410
 				break;
411 411
 			case 'ipage':
412
-				if ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) {
412
+				if (strpos(DB_HOST, 'ipagemysql.com') !== false) {
413 413
 					$return = true;
414 414
 				}
415 415
 				break;
416 416
 			case 'ipower':
417
-				if ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) {
417
+				if (strpos(DB_HOST, 'ipowermysql.com') !== false) {
418 418
 					$return = true;
419 419
 				}
420 420
 				break;
421 421
 			case 'mediatemplegrid':
422
-				if ( strpos( DB_HOST, '.gridserver.com' ) !== false ) {
422
+				if (strpos(DB_HOST, '.gridserver.com') !== false) {
423 423
 					$return = true;
424 424
 				}
425 425
 				break;
426 426
 			case 'pairnetworks':
427
-				if ( strpos( DB_HOST, '.pair.com' ) !== false ) {
427
+				if (strpos(DB_HOST, '.pair.com') !== false) {
428 428
 					$return = true;
429 429
 				}
430 430
 				break;
431 431
 			case 'rackspacecloud':
432
-				if ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) {
432
+				if (strpos(DB_HOST, '.stabletransit.com') !== false) {
433 433
 					$return = true;
434 434
 				}
435 435
 				break;
436 436
 			case 'sysfix.eu':
437 437
 			case 'sysfix.eupowerhosting':
438
-				if ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) {
438
+				if (strpos(DB_HOST, '.sysfix.eu') !== false) {
439 439
 					$return = true;
440 440
 				}
441 441
 				break;
442 442
 			case 'flywheel':
443
-				if ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) {
443
+				if (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) {
444 444
 					$return = true;
445 445
 				}
446 446
 				break;
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
  * @param string $replacement Optional. The function that should have been called.
474 474
  * @param array  $backtrace   Optional. Contains stack backtrace of deprecated function.
475 475
  */
476
-function _give_deprecated_function( $function, $version, $replacement = null, $backtrace = null ) {
476
+function _give_deprecated_function($function, $version, $replacement = null, $backtrace = null) {
477 477
 
478 478
 	/**
479 479
 	 * Fires while give deprecated function call occurs.
@@ -486,19 +486,19 @@  discard block
 block discarded – undo
486 486
 	 * @param string $replacement Optional. The function that should have been called.
487 487
 	 * @param string $version     The plugin version that deprecated the function.
488 488
 	 */
489
-	do_action( 'give_deprecated_function_run', $function, $replacement, $version );
489
+	do_action('give_deprecated_function_run', $function, $replacement, $version);
490 490
 
491
-	$show_errors = current_user_can( 'manage_options' );
491
+	$show_errors = current_user_can('manage_options');
492 492
 
493 493
 	// Allow plugin to filter the output error trigger.
494
-	if ( WP_DEBUG && apply_filters( 'give_deprecated_function_trigger_error', $show_errors ) ) {
495
-		if ( ! is_null( $replacement ) ) {
496
-			trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give' ), $function, $version, $replacement ) );
497
-			trigger_error( print_r( $backtrace, 1 ) ); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine.
494
+	if (WP_DEBUG && apply_filters('give_deprecated_function_trigger_error', $show_errors)) {
495
+		if ( ! is_null($replacement)) {
496
+			trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give'), $function, $version, $replacement));
497
+			trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine.
498 498
 			// Alternatively we could dump this to a file.
499 499
 		} else {
500
-			trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give' ), $function, $version ) );
501
-			trigger_error( print_r( $backtrace, 1 ) );// Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine.
500
+			trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give'), $function, $version));
501
+			trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine.
502 502
 			// Alternatively we could dump this to a file.
503 503
 		}
504 504
 	}
@@ -512,11 +512,11 @@  discard block
 block discarded – undo
512 512
  * @return string $post_id
513 513
  */
514 514
 function give_get_admin_post_id() {
515
-	$post_id = isset( $_REQUEST['post'] ) ? absint( $_REQUEST['post'] ) : null;
515
+	$post_id = isset($_REQUEST['post']) ? absint($_REQUEST['post']) : null;
516 516
 
517
-	$post_id = ! empty( $post_id ) ? $post_id : ( isset( $_REQUEST['post_id'] ) ? absint( $_REQUEST['post_id'] ) : null );
517
+	$post_id = ! empty($post_id) ? $post_id : (isset($_REQUEST['post_id']) ? absint($_REQUEST['post_id']) : null);
518 518
 
519
-	$post_id = ! empty( $post_id ) ? $post_id : ( isset( $_REQUEST['post_ID'] ) ? absint( $_REQUEST['post_ID'] ) : null );
519
+	$post_id = ! empty($post_id) ? $post_id : (isset($_REQUEST['post_ID']) ? absint($_REQUEST['post_ID']) : null);
520 520
 
521 521
 	return $post_id;
522 522
 }
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
  * @return string Arg separator output
529 529
  */
530 530
 function give_get_php_arg_separator_output() {
531
-	return ini_get( 'arg_separator.output' );
531
+	return ini_get('arg_separator.output');
532 532
 }
533 533
 
534 534
 
@@ -543,10 +543,10 @@  discard block
 block discarded – undo
543 543
  *
544 544
  * @return string Short month name
545 545
  */
546
-function give_month_num_to_name( $n ) {
547
-	$timestamp = mktime( 0, 0, 0, $n, 1, 2005 );
546
+function give_month_num_to_name($n) {
547
+	$timestamp = mktime(0, 0, 0, $n, 1, 2005);
548 548
 
549
-	return date_i18n( 'M', $timestamp );
549
+	return date_i18n('M', $timestamp);
550 550
 }
551 551
 
552 552
 
@@ -559,10 +559,10 @@  discard block
 block discarded – undo
559 559
  *
560 560
  * @return bool Whether or not function is disabled.
561 561
  */
562
-function give_is_func_disabled( $function ) {
563
-	$disabled = explode( ',', ini_get( 'disable_functions' ) );
562
+function give_is_func_disabled($function) {
563
+	$disabled = explode(',', ini_get('disable_functions'));
564 564
 
565
-	return in_array( $function, $disabled );
565
+	return in_array($function, $disabled);
566 566
 }
567 567
 
568 568
 /**
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
 function give_get_newsletter() {
574 574
 	?>
575 575
 
576
-	<p class="newsletter-intro"><?php esc_html_e( 'Be sure to sign up for the Give newsletter below to stay informed of important updates and news.', 'give' ); ?></p>
576
+	<p class="newsletter-intro"><?php esc_html_e('Be sure to sign up for the Give newsletter below to stay informed of important updates and news.', 'give'); ?></p>
577 577
 
578 578
 	<div class="give-newsletter-form-wrap">
579 579
 
@@ -581,33 +581,33 @@  discard block
 block discarded – undo
581 581
 		      method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate"
582 582
 		      target="_blank">
583 583
 			<div class="give-newsletter-confirmation">
584
-				<p><?php esc_html_e( 'To complete your subscription, click the confirmation link in your email. Thank you!', 'give' ); ?></p>
584
+				<p><?php esc_html_e('To complete your subscription, click the confirmation link in your email. Thank you!', 'give'); ?></p>
585 585
 			</div>
586 586
 
587 587
 			<table class="form-table give-newsletter-form">
588 588
 				<tr valign="middle">
589 589
 					<td>
590 590
 						<label for="mce-EMAIL"
591
-						       class="screen-reader-text"><?php esc_html_e( 'Email Address (required)', 'give' ); ?></label>
591
+						       class="screen-reader-text"><?php esc_html_e('Email Address (required)', 'give'); ?></label>
592 592
 						<input type="email" name="EMAIL" id="mce-EMAIL"
593
-						       placeholder="<?php esc_attr_e( 'Email Address (required)', 'give' ); ?>"
593
+						       placeholder="<?php esc_attr_e('Email Address (required)', 'give'); ?>"
594 594
 						       class="required email" value="" required>
595 595
 					</td>
596 596
 					<td>
597 597
 						<label for="mce-FNAME"
598
-						       class="screen-reader-text"><?php esc_html_e( 'First Name', 'give' ); ?></label>
598
+						       class="screen-reader-text"><?php esc_html_e('First Name', 'give'); ?></label>
599 599
 						<input type="text" name="FNAME" id="mce-FNAME"
600
-						       placeholder="<?php esc_attr_e( 'First Name', 'give' ); ?>" class="" value="" required>
600
+						       placeholder="<?php esc_attr_e('First Name', 'give'); ?>" class="" value="" required>
601 601
 					</td>
602 602
 					<td>
603 603
 						<label for="mce-LNAME"
604
-						       class="screen-reader-text"><?php esc_html_e( 'Last Name', 'give' ); ?></label>
604
+						       class="screen-reader-text"><?php esc_html_e('Last Name', 'give'); ?></label>
605 605
 						<input type="text" name="LNAME" id="mce-LNAME"
606
-						       placeholder="<?php esc_attr_e( 'Last Name', 'give' ); ?>" class="" value="">
606
+						       placeholder="<?php esc_attr_e('Last Name', 'give'); ?>" class="" value="">
607 607
 					</td>
608 608
 					<td>
609 609
 						<input type="submit" name="subscribe" id="mc-embedded-subscribe" class="button"
610
-						       value="<?php esc_attr_e( 'Subscribe', 'give' ); ?>">
610
+						       value="<?php esc_attr_e('Subscribe', 'give'); ?>">
611 611
 					</td>
612 612
 				</tr>
613 613
 			</table>
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
  *
665 665
  * @return string
666 666
  */
667
-function give_svg_icons( $icon ) {
667
+function give_svg_icons($icon) {
668 668
 
669 669
 	// Store your SVGs in an associative array
670 670
 	$svgs = array(
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
 	);
677 677
 
678 678
 	// Return the chosen icon's SVG string
679
-	return $svgs[ $icon ];
679
+	return $svgs[$icon];
680 680
 }
681 681
 
682 682
 /**
@@ -688,15 +688,15 @@  discard block
 block discarded – undo
688 688
  *
689 689
  * @return mixed
690 690
  */
691
-function modify_nav_menu_meta_box_object( $post_type ) {
692
-	if ( isset( $post_type->name ) && $post_type->name == 'give_forms' ) {
693
-		$post_type->labels->name = esc_html__( 'Donation Forms', 'give' );
691
+function modify_nav_menu_meta_box_object($post_type) {
692
+	if (isset($post_type->name) && $post_type->name == 'give_forms') {
693
+		$post_type->labels->name = esc_html__('Donation Forms', 'give');
694 694
 	}
695 695
 
696 696
 	return $post_type;
697 697
 }
698 698
 
699
-add_filter( 'nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object' );
699
+add_filter('nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object');
700 700
 
701 701
 /**
702 702
  * Show Donation Forms Post Type in Appearance > Menus by default on fresh install.
@@ -713,30 +713,30 @@  discard block
 block discarded – undo
713 713
 	$screen = get_current_screen();
714 714
 
715 715
 	// Proceed, if current screen is navigation menus.
716
-	if ( 'nav-menus' === $screen->id && give_is_setting_enabled( give_get_option( 'forms_singular' ) ) && ! get_user_option( 'give_is_donation_forms_menu_updated' ) ) {
716
+	if ('nav-menus' === $screen->id && give_is_setting_enabled(give_get_option('forms_singular')) && ! get_user_option('give_is_donation_forms_menu_updated')) {
717 717
 
718 718
 		// Return false, if it fails to retrieve hidden meta box list and is not admin.
719
-		if ( ! is_admin() || ( ! $hidden_meta_boxes = get_user_option( 'metaboxhidden_nav-menus' ) ) ) {
719
+		if ( ! is_admin() || ( ! $hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus'))) {
720 720
 			return false;
721 721
 		}
722 722
 
723 723
 		// Return false, In case, we don't find 'Donation Form' in hidden meta box list.
724
-		if ( ! in_array( 'add-post-type-give_forms', $hidden_meta_boxes, true ) ) {
724
+		if ( ! in_array('add-post-type-give_forms', $hidden_meta_boxes, true)) {
725 725
 			return false;
726 726
 		}
727 727
 
728 728
 		// Exclude 'Donation Form' value from hidden meta box's list.
729
-		$hidden_meta_boxes = array_diff( $hidden_meta_boxes, array( 'add-post-type-give_forms' ) );
729
+		$hidden_meta_boxes = array_diff($hidden_meta_boxes, array('add-post-type-give_forms'));
730 730
 
731 731
 		// Get current user ID.
732 732
 		$user = wp_get_current_user();
733 733
 
734
-		update_user_option( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true );
735
-		update_user_option( $user->ID, 'give_is_donation_forms_menu_updated', true, true );
734
+		update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true);
735
+		update_user_option($user->ID, 'give_is_donation_forms_menu_updated', true, true);
736 736
 	}
737 737
 }
738 738
 
739
-add_action( 'current_screen', 'give_donation_metabox_menu' );
739
+add_action('current_screen', 'give_donation_metabox_menu');
740 740
 
741 741
 /**
742 742
  * Array_column backup usage
@@ -749,7 +749,7 @@  discard block
 block discarded – undo
749 749
  * @license    https://opensource.org/licenses/MIT MIT
750 750
  */
751 751
 
752
-if ( ! function_exists( 'array_column' ) ) {
752
+if ( ! function_exists('array_column')) {
753 753
 	/**
754 754
 	 * Returns the values from a single column of the input array, identified by
755 755
 	 * the $columnKey.
@@ -768,43 +768,43 @@  discard block
 block discarded – undo
768 768
 	 *
769 769
 	 * @return array
770 770
 	 */
771
-	function array_column( $input = null, $columnKey = null, $indexKey = null ) {
771
+	function array_column($input = null, $columnKey = null, $indexKey = null) {
772 772
 		// Using func_get_args() in order to check for proper number of
773 773
 		// parameters and trigger errors exactly as the built-in array_column()
774 774
 		// does in PHP 5.5.
775 775
 		$argc   = func_num_args();
776 776
 		$params = func_get_args();
777 777
 
778
-		if ( $argc < 2 ) {
779
-			trigger_error( sprintf( esc_html__( 'array_column() expects at least 2 parameters, %s given.', 'give' ), $argc ), E_USER_WARNING );
778
+		if ($argc < 2) {
779
+			trigger_error(sprintf(esc_html__('array_column() expects at least 2 parameters, %s given.', 'give'), $argc), E_USER_WARNING);
780 780
 
781 781
 			return null;
782 782
 		}
783 783
 
784
-		if ( ! is_array( $params[0] ) ) {
785
-			trigger_error( sprintf( esc_html__( 'array_column() expects parameter 1 to be array, %s given.', 'give' ), gettype( $params[0] ) ), E_USER_WARNING );
784
+		if ( ! is_array($params[0])) {
785
+			trigger_error(sprintf(esc_html__('array_column() expects parameter 1 to be array, %s given.', 'give'), gettype($params[0])), E_USER_WARNING);
786 786
 
787 787
 			return null;
788 788
 		}
789 789
 
790
-		if ( ! is_int( $params[1] ) && ! is_float( $params[1] ) && ! is_string( $params[1] ) && $params[1] !== null && ! ( is_object( $params[1] ) && method_exists( $params[1], '__toString' ) ) ) {
791
-			trigger_error( esc_html__( 'array_column(): The column key should be either a string or an integer.', 'give' ), E_USER_WARNING );
790
+		if ( ! is_int($params[1]) && ! is_float($params[1]) && ! is_string($params[1]) && $params[1] !== null && ! (is_object($params[1]) && method_exists($params[1], '__toString'))) {
791
+			trigger_error(esc_html__('array_column(): The column key should be either a string or an integer.', 'give'), E_USER_WARNING);
792 792
 
793 793
 			return false;
794 794
 		}
795 795
 
796
-		if ( isset( $params[2] ) && ! is_int( $params[2] ) && ! is_float( $params[2] ) && ! is_string( $params[2] ) && ! ( is_object( $params[2] ) && method_exists( $params[2], '__toString' ) ) ) {
797
-			trigger_error( esc_html__( 'array_column(): The index key should be either a string or an integer.', 'give' ), E_USER_WARNING );
796
+		if (isset($params[2]) && ! is_int($params[2]) && ! is_float($params[2]) && ! is_string($params[2]) && ! (is_object($params[2]) && method_exists($params[2], '__toString'))) {
797
+			trigger_error(esc_html__('array_column(): The index key should be either a string or an integer.', 'give'), E_USER_WARNING);
798 798
 
799 799
 			return false;
800 800
 		}
801 801
 
802 802
 		$paramsInput     = $params[0];
803
-		$paramsColumnKey = ( $params[1] !== null ) ? (string) $params[1] : null;
803
+		$paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null;
804 804
 
805 805
 		$paramsIndexKey = null;
806
-		if ( isset( $params[2] ) ) {
807
-			if ( is_float( $params[2] ) || is_int( $params[2] ) ) {
806
+		if (isset($params[2])) {
807
+			if (is_float($params[2]) || is_int($params[2])) {
808 808
 				$paramsIndexKey = (int) $params[2];
809 809
 			} else {
810 810
 				$paramsIndexKey = (string) $params[2];
@@ -813,26 +813,26 @@  discard block
 block discarded – undo
813 813
 
814 814
 		$resultArray = array();
815 815
 
816
-		foreach ( $paramsInput as $row ) {
816
+		foreach ($paramsInput as $row) {
817 817
 			$key    = $value = null;
818 818
 			$keySet = $valueSet = false;
819 819
 
820
-			if ( $paramsIndexKey !== null && array_key_exists( $paramsIndexKey, $row ) ) {
820
+			if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) {
821 821
 				$keySet = true;
822
-				$key    = (string) $row[ $paramsIndexKey ];
822
+				$key    = (string) $row[$paramsIndexKey];
823 823
 			}
824 824
 
825
-			if ( $paramsColumnKey === null ) {
825
+			if ($paramsColumnKey === null) {
826 826
 				$valueSet = true;
827 827
 				$value    = $row;
828
-			} elseif ( is_array( $row ) && array_key_exists( $paramsColumnKey, $row ) ) {
828
+			} elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) {
829 829
 				$valueSet = true;
830
-				$value    = $row[ $paramsColumnKey ];
830
+				$value    = $row[$paramsColumnKey];
831 831
 			}
832 832
 
833
-			if ( $valueSet ) {
834
-				if ( $keySet ) {
835
-					$resultArray[ $key ] = $value;
833
+			if ($valueSet) {
834
+				if ($keySet) {
835
+					$resultArray[$key] = $value;
836 836
 				} else {
837 837
 					$resultArray[] = $value;
838 838
 				}
@@ -852,54 +852,54 @@  discard block
 block discarded – undo
852 852
  *
853 853
  * @return bool Whether the receipt is visible or not.
854 854
  */
855
-function give_can_view_receipt( $payment_key = '' ) {
855
+function give_can_view_receipt($payment_key = '') {
856 856
 
857 857
 	$return = false;
858 858
 
859
-	if ( empty( $payment_key ) ) {
859
+	if (empty($payment_key)) {
860 860
 		return $return;
861 861
 	}
862 862
 
863 863
 	global $give_receipt_args;
864 864
 
865
-	$give_receipt_args['id'] = give_get_donation_id_by_key( $payment_key );
865
+	$give_receipt_args['id'] = give_get_donation_id_by_key($payment_key);
866 866
 
867
-	$user_id = (int) give_get_payment_user_id( $give_receipt_args['id'] );
867
+	$user_id = (int) give_get_payment_user_id($give_receipt_args['id']);
868 868
 
869
-	$payment_meta = give_get_payment_meta( $give_receipt_args['id'] );
869
+	$payment_meta = give_get_payment_meta($give_receipt_args['id']);
870 870
 
871
-	if ( is_user_logged_in() ) {
872
-		if ( $user_id === (int) get_current_user_id() ) {
871
+	if (is_user_logged_in()) {
872
+		if ($user_id === (int) get_current_user_id()) {
873 873
 			$return = true;
874
-		} elseif ( wp_get_current_user()->user_email === give_get_payment_user_email( $give_receipt_args['id'] ) ) {
874
+		} elseif (wp_get_current_user()->user_email === give_get_payment_user_email($give_receipt_args['id'])) {
875 875
 			$return = true;
876
-		} elseif ( current_user_can( 'view_give_sensitive_data' ) ) {
876
+		} elseif (current_user_can('view_give_sensitive_data')) {
877 877
 			$return = true;
878 878
 		}
879 879
 	}
880 880
 
881 881
 	// Check whether it is purchase session?
882 882
 	$purchase_session = give_get_purchase_session();
883
-	if ( ! empty( $purchase_session ) && ! is_user_logged_in() ) {
884
-		if ( $purchase_session['purchase_key'] === $payment_meta['key'] ) {
883
+	if ( ! empty($purchase_session) && ! is_user_logged_in()) {
884
+		if ($purchase_session['purchase_key'] === $payment_meta['key']) {
885 885
 			$return = true;
886 886
 		}
887 887
 	}
888 888
 
889 889
 	// Check whether it is receipt access session?
890 890
 	$receipt_session = give_get_receipt_session();
891
-	if ( ! empty( $receipt_session ) && ! is_user_logged_in() ) {
892
-		if ( $receipt_session === $payment_meta['key'] ) {
891
+	if ( ! empty($receipt_session) && ! is_user_logged_in()) {
892
+		if ($receipt_session === $payment_meta['key']) {
893 893
 			$return = true;
894 894
 		}
895 895
 	}
896 896
 
897 897
 	// Check whether it is history access session?
898
-	if ( true === give_get_history_session() ) {
898
+	if (true === give_get_history_session()) {
899 899
 		$return = true;
900 900
 	}
901 901
 
902
-	return (bool) apply_filters( 'give_can_view_receipt', $return, $payment_key );
902
+	return (bool) apply_filters('give_can_view_receipt', $return, $payment_key);
903 903
 
904 904
 }
905 905
 
@@ -908,7 +908,7 @@  discard block
 block discarded – undo
908 908
  *
909 909
  * Fallback in case the calendar extension is not loaded in PHP; Only supports Gregorian calendar
910 910
  */
911
-if ( ! function_exists( 'cal_days_in_month' ) ) {
911
+if ( ! function_exists('cal_days_in_month')) {
912 912
 	/**
913 913
 	 * cal_days_in_month
914 914
 	 *
@@ -918,8 +918,8 @@  discard block
 block discarded – undo
918 918
 	 *
919 919
 	 * @return bool|string
920 920
 	 */
921
-	function cal_days_in_month( $calendar, $month, $year ) {
922
-		return date( 't', mktime( 0, 0, 0, $month, 1, $year ) );
921
+	function cal_days_in_month($calendar, $month, $year) {
922
+		return date('t', mktime(0, 0, 0, $month, 1, $year));
923 923
 	}
924 924
 }
925 925
 
@@ -938,40 +938,40 @@  discard block
 block discarded – undo
938 938
  */
939 939
 function give_get_plugins() {
940 940
 	$plugins             = get_plugins();
941
-	$active_plugin_paths = (array) get_option( 'active_plugins', array() );
941
+	$active_plugin_paths = (array) get_option('active_plugins', array());
942 942
 
943
-	if ( is_multisite() ) {
944
-		$network_activated_plugin_paths = array_keys( get_site_option( 'active_sitewide_plugins', array() ) );
945
-		$active_plugin_paths            = array_merge( $active_plugin_paths, $network_activated_plugin_paths );
943
+	if (is_multisite()) {
944
+		$network_activated_plugin_paths = array_keys(get_site_option('active_sitewide_plugins', array()));
945
+		$active_plugin_paths            = array_merge($active_plugin_paths, $network_activated_plugin_paths);
946 946
 	}
947 947
 
948
-	foreach ( $plugins as $plugin_path => $plugin_data ) {
948
+	foreach ($plugins as $plugin_path => $plugin_data) {
949 949
 		// Is plugin active?
950
-		if ( in_array( $plugin_path, $active_plugin_paths ) ) {
951
-			$plugins[ $plugin_path ]['Status'] = 'active';
950
+		if (in_array($plugin_path, $active_plugin_paths)) {
951
+			$plugins[$plugin_path]['Status'] = 'active';
952 952
 		} else {
953
-			$plugins[ $plugin_path ]['Status'] = 'inactive';
953
+			$plugins[$plugin_path]['Status'] = 'inactive';
954 954
 		}
955 955
 
956
-		$dirname = strtolower( dirname( $plugin_path ) );
956
+		$dirname = strtolower(dirname($plugin_path));
957 957
 
958 958
 		// Is plugin a Give add-on by WordImpress?
959
-		if ( strstr( $dirname, 'give-' ) && strstr( $plugin_data['AuthorURI'], 'wordimpress.com' ) ) {
959
+		if (strstr($dirname, 'give-') && strstr($plugin_data['AuthorURI'], 'wordimpress.com')) {
960 960
 			// Plugin is a Give-addon.
961
-			$plugins[ $plugin_path ]['Type'] = 'add-on';
961
+			$plugins[$plugin_path]['Type'] = 'add-on';
962 962
 
963 963
 			/* @var stdClass $license_active */
964
-			$license_active = __give_get_active_license_info( Give_License::get_short_name( $plugin_data['Name'] ) );
964
+			$license_active = __give_get_active_license_info(Give_License::get_short_name($plugin_data['Name']));
965 965
 
966 966
 			// Does a valid license exist?
967
-			if ( ! empty( $license_active ) && 'valid' === $license_active->license ) {
968
-				$plugins[ $plugin_path ]['License'] = true;
967
+			if ( ! empty($license_active) && 'valid' === $license_active->license) {
968
+				$plugins[$plugin_path]['License'] = true;
969 969
 			} else {
970
-				$plugins[ $plugin_path ]['License'] = false;
970
+				$plugins[$plugin_path]['License'] = false;
971 971
 			}
972 972
 		} else {
973 973
 			// Plugin is not a Give add-on.
974
-			$plugins[ $plugin_path ]['Type'] = 'other';
974
+			$plugins[$plugin_path]['Type'] = 'other';
975 975
 		}
976 976
 	}
977 977
 
@@ -987,13 +987,13 @@  discard block
 block discarded – undo
987 987
  *
988 988
  * @return bool
989 989
  */
990
-function give_is_terms_enabled( $form_id ) {
991
-	$form_option = give_get_meta( $form_id, '_give_terms_option', true );
990
+function give_is_terms_enabled($form_id) {
991
+	$form_option = give_get_meta($form_id, '_give_terms_option', true);
992 992
 
993
-	if ( give_is_setting_enabled( $form_option, 'global' ) && give_is_setting_enabled( give_get_option( 'terms' ) ) ) {
993
+	if (give_is_setting_enabled($form_option, 'global') && give_is_setting_enabled(give_get_option('terms'))) {
994 994
 		return true;
995 995
 
996
-	} elseif ( give_is_setting_enabled( $form_option ) ) {
996
+	} elseif (give_is_setting_enabled($form_option)) {
997 997
 		return true;
998 998
 
999 999
 	} else {
@@ -1017,10 +1017,10 @@  discard block
 block discarded – undo
1017 1017
  *
1018 1018
  * @return WP_Error|bool
1019 1019
  */
1020
-function give_delete_donation_stats( $date_range = '', $args = array() ) {
1020
+function give_delete_donation_stats($date_range = '', $args = array()) {
1021 1021
 
1022 1022
 	// Delete all cache.
1023
-	$status = Give_Cache::delete( Give_Cache::get_options_like( 'give_stats' ) );
1023
+	$status = Give_Cache::delete(Give_Cache::get_options_like('give_stats'));
1024 1024
 
1025 1025
 	/**
1026 1026
 	 * Fire the action when donation stats delete.
@@ -1030,7 +1030,7 @@  discard block
 block discarded – undo
1030 1030
 	 * @param string|array $date_range
1031 1031
 	 * @param array        $args
1032 1032
 	 */
1033
-	do_action( 'give_delete_donation_stats', $status, $date_range, $args );
1033
+	do_action('give_delete_donation_stats', $status, $date_range, $args);
1034 1034
 
1035 1035
 	return $status;
1036 1036
 }
@@ -1044,7 +1044,7 @@  discard block
 block discarded – undo
1044 1044
 function give_is_add_new_form_page() {
1045 1045
 	$status = false;
1046 1046
 
1047
-	if ( false !== strpos( $_SERVER['REQUEST_URI'], '/wp-admin/post-new.php?post_type=give_forms' ) ) {
1047
+	if (false !== strpos($_SERVER['REQUEST_URI'], '/wp-admin/post-new.php?post_type=give_forms')) {
1048 1048
 		$status = true;
1049 1049
 	}
1050 1050
 
@@ -1067,15 +1067,15 @@  discard block
 block discarded – undo
1067 1067
  *
1068 1068
  * @return mixed
1069 1069
  */
1070
-function give_get_meta( $id, $meta_key = '', $single = false, $default = false ) {
1070
+function give_get_meta($id, $meta_key = '', $single = false, $default = false) {
1071 1071
 	/**
1072 1072
 	 * Filter the meta value
1073 1073
 	 *
1074 1074
 	 * @since 1.8.8
1075 1075
 	 */
1076
-	$meta_value = apply_filters( 'give_get_meta', get_post_meta( $id, $meta_key, $single ), $id, $meta_key, $default );
1076
+	$meta_value = apply_filters('give_get_meta', get_post_meta($id, $meta_key, $single), $id, $meta_key, $default);
1077 1077
 
1078
-	if ( ( empty( $meta_key ) || empty( $meta_value ) ) && $default ) {
1078
+	if ((empty($meta_key) || empty($meta_value)) && $default) {
1079 1079
 		$meta_value = $default;
1080 1080
 	}
1081 1081
 
@@ -1094,15 +1094,15 @@  discard block
 block discarded – undo
1094 1094
  *
1095 1095
  * @return mixed
1096 1096
  */
1097
-function give_update_meta( $id, $meta_key, $meta_value, $prev_value = '' ) {
1098
-	$status = update_post_meta( $id, $meta_key, $meta_value, $prev_value );
1097
+function give_update_meta($id, $meta_key, $meta_value, $prev_value = '') {
1098
+	$status = update_post_meta($id, $meta_key, $meta_value, $prev_value);
1099 1099
 
1100 1100
 	/**
1101 1101
 	 * Filter the meta value update status
1102 1102
 	 *
1103 1103
 	 * @since 1.8.8
1104 1104
 	 */
1105
-	return apply_filters( 'give_update_meta', $status, $id, $meta_key, $meta_value );
1105
+	return apply_filters('give_update_meta', $status, $id, $meta_key, $meta_value);
1106 1106
 }
1107 1107
 
1108 1108
 /**
@@ -1116,15 +1116,15 @@  discard block
 block discarded – undo
1116 1116
  *
1117 1117
  * @return mixed
1118 1118
  */
1119
-function give_delete_meta( $id, $meta_key, $meta_value = '' ) {
1120
-	$status = delete_post_meta( $id, $meta_key, $meta_value );
1119
+function give_delete_meta($id, $meta_key, $meta_value = '') {
1120
+	$status = delete_post_meta($id, $meta_key, $meta_value);
1121 1121
 
1122 1122
 	/**
1123 1123
 	 * Filter the meta value delete status
1124 1124
 	 *
1125 1125
 	 * @since 1.8.8
1126 1126
 	 */
1127
-	return apply_filters( 'give_delete_meta', $status, $id, $meta_key, $meta_value );
1127
+	return apply_filters('give_delete_meta', $status, $id, $meta_key, $meta_value);
1128 1128
 }
1129 1129
 
1130 1130
 /**
@@ -1136,23 +1136,23 @@  discard block
 block discarded – undo
1136 1136
  *
1137 1137
  * @return bool                   If the action has been added to the completed actions array
1138 1138
  */
1139
-function give_has_upgrade_completed( $upgrade_action = '' ) {
1139
+function give_has_upgrade_completed($upgrade_action = '') {
1140 1140
 	// Bailout.
1141
-	if ( empty( $upgrade_action ) ) {
1141
+	if (empty($upgrade_action)) {
1142 1142
 		return false;
1143 1143
 	}
1144 1144
 
1145 1145
 	// Fresh install?
1146 1146
 	// If fresh install then all upgrades will be consider as completed.
1147
-	$is_fresh_install = ! get_option( 'give_version' );
1148
-	if ( $is_fresh_install ) {
1147
+	$is_fresh_install = ! get_option('give_version');
1148
+	if ($is_fresh_install) {
1149 1149
 		return true;
1150 1150
 	}
1151 1151
 
1152 1152
 
1153 1153
 	$completed_upgrades = give_get_completed_upgrades();
1154 1154
 
1155
-	return in_array( $upgrade_action, $completed_upgrades );
1155
+	return in_array($upgrade_action, $completed_upgrades);
1156 1156
 
1157 1157
 }
1158 1158
 
@@ -1164,8 +1164,8 @@  discard block
 block discarded – undo
1164 1164
  * @return mixed   When nothing to resume returns false, otherwise starts the upgrade where it left off
1165 1165
  */
1166 1166
 function give_maybe_resume_upgrade() {
1167
-	$doing_upgrade = get_option( 'give_doing_upgrade', false );
1168
-	if ( empty( $doing_upgrade ) ) {
1167
+	$doing_upgrade = get_option('give_doing_upgrade', false);
1168
+	if (empty($doing_upgrade)) {
1169 1169
 		return false;
1170 1170
 	}
1171 1171
 
@@ -1181,9 +1181,9 @@  discard block
 block discarded – undo
1181 1181
  *
1182 1182
  * @return bool                   If the function was successfully added
1183 1183
  */
1184
-function give_set_upgrade_complete( $upgrade_action = '' ) {
1184
+function give_set_upgrade_complete($upgrade_action = '') {
1185 1185
 
1186
-	if ( empty( $upgrade_action ) ) {
1186
+	if (empty($upgrade_action)) {
1187 1187
 		return false;
1188 1188
 	}
1189 1189
 
@@ -1191,16 +1191,16 @@  discard block
 block discarded – undo
1191 1191
 	$completed_upgrades[] = $upgrade_action;
1192 1192
 
1193 1193
 	// Remove any blanks, and only show uniques.
1194
-	$completed_upgrades = array_unique( array_values( $completed_upgrades ) );
1194
+	$completed_upgrades = array_unique(array_values($completed_upgrades));
1195 1195
 
1196 1196
 	/**
1197 1197
 	 * Fire the action when any upgrade set to complete.
1198 1198
 	 *
1199 1199
 	 * @since 1.8.12
1200 1200
 	 */
1201
-	do_action( 'give_set_upgrade_completed', $upgrade_action, $completed_upgrades );
1201
+	do_action('give_set_upgrade_completed', $upgrade_action, $completed_upgrades);
1202 1202
 
1203
-	return update_option( 'give_completed_upgrades', $completed_upgrades, false );
1203
+	return update_option('give_completed_upgrades', $completed_upgrades, false);
1204 1204
 }
1205 1205
 
1206 1206
 /**
@@ -1210,7 +1210,7 @@  discard block
 block discarded – undo
1210 1210
  * @return array The array of completed upgrades
1211 1211
  */
1212 1212
 function give_get_completed_upgrades() {
1213
-	return (array) get_option( 'give_completed_upgrades' );
1213
+	return (array) get_option('give_completed_upgrades');
1214 1214
 }
1215 1215
 
1216 1216
 /**
@@ -1225,16 +1225,16 @@  discard block
 block discarded – undo
1225 1225
  *
1226 1226
  * @return null|array
1227 1227
  */
1228
-function __give_v20_bc_table_details( $type ) {
1228
+function __give_v20_bc_table_details($type) {
1229 1229
 	global $wpdb;
1230 1230
 	$table = array();
1231 1231
 
1232 1232
 	// Bailout.
1233
-	if ( empty( $type ) ) {
1233
+	if (empty($type)) {
1234 1234
 		return null;
1235 1235
 	}
1236 1236
 
1237
-	switch ( $type ) {
1237
+	switch ($type) {
1238 1238
 		case 'form':
1239 1239
 			$table['name']         = $wpdb->formmeta;
1240 1240
 			$table['column']['id'] = 'form_id';
@@ -1243,11 +1243,11 @@  discard block
 block discarded – undo
1243 1243
 
1244 1244
 		case 'payment':
1245 1245
 			$table['name']         = $wpdb->donationmeta;
1246
-			$table['column']['id'] = Give()->payment_meta->get_meta_type() . '_id';
1246
+			$table['column']['id'] = Give()->payment_meta->get_meta_type().'_id';
1247 1247
 	}
1248 1248
 
1249 1249
 	// Backward compatibility.
1250
-	if ( ! give_has_upgrade_completed( 'v20_move_metadata_into_new_table' ) ) {
1250
+	if ( ! give_has_upgrade_completed('v20_move_metadata_into_new_table')) {
1251 1251
 		$table['name']         = $wpdb->postmeta;
1252 1252
 		$table['column']['id'] = 'post_id';
1253 1253
 	}
@@ -1263,22 +1263,22 @@  discard block
 block discarded – undo
1263 1263
  *
1264 1264
  * @param WP_Query $query
1265 1265
  */
1266
-function give_remove_pages_from_search( $query ) {
1266
+function give_remove_pages_from_search($query) {
1267 1267
 
1268
-	if ( ! $query->is_admin && $query->is_search && $query->is_main_query() ) {
1268
+	if ( ! $query->is_admin && $query->is_search && $query->is_main_query()) {
1269 1269
 
1270
-		$transaction_failed = give_get_option( 'failure_page', 0 );
1271
-		$success_page       = give_get_option( 'success_page', 0 );
1270
+		$transaction_failed = give_get_option('failure_page', 0);
1271
+		$success_page       = give_get_option('success_page', 0);
1272 1272
 
1273
-		$args = apply_filters( 'give_remove_pages_from_search', array(
1273
+		$args = apply_filters('give_remove_pages_from_search', array(
1274 1274
 			$transaction_failed,
1275 1275
 			$success_page,
1276
-		), $query );
1277
-		$query->set( 'post__not_in', $args );
1276
+		), $query);
1277
+		$query->set('post__not_in', $args);
1278 1278
 	}
1279 1279
 }
1280 1280
 
1281
-add_action( 'pre_get_posts', 'give_remove_pages_from_search', 10, 1 );
1281
+add_action('pre_get_posts', 'give_remove_pages_from_search', 10, 1);
1282 1282
 
1283 1283
 /**
1284 1284
  * Inserts a new key/value before a key in the array.
@@ -1294,14 +1294,14 @@  discard block
 block discarded – undo
1294 1294
  *
1295 1295
  * @see   array_insert_before()
1296 1296
  */
1297
-function give_array_insert_before( $key, array &$array, $new_key, $new_value ) {
1298
-	if ( array_key_exists( $key, $array ) ) {
1297
+function give_array_insert_before($key, array &$array, $new_key, $new_value) {
1298
+	if (array_key_exists($key, $array)) {
1299 1299
 		$new = array();
1300
-		foreach ( $array as $k => $value ) {
1301
-			if ( $k === $key ) {
1302
-				$new[ $new_key ] = $new_value;
1300
+		foreach ($array as $k => $value) {
1301
+			if ($k === $key) {
1302
+				$new[$new_key] = $new_value;
1303 1303
 			}
1304
-			$new[ $k ] = $value;
1304
+			$new[$k] = $value;
1305 1305
 		}
1306 1306
 
1307 1307
 		return $new;
@@ -1324,13 +1324,13 @@  discard block
 block discarded – undo
1324 1324
  *
1325 1325
  * @see   array_insert_before()
1326 1326
  */
1327
-function give_array_insert_after( $key, array &$array, $new_key, $new_value ) {
1328
-	if ( array_key_exists( $key, $array ) ) {
1327
+function give_array_insert_after($key, array &$array, $new_key, $new_value) {
1328
+	if (array_key_exists($key, $array)) {
1329 1329
 		$new = array();
1330
-		foreach ( $array as $k => $value ) {
1331
-			$new[ $k ] = $value;
1332
-			if ( $k === $key ) {
1333
-				$new[ $new_key ] = $new_value;
1330
+		foreach ($array as $k => $value) {
1331
+			$new[$k] = $value;
1332
+			if ($k === $key) {
1333
+				$new[$new_key] = $new_value;
1334 1334
 			}
1335 1335
 		}
1336 1336
 
@@ -1357,21 +1357,21 @@  discard block
 block discarded – undo
1357 1357
  *               corresponding to `$index_key`. If `$index_key` is null, array keys from the original
1358 1358
  *               `$list` will be preserved in the results.
1359 1359
  */
1360
-function give_list_pluck( $list, $field, $index_key = null ) {
1360
+function give_list_pluck($list, $field, $index_key = null) {
1361 1361
 
1362
-	if ( ! $index_key ) {
1362
+	if ( ! $index_key) {
1363 1363
 		/**
1364 1364
 		 * This is simple. Could at some point wrap array_column()
1365 1365
 		 * if we knew we had an array of arrays.
1366 1366
 		 */
1367
-		foreach ( $list as $key => $value ) {
1368
-			if ( is_object( $value ) ) {
1369
-				if ( isset( $value->$field ) ) {
1370
-					$list[ $key ] = $value->$field;
1367
+		foreach ($list as $key => $value) {
1368
+			if (is_object($value)) {
1369
+				if (isset($value->$field)) {
1370
+					$list[$key] = $value->$field;
1371 1371
 				}
1372 1372
 			} else {
1373
-				if ( isset( $value[ $field ] ) ) {
1374
-					$list[ $key ] = $value[ $field ];
1373
+				if (isset($value[$field])) {
1374
+					$list[$key] = $value[$field];
1375 1375
 				}
1376 1376
 			}
1377 1377
 		}
@@ -1384,18 +1384,18 @@  discard block
 block discarded – undo
1384 1384
 	 * to the end of the stack. This is how array_column() behaves.
1385 1385
 	 */
1386 1386
 	$newlist = array();
1387
-	foreach ( $list as $value ) {
1388
-		if ( is_object( $value ) ) {
1389
-			if ( isset( $value->$index_key ) ) {
1390
-				$newlist[ $value->$index_key ] = $value->$field;
1387
+	foreach ($list as $value) {
1388
+		if (is_object($value)) {
1389
+			if (isset($value->$index_key)) {
1390
+				$newlist[$value->$index_key] = $value->$field;
1391 1391
 			} else {
1392 1392
 				$newlist[] = $value->$field;
1393 1393
 			}
1394 1394
 		} else {
1395
-			if ( isset( $value[ $index_key ] ) ) {
1396
-				$newlist[ $value[ $index_key ] ] = $value[ $field ];
1395
+			if (isset($value[$index_key])) {
1396
+				$newlist[$value[$index_key]] = $value[$field];
1397 1397
 			} else {
1398
-				$newlist[] = $value[ $field ];
1398
+				$newlist[] = $value[$field];
1399 1399
 			}
1400 1400
 		}
1401 1401
 	}
@@ -1418,8 +1418,8 @@  discard block
 block discarded – undo
1418 1418
  *
1419 1419
  * @return int|false Meta ID on success, false on failure.
1420 1420
  */
1421
-function add_donor_meta( $donor_id, $meta_key, $meta_value, $unique = false ) {
1422
-	return add_metadata( 'give_customer', $donor_id, $meta_key, $meta_value, $unique );
1421
+function add_donor_meta($donor_id, $meta_key, $meta_value, $unique = false) {
1422
+	return add_metadata('give_customer', $donor_id, $meta_key, $meta_value, $unique);
1423 1423
 }
1424 1424
 
1425 1425
 /**
@@ -1437,8 +1437,8 @@  discard block
 block discarded – undo
1437 1437
  *
1438 1438
  * @return bool True on success, false on failure.
1439 1439
  */
1440
-function delete_donor_meta( $donor_id, $meta_key, $meta_value = '' ) {
1441
-	return delete_metadata( 'give_customer', $donor_id, $meta_key, $meta_value );
1440
+function delete_donor_meta($donor_id, $meta_key, $meta_value = '') {
1441
+	return delete_metadata('give_customer', $donor_id, $meta_key, $meta_value);
1442 1442
 }
1443 1443
 
1444 1444
 /**
@@ -1453,8 +1453,8 @@  discard block
 block discarded – undo
1453 1453
  * @return mixed Will be an array if $single is false. Will be value of meta data field if $single
1454 1454
  *  is true.
1455 1455
  */
1456
-function get_donor_meta( $donor_id, $key = '', $single = false ) {
1457
-	return get_metadata( 'give_customer', $donor_id, $key, $single );
1456
+function get_donor_meta($donor_id, $key = '', $single = false) {
1457
+	return get_metadata('give_customer', $donor_id, $key, $single);
1458 1458
 }
1459 1459
 
1460 1460
 /**
@@ -1471,8 +1471,8 @@  discard block
 block discarded – undo
1471 1471
  *
1472 1472
  * @return int|bool Meta ID if the key didn't exist, true on successful update, false on failure.
1473 1473
  */
1474
-function update_donor_meta( $donor_id, $meta_key, $meta_value, $prev_value = '' ) {
1475
-	return update_metadata( 'give_customer', $donor_id, $meta_key, $meta_value, $prev_value );
1474
+function update_donor_meta($donor_id, $meta_key, $meta_value, $prev_value = '') {
1475
+	return update_metadata('give_customer', $donor_id, $meta_key, $meta_value, $prev_value);
1476 1476
 }
1477 1477
 
1478 1478
 
@@ -1485,55 +1485,55 @@  discard block
 block discarded – undo
1485 1485
  *
1486 1486
  * @return void
1487 1487
  */
1488
-function give_recount_form_income_donation( $form_id = 0 ) {
1488
+function give_recount_form_income_donation($form_id = 0) {
1489 1489
 	// Check if form id is not empty.
1490
-	if ( ! empty( $form_id ) ) {
1490
+	if ( ! empty($form_id)) {
1491 1491
 		/**
1492 1492
 		 * Filter to modify payment status.
1493 1493
 		 *
1494 1494
 		 * @since 1.8.13
1495 1495
 		 */
1496
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
1496
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
1497 1497
 
1498 1498
 		/**
1499 1499
 		 * Filter to modify args of payment query before recalculating the form total
1500 1500
 		 *
1501 1501
 		 * @since 1.8.13
1502 1502
 		 */
1503
-		$args = apply_filters( 'give_recount_form_stats_args', array(
1503
+		$args = apply_filters('give_recount_form_stats_args', array(
1504 1504
 				'give_forms'     => $form_id,
1505 1505
 				'status'         => $accepted_statuses,
1506
-				'posts_per_page' => - 1,
1506
+				'posts_per_page' => -1,
1507 1507
 				'fields'         => 'ids',
1508
-			) );
1508
+			));
1509 1509
 
1510 1510
 		$totals = array(
1511 1511
 			'sales'    => 0,
1512 1512
 			'earnings' => 0,
1513 1513
 		);
1514 1514
 
1515
-		$payments = new Give_Payments_Query( $args );
1515
+		$payments = new Give_Payments_Query($args);
1516 1516
 		$payments = $payments->get_payments();
1517 1517
 
1518
-		if ( $payments ) {
1519
-			foreach ( $payments as $payment ) {
1518
+		if ($payments) {
1519
+			foreach ($payments as $payment) {
1520 1520
 				// Ensure acceptible status only
1521
-				if ( ! in_array( $payment->post_status, $accepted_statuses ) ) {
1521
+				if ( ! in_array($payment->post_status, $accepted_statuses)) {
1522 1522
 					continue;
1523 1523
 				}
1524 1524
 
1525 1525
 				// Ensure only payments for this form are counted
1526
-				if ( $payment->form_id != $form_id ) {
1526
+				if ($payment->form_id != $form_id) {
1527 1527
 					continue;
1528 1528
 				}
1529 1529
 
1530
-				$totals['sales'] ++;
1530
+				$totals['sales']++;
1531 1531
 				$totals['earnings'] += $payment->total;
1532 1532
 
1533 1533
 			}
1534 1534
 		}
1535
-		give_update_meta( $form_id, '_give_form_sales', $totals['sales'] );
1536
-		give_update_meta( $form_id, '_give_form_earnings', give_sanitize_amount_for_db( $totals['earnings'] ) );
1535
+		give_update_meta($form_id, '_give_form_sales', $totals['sales']);
1536
+		give_update_meta($form_id, '_give_form_earnings', give_sanitize_amount_for_db($totals['earnings']));
1537 1537
 	}// End if().
1538 1538
 }
1539 1539
 
@@ -1548,26 +1548,26 @@  discard block
 block discarded – undo
1548 1548
  *
1549 1549
  * @return string
1550 1550
  */
1551
-function give_get_attribute_str( $attributes, $default_attributes = array() ) {
1551
+function give_get_attribute_str($attributes, $default_attributes = array()) {
1552 1552
 	$attribute_str = '';
1553 1553
 
1554
-	if( isset( $attributes['attributes'] ) ) {
1554
+	if (isset($attributes['attributes'])) {
1555 1555
 		$attributes = $attributes['attributes'];
1556 1556
 	}
1557 1557
 
1558
-	if( ! empty( $default_attributes ) ) {
1559
-		$attributes = wp_parse_args( $attributes, $default_attributes );
1558
+	if ( ! empty($default_attributes)) {
1559
+		$attributes = wp_parse_args($attributes, $default_attributes);
1560 1560
 	}
1561 1561
 
1562
-	if ( empty( $attributes ) ) {
1562
+	if (empty($attributes)) {
1563 1563
 		return $attribute_str;
1564 1564
 	}
1565 1565
 
1566
-	foreach ( $attributes as $tag => $value ) {
1566
+	foreach ($attributes as $tag => $value) {
1567 1567
 		$attribute_str .= " {$tag}=\"{$value}\"";
1568 1568
 	}
1569 1569
 
1570
-	return trim( $attribute_str );
1570
+	return trim($attribute_str);
1571 1571
 }
1572 1572
 
1573 1573
 /**
@@ -1580,7 +1580,7 @@  discard block
 block discarded – undo
1580 1580
 function give_get_wp_upload_dir() {
1581 1581
 	$wp_upload_dir = wp_upload_dir();
1582 1582
 
1583
-	return ( ! empty( $wp_upload_dir['path'] ) ? $wp_upload_dir['path'] : false );
1583
+	return ( ! empty($wp_upload_dir['path']) ? $wp_upload_dir['path'] : false);
1584 1584
 }
1585 1585
 
1586 1586
 /**
@@ -1592,15 +1592,15 @@  discard block
 block discarded – undo
1592 1592
  *
1593 1593
  * @return string|bool $file_contents File content
1594 1594
  */
1595
-function give_get_core_settings_json( $file_name ) {
1595
+function give_get_core_settings_json($file_name) {
1596 1596
 	$upload_dir = give_get_wp_upload_dir();
1597
-	$file_path  = $upload_dir . '/' . $file_name;
1597
+	$file_path  = $upload_dir.'/'.$file_name;
1598 1598
 
1599
-	if ( is_wp_error( $file_path ) || empty( $file_path ) ) {
1600
-		Give_Admin_Settings::add_error( 'give-import-csv', __( 'Please upload or provide a valid JSON file.', 'give' ) );
1599
+	if (is_wp_error($file_path) || empty($file_path)) {
1600
+		Give_Admin_Settings::add_error('give-import-csv', __('Please upload or provide a valid JSON file.', 'give'));
1601 1601
 	}
1602 1602
 
1603
-	$file_contents = file_get_contents( $file_path );
1603
+	$file_contents = file_get_contents($file_path);
1604 1604
 
1605 1605
 	return $file_contents;
1606 1606
 }
@@ -1613,7 +1613,7 @@  discard block
 block discarded – undo
1613 1613
  * @return int $country The two letter country code for the site's base country
1614 1614
  */
1615 1615
 function give_get_limit_display_donations() {
1616
-	return give_get_option( 'limit_display_donations', 1 );
1616
+	return give_get_option('limit_display_donations', 1);
1617 1617
 }
1618 1618
 
1619 1619
 /**
@@ -1622,7 +1622,7 @@  discard block
 block discarded – undo
1622 1622
  * @since 1.8.17
1623 1623
  */
1624 1624
 function give_donation_history_table_end() {
1625
-	$email = Give()->session->get( 'give_email' );
1625
+	$email = Give()->session->get('give_email');
1626 1626
 	?>
1627 1627
 	<tfoot>
1628 1628
 	<tr>
@@ -1630,15 +1630,15 @@  discard block
 block discarded – undo
1630 1630
 			<div class="give-security-wrap">
1631 1631
 				<div class="give-security-column give-security-description-wrap">
1632 1632
 					<?php
1633
-					echo sprintf( __( 'For security reasons, please confirm your email address (%s) to view your complete donation history.', 'give' ), $email );
1633
+					echo sprintf(__('For security reasons, please confirm your email address (%s) to view your complete donation history.', 'give'), $email);
1634 1634
 					?>
1635 1635
 				</div>
1636 1636
 				<div class="give-security-column give-security-button-wrap">
1637 1637
 					<a href="#" data-email="<?php echo $email; ?>" id="give-confirm-email-btn"
1638 1638
 					   class="give-confirm-email-btn give-btn">
1639
-						<?php _e( 'Confirm Email', 'give' ); ?>
1639
+						<?php _e('Confirm Email', 'give'); ?>
1640 1640
 					</a>
1641
-					<span><?php _e( 'Email Sent!', 'give' ); ?></span>
1641
+					<span><?php _e('Email Sent!', 'give'); ?></span>
1642 1642
 				</div>
1643 1643
 			</div>
1644 1644
 		</td>
@@ -1659,10 +1659,10 @@  discard block
 block discarded – undo
1659 1659
  *
1660 1660
  * @return void
1661 1661
  */
1662
-function give_doing_it_wrong( $function, $message, $version ) {
1663
-	$message .= "\nBacktrace:" . wp_debug_backtrace_summary();
1662
+function give_doing_it_wrong($function, $message, $version) {
1663
+	$message .= "\nBacktrace:".wp_debug_backtrace_summary();
1664 1664
 
1665
-	_doing_it_wrong( $function, $message, $version );
1665
+	_doing_it_wrong($function, $message, $version);
1666 1666
 }
1667 1667
 
1668 1668
 
@@ -1672,10 +1672,10 @@  discard block
 block discarded – undo
1672 1672
  * @since 1.8.18
1673 1673
  */
1674 1674
 function give_ignore_user_abort() {
1675
-	ignore_user_abort( true );
1675
+	ignore_user_abort(true);
1676 1676
 
1677
-	if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
1678
-		set_time_limit( 0 );
1677
+	if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
1678
+		set_time_limit(0);
1679 1679
 	}
1680 1680
 }
1681 1681
 
@@ -1689,28 +1689,28 @@  discard block
 block discarded – undo
1689 1689
  *
1690 1690
  * @return int
1691 1691
  */
1692
-function give_get_total_post_type_count( $post_type = '', $args = array() ) {
1692
+function give_get_total_post_type_count($post_type = '', $args = array()) {
1693 1693
 	global $wpdb;
1694 1694
 	$where = '';
1695 1695
 
1696
-	if ( ! $post_type ) {
1696
+	if ( ! $post_type) {
1697 1697
 		return 0;
1698 1698
 	}
1699 1699
 
1700 1700
 	// Bulit where query
1701
-	if ( ! empty( $post_type ) ) {
1701
+	if ( ! empty($post_type)) {
1702 1702
 		$where .= ' WHERE';
1703 1703
 
1704
-		if ( is_array( $post_type ) ) {
1705
-			$where .= " post_type='" . implode( "' OR post_type='", $post_type ) . "'";
1704
+		if (is_array($post_type)) {
1705
+			$where .= " post_type='".implode("' OR post_type='", $post_type)."'";
1706 1706
 		} else {
1707 1707
 			$where .= " post_type='{$post_type}'";
1708 1708
 		}
1709 1709
 	}
1710 1710
 
1711
-	$result = $wpdb->get_var( "SELECT count(ID) FROM {$wpdb->posts}{$where}" );
1711
+	$result = $wpdb->get_var("SELECT count(ID) FROM {$wpdb->posts}{$where}");
1712 1712
 
1713
-	return absint( $result );
1713
+	return absint($result);
1714 1714
 }
1715 1715
 
1716 1716
 /**
@@ -1723,9 +1723,9 @@  discard block
 block discarded – undo
1723 1723
  *
1724 1724
  * @credit WooCommerce
1725 1725
  */
1726
-function give_maybe_define_constant( $name, $value ) {
1727
-	if ( ! defined( $name ) ) {
1728
-		define( $name, $value );
1726
+function give_maybe_define_constant($name, $value) {
1727
+	if ( ! defined($name)) {
1728
+		define($name, $value);
1729 1729
 	}
1730 1730
 }
1731 1731
 
@@ -1739,10 +1739,10 @@  discard block
 block discarded – undo
1739 1739
  *
1740 1740
  * @return string
1741 1741
  */
1742
-function give_time_do_tags( $string, $timestamp = 0 ) {
1743
-	$current_time = ! empty( $timestamp ) ? $timestamp : current_time( 'timestamp' );
1742
+function give_time_do_tags($string, $timestamp = 0) {
1743
+	$current_time = ! empty($timestamp) ? $timestamp : current_time('timestamp');
1744 1744
 
1745
-	$formatted_string = str_replace( array(
1745
+	$formatted_string = str_replace(array(
1746 1746
 		'{D}',
1747 1747
 		'{DD}',
1748 1748
 		'{M}',
@@ -1754,23 +1754,23 @@  discard block
 block discarded – undo
1754 1754
 		'{N}',
1755 1755
 		'{S}'
1756 1756
 	), array(
1757
-			date( 'j', $current_time ),
1758
-			date( 'd', $current_time ),
1759
-			date( 'n', $current_time ),
1760
-			date( 'm', $current_time ),
1761
-			date( 'Y', $current_time ),
1762
-			date( 'Y', $current_time ),
1763
-			date( 'G', $current_time ),
1764
-			date( 'H', $current_time ),
1765
-			date( 's', $current_time )
1766
-		), $string );
1757
+			date('j', $current_time),
1758
+			date('d', $current_time),
1759
+			date('n', $current_time),
1760
+			date('m', $current_time),
1761
+			date('Y', $current_time),
1762
+			date('Y', $current_time),
1763
+			date('G', $current_time),
1764
+			date('H', $current_time),
1765
+			date('s', $current_time)
1766
+		), $string);
1767 1767
 
1768 1768
 	/**
1769 1769
 	 * Filter the parsed string.
1770 1770
 	 *
1771 1771
 	 * @since 2.1.0
1772 1772
 	 */
1773
-	return apply_filters( 'give_time_do_tags', $formatted_string, $string, $timestamp );
1773
+	return apply_filters('give_time_do_tags', $formatted_string, $string, $timestamp);
1774 1774
 }
1775 1775
 
1776 1776
 
@@ -1783,23 +1783,23 @@  discard block
 block discarded – undo
1783 1783
  *
1784 1784
  * @return bool
1785 1785
  */
1786
-function give_is_company_field_enabled( $form_id ) {
1787
-	$form_setting_val   = give_get_meta( $form_id, '_give_company_field', true );
1788
-	$global_setting_val = give_get_option( 'company_field' );
1786
+function give_is_company_field_enabled($form_id) {
1787
+	$form_setting_val   = give_get_meta($form_id, '_give_company_field', true);
1788
+	$global_setting_val = give_get_option('company_field');
1789 1789
 
1790
-	if ( ! empty( $form_setting_val ) ) {
1791
-		if ( give_is_setting_enabled( $form_setting_val, array( 'required', 'optional' ) ) ) {
1790
+	if ( ! empty($form_setting_val)) {
1791
+		if (give_is_setting_enabled($form_setting_val, array('required', 'optional'))) {
1792 1792
 			return true;
1793
-		} elseif ( 'global' === $form_setting_val && give_is_setting_enabled( $global_setting_val, array(
1793
+		} elseif ('global' === $form_setting_val && give_is_setting_enabled($global_setting_val, array(
1794 1794
 				'required',
1795 1795
 				'optional'
1796
-			) ) ) {
1796
+			))) {
1797 1797
 			return true;
1798 1798
 		} else {
1799 1799
 			return false;
1800 1800
 		}
1801 1801
 
1802
-	} elseif ( give_is_setting_enabled( $global_setting_val, array( 'required', 'optional' ) ) ) {
1802
+	} elseif (give_is_setting_enabled($global_setting_val, array('required', 'optional'))) {
1803 1803
 		return true;
1804 1804
 
1805 1805
 	} else {
@@ -1816,19 +1816,19 @@  discard block
 block discarded – undo
1816 1816
  *
1817 1817
  * @return bool
1818 1818
  */
1819
-function give_is_anonymous_donation_field_enabled( $form_id ) {
1820
-	$form_setting_val   = give_get_meta( $form_id, '_give_anonymous_donation', true, 'global' );
1821
-	$global_setting_val = give_get_option( 'anonymous_donation', 'disabled' );
1819
+function give_is_anonymous_donation_field_enabled($form_id) {
1820
+	$form_setting_val   = give_get_meta($form_id, '_give_anonymous_donation', true, 'global');
1821
+	$global_setting_val = give_get_option('anonymous_donation', 'disabled');
1822 1822
 
1823
-	if ( ! empty( $form_setting_val ) ) {
1824
-		if( give_is_setting_enabled( $form_setting_val ) ) {
1823
+	if ( ! empty($form_setting_val)) {
1824
+		if (give_is_setting_enabled($form_setting_val)) {
1825 1825
 			return true;
1826
-		}elseif ( 'global' === $form_setting_val && give_is_setting_enabled( $global_setting_val ) ){
1826
+		}elseif ('global' === $form_setting_val && give_is_setting_enabled($global_setting_val)) {
1827 1827
 			return true;
1828
-		}else{
1828
+		} else {
1829 1829
 			return false;
1830 1830
 		}
1831
-	} elseif ( give_is_setting_enabled( $global_setting_val ) ) {
1831
+	} elseif (give_is_setting_enabled($global_setting_val)) {
1832 1832
 		return true;
1833 1833
 	}
1834 1834
 
@@ -1844,19 +1844,19 @@  discard block
 block discarded – undo
1844 1844
  *
1845 1845
  * @return bool
1846 1846
  */
1847
-function give_is_donor_comment_field_enabled( $form_id ) {
1848
-	$form_setting_val   = give_get_meta( $form_id, '_give_donor_comment', true, 'global' );
1849
-	$global_setting_val = give_get_option( 'donor_comment', 'disabled' );
1847
+function give_is_donor_comment_field_enabled($form_id) {
1848
+	$form_setting_val   = give_get_meta($form_id, '_give_donor_comment', true, 'global');
1849
+	$global_setting_val = give_get_option('donor_comment', 'disabled');
1850 1850
 
1851
-	if ( ! empty( $form_setting_val ) ) {
1852
-		if( give_is_setting_enabled( $form_setting_val ) ) {
1851
+	if ( ! empty($form_setting_val)) {
1852
+		if (give_is_setting_enabled($form_setting_val)) {
1853 1853
 			return true;
1854
-		} elseif ( 'global' === $form_setting_val && give_is_setting_enabled( $global_setting_val ) ){
1854
+		} elseif ('global' === $form_setting_val && give_is_setting_enabled($global_setting_val)) {
1855 1855
 			return true;
1856
-		}else{
1856
+		} else {
1857 1857
 			return false;
1858 1858
 		}
1859
-	} elseif ( give_is_setting_enabled( $global_setting_val ) ) {
1859
+	} elseif (give_is_setting_enabled($global_setting_val)) {
1860 1860
 		return true;
1861 1861
 	}
1862 1862
 
@@ -1874,13 +1874,13 @@  discard block
 block discarded – undo
1874 1874
  *
1875 1875
  * @return array
1876 1876
  */
1877
-function __give_get_active_license_info( $license_id ) {
1877
+function __give_get_active_license_info($license_id) {
1878 1878
 	global $wpdb;
1879 1879
 	$option_name = "{$license_id}_license_active";
1880 1880
 	$data        = array();
1881 1881
 
1882
-	if ( ! isset( $GLOBALS['give_active_licenses_info'] ) ) {
1883
-		$GLOBALS['give_active_licenses_info']  = array();
1882
+	if ( ! isset($GLOBALS['give_active_licenses_info'])) {
1883
+		$GLOBALS['give_active_licenses_info'] = array();
1884 1884
 
1885 1885
 		$licenses_info = $wpdb->get_results(
1886 1886
 			"
@@ -1892,16 +1892,16 @@  discard block
 block discarded – undo
1892 1892
 			ARRAY_A
1893 1893
 		);
1894 1894
 
1895
-		if ( ! empty( $licenses_info ) ) {
1895
+		if ( ! empty($licenses_info)) {
1896 1896
 			$GLOBALS['give_active_licenses_info'] = array_combine(
1897
-				wp_list_pluck( $licenses_info, 'option_name' ),
1898
-				wp_list_pluck( $licenses_info, 'option_value' )
1897
+				wp_list_pluck($licenses_info, 'option_name'),
1898
+				wp_list_pluck($licenses_info, 'option_value')
1899 1899
 			);
1900 1900
 		}
1901 1901
 	}
1902 1902
 
1903
-	if ( in_array( $option_name, array_keys( $GLOBALS['give_active_licenses_info'] ) ) ) {
1904
-		$data = maybe_unserialize( $GLOBALS['give_active_licenses_info'][ $option_name ] );
1903
+	if (in_array($option_name, array_keys($GLOBALS['give_active_licenses_info']))) {
1904
+		$data = maybe_unserialize($GLOBALS['give_active_licenses_info'][$option_name]);
1905 1905
 	}
1906 1906
 
1907 1907
 	return $data;
@@ -1917,18 +1917,18 @@  discard block
 block discarded – undo
1917 1917
  *
1918 1918
  * @return array
1919 1919
  */
1920
-function __give_get_active_by_user_meta( $banner_addon_name ) {
1920
+function __give_get_active_by_user_meta($banner_addon_name) {
1921 1921
 	global $wpdb;
1922 1922
 
1923 1923
 	// Get the option key.
1924
-	$option_name = Give_Addon_Activation_Banner::get_banner_user_meta_key( $banner_addon_name );
1924
+	$option_name = Give_Addon_Activation_Banner::get_banner_user_meta_key($banner_addon_name);
1925 1925
 	$data        = array();
1926 1926
 
1927 1927
 	if (
1928
-		! isset( $GLOBALS['give_addon_activated_by_user'][ $banner_addon_name ] )
1929
-		|| empty( $GLOBALS['give_addon_activated_by_user'][ $banner_addon_name ] )
1928
+		! isset($GLOBALS['give_addon_activated_by_user'][$banner_addon_name])
1929
+		|| empty($GLOBALS['give_addon_activated_by_user'][$banner_addon_name])
1930 1930
 	) {
1931
-		$GLOBALS['give_addon_activated_by_user'][ $banner_addon_name ] = array();
1931
+		$GLOBALS['give_addon_activated_by_user'][$banner_addon_name] = array();
1932 1932
 
1933 1933
 		// Get the meta of activation banner by user.
1934 1934
 		$activation_banners = $wpdb->get_results(
@@ -1941,16 +1941,16 @@  discard block
 block discarded – undo
1941 1941
 			ARRAY_A
1942 1942
 		);
1943 1943
 
1944
-		if ( ! empty( $activation_banners ) ) {
1944
+		if ( ! empty($activation_banners)) {
1945 1945
 			$GLOBALS['give_addon_activated_by_user'] = array_combine(
1946
-				wp_list_pluck( $activation_banners, 'option_name' ),
1947
-				wp_list_pluck( $activation_banners, 'option_value' )
1946
+				wp_list_pluck($activation_banners, 'option_name'),
1947
+				wp_list_pluck($activation_banners, 'option_value')
1948 1948
 			);
1949 1949
 		}
1950 1950
 	}
1951 1951
 
1952
-	if ( in_array( $option_name, array_keys( $GLOBALS['give_addon_activated_by_user'] ) ) ) {
1953
-		$data = maybe_unserialize( $GLOBALS['give_addon_activated_by_user'][ $option_name ] );
1952
+	if (in_array($option_name, array_keys($GLOBALS['give_addon_activated_by_user']))) {
1953
+		$data = maybe_unserialize($GLOBALS['give_addon_activated_by_user'][$option_name]);
1954 1954
 	}
1955 1955
 
1956 1956
 	return $data;
@@ -1963,13 +1963,13 @@  discard block
 block discarded – undo
1963 1963
  *
1964 1964
  * @return int
1965 1965
  */
1966
-function give_get_nonce_life(){
1966
+function give_get_nonce_life() {
1967 1967
 	/**
1968 1968
 	 * Filters the lifespan of nonces in seconds.
1969 1969
 	 *
1970 1970
 	 * @see wp-inlucdes/pluggable.php:wp_nonce_tick
1971 1971
 	 */
1972
-	return (int) apply_filters( 'nonce_life', DAY_IN_SECONDS );
1972
+	return (int) apply_filters('nonce_life', DAY_IN_SECONDS);
1973 1973
 }
1974 1974
 
1975 1975
 /**
@@ -1983,11 +1983,11 @@  discard block
 block discarded – undo
1983 1983
  *
1984 1984
  * @return string
1985 1985
  */
1986
-function give_get_nonce_field( $action, $name, $referer = false ) {
1986
+function give_get_nonce_field($action, $name, $referer = false) {
1987 1987
 	return str_replace(
1988 1988
 		"id=\"{$name}\"",
1989 1989
 		'',
1990
-		wp_nonce_field( $action, $name, $referer, false )
1990
+		wp_nonce_field($action, $name, $referer, false)
1991 1991
 	);
1992 1992
 }
1993 1993
 
@@ -2000,31 +2000,31 @@  discard block
 block discarded – undo
2000 2000
  *
2001 2001
  * @return array
2002 2002
  */
2003
-function give_goal_progress_stats( $form ) {
2003
+function give_goal_progress_stats($form) {
2004 2004
 
2005
-	if ( ! $form instanceof Give_Donate_Form ) {
2006
-		$form = new Give_Donate_Form( $form );
2005
+	if ( ! $form instanceof Give_Donate_Form) {
2006
+		$form = new Give_Donate_Form($form);
2007 2007
 	}
2008 2008
 
2009 2009
 	$donors = '';
2010 2010
 
2011
-	$goal_format = give_get_form_goal_format( $form->ID );
2011
+	$goal_format = give_get_form_goal_format($form->ID);
2012 2012
 
2013 2013
 	/**
2014 2014
 	 * Filter the form.
2015 2015
 	 *
2016 2016
 	 * @since 1.8.8
2017 2017
 	 */
2018
-	$total_goal = apply_filters( 'give_goal_amount_target_output', round( give_maybe_sanitize_amount( $form->goal ) ), $form->ID, $form );
2018
+	$total_goal = apply_filters('give_goal_amount_target_output', round(give_maybe_sanitize_amount($form->goal)), $form->ID, $form);
2019 2019
 
2020
-	switch ( $goal_format ) {
2020
+	switch ($goal_format) {
2021 2021
 		case  'donation':
2022 2022
 			/**
2023 2023
 			 * Filter the form donations.
2024 2024
 			 *
2025 2025
 			 * @since 2.1
2026 2026
 			 */
2027
-			$actual = $donations = apply_filters( 'give_goal_donations_raised_output', $form->sales, $form->ID, $form );
2027
+			$actual = $donations = apply_filters('give_goal_donations_raised_output', $form->sales, $form->ID, $form);
2028 2028
 			break;
2029 2029
 		case 'donors':
2030 2030
 			/**
@@ -2038,7 +2038,7 @@  discard block
 block discarded – undo
2038 2038
 			 *
2039 2039
 			 * @return int $donors Total number of donors that donated to the form.
2040 2040
 			 */
2041
-			$actual = $donors = apply_filters( 'give_goal_donors_target_output', give_get_form_donor_count( $form->ID ), $form->ID, $form );
2041
+			$actual = $donors = apply_filters('give_goal_donors_target_output', give_get_form_donor_count($form->ID), $form->ID, $form);
2042 2042
 			break;
2043 2043
 		default :
2044 2044
 			/**
@@ -2046,11 +2046,11 @@  discard block
 block discarded – undo
2046 2046
 			 *
2047 2047
 			 * @since 1.8.8
2048 2048
 			 */
2049
-			$actual = $income = apply_filters( 'give_goal_amount_raised_output', $form->earnings, $form->ID, $form );
2049
+			$actual = $income = apply_filters('give_goal_amount_raised_output', $form->earnings, $form->ID, $form);
2050 2050
 			break;
2051 2051
 	}
2052 2052
 
2053
-	$progress = $total_goal ? round( ( $actual / $total_goal ) * 100, 2 ) : 0;
2053
+	$progress = $total_goal ? round(($actual / $total_goal) * 100, 2) : 0;
2054 2054
 
2055 2055
 	$stats_array = array(
2056 2056
 		'raw_actual' => $actual,
@@ -2062,20 +2062,20 @@  discard block
 block discarded – undo
2062 2062
 	 *
2063 2063
 	 * @since 1.8.8
2064 2064
 	 */
2065
-	$progress = apply_filters( 'give_goal_amount_funded_percentage_output', $progress, $form->ID, $form );
2065
+	$progress = apply_filters('give_goal_amount_funded_percentage_output', $progress, $form->ID, $form);
2066 2066
 
2067 2067
 	// Define Actual Goal based on the goal format.
2068
-	if ( 'percentage' === $goal_format ) {
2068
+	if ('percentage' === $goal_format) {
2069 2069
 		$actual = "{$actual}%";
2070
-	} else if ( 'amount' === $goal_format ) {
2071
-		$actual = give_currency_filter( give_format_amount( $actual ) );
2070
+	} else if ('amount' === $goal_format) {
2071
+		$actual = give_currency_filter(give_format_amount($actual));
2072 2072
 	}
2073 2073
 
2074 2074
 	// Define Total Goal based on the goal format.
2075
-	if ( 'percentage' === $goal_format ) {
2075
+	if ('percentage' === $goal_format) {
2076 2076
 		$total_goal = '';
2077
-	} else if ( 'amount' === $goal_format ) {
2078
-		$total_goal = give_currency_filter( give_format_amount( $total_goal ) );
2077
+	} else if ('amount' === $goal_format) {
2078
+		$total_goal = give_currency_filter(give_format_amount($total_goal));
2079 2079
 	}
2080 2080
 
2081 2081
 	$stats_array = array_merge(
@@ -2093,7 +2093,7 @@  discard block
 block discarded – undo
2093 2093
 	 *
2094 2094
 	 * @since 2.1
2095 2095
 	 */
2096
-	return apply_filters( 'give_goal_progress_stats', $stats_array );
2096
+	return apply_filters('give_goal_progress_stats', $stats_array);
2097 2097
 }
2098 2098
 
2099 2099
 /**
@@ -2105,20 +2105,20 @@  discard block
 block discarded – undo
2105 2105
  *
2106 2106
  * @return mixed
2107 2107
  */
2108
-function give_get_name_title_prefixes( $form_id = 0 ) {
2108
+function give_get_name_title_prefixes($form_id = 0) {
2109 2109
 
2110
-	$name_title_prefix = give_is_name_title_prefix_enabled( $form_id );
2111
-	$title_prefixes    = give_get_option( 'title_prefixes' );
2110
+	$name_title_prefix = give_is_name_title_prefix_enabled($form_id);
2111
+	$title_prefixes    = give_get_option('title_prefixes');
2112 2112
 
2113 2113
 	// If form id exists, then fetch form specific title prefixes.
2114
-	if ( intval( $form_id ) > 0 && $name_title_prefix ) {
2114
+	if (intval($form_id) > 0 && $name_title_prefix) {
2115 2115
 
2116
-		$form_title_prefix = give_get_meta( $form_id, '_give_name_title_prefix', true );
2117
-		if ( 'global' !== $form_title_prefix ) {
2118
-			$form_title_prefixes = give_get_meta( $form_id, '_give_title_prefixes', true );
2116
+		$form_title_prefix = give_get_meta($form_id, '_give_name_title_prefix', true);
2117
+		if ('global' !== $form_title_prefix) {
2118
+			$form_title_prefixes = give_get_meta($form_id, '_give_title_prefixes', true);
2119 2119
 
2120 2120
 			// Check whether the form based title prefixes exists or not.
2121
-			if ( is_array( $form_title_prefixes ) && count( $form_title_prefixes ) > 0 ) {
2121
+			if (is_array($form_title_prefixes) && count($form_title_prefixes) > 0) {
2122 2122
 				$title_prefixes = $form_title_prefixes;
2123 2123
 			}
2124 2124
 		}
@@ -2137,22 +2137,22 @@  discard block
 block discarded – undo
2137 2137
  *
2138 2138
  * @return bool
2139 2139
  */
2140
-function give_is_name_title_prefix_enabled( $form_id = 0, $status = '' ) {
2141
-	if ( empty( $status ) ) {
2142
-		$status = array( 'required', 'optional' );
2140
+function give_is_name_title_prefix_enabled($form_id = 0, $status = '') {
2141
+	if (empty($status)) {
2142
+		$status = array('required', 'optional');
2143 2143
 	} else {
2144
-		$status = array( $status );
2144
+		$status = array($status);
2145 2145
 	}
2146 2146
 
2147
-	$title_prefix_status = give_is_setting_enabled( give_get_option( 'name_title_prefix' ), $status );
2147
+	$title_prefix_status = give_is_setting_enabled(give_get_option('name_title_prefix'), $status);
2148 2148
 
2149
-	if ( intval( $form_id ) > 0 ) {
2150
-		$form_title_prefix = give_get_meta( $form_id, '_give_name_title_prefix', true );
2149
+	if (intval($form_id) > 0) {
2150
+		$form_title_prefix = give_get_meta($form_id, '_give_name_title_prefix', true);
2151 2151
 
2152
-		if ( 'disabled' === $form_title_prefix ) {
2152
+		if ('disabled' === $form_title_prefix) {
2153 2153
 			$title_prefix_status = false;
2154
-		} elseif ( in_array( $form_title_prefix, $status, true ) ) {
2155
-			$title_prefix_status = give_is_setting_enabled( $form_title_prefix, $status );
2154
+		} elseif (in_array($form_title_prefix, $status, true)) {
2155
+			$title_prefix_status = give_is_setting_enabled($form_title_prefix, $status);
2156 2156
 		}
2157 2157
 	}
2158 2158
 
@@ -2169,18 +2169,18 @@  discard block
 block discarded – undo
2169 2169
  *
2170 2170
  * @return object
2171 2171
  */
2172
-function give_get_name_with_title_prefixes( $donor ) {
2172
+function give_get_name_with_title_prefixes($donor) {
2173 2173
 
2174 2174
 	// Prepare Give_Donor object, if $donor is numeric.
2175
-	if ( is_numeric( $donor ) ) {
2176
-		$donor = new Give_Donor( $donor );
2175
+	if (is_numeric($donor)) {
2176
+		$donor = new Give_Donor($donor);
2177 2177
 	}
2178 2178
 
2179
-	$title_prefix = Give()->donor_meta->get_meta( $donor->id, '_give_donor_title_prefix', true );
2179
+	$title_prefix = Give()->donor_meta->get_meta($donor->id, '_give_donor_title_prefix', true);
2180 2180
 
2181 2181
 	// Update Donor name, if non empty title prefix.
2182
-	if ( ! empty( $title_prefix ) ) {
2183
-		$donor->name = give_get_donor_name_with_title_prefixes( $title_prefix, $donor->name );
2182
+	if ( ! empty($title_prefix)) {
2183
+		$donor->name = give_get_donor_name_with_title_prefixes($title_prefix, $donor->name);
2184 2184
 	}
2185 2185
 
2186 2186
 	return $donor;
@@ -2196,15 +2196,15 @@  discard block
 block discarded – undo
2196 2196
  *
2197 2197
  * @return string
2198 2198
  */
2199
-function give_get_donor_name_with_title_prefixes( $title_prefix, $name ) {
2199
+function give_get_donor_name_with_title_prefixes($title_prefix, $name) {
2200 2200
 
2201 2201
 	$donor_name = $name;
2202 2202
 
2203
-	if ( ! empty( $title_prefix ) && ! empty( $name ) ) {
2203
+	if ( ! empty($title_prefix) && ! empty($name)) {
2204 2204
 		$donor_name = "{$title_prefix} {$name}";
2205 2205
 	}
2206 2206
 
2207
-	return trim( $donor_name );
2207
+	return trim($donor_name);
2208 2208
 }
2209 2209
 
2210 2210
 /**
@@ -2224,9 +2224,9 @@  discard block
 block discarded – undo
2224 2224
 	return apply_filters(
2225 2225
 		'give_get_default_title_prefixes',
2226 2226
 		array(
2227
-			'Mr.'  => __( 'Mr.', 'give' ),
2228
-			'Mrs.' => __( 'Mrs.', 'give' ),
2229
-			'Ms.'  => __( 'Ms.', 'give' ),
2227
+			'Mr.'  => __('Mr.', 'give'),
2228
+			'Mrs.' => __('Mrs.', 'give'),
2229
+			'Ms.'  => __('Ms.', 'give'),
2230 2230
 		)
2231 2231
 	);
2232 2232
 }
@@ -2240,27 +2240,27 @@  discard block
 block discarded – undo
2240 2240
  *
2241 2241
  * @return bool
2242 2242
  */
2243
-function give_is_name_title_prefix_required( $form_id = 0 ) {
2243
+function give_is_name_title_prefix_required($form_id = 0) {
2244 2244
 
2245 2245
 	// Bail out, if name title prefix is not enabled.
2246
-	if ( ! give_is_name_title_prefix_enabled( $form_id ) ) {
2246
+	if ( ! give_is_name_title_prefix_enabled($form_id)) {
2247 2247
 		return false;
2248 2248
 	}
2249 2249
 
2250
-	$status      = array( 'optional' );
2251
-	$is_optional = give_is_setting_enabled( give_get_option( 'name_title_prefix' ), $status );
2250
+	$status      = array('optional');
2251
+	$is_optional = give_is_setting_enabled(give_get_option('name_title_prefix'), $status);
2252 2252
 
2253
-	if ( intval( $form_id ) > 0 ) {
2254
-		$form_title_prefix = give_get_meta( $form_id, '_give_name_title_prefix', true );
2253
+	if (intval($form_id) > 0) {
2254
+		$form_title_prefix = give_get_meta($form_id, '_give_name_title_prefix', true);
2255 2255
 
2256
-		if ( 'required' === $form_title_prefix ) {
2256
+		if ('required' === $form_title_prefix) {
2257 2257
 			$is_optional = false;
2258
-		} elseif ( 'optional' === $form_title_prefix ) {
2258
+		} elseif ('optional' === $form_title_prefix) {
2259 2259
 			$is_optional = true;
2260 2260
 		}
2261 2261
 	}
2262 2262
 
2263
-	return ( ! $is_optional );
2263
+	return ( ! $is_optional);
2264 2264
 }
2265 2265
 
2266 2266
 /**
@@ -2271,11 +2271,11 @@  discard block
 block discarded – undo
2271 2271
  * @return array $message admin message key.
2272 2272
  */
2273 2273
 function give_get_admin_messages_key() {
2274
-	$messages = empty( $_GET['give-messages'] ) ? array() : give_clean( $_GET['give-messages'] );
2274
+	$messages = empty($_GET['give-messages']) ? array() : give_clean($_GET['give-messages']);
2275 2275
 
2276 2276
 	// backward compatibility.
2277
-	if ( ! empty( $_GET['give-message'] ) ) {
2278
-		$messages[] = give_clean( $_GET['give-message'] );
2277
+	if ( ! empty($_GET['give-message'])) {
2278
+		$messages[] = give_clean($_GET['give-message']);
2279 2279
 	}
2280 2280
 
2281 2281
 	/**
@@ -2287,7 +2287,7 @@  discard block
 block discarded – undo
2287 2287
 	 *
2288 2288
 	 * @return array $message admin message key.
2289 2289
 	 */
2290
-	return (array) apply_filters( 'give_get_admin_messages_key', $messages );
2290
+	return (array) apply_filters('give_get_admin_messages_key', $messages);
2291 2291
 }
2292 2292
 
2293 2293
 /**
@@ -2300,7 +2300,7 @@  discard block
 block discarded – undo
2300 2300
 function give_get_user_agent() {
2301 2301
 
2302 2302
 	// Get User Agent.
2303
-	$user_agent = ! empty( $_SERVER['HTTP_USER_AGENT'] ) ? give_clean( $_SERVER['HTTP_USER_AGENT'] ) : ''; // WPCS: input var ok.
2303
+	$user_agent = ! empty($_SERVER['HTTP_USER_AGENT']) ? give_clean($_SERVER['HTTP_USER_AGENT']) : ''; // WPCS: input var ok.
2304 2304
 
2305 2305
 	return $user_agent;
2306 2306
 }
@@ -2315,11 +2315,11 @@  discard block
 block discarded – undo
2315 2315
  * @param  integer $expire Expiry of the cookie.
2316 2316
  * @param  bool    $secure Whether the cookie should be served only over https.
2317 2317
  */
2318
-function give_setcookie( $name, $value, $expire = 0, $secure = false ) {
2319
-	if ( ! headers_sent() ) {
2318
+function give_setcookie($name, $value, $expire = 0, $secure = false) {
2319
+	if ( ! headers_sent()) {
2320 2320
 		setcookie(
2321
-			$name,$value, $expire, COOKIEPATH ? COOKIEPATH : '/', COOKIE_DOMAIN, $secure,
2322
-			apply_filters( 'give_cookie_httponly', false, $name, $value, $expire, $secure )
2321
+			$name, $value, $expire, COOKIEPATH ? COOKIEPATH : '/', COOKIE_DOMAIN, $secure,
2322
+			apply_filters('give_cookie_httponly', false, $name, $value, $expire, $secure)
2323 2323
 		);
2324 2324
 	}
2325 2325
 }
@@ -2333,7 +2333,7 @@  discard block
 block discarded – undo
2333 2333
  *
2334 2334
  * @return string Formatted address.
2335 2335
  */
2336
-function give_get_formatted_address( $address = array() ) {
2336
+function give_get_formatted_address($address = array()) {
2337 2337
 	$formatted_address = '';
2338 2338
 
2339 2339
 	/**
@@ -2341,21 +2341,21 @@  discard block
 block discarded – undo
2341 2341
 	 *
2342 2342
 	 * @since 2.2.0
2343 2343
 	 */
2344
-	$address_format = apply_filters( 'give_address_format_template', "{street_address}\n{city}, {state} {postal_code}\n{country}" );
2345
-	preg_match_all( "/{([A-z0-9\-\_\ ]+)}/s", $address_format, $matches );
2344
+	$address_format = apply_filters('give_address_format_template', "{street_address}\n{city}, {state} {postal_code}\n{country}");
2345
+	preg_match_all("/{([A-z0-9\-\_\ ]+)}/s", $address_format, $matches);
2346 2346
 
2347
-	if( ! empty( $matches ) && ! empty( $address ) ) {
2347
+	if ( ! empty($matches) && ! empty($address)) {
2348 2348
 		$address_values = array();
2349 2349
 
2350
-		foreach ($matches[1] as $address_tag ) {
2351
-			$address_values[ $address_tag ] = '';
2350
+		foreach ($matches[1] as $address_tag) {
2351
+			$address_values[$address_tag] = '';
2352 2352
 
2353
-			if( isset( $address[$address_tag] ) ) {
2354
-				$address_values[ $address_tag ] = $address[$address_tag];
2353
+			if (isset($address[$address_tag])) {
2354
+				$address_values[$address_tag] = $address[$address_tag];
2355 2355
 			}
2356 2356
 		}
2357 2357
 
2358
-		$formatted_address  = str_ireplace( $matches[0], $address_values, $address_format );
2358
+		$formatted_address = str_ireplace($matches[0], $address_values, $address_format);
2359 2359
 	}
2360 2360
 
2361 2361
 	/**
@@ -2366,7 +2366,7 @@  discard block
 block discarded – undo
2366 2366
 	 * @param string $formatted_address Formatted address.
2367 2367
 	 * @param string $address_format    Format of the address.
2368 2368
 	 */
2369
-	$formatted_address = apply_filters( 'give_get_formatted_address', $formatted_address, $address_format, $address );
2369
+	$formatted_address = apply_filters('give_get_formatted_address', $formatted_address, $address_format, $address);
2370 2370
 
2371 2371
 	return $formatted_address;
2372 2372
 }
@@ -2380,10 +2380,10 @@  discard block
 block discarded – undo
2380 2380
  *
2381 2381
  * @return string The JS date format.
2382 2382
  */
2383
-function give_convert_php_date_format_to_js( $php_format ) {
2383
+function give_convert_php_date_format_to_js($php_format) {
2384 2384
 	$js_format = $php_format;
2385 2385
 
2386
-	switch ( $php_format ) {
2386
+	switch ($php_format) {
2387 2387
 		case 'F j, Y':
2388 2388
 			$js_format = 'MM dd, yy';
2389 2389
 			break;
@@ -2406,7 +2406,7 @@  discard block
 block discarded – undo
2406 2406
 	 * @param string $js_format  The JS date format.
2407 2407
 	 * @param string $php_format The PHP date format.
2408 2408
 	 */
2409
-	$js_format = apply_filters( 'give_js_date_format', $js_format, $php_format );
2409
+	$js_format = apply_filters('give_js_date_format', $js_format, $php_format);
2410 2410
 
2411 2411
 	return $js_format;
2412 2412
 }
@@ -2420,5 +2420,5 @@  discard block
 block discarded – undo
2420 2420
  */
2421 2421
 function give_get_localized_date_format_to_js() {
2422 2422
 
2423
-	return give_convert_php_date_format_to_js( get_option( 'date_format' ) );
2423
+	return give_convert_php_date_format_to_js(get_option('date_format'));
2424 2424
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1823,9 +1823,9 @@  discard block
 block discarded – undo
1823 1823
 	if ( ! empty( $form_setting_val ) ) {
1824 1824
 		if( give_is_setting_enabled( $form_setting_val ) ) {
1825 1825
 			return true;
1826
-		}elseif ( 'global' === $form_setting_val && give_is_setting_enabled( $global_setting_val ) ){
1826
+		} elseif ( 'global' === $form_setting_val && give_is_setting_enabled( $global_setting_val ) ){
1827 1827
 			return true;
1828
-		}else{
1828
+		} else{
1829 1829
 			return false;
1830 1830
 		}
1831 1831
 	} elseif ( give_is_setting_enabled( $global_setting_val ) ) {
@@ -1853,7 +1853,7 @@  discard block
 block discarded – undo
1853 1853
 			return true;
1854 1854
 		} elseif ( 'global' === $form_setting_val && give_is_setting_enabled( $global_setting_val ) ){
1855 1855
 			return true;
1856
-		}else{
1856
+		} else{
1857 1857
 			return false;
1858 1858
 		}
1859 1859
 	} elseif ( give_is_setting_enabled( $global_setting_val ) ) {
Please login to merge, or discard this patch.