Test Failed
Pull Request — master (#2211)
by Ravinder
05:56 queued 47s
created
includes/admin/payments/actions.php 1 patch
Spacing   +124 added lines, -124 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -25,52 +25,52 @@  discard block
 block discarded – undo
25 25
  *
26 26
  * @return      void
27 27
  */
28
-function give_update_payment_details( $data ) {
28
+function give_update_payment_details($data) {
29 29
 
30
-	if ( ! current_user_can( 'edit_give_payments', $data['give_payment_id'] ) ) {
31
-		wp_die( esc_html__( 'You do not have permission to edit payments.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
30
+	if ( ! current_user_can('edit_give_payments', $data['give_payment_id'])) {
31
+		wp_die(esc_html__('You do not have permission to edit payments.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
32 32
 	}
33 33
 
34
-	check_admin_referer( 'give_update_payment_details_nonce' );
34
+	check_admin_referer('give_update_payment_details_nonce');
35 35
 
36 36
 	// Retrieve the payment ID.
37
-	$payment_id = absint( $data['give_payment_id'] );
37
+	$payment_id = absint($data['give_payment_id']);
38 38
 
39 39
 	/* @var Give_Payment $payment */
40
-	$payment = new Give_Payment( $payment_id );
40
+	$payment = new Give_Payment($payment_id);
41 41
 
42 42
 	// Retrieve existing payment meta.
43 43
 	$meta      = $payment->get_meta();
44 44
 	$user_info = $payment->user_info;
45 45
 
46 46
 	$status = $data['give-payment-status'];
47
-	$date   = sanitize_text_field( $data['give-payment-date'] );
48
-	$hour   = sanitize_text_field( $data['give-payment-time-hour'] );
47
+	$date   = sanitize_text_field($data['give-payment-date']);
48
+	$hour   = sanitize_text_field($data['give-payment-time-hour']);
49 49
 
50 50
 	// Restrict to our high and low.
51
-	if ( $hour > 23 ) {
51
+	if ($hour > 23) {
52 52
 		$hour = 23;
53
-	} elseif ( $hour < 0 ) {
53
+	} elseif ($hour < 0) {
54 54
 		$hour = 00;
55 55
 	}
56 56
 
57
-	$minute = sanitize_text_field( $data['give-payment-time-min'] );
57
+	$minute = sanitize_text_field($data['give-payment-time-min']);
58 58
 
59 59
 	// Restrict to our high and low.
60
-	if ( $minute > 59 ) {
60
+	if ($minute > 59) {
61 61
 		$minute = 59;
62
-	} elseif ( $minute < 0 ) {
62
+	} elseif ($minute < 0) {
63 63
 		$minute = 00;
64 64
 	}
65 65
 
66
-	$address = give_clean( $data['give-payment-address'][0] );
66
+	$address = give_clean($data['give-payment-address'][0]);
67 67
 
68 68
 	$curr_total = $payment->total;
69
-	$new_total  = give_maybe_sanitize_amount( $data['give-payment-total'] );
70
-	$date       = date( 'Y-m-d', strtotime( $date ) ) . ' ' . $hour . ':' . $minute . ':00';
69
+	$new_total  = give_maybe_sanitize_amount($data['give-payment-total']);
70
+	$date       = date('Y-m-d', strtotime($date)).' '.$hour.':'.$minute.':00';
71 71
 
72
-	$curr_donor_id = sanitize_text_field( $data['give-current-donor'] );
73
-	$new_donor_id  = sanitize_text_field( $data['donor-id'] );
72
+	$curr_donor_id = sanitize_text_field($data['give-current-donor']);
73
+	$new_donor_id  = sanitize_text_field($data['donor-id']);
74 74
 
75 75
 	/**
76 76
 	 * Fires before updating edited donation.
@@ -80,98 +80,98 @@  discard block
 block discarded – undo
80 80
 	 *
81 81
 	 * @param int $payment_id The ID of the payment.
82 82
 	 */
83
-	do_action( 'give_update_edited_donation', $payment_id );
83
+	do_action('give_update_edited_donation', $payment_id);
84 84
 
85 85
 	$payment->date = $date;
86 86
 	$updated       = $payment->save();
87 87
 
88
-	if ( 0 === $updated ) {
89
-		wp_die( esc_html__( 'Error Updating Donation.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) );
88
+	if (0 === $updated) {
89
+		wp_die(esc_html__('Error Updating Donation.', 'give'), esc_html__('Error', 'give'), array('response' => 400));
90 90
 	}
91 91
 
92 92
 	$donor_changed = false;
93 93
 
94
-	if ( isset( $data['give-new-donor'] ) && $data['give-new-donor'] == '1' ) {
94
+	if (isset($data['give-new-donor']) && $data['give-new-donor'] == '1') {
95 95
 
96
-		$email = isset( $data['give-new-donor-email'] ) ? sanitize_text_field( $data['give-new-donor-email'] ) : '';
97
-		$names = isset( $data['give-new-donor-name'] ) ? sanitize_text_field( $data['give-new-donor-name'] ) : '';
96
+		$email = isset($data['give-new-donor-email']) ? sanitize_text_field($data['give-new-donor-email']) : '';
97
+		$names = isset($data['give-new-donor-name']) ? sanitize_text_field($data['give-new-donor-name']) : '';
98 98
 
99
-		if ( empty( $email ) || empty( $names ) ) {
100
-			wp_die( esc_html__( 'New donors require a name and email address.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) );
99
+		if (empty($email) || empty($names)) {
100
+			wp_die(esc_html__('New donors require a name and email address.', 'give'), esc_html__('Error', 'give'), array('response' => 400));
101 101
 		}
102 102
 
103
-		$donor = new Give_Donor( $email );
104
-		if ( empty( $donor->id ) ) {
105
-			$donor_data = array( 'name' => $names, 'email' => $email );
106
-			$user_id       = email_exists( $email );
107
-			if ( false !== $user_id ) {
103
+		$donor = new Give_Donor($email);
104
+		if (empty($donor->id)) {
105
+			$donor_data = array('name' => $names, 'email' => $email);
106
+			$user_id = email_exists($email);
107
+			if (false !== $user_id) {
108 108
 				$donor_data['user_id'] = $user_id;
109 109
 			}
110 110
 
111
-			if ( ! $donor->create( $donor_data ) ) {
111
+			if ( ! $donor->create($donor_data)) {
112 112
 				// Failed to crete the new donor, assume the previous donor.
113 113
 				$donor_changed = false;
114
-				$donor         = new Give_Donor( $curr_donor_id );
115
-				give_set_error( 'give-payment-new-donor-fail', __( 'Error creating new donor.', 'give' ) );
114
+				$donor         = new Give_Donor($curr_donor_id);
115
+				give_set_error('give-payment-new-donor-fail', __('Error creating new donor.', 'give'));
116 116
 			}
117 117
 		}
118 118
 
119 119
 		$new_donor_id = $donor->id;
120 120
 
121
-		$previous_donor = new Give_Donor( $curr_donor_id );
121
+		$previous_donor = new Give_Donor($curr_donor_id);
122 122
 
123 123
 		$donor_changed = true;
124 124
 
125
-	} elseif ( $curr_donor_id !== $new_donor_id ) {
125
+	} elseif ($curr_donor_id !== $new_donor_id) {
126 126
 
127
-		$donor = new Give_Donor( $new_donor_id );
127
+		$donor = new Give_Donor($new_donor_id);
128 128
 		$email    = $donor->email;
129 129
 		$names    = $donor->name;
130 130
 
131
-		$previous_donor = new Give_Donor( $curr_donor_id );
131
+		$previous_donor = new Give_Donor($curr_donor_id);
132 132
 
133 133
 		$donor_changed = true;
134 134
 
135 135
 	} else {
136 136
 
137
-		$donor = new Give_Donor( $curr_donor_id );
137
+		$donor = new Give_Donor($curr_donor_id);
138 138
 		$email    = $donor->email;
139 139
 		$names    = $donor->name;
140 140
 
141 141
 	}
142 142
 
143 143
 	// Setup first and last name from input values.
144
-	$names      = explode( ' ', $names );
145
-	$first_name = ! empty( $names[0] ) ? $names[0] : '';
144
+	$names      = explode(' ', $names);
145
+	$first_name = ! empty($names[0]) ? $names[0] : '';
146 146
 	$last_name  = '';
147
-	if ( ! empty( $names[1] ) ) {
148
-		unset( $names[0] );
149
-		$last_name = implode( ' ', $names );
147
+	if ( ! empty($names[1])) {
148
+		unset($names[0]);
149
+		$last_name = implode(' ', $names);
150 150
 	}
151 151
 
152
-	if ( $donor_changed ) {
152
+	if ($donor_changed) {
153 153
 
154 154
 		// Remove the stats and payment from the previous donor and attach it to the new donor.
155
-		$previous_donor->remove_payment( $payment_id, false );
156
-		$donor->attach_payment( $payment_id, false );
155
+		$previous_donor->remove_payment($payment_id, false);
156
+		$donor->attach_payment($payment_id, false);
157 157
 
158
-		if ( 'publish' == $status ) {
158
+		if ('publish' == $status) {
159 159
 
160 160
 			// Reduce previous user donation count and amount.
161 161
 			$previous_donor->decrease_donation_count();
162
-			$previous_donor->decrease_value( $curr_total );
162
+			$previous_donor->decrease_value($curr_total);
163 163
 
164 164
 			// If donation was completed adjust stats of new donors.
165 165
 			$donor->increase_purchase_count();
166
-			$donor->increase_value( $new_total );
166
+			$donor->increase_value($new_total);
167 167
 		}
168 168
 
169 169
 		$payment->customer_id = $donor->id;
170 170
 	} else {
171 171
 
172
-		if ( 'publish' === $status ) {
172
+		if ('publish' === $status) {
173 173
 			// Update user donation stat.
174
-			$donor->update_donation_value( $curr_total, $new_total );
174
+			$donor->update_donation_value($curr_total, $new_total);
175 175
 		}
176 176
 	}
177 177
 
@@ -184,10 +184,10 @@  discard block
 block discarded – undo
184 184
 	$payment->total      = $new_total;
185 185
 
186 186
 	// Check for payment notes.
187
-	if ( ! empty( $data['give-payment-note'] ) ) {
187
+	if ( ! empty($data['give-payment-note'])) {
188 188
 
189
-		$note = wp_kses( $data['give-payment-note'], array() );
190
-		give_insert_payment_note( $payment_id, $note );
189
+		$note = wp_kses($data['give-payment-note'], array());
190
+		give_insert_payment_note($payment_id, $note);
191 191
 
192 192
 	}
193 193
 
@@ -195,17 +195,17 @@  discard block
 block discarded – undo
195 195
 	$payment->status = $status;
196 196
 
197 197
 	// Adjust total store earnings if the payment total has been changed.
198
-	if ( $new_total !== $curr_total && 'publish' == $status ) {
198
+	if ($new_total !== $curr_total && 'publish' == $status) {
199 199
 
200
-		if ( $new_total > $curr_total ) {
200
+		if ($new_total > $curr_total) {
201 201
 			// Increase if our new total is higher.
202 202
 			$difference = $new_total - $curr_total;
203
-			give_increase_total_earnings( $difference );
203
+			give_increase_total_earnings($difference);
204 204
 
205
-		} elseif ( $curr_total > $new_total ) {
205
+		} elseif ($curr_total > $new_total) {
206 206
 			// Decrease if our new total is lower.
207 207
 			$difference = $curr_total - $new_total;
208
-			give_decrease_total_earnings( $difference );
208
+			give_decrease_total_earnings($difference);
209 209
 
210 210
 		}
211 211
 	}
@@ -213,16 +213,16 @@  discard block
 block discarded – undo
213 213
 	$payment->save();
214 214
 
215 215
 	// Get new give form ID.
216
-	$new_form_id     = absint( $data['give-payment-form-select'] );
217
-	$current_form_id = absint( $payment->get_meta( '_give_payment_form_id' ) );
216
+	$new_form_id     = absint($data['give-payment-form-select']);
217
+	$current_form_id = absint($payment->get_meta('_give_payment_form_id'));
218 218
 
219 219
 	// We are adding payment transfer code in last to remove any conflict with above functionality.
220 220
 	// For example: above code will automatically handle form stat (increase/decrease) when payment status changes.
221 221
 	// Check if user want to transfer current payment to new give form id.
222
-	if ( $new_form_id != $current_form_id ) {
222
+	if ($new_form_id != $current_form_id) {
223 223
 
224 224
 		// Get new give form title.
225
-		$new_form_title = get_the_title( $new_form_id );
225
+		$new_form_title = get_the_title($new_form_id);
226 226
 
227 227
 		// Update new give form data in payment data.
228 228
 		$payment_meta               = $payment->get_meta();
@@ -230,43 +230,43 @@  discard block
 block discarded – undo
230 230
 		$payment_meta['form_id']    = $new_form_id;
231 231
 
232 232
 		// Update price id post meta data for set donation form.
233
-		if ( ! give_has_variable_prices( $new_form_id ) ) {
233
+		if ( ! give_has_variable_prices($new_form_id)) {
234 234
 			$payment_meta['price_id'] = '';
235 235
 		}
236 236
 
237 237
 		// Update payment give form meta data.
238
-		$payment->update_meta( '_give_payment_form_id', $new_form_id );
239
-		$payment->update_meta( '_give_payment_form_title', $new_form_title );
240
-		$payment->update_meta( '_give_payment_meta', $payment_meta );
238
+		$payment->update_meta('_give_payment_form_id', $new_form_id);
239
+		$payment->update_meta('_give_payment_form_title', $new_form_title);
240
+		$payment->update_meta('_give_payment_meta', $payment_meta);
241 241
 
242 242
 		// Update price id payment metadata.
243
-		if ( ! give_has_variable_prices( $new_form_id ) ) {
244
-			$payment->update_meta( '_give_payment_price_id', '' );
243
+		if ( ! give_has_variable_prices($new_form_id)) {
244
+			$payment->update_meta('_give_payment_price_id', '');
245 245
 		}
246 246
 
247 247
 		// If donation was completed, adjust stats of forms.
248
-		if ( 'publish' == $status ) {
248
+		if ('publish' == $status) {
249 249
 
250 250
 			// Decrease sale of old give form. For other payment status.
251
-			$current_form = new Give_Donate_Form( $current_form_id );
251
+			$current_form = new Give_Donate_Form($current_form_id);
252 252
 			$current_form->decrease_sales();
253
-			$current_form->decrease_earnings( $curr_total );
253
+			$current_form->decrease_earnings($curr_total);
254 254
 
255 255
 			// Increase sale of new give form.
256
-			$new_form = new Give_Donate_Form( $new_form_id );
256
+			$new_form = new Give_Donate_Form($new_form_id);
257 257
 			$new_form->increase_sales();
258
-			$new_form->increase_earnings( $new_total );
258
+			$new_form->increase_earnings($new_total);
259 259
 		}
260 260
 
261 261
 		// Re setup payment to update new meta value in object.
262
-		$payment->update_payment_setup( $payment->ID );
262
+		$payment->update_payment_setup($payment->ID);
263 263
 	}
264 264
 
265 265
 	// Update price id if current form is variable form.
266 266
 	/* @var Give_Donate_Form $form */
267
-	$form = new Give_Donate_Form( $payment->form_id );
267
+	$form = new Give_Donate_Form($payment->form_id);
268 268
 
269
-	if ( isset( $data['give-variable-price'] ) && $form->has_variable_prices() ) {
269
+	if (isset($data['give-variable-price']) && $form->has_variable_prices()) {
270 270
 
271 271
 		// Get payment meta data.
272 272
 		$payment_meta = $payment->get_meta();
@@ -275,9 +275,9 @@  discard block
 block discarded – undo
275 275
 		$price_id = '';
276 276
 
277 277
 		// Get price info
278
-		if( 0 <= $data['give-variable-price'] ) {
279
-			foreach ( $form->prices as $variable_price ) {
280
-				if( $new_total === give_maybe_sanitize_amount( $variable_price['_give_amount'] ) ) {
278
+		if (0 <= $data['give-variable-price']) {
279
+			foreach ($form->prices as $variable_price) {
280
+				if ($new_total === give_maybe_sanitize_amount($variable_price['_give_amount'])) {
281 281
 					$price_info = $variable_price;
282 282
 					break;
283 283
 				}
@@ -285,15 +285,15 @@  discard block
 block discarded – undo
285 285
 		}
286 286
 
287 287
 		// Set price id.
288
-		if( ! empty( $price_info ) ) {
288
+		if ( ! empty($price_info)) {
289 289
 			$price_id = $data['give-variable-price'];
290 290
 
291
-			if( $data['give-variable-price'] !== $price_info['_give_id']['level_id'] ) {
291
+			if ($data['give-variable-price'] !== $price_info['_give_id']['level_id']) {
292 292
 				// Set price id to amount match.
293 293
 				$price_id = $price_info['_give_id']['level_id'];
294 294
 			}
295 295
 
296
-		} elseif( $form->is_custom_price_mode() ){
296
+		} elseif ($form->is_custom_price_mode()) {
297 297
 			$price_id = 'custom';
298 298
 		}
299 299
 
@@ -301,11 +301,11 @@  discard block
 block discarded – undo
301 301
 		$payment_meta['price_id'] = $price_id;
302 302
 
303 303
 		// Update payment give form meta data.
304
-		$payment->update_meta( '_give_payment_price_id', $price_id );
305
-		$payment->update_meta( '_give_payment_meta', $payment_meta );
304
+		$payment->update_meta('_give_payment_price_id', $price_id);
305
+		$payment->update_meta('_give_payment_meta', $payment_meta);
306 306
 
307 307
 		// Re setup payment to update new meta value in object.
308
-		$payment->update_payment_setup( $payment->ID );
308
+		$payment->update_payment_setup($payment->ID);
309 309
 	}
310 310
 
311 311
 	/**
@@ -316,13 +316,13 @@  discard block
 block discarded – undo
316 316
 	 *
317 317
 	 * @param int $payment_id The ID of the payment.
318 318
 	 */
319
-	do_action( 'give_updated_edited_donation', $payment_id );
319
+	do_action('give_updated_edited_donation', $payment_id);
320 320
 
321
-	wp_safe_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&give-message=payment-updated&id=' . $payment_id ) );
321
+	wp_safe_redirect(admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&give-message=payment-updated&id='.$payment_id));
322 322
 	exit;
323 323
 }
324 324
 
325
-add_action( 'give_update_payment_details', 'give_update_payment_details' );
325
+add_action('give_update_payment_details', 'give_update_payment_details');
326 326
 
327 327
 /**
328 328
  * Trigger a Donation Deletion.
@@ -333,48 +333,48 @@  discard block
 block discarded – undo
333 333
  *
334 334
  * @return void
335 335
  */
336
-function give_trigger_donation_delete( $data ) {
337
-	if ( wp_verify_nonce( $data['_wpnonce'], 'give_donation_nonce' ) ) {
336
+function give_trigger_donation_delete($data) {
337
+	if (wp_verify_nonce($data['_wpnonce'], 'give_donation_nonce')) {
338 338
 
339
-		$payment_id = absint( $data['purchase_id'] );
339
+		$payment_id = absint($data['purchase_id']);
340 340
 
341
-		if ( ! current_user_can( 'edit_give_payments', $payment_id ) ) {
342
-			wp_die( __( 'You do not have permission to edit payments.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
341
+		if ( ! current_user_can('edit_give_payments', $payment_id)) {
342
+			wp_die(__('You do not have permission to edit payments.', 'give'), __('Error', 'give'), array('response' => 403));
343 343
 		}
344 344
 
345
-		give_delete_donation( $payment_id );
346
-		wp_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&give-message=donation_deleted' ) );
345
+		give_delete_donation($payment_id);
346
+		wp_redirect(admin_url('edit.php?post_type=give_forms&page=give-payment-history&give-message=donation_deleted'));
347 347
 		give_die();
348 348
 	}
349 349
 }
350 350
 
351
-add_action( 'give_delete_payment', 'give_trigger_donation_delete' );
351
+add_action('give_delete_payment', 'give_trigger_donation_delete');
352 352
 
353 353
 /**
354 354
  * AJAX Store Donation Note
355 355
  */
356 356
 function give_ajax_store_payment_note() {
357 357
 
358
-	$payment_id = absint( $_POST['payment_id'] );
359
-	$note       = wp_kses( $_POST['note'], array() );
358
+	$payment_id = absint($_POST['payment_id']);
359
+	$note       = wp_kses($_POST['note'], array());
360 360
 
361
-	if ( ! current_user_can( 'edit_give_payments', $payment_id ) ) {
362
-		wp_die( __( 'You do not have permission to edit payments.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
361
+	if ( ! current_user_can('edit_give_payments', $payment_id)) {
362
+		wp_die(__('You do not have permission to edit payments.', 'give'), __('Error', 'give'), array('response' => 403));
363 363
 	}
364 364
 
365
-	if ( empty( $payment_id ) ) {
366
-		die( '-1' );
365
+	if (empty($payment_id)) {
366
+		die('-1');
367 367
 	}
368 368
 
369
-	if ( empty( $note ) ) {
370
-		die( '-1' );
369
+	if (empty($note)) {
370
+		die('-1');
371 371
 	}
372 372
 
373
-	$note_id = give_insert_payment_note( $payment_id, $note );
374
-	die( give_get_payment_note_html( $note_id ) );
373
+	$note_id = give_insert_payment_note($payment_id, $note);
374
+	die(give_get_payment_note_html($note_id));
375 375
 }
376 376
 
377
-add_action( 'wp_ajax_give_insert_payment_note', 'give_ajax_store_payment_note' );
377
+add_action('wp_ajax_give_insert_payment_note', 'give_ajax_store_payment_note');
378 378
 
379 379
 /**
380 380
  * Triggers a donation note deletion without ajax
@@ -385,24 +385,24 @@  discard block
 block discarded – undo
385 385
  *
386 386
  * @return void
387 387
  */
388
-function give_trigger_payment_note_deletion( $data ) {
388
+function give_trigger_payment_note_deletion($data) {
389 389
 
390
-	if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_delete_payment_note_' . $data['note_id'] ) ) {
390
+	if ( ! wp_verify_nonce($data['_wpnonce'], 'give_delete_payment_note_'.$data['note_id'])) {
391 391
 		return;
392 392
 	}
393 393
 
394
-	if ( ! current_user_can( 'edit_give_payments', $data['payment_id'] ) ) {
395
-		wp_die( esc_html__( 'You do not have permission to edit payments.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
394
+	if ( ! current_user_can('edit_give_payments', $data['payment_id'])) {
395
+		wp_die(esc_html__('You do not have permission to edit payments.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
396 396
 	}
397 397
 
398
-	$edit_order_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&give-message=donation-note-deleted&id=' . absint( $data['payment_id'] ) );
398
+	$edit_order_url = admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&give-message=donation-note-deleted&id='.absint($data['payment_id']));
399 399
 
400
-	give_delete_payment_note( $data['note_id'], $data['payment_id'] );
400
+	give_delete_payment_note($data['note_id'], $data['payment_id']);
401 401
 
402
-	wp_redirect( $edit_order_url );
402
+	wp_redirect($edit_order_url);
403 403
 }
404 404
 
405
-add_action( 'give_delete_payment_note', 'give_trigger_payment_note_deletion' );
405
+add_action('give_delete_payment_note', 'give_trigger_payment_note_deletion');
406 406
 
407 407
 /**
408 408
  * Delete a payment note deletion with ajax
@@ -413,16 +413,16 @@  discard block
 block discarded – undo
413 413
  */
414 414
 function give_ajax_delete_payment_note() {
415 415
 
416
-	if ( ! current_user_can( 'edit_give_payments', $_POST['payment_id'] ) ) {
417
-		wp_die( esc_html__( 'You do not have permission to edit payments.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
416
+	if ( ! current_user_can('edit_give_payments', $_POST['payment_id'])) {
417
+		wp_die(esc_html__('You do not have permission to edit payments.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
418 418
 	}
419 419
 
420
-	if ( give_delete_payment_note( $_POST['note_id'], $_POST['payment_id'] ) ) {
421
-		die( '1' );
420
+	if (give_delete_payment_note($_POST['note_id'], $_POST['payment_id'])) {
421
+		die('1');
422 422
 	} else {
423
-		die( '-1' );
423
+		die('-1');
424 424
 	}
425 425
 
426 426
 }
427 427
 
428
-add_action( 'wp_ajax_give_delete_payment_note', 'give_ajax_delete_payment_note' );
428
+add_action('wp_ajax_give_delete_payment_note', 'give_ajax_delete_payment_note');
Please login to merge, or discard this patch.
includes/emails/functions.php 1 patch
Spacing   +130 added lines, -130 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -26,11 +26,11 @@  discard block
 block discarded – undo
26 26
  *
27 27
  * @return void
28 28
  */
29
-function give_email_donation_receipt( $payment_id, $admin_notice = true ) {
29
+function give_email_donation_receipt($payment_id, $admin_notice = true) {
30 30
 
31
-	$payment_data = give_get_payment_meta( $payment_id );
31
+	$payment_data = give_get_payment_meta($payment_id);
32 32
 
33
-	$from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) );
33
+	$from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES));
34 34
 
35 35
 	/**
36 36
 	 * Filters the from name.
@@ -40,9 +40,9 @@  discard block
 block discarded – undo
40 40
 	 *
41 41
 	 * @since 1.0
42 42
 	 */
43
-	$from_name = apply_filters( 'give_donation_from_name', $from_name, $payment_id, $payment_data );
43
+	$from_name = apply_filters('give_donation_from_name', $from_name, $payment_id, $payment_data);
44 44
 
45
-	$from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) );
45
+	$from_email = give_get_option('from_email', get_bloginfo('admin_email'));
46 46
 
47 47
 	/**
48 48
 	 * Filters the from email.
@@ -52,19 +52,19 @@  discard block
 block discarded – undo
52 52
 	 *
53 53
 	 * @since 1.0
54 54
 	 */
55
-	$from_email = apply_filters( 'give_donation_from_address', $from_email, $payment_id, $payment_data );
55
+	$from_email = apply_filters('give_donation_from_address', $from_email, $payment_id, $payment_data);
56 56
 
57
-	$to_email = give_get_payment_user_email( $payment_id );
57
+	$to_email = give_get_payment_user_email($payment_id);
58 58
 
59
-	$subject = give_get_option( 'donation_subject', __( 'Donation Receipt', 'give' ) );
59
+	$subject = give_get_option('donation_subject', __('Donation Receipt', 'give'));
60 60
 
61 61
 	/**
62 62
 	 * Filters the donation email receipt subject.
63 63
 	 *
64 64
 	 * @since 1.0
65 65
 	 */
66
-	$subject = apply_filters( 'give_donation_subject', wp_strip_all_tags( $subject ), $payment_id );
67
-	$subject = give_do_email_tags( $subject, $payment_id );
66
+	$subject = apply_filters('give_donation_subject', wp_strip_all_tags($subject), $payment_id);
67
+	$subject = give_do_email_tags($subject, $payment_id);
68 68
 
69 69
 	/**
70 70
 	 * Filters the donation email receipt attachments. By default, there is no attachment but plugins can hook in to provide one more multiple for the donor. Examples would be a printable ticket or PDF receipt.
@@ -74,14 +74,14 @@  discard block
 block discarded – undo
74 74
 	 *
75 75
 	 * @since 1.0
76 76
 	 */
77
-	$attachments = apply_filters( 'give_receipt_attachments', array(), $payment_id, $payment_data );
78
-	$message     = give_do_email_tags( give_get_email_body_content( $payment_id, $payment_data ), $payment_id );
77
+	$attachments = apply_filters('give_receipt_attachments', array(), $payment_id, $payment_data);
78
+	$message     = give_do_email_tags(give_get_email_body_content($payment_id, $payment_data), $payment_id);
79 79
 
80 80
 	$emails = Give()->emails;
81 81
 
82
-	$emails->__set( 'from_name', $from_name );
83
-	$emails->__set( 'from_email', $from_email );
84
-	$emails->__set( 'heading', __( 'Donation Receipt', 'give' ) );
82
+	$emails->__set('from_name', $from_name);
83
+	$emails->__set('from_email', $from_email);
84
+	$emails->__set('heading', __('Donation Receipt', 'give'));
85 85
 
86 86
 	/**
87 87
 	 * Filters the donation receipt's email headers.
@@ -91,14 +91,14 @@  discard block
 block discarded – undo
91 91
 	 *
92 92
 	 * @since 1.0
93 93
 	 */
94
-	$headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data );
95
-	$emails->__set( 'headers', $headers );
94
+	$headers = apply_filters('give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data);
95
+	$emails->__set('headers', $headers);
96 96
 
97 97
 	//Send the donation receipt.
98
-	$emails->send( $to_email, $subject, $message, $attachments );
98
+	$emails->send($to_email, $subject, $message, $attachments);
99 99
 
100 100
 	//If admin notifications are on, send the admin notice.
101
-	if ( $admin_notice && ! give_admin_notices_disabled( $payment_id ) ) {
101
+	if ($admin_notice && ! give_admin_notices_disabled($payment_id)) {
102 102
 		/**
103 103
 		 * Fires in the donation email receipt.
104 104
 		 *
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 		 * @param int   $payment_id   Payment id.
110 110
 		 * @param mixed $payment_data Payment meta data.
111 111
 		 */
112
-		do_action( 'give_admin_donation_email', $payment_id, $payment_data );
112
+		do_action('give_admin_donation_email', $payment_id, $payment_data);
113 113
 	}
114 114
 }
115 115
 
@@ -122,41 +122,41 @@  discard block
 block discarded – undo
122 122
  */
123 123
 function give_email_test_donation_receipt() {
124 124
 
125
-	$from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) );
125
+	$from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES));
126 126
 
127 127
 	/**
128 128
 	 * Filters the from name.
129 129
 	 *
130 130
 	 * @since 1.7
131 131
 	 */
132
-	$from_name = apply_filters( 'give_donation_from_name', $from_name, 0, array() );
132
+	$from_name = apply_filters('give_donation_from_name', $from_name, 0, array());
133 133
 
134
-	$from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) );
134
+	$from_email = give_get_option('from_email', get_bloginfo('admin_email'));
135 135
 
136 136
 	/**
137 137
 	 * Filters the from email.
138 138
 	 *
139 139
 	 * @since 1.7
140 140
 	 */
141
-	$from_email = apply_filters( 'give_donation_from_address', $from_email, 0, array() );
141
+	$from_email = apply_filters('give_donation_from_address', $from_email, 0, array());
142 142
 
143
-	$subject = give_get_option( 'donation_subject', __( 'Donation Receipt', 'give' ) );
144
-	$subject = apply_filters( 'give_donation_subject', wp_strip_all_tags( $subject ), 0 );
145
-	$subject = give_do_email_tags( $subject, 0 );
143
+	$subject = give_get_option('donation_subject', __('Donation Receipt', 'give'));
144
+	$subject = apply_filters('give_donation_subject', wp_strip_all_tags($subject), 0);
145
+	$subject = give_do_email_tags($subject, 0);
146 146
 
147
-	$attachments = apply_filters( 'give_receipt_attachments', array(), 0, array() );
147
+	$attachments = apply_filters('give_receipt_attachments', array(), 0, array());
148 148
 
149
-	$message = give_email_preview_template_tags( give_get_email_body_content( 0, array() ) );
149
+	$message = give_email_preview_template_tags(give_get_email_body_content(0, array()));
150 150
 
151 151
 	$emails = Give()->emails;
152
-	$emails->__set( 'from_name', $from_name );
153
-	$emails->__set( 'from_email', $from_email );
154
-	$emails->__set( 'heading', __( 'Donation Receipt', 'give' ) );
152
+	$emails->__set('from_name', $from_name);
153
+	$emails->__set('from_email', $from_email);
154
+	$emails->__set('heading', __('Donation Receipt', 'give'));
155 155
 
156
-	$headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), 0, array() );
157
-	$emails->__set( 'headers', $headers );
156
+	$headers = apply_filters('give_receipt_headers', $emails->get_headers(), 0, array());
157
+	$emails->__set('headers', $headers);
158 158
 
159
-	$emails->send( give_get_admin_notice_emails(), $subject, $message, $attachments );
159
+	$emails->send(give_get_admin_notice_emails(), $subject, $message, $attachments);
160 160
 
161 161
 }
162 162
 
@@ -170,49 +170,49 @@  discard block
 block discarded – undo
170 170
  *
171 171
  * @return void
172 172
  */
173
-function give_admin_email_notice( $payment_id = 0, $payment_data = array() ) {
173
+function give_admin_email_notice($payment_id = 0, $payment_data = array()) {
174 174
 
175
-	$payment_id = absint( $payment_id );
175
+	$payment_id = absint($payment_id);
176 176
 
177
-	if ( empty( $payment_id ) ) {
177
+	if (empty($payment_id)) {
178 178
 		return;
179 179
 	}
180 180
 
181
-	if ( ! give_get_payment_by( 'id', $payment_id ) ) {
181
+	if ( ! give_get_payment_by('id', $payment_id)) {
182 182
 		return;
183 183
 	}
184 184
 
185
-	$from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) );
185
+	$from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES));
186 186
 
187 187
 	/**
188 188
 	 * Filters the from name.
189 189
 	 *
190 190
 	 * @since 1.0
191 191
 	 */
192
-	$from_name = apply_filters( 'give_donation_from_name', $from_name, $payment_id, $payment_data );
192
+	$from_name = apply_filters('give_donation_from_name', $from_name, $payment_id, $payment_data);
193 193
 
194
-	$from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) );
194
+	$from_email = give_get_option('from_email', get_bloginfo('admin_email'));
195 195
 
196 196
 	/**
197 197
 	 * Filters the from email.
198 198
 	 *
199 199
 	 * @since 1.0
200 200
 	 */
201
-	$from_email = apply_filters( 'give_donation_from_address', $from_email, $payment_id, $payment_data );
201
+	$from_email = apply_filters('give_donation_from_address', $from_email, $payment_id, $payment_data);
202 202
 
203 203
 	/* translators: %s: payment id */
204
-	$subject = give_get_option( 'donation_notification_subject', sprintf( esc_html__( 'New Donation - Payment #%s', 'give' ), $payment_id ) );
204
+	$subject = give_get_option('donation_notification_subject', sprintf(esc_html__('New Donation - Payment #%s', 'give'), $payment_id));
205 205
 
206 206
 	/**
207 207
 	 * Filters the donation notification subject.
208 208
 	 *
209 209
 	 * @since 1.0
210 210
 	 */
211
-	$subject = apply_filters( 'give_admin_donation_notification_subject', wp_strip_all_tags( $subject ), $payment_id );
212
-	$subject = give_do_email_tags( $subject, $payment_id );
211
+	$subject = apply_filters('give_admin_donation_notification_subject', wp_strip_all_tags($subject), $payment_id);
212
+	$subject = give_do_email_tags($subject, $payment_id);
213 213
 
214
-	$headers = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n";
215
-	$headers .= "Reply-To: " . $from_email . "\r\n";
214
+	$headers = "From: ".stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8'))." <$from_email>\r\n";
215
+	$headers .= "Reply-To: ".$from_email."\r\n";
216 216
 	//$headers  .= "MIME-Version: 1.0\r\n";
217 217
 	$headers .= "Content-Type: text/html; charset=utf-8\r\n";
218 218
 
@@ -221,28 +221,28 @@  discard block
 block discarded – undo
221 221
 	 *
222 222
 	 * @since 1.0
223 223
 	 */
224
-	$headers = apply_filters( 'give_admin_donation_notification_headers', $headers, $payment_id, $payment_data );
224
+	$headers = apply_filters('give_admin_donation_notification_headers', $headers, $payment_id, $payment_data);
225 225
 
226 226
 	/**
227 227
 	 * Filters the donation notification email attachments. By default, there is no attachment but plugins can hook in to provide one more multiple.
228 228
 	 *
229 229
 	 * @since 1.0
230 230
 	 */
231
-	$attachments = apply_filters( 'give_admin_donation_notification_attachments', array(), $payment_id, $payment_data );
231
+	$attachments = apply_filters('give_admin_donation_notification_attachments', array(), $payment_id, $payment_data);
232 232
 
233
-	$message = give_get_donation_notification_body_content( $payment_id, $payment_data );
233
+	$message = give_get_donation_notification_body_content($payment_id, $payment_data);
234 234
 
235 235
 	$emails = Give()->emails;
236
-	$emails->__set( 'from_name', $from_name );
237
-	$emails->__set( 'from_email', $from_email );
238
-	$emails->__set( 'headers', $headers );
239
-	$emails->__set( 'heading', __( 'New Donation!', 'give' ) );
236
+	$emails->__set('from_name', $from_name);
237
+	$emails->__set('from_email', $from_email);
238
+	$emails->__set('headers', $headers);
239
+	$emails->__set('heading', __('New Donation!', 'give'));
240 240
 
241
-	$emails->send( give_get_admin_notice_emails(), $subject, $message, $attachments );
241
+	$emails->send(give_get_admin_notice_emails(), $subject, $message, $attachments);
242 242
 
243 243
 }
244 244
 
245
-add_action( 'give_admin_donation_email', 'give_admin_email_notice', 10, 2 );
245
+add_action('give_admin_donation_email', 'give_admin_email_notice', 10, 2);
246 246
 
247 247
 /**
248 248
  * Retrieves the emails for which admin notifications are sent to (these can be changed in the Give Settings).
@@ -252,12 +252,12 @@  discard block
 block discarded – undo
252 252
  */
253 253
 function give_get_admin_notice_emails() {
254 254
 
255
-	$email_option = give_get_option( 'admin_notice_emails' );
255
+	$email_option = give_get_option('admin_notice_emails');
256 256
 
257
-	$emails = ! empty( $email_option ) && strlen( trim( $email_option ) ) > 0 ? $email_option : get_bloginfo( 'admin_email' );
258
-	$emails = give_clean( explode( "\n", $emails ) );
257
+	$emails = ! empty($email_option) && strlen(trim($email_option)) > 0 ? $email_option : get_bloginfo('admin_email');
258
+	$emails = give_clean(explode("\n", $emails));
259 259
 
260
-	return apply_filters( 'give_admin_notice_emails', $emails );
260
+	return apply_filters('give_admin_notice_emails', $emails);
261 261
 }
262 262
 
263 263
 /**
@@ -269,11 +269,11 @@  discard block
 block discarded – undo
269 269
  *
270 270
  * @return mixed
271 271
  */
272
-function give_admin_notices_disabled( $payment_id = 0 ) {
272
+function give_admin_notices_disabled($payment_id = 0) {
273 273
 
274 274
 	return apply_filters(
275 275
 		'give_admin_notices_disabled',
276
-		! give_is_setting_enabled( give_get_option( 'admin_notices' ) ),
276
+		! give_is_setting_enabled(give_get_option('admin_notices')),
277 277
 		$payment_id
278 278
 	);
279 279
 }
@@ -288,19 +288,19 @@  discard block
 block discarded – undo
288 288
  */
289 289
 function give_get_default_donation_notification_email() {
290 290
 
291
-	$default_email_body = __( 'Hi there,', 'give' ) . "\n\n";
292
-	$default_email_body .= __( 'This email is to inform you that a new donation has been made on your website:', 'give' ) . ' <a href="' . get_bloginfo( 'url' ) . '" target="_blank">' . get_bloginfo( 'url' ) . '</a>' . ".\n\n";
293
-	$default_email_body .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {name}' . "\n";
294
-	$default_email_body .= '<strong>' . __( 'Donation:', 'give' ) . '</strong> {donation}' . "\n";
295
-	$default_email_body .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n";
296
-	$default_email_body .= '<strong>' . __( 'Payment Method:', 'give' ) . '</strong> {payment_method}' . "\n\n";
297
-	$default_email_body .= __( 'Thank you,', 'give' ) . "\n\n";
298
-	$default_email_body .= '{sitename}' . "\n";
291
+	$default_email_body = __('Hi there,', 'give')."\n\n";
292
+	$default_email_body .= __('This email is to inform you that a new donation has been made on your website:', 'give').' <a href="'.get_bloginfo('url').'" target="_blank">'.get_bloginfo('url').'</a>'.".\n\n";
293
+	$default_email_body .= '<strong>'.__('Donor:', 'give').'</strong> {name}'."\n";
294
+	$default_email_body .= '<strong>'.__('Donation:', 'give').'</strong> {donation}'."\n";
295
+	$default_email_body .= '<strong>'.__('Amount:', 'give').'</strong> {amount}'."\n";
296
+	$default_email_body .= '<strong>'.__('Payment Method:', 'give').'</strong> {payment_method}'."\n\n";
297
+	$default_email_body .= __('Thank you,', 'give')."\n\n";
298
+	$default_email_body .= '{sitename}'."\n";
299 299
 
300
-	$custom_message = give_get_option( 'donation_notification' );
301
-	$message        = ! empty( $custom_message ) ? $custom_message : $default_email_body;
300
+	$custom_message = give_get_option('donation_notification');
301
+	$message        = ! empty($custom_message) ? $custom_message : $default_email_body;
302 302
 
303
-	return apply_filters( 'give_default_donation_notification_email', $message );
303
+	return apply_filters('give_default_donation_notification_email', $message);
304 304
 }
305 305
 
306 306
 
@@ -314,25 +314,25 @@  discard block
 block discarded – undo
314 314
  */
315 315
 function give_get_default_donation_receipt_email() {
316 316
 
317
-	$default_email_body = __( 'Dear', 'give' ) . " {name},\n\n";
318
-	$default_email_body .= __( 'Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give' ) . "\n\n";
319
-	$default_email_body .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {fullname}' . "\n";
320
-	$default_email_body .= '<strong>' . __( 'Donation:', 'give' ) . '</strong> {donation}' . "\n";
321
-	$default_email_body .= '<strong>' . __( 'Donation Date:', 'give' ) . '</strong> {date}' . "\n";
322
-	$default_email_body .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n";
323
-	$default_email_body .= '<strong>' . __( 'Payment Method:', 'give' ) . '</strong> {payment_method}' . "\n";
324
-	$default_email_body .= '<strong>' . __( 'Payment ID:', 'give' ) . '</strong> {payment_id}' . "\n";
325
-	$default_email_body .= '<strong>' . __( 'Receipt ID:', 'give' ) . '</strong> {receipt_id}' . "\n\n";
326
-	$default_email_body .= '{receipt_link}' . "\n\n";
317
+	$default_email_body = __('Dear', 'give')." {name},\n\n";
318
+	$default_email_body .= __('Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give')."\n\n";
319
+	$default_email_body .= '<strong>'.__('Donor:', 'give').'</strong> {fullname}'."\n";
320
+	$default_email_body .= '<strong>'.__('Donation:', 'give').'</strong> {donation}'."\n";
321
+	$default_email_body .= '<strong>'.__('Donation Date:', 'give').'</strong> {date}'."\n";
322
+	$default_email_body .= '<strong>'.__('Amount:', 'give').'</strong> {amount}'."\n";
323
+	$default_email_body .= '<strong>'.__('Payment Method:', 'give').'</strong> {payment_method}'."\n";
324
+	$default_email_body .= '<strong>'.__('Payment ID:', 'give').'</strong> {payment_id}'."\n";
325
+	$default_email_body .= '<strong>'.__('Receipt ID:', 'give').'</strong> {receipt_id}'."\n\n";
326
+	$default_email_body .= '{receipt_link}'."\n\n";
327 327
 	$default_email_body .= "\n\n";
328
-	$default_email_body .= __( 'Sincerely,', 'give' ) . "\n";
329
-	$default_email_body .= '{sitename}' . "\n";
328
+	$default_email_body .= __('Sincerely,', 'give')."\n";
329
+	$default_email_body .= '{sitename}'."\n";
330 330
 
331
-	$custom_message = give_get_option( 'donation_receipt' );
331
+	$custom_message = give_get_option('donation_receipt');
332 332
 
333
-	$message = ! empty( $custom_message ) ? $custom_message : $default_email_body;
333
+	$message = ! empty($custom_message) ? $custom_message : $default_email_body;
334 334
 
335
-	return apply_filters( 'give_default_donation_receipt_email', $message );
335
+	return apply_filters('give_default_donation_receipt_email', $message);
336 336
 }
337 337
 
338 338
 /**
@@ -345,22 +345,22 @@  discard block
 block discarded – undo
345 345
  *
346 346
  * @return array $email_names
347 347
  */
348
-function give_get_email_names( $user_info, $payment = false ) {
348
+function give_get_email_names($user_info, $payment = false) {
349 349
 	$email_names = array();
350 350
 
351
-	if ( is_a( $payment, 'Give_Payment' ) ) {
351
+	if (is_a($payment, 'Give_Payment')) {
352 352
 
353
-		if ( $payment->user_id > 0 ) {
353
+		if ($payment->user_id > 0) {
354 354
 
355
-			$user_data               = get_userdata( $payment->user_id );
355
+			$user_data               = get_userdata($payment->user_id);
356 356
 			$email_names['name']     = $payment->first_name;
357
-			$email_names['fullname'] = trim( $payment->first_name . ' ' . $payment->last_name );
357
+			$email_names['fullname'] = trim($payment->first_name.' '.$payment->last_name);
358 358
 			$email_names['username'] = $user_data->user_login;
359 359
 
360
-		} elseif ( ! empty( $payment->first_name ) ) {
360
+		} elseif ( ! empty($payment->first_name)) {
361 361
 
362 362
 			$email_names['name']     = $payment->first_name;
363
-			$email_names['fullname'] = trim( $payment->first_name . ' ' . $payment->last_name );
363
+			$email_names['fullname'] = trim($payment->first_name.' '.$payment->last_name);
364 364
 			$email_names['username'] = $payment->first_name;
365 365
 
366 366
 		} else {
@@ -373,30 +373,30 @@  discard block
 block discarded – undo
373 373
 	} else {
374 374
 
375 375
 		// Support for old serialized data.
376
-		if ( is_serialized( $user_info ) ) {
376
+		if (is_serialized($user_info)) {
377 377
 
378 378
 			// Security check.
379
-			preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches );
380
-			if ( ! empty( $matches ) ) {
379
+			preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches);
380
+			if ( ! empty($matches)) {
381 381
 				return array(
382 382
 					'name'     => '',
383 383
 					'fullname' => '',
384 384
 					'username' => '',
385 385
 				);
386 386
 			} else {
387
-				$user_info = maybe_unserialize( $user_info );
387
+				$user_info = maybe_unserialize($user_info);
388 388
 			}
389 389
 
390 390
 		}
391 391
 
392
-		if ( isset( $user_info['id'] ) && $user_info['id'] > 0 && isset( $user_info['first_name'] ) ) {
393
-			$user_data               = get_userdata( $user_info['id'] );
392
+		if (isset($user_info['id']) && $user_info['id'] > 0 && isset($user_info['first_name'])) {
393
+			$user_data               = get_userdata($user_info['id']);
394 394
 			$email_names['name']     = $user_info['first_name'];
395
-			$email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name'];
395
+			$email_names['fullname'] = $user_info['first_name'].' '.$user_info['last_name'];
396 396
 			$email_names['username'] = $user_data->user_login;
397
-		} elseif ( isset( $user_info['first_name'] ) ) {
397
+		} elseif (isset($user_info['first_name'])) {
398 398
 			$email_names['name']     = $user_info['first_name'];
399
-			$email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name'];
399
+			$email_names['fullname'] = $user_info['first_name'].' '.$user_info['last_name'];
400 400
 			$email_names['username'] = $user_info['first_name'];
401 401
 		} else {
402 402
 			$email_names['name']     = $user_info['email'];
@@ -416,37 +416,37 @@  discard block
 block discarded – undo
416 416
  *
417 417
  * @since 1.8.14
418 418
  */
419
-function give_admin_email_user_donor_disconnection( $user_id, $donor_id ) {
419
+function give_admin_email_user_donor_disconnection($user_id, $donor_id) {
420 420
 
421
-	$user_id  = absint( $user_id );
422
-	$donor_id = absint( $donor_id );
421
+	$user_id  = absint($user_id);
422
+	$donor_id = absint($donor_id);
423 423
 
424 424
 	// Bail Out, if user id doesn't exists.
425
-	if ( empty( $user_id ) ) {
425
+	if (empty($user_id)) {
426 426
 		return;
427 427
 	}
428 428
 
429 429
 	// Bail Out, if donor id doesn't exists.
430
-	if ( empty( $donor_id ) ) {
430
+	if (empty($donor_id)) {
431 431
 		return;
432 432
 	}
433 433
 
434
-	$from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) );
434
+	$from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES));
435 435
 
436
-	$from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) );
436
+	$from_email = give_get_option('from_email', get_bloginfo('admin_email'));
437 437
 
438 438
 	/* translators: %s: payment id */
439
-	$subject = __( 'Attention: User tries to login whose Donor profile is disconnected!', 'give' );
439
+	$subject = __('Attention: User tries to login whose Donor profile is disconnected!', 'give');
440 440
 
441 441
 	/**
442 442
 	 * Filters the Donor-User Disconnection notification subject.
443 443
 	 *
444 444
 	 * @since 1.8.14
445 445
 	 */
446
-	$subject = apply_filters( 'give_admin_donor_user_disconnection_notification_subject', wp_strip_all_tags( $subject ) );
446
+	$subject = apply_filters('give_admin_donor_user_disconnection_notification_subject', wp_strip_all_tags($subject));
447 447
 
448
-	$headers = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n";
449
-	$headers .= "Reply-To: " . $from_email . "\r\n";
448
+	$headers = "From: ".stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8'))." <$from_email>\r\n";
449
+	$headers .= "Reply-To: ".$from_email."\r\n";
450 450
 	$headers .= "Content-Type: text/html; charset=utf-8\r\n";
451 451
 
452 452
 	/**
@@ -454,25 +454,25 @@  discard block
 block discarded – undo
454 454
 	 *
455 455
 	 * @since 1.8.14
456 456
 	 */
457
-	$headers = apply_filters( 'give_admin_donor_user_disconnection_notification_headers', $headers );
457
+	$headers = apply_filters('give_admin_donor_user_disconnection_notification_headers', $headers);
458 458
 
459
-	$message = __( 'Hi Admin,', 'give' ) . "\n\n";
460
-	$message .= __( 'This email is to inform you that a user has tried logging in. But, User was unable to login due to User-Donor profile disconnection.', 'give' ) . "\n\n";
461
-	$message .= __( 'Do you want to reconnect User and Donor profile again?', 'give' ) . "\n\n";
459
+	$message = __('Hi Admin,', 'give')."\n\n";
460
+	$message .= __('This email is to inform you that a user has tried logging in. But, User was unable to login due to User-Donor profile disconnection.', 'give')."\n\n";
461
+	$message .= __('Do you want to reconnect User and Donor profile again?', 'give')."\n\n";
462 462
 	$message .= sprintf(
463 463
 		'<a href="%1$s">%2$s</a>',
464
-		esc_url( admin_url() . 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor_id . '&user_id=' . $user_id . '&give-message=reconnect-user' ),
465
-		__( 'Reconnect User', 'give' ) . "\n\n"
464
+		esc_url(admin_url().'edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor_id.'&user_id='.$user_id.'&give-message=reconnect-user'),
465
+		__('Reconnect User', 'give')."\n\n"
466 466
 	);
467
-	$message .= __( 'Thank you,', 'give' ) . "\n\n";
468
-	$message .= '{sitename}' . "\n";
467
+	$message .= __('Thank you,', 'give')."\n\n";
468
+	$message .= '{sitename}'."\n";
469 469
 
470 470
 	$emails = Give()->emails;
471
-	$emails->__set( 'from_name', $from_name );
472
-	$emails->__set( 'from_email', $from_email );
473
-	$emails->__set( 'headers', $headers );
474
-	$emails->__set( 'heading', __( 'User - Donor Profile Disconnection', 'give' ) );
471
+	$emails->__set('from_name', $from_name);
472
+	$emails->__set('from_email', $from_email);
473
+	$emails->__set('headers', $headers);
474
+	$emails->__set('heading', __('User - Donor Profile Disconnection', 'give'));
475 475
 
476
-	$emails->send( give_get_admin_notice_emails(), $subject, give_do_email_tags( $message ) );
476
+	$emails->send(give_get_admin_notice_emails(), $subject, give_do_email_tags($message));
477 477
 
478 478
 }
Please login to merge, or discard this patch.
includes/class-notices.php 1 patch
Spacing   +95 added lines, -95 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
 
@@ -53,21 +53,21 @@  discard block
 block discarded – undo
53 53
 	 * @since 1.0
54 54
 	 */
55 55
 	public function __construct() {
56
-		add_action( 'admin_notices', array( $this, 'render_admin_notices' ), 999 );
57
-		add_action( 'give_dismiss_notices', array( $this, 'dismiss_notices' ) );
56
+		add_action('admin_notices', array($this, 'render_admin_notices'), 999);
57
+		add_action('give_dismiss_notices', array($this, 'dismiss_notices'));
58 58
 
59
-		add_action( 'give_frontend_notices', array( $this, 'render_frontend_notices' ), 999 );
60
-		add_action( 'give_donation_form_before_personal_info', array( $this, 'render_frontend_notices' ) );
61
-		add_action( 'give_ajax_donation_errors', array( $this, 'render_frontend_notices' ) );
59
+		add_action('give_frontend_notices', array($this, 'render_frontend_notices'), 999);
60
+		add_action('give_donation_form_before_personal_info', array($this, 'render_frontend_notices'));
61
+		add_action('give_ajax_donation_errors', array($this, 'render_frontend_notices'));
62 62
 
63 63
 		/**
64 64
 		 * Backward compatibility for deprecated params.
65 65
 		 *
66 66
 		 * @since 1.8.14
67 67
 		 */
68
-		add_filter( 'give_register_notice_args', array( $this, 'bc_deprecated_params' ) );
69
-		add_filter( 'give_frontend_errors_args', array( $this, 'bc_deprecated_params' ) );
70
-		add_filter( 'give_frontend_notice_args', array( $this, 'bc_deprecated_params' ) );
68
+		add_filter('give_register_notice_args', array($this, 'bc_deprecated_params'));
69
+		add_filter('give_frontend_errors_args', array($this, 'bc_deprecated_params'));
70
+		add_filter('give_frontend_notice_args', array($this, 'bc_deprecated_params'));
71 71
 	}
72 72
 
73 73
 	/**
@@ -80,19 +80,19 @@  discard block
 block discarded – undo
80 80
 	 *
81 81
 	 * @return array
82 82
 	 */
83
-	public function bc_deprecated_params( $args ) {
83
+	public function bc_deprecated_params($args) {
84 84
 		/**
85 85
 		 *  Param: auto_dismissible
86 86
 		 *  deprecated in 1.8.14
87 87
 		 *
88 88
 		 *  Check if auto_dismissible is set and it true then unset and change dismissible parameter value to auto
89 89
 		 */
90
-		if ( isset( $args['auto_dismissible'] ) ) {
91
-			if ( ! empty( $args['auto_dismissible'] ) ) {
90
+		if (isset($args['auto_dismissible'])) {
91
+			if ( ! empty($args['auto_dismissible'])) {
92 92
 				$args['dismissible'] = 'auto';
93 93
 			}
94 94
 			// unset auto_dismissible as it has been deprecated.
95
-			unset( $args['auto_dismissible'] );
95
+			unset($args['auto_dismissible']);
96 96
 		}
97 97
 
98 98
 		return $args;
@@ -108,9 +108,9 @@  discard block
 block discarded – undo
108 108
 	 *
109 109
 	 * @return bool
110 110
 	 */
111
-	public function register_notice( $notice_args ) {
111
+	public function register_notice($notice_args) {
112 112
 		// Bailout.
113
-		if ( empty( $notice_args['id'] ) || array_key_exists( $notice_args['id'], self::$notices ) ) {
113
+		if (empty($notice_args['id']) || array_key_exists($notice_args['id'], self::$notices)) {
114 114
 			return false;
115 115
 		}
116 116
 
@@ -148,39 +148,39 @@  discard block
 block discarded – undo
148 148
 		 *
149 149
 		 * @since 1.8.14
150 150
 		 */
151
-		$notice_args = apply_filters( 'give_register_notice_args', $notice_args );
151
+		$notice_args = apply_filters('give_register_notice_args', $notice_args);
152 152
 
153 153
 		// Set extra dismiss links if any.
154
-		if ( false !== strpos( $notice_args['description'], 'data-dismiss-interval' ) ) {
154
+		if (false !== strpos($notice_args['description'], 'data-dismiss-interval')) {
155 155
 
156
-			preg_match_all( "/data-([^\"]*)=\"([^\"]*)\"/", $notice_args['description'], $extra_notice_dismiss_link );
156
+			preg_match_all("/data-([^\"]*)=\"([^\"]*)\"/", $notice_args['description'], $extra_notice_dismiss_link);
157 157
 
158
-			if ( ! empty( $extra_notice_dismiss_link ) ) {
159
-				$extra_notice_dismiss_links = array_chunk( current( $extra_notice_dismiss_link ), 3 );
160
-				foreach ( $extra_notice_dismiss_links as $extra_notice_dismiss_link ) {
158
+			if ( ! empty($extra_notice_dismiss_link)) {
159
+				$extra_notice_dismiss_links = array_chunk(current($extra_notice_dismiss_link), 3);
160
+				foreach ($extra_notice_dismiss_links as $extra_notice_dismiss_link) {
161 161
 					// Create array og key ==> value by parsing query string created after renaming data attributes.
162
-					$data_attribute_query_str = str_replace( array( 'data-', '-', '"' ), array(
162
+					$data_attribute_query_str = str_replace(array('data-', '-', '"'), array(
163 163
 						'',
164 164
 						'_',
165 165
 						'',
166
-					), implode( '&', $extra_notice_dismiss_link ) );
166
+					), implode('&', $extra_notice_dismiss_link));
167 167
 
168
-					$notice_args['extra_links'][] = wp_parse_args( $data_attribute_query_str );
168
+					$notice_args['extra_links'][] = wp_parse_args($data_attribute_query_str);
169 169
 				}
170 170
 			}
171 171
 		}
172 172
 
173 173
 
174
-		self::$notices[ $notice_args['id'] ] = $notice_args;
174
+		self::$notices[$notice_args['id']] = $notice_args;
175 175
 
176 176
 		// Auto set show param if not already set.
177
-		if ( ! isset( self::$notices[ $notice_args['id'] ]['show'] ) ) {
178
-			self::$notices[ $notice_args['id'] ]['show'] = $this->is_notice_dismissed( $notice_args ) ? false : true;
177
+		if ( ! isset(self::$notices[$notice_args['id']]['show'])) {
178
+			self::$notices[$notice_args['id']]['show'] = $this->is_notice_dismissed($notice_args) ? false : true;
179 179
 		}
180 180
 
181 181
 		// Auto set time interval for shortly.
182
-		if ( 'shortly' === self::$notices[ $notice_args['id'] ]['dismiss_interval'] ) {
183
-			self::$notices[ $notice_args['id'] ]['dismiss_interval_time'] = DAY_IN_SECONDS;
182
+		if ('shortly' === self::$notices[$notice_args['id']]['dismiss_interval']) {
183
+			self::$notices[$notice_args['id']]['dismiss_interval_time'] = DAY_IN_SECONDS;
184 184
 		}
185 185
 
186 186
 		return true;
@@ -194,44 +194,44 @@  discard block
 block discarded – undo
194 194
 	 */
195 195
 	public function render_admin_notices() {
196 196
 		// Bailout.
197
-		if ( empty( self::$notices ) ) {
197
+		if (empty(self::$notices)) {
198 198
 			return;
199 199
 		}
200 200
 
201 201
 		$output = '';
202 202
 
203
-		foreach ( self::$notices as $notice_id => $notice ) {
203
+		foreach (self::$notices as $notice_id => $notice) {
204 204
 			// Check flag set to true to show notice.
205
-			if ( ! $notice['show'] ) {
205
+			if ( ! $notice['show']) {
206 206
 				continue;
207 207
 			}
208 208
 
209 209
 			// Check if notice dismissible or not.
210
-			if ( ! self::$has_auto_dismissible_notice ) {
211
-				self::$has_auto_dismissible_notice = ( 'auto' === $notice['dismissible'] );
210
+			if ( ! self::$has_auto_dismissible_notice) {
211
+				self::$has_auto_dismissible_notice = ('auto' === $notice['dismissible']);
212 212
 			}
213 213
 
214 214
 			// Check if notice dismissible or not.
215
-			if ( ! self::$has_dismiss_interval_notice ) {
215
+			if ( ! self::$has_dismiss_interval_notice) {
216 216
 				self::$has_dismiss_interval_notice = $notice['dismiss_interval'];
217 217
 			}
218 218
 
219
-			$css_id = ( false === strpos( $notice['id'], 'give' ) ? "give-{$notice['id']}" : $notice['id'] );
219
+			$css_id = (false === strpos($notice['id'], 'give') ? "give-{$notice['id']}" : $notice['id']);
220 220
 
221
-			$css_class = 'give-notice notice ' . ( empty( $notice['dismissible'] ) ? 'non' : 'is' ) . "-dismissible {$notice['type']} notice-{$notice['type']}";
222
-			$output    .= sprintf(
223
-				'<div id="%1$s" class="%2$s" data-dismissible="%3$s" data-dismissible-type="%4$s" data-dismiss-interval="%5$s" data-notice-id="%6$s" data-security="%7$s" data-dismiss-interval-time="%8$s" style="display: none">' . " \n",
221
+			$css_class = 'give-notice notice '.(empty($notice['dismissible']) ? 'non' : 'is')."-dismissible {$notice['type']} notice-{$notice['type']}";
222
+			$output .= sprintf(
223
+				'<div id="%1$s" class="%2$s" data-dismissible="%3$s" data-dismissible-type="%4$s" data-dismiss-interval="%5$s" data-notice-id="%6$s" data-security="%7$s" data-dismiss-interval-time="%8$s" style="display: none">'." \n",
224 224
 				$css_id,
225 225
 				$css_class,
226
-				give_clean( $notice['dismissible'] ),
226
+				give_clean($notice['dismissible']),
227 227
 				$notice['dismissible_type'],
228 228
 				$notice['dismiss_interval'],
229 229
 				$notice['id'],
230
-				empty( $notice['dismissible_type'] ) ? '' : wp_create_nonce( "give_edit_{$notice_id}_notice" ),
230
+				empty($notice['dismissible_type']) ? '' : wp_create_nonce("give_edit_{$notice_id}_notice"),
231 231
 				$notice['dismiss_interval_time']
232 232
 			);
233 233
 
234
-			$output .= ( 0 === strpos( $notice['description'], '<div' ) || 0 === strpos( $notice['description'], '<p' ) ? $notice['description'] : "<p>{$notice['description']}</p>" );
234
+			$output .= (0 === strpos($notice['description'], '<div') || 0 === strpos($notice['description'], '<p') ? $notice['description'] : "<p>{$notice['description']}</p>");
235 235
 			$output .= "</div> \n";
236 236
 		}
237 237
 
@@ -249,18 +249,18 @@  discard block
 block discarded – undo
249 249
 	 *
250 250
 	 * @param int $form_id
251 251
 	 */
252
-	public function render_frontend_notices( $form_id = 0 ) {
252
+	public function render_frontend_notices($form_id = 0) {
253 253
 		$errors = give_get_errors();
254 254
 
255
-		$request_form_id = isset( $_REQUEST['form-id'] ) ? absint( $_REQUEST['form-id'] ) : 0;
255
+		$request_form_id = isset($_REQUEST['form-id']) ? absint($_REQUEST['form-id']) : 0;
256 256
 
257 257
 		// Sanity checks first: Ensure that gateway returned errors display on the appropriate form.
258
-		if ( ! isset( $_POST['give_ajax'] ) && $request_form_id !== $form_id ) {
258
+		if ( ! isset($_POST['give_ajax']) && $request_form_id !== $form_id) {
259 259
 			return;
260 260
 		}
261 261
 
262
-		if ( $errors ) {
263
-			self::print_frontend_errors( $errors );
262
+		if ($errors) {
263
+			self::print_frontend_errors($errors);
264 264
 
265 265
 			give_clear_errors();
266 266
 		}
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 	 * @access private
274 274
 	 */
275 275
 	private function print_js() {
276
-		if ( self::$has_auto_dismissible_notice ) :
276
+		if (self::$has_auto_dismissible_notice) :
277 277
 			?>
278 278
 			<script>
279 279
 				jQuery(document).ready(function () {
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 			<?php
290 290
 		endif;
291 291
 
292
-		if ( self::$has_dismiss_interval_notice ) :
292
+		if (self::$has_dismiss_interval_notice) :
293 293
 			?>
294 294
 			<script>
295 295
 				jQuery(document).ready(function () {
@@ -368,29 +368,29 @@  discard block
 block discarded – undo
368 368
 	 * @access public
369 369
 	 */
370 370
 	public function dismiss_notices() {
371
-		$_post     = give_clean( $_POST );
372
-		$notice_id = esc_attr( $_post['notice_id'] );
371
+		$_post     = give_clean($_POST);
372
+		$notice_id = esc_attr($_post['notice_id']);
373 373
 
374 374
 		// Bailout.
375 375
 		if (
376
-			empty( $notice_id ) ||
377
-			empty( $_post['dismissible_type'] ) ||
378
-			empty( $_post['dismiss_interval'] ) ||
379
-			! check_ajax_referer( "give_edit_{$notice_id}_notice", '_wpnonce' )
376
+			empty($notice_id) ||
377
+			empty($_post['dismissible_type']) ||
378
+			empty($_post['dismiss_interval']) ||
379
+			! check_ajax_referer("give_edit_{$notice_id}_notice", '_wpnonce')
380 380
 		) {
381 381
 			wp_send_json_error();
382 382
 		}
383 383
 
384
-		$notice_key = Give()->notices->get_notice_key( $notice_id, $_post['dismiss_interval'] );
385
-		if ( 'user' === $_post['dismissible_type'] ) {
384
+		$notice_key = Give()->notices->get_notice_key($notice_id, $_post['dismiss_interval']);
385
+		if ('user' === $_post['dismissible_type']) {
386 386
 			$current_user = wp_get_current_user();
387
-			$notice_key   = Give()->notices->get_notice_key( $notice_id, $_post['dismiss_interval'], $current_user->ID );
387
+			$notice_key   = Give()->notices->get_notice_key($notice_id, $_post['dismiss_interval'], $current_user->ID);
388 388
 		}
389 389
 
390
-		$notice_dismiss_time = ! empty( $_post['dismiss_interval_time'] ) ? $_post['dismiss_interval_time'] : null;
390
+		$notice_dismiss_time = ! empty($_post['dismiss_interval_time']) ? $_post['dismiss_interval_time'] : null;
391 391
 
392 392
 		// Save option to hide notice.
393
-		Give_Cache::set( $notice_key, true, $notice_dismiss_time, true );
393
+		Give_Cache::set($notice_key, true, $notice_dismiss_time, true);
394 394
 
395 395
 		wp_send_json_success();
396 396
 	}
@@ -408,18 +408,18 @@  discard block
 block discarded – undo
408 408
 	 *
409 409
 	 * @return string
410 410
 	 */
411
-	public function get_notice_key( $notice_id, $dismiss_interval = null, $user_id = 0 ) {
411
+	public function get_notice_key($notice_id, $dismiss_interval = null, $user_id = 0) {
412 412
 		$notice_key = "_give_notice_{$notice_id}";
413 413
 
414
-		if ( ! empty( $dismiss_interval ) ) {
414
+		if ( ! empty($dismiss_interval)) {
415 415
 			$notice_key .= "_{$dismiss_interval}";
416 416
 		}
417 417
 
418
-		if ( $user_id ) {
418
+		if ($user_id) {
419 419
 			$notice_key .= "_{$user_id}";
420 420
 		}
421 421
 
422
-		$notice_key = sanitize_key( $notice_key );
422
+		$notice_key = sanitize_key($notice_key);
423 423
 
424 424
 		return $notice_key;
425 425
 	}
@@ -432,11 +432,11 @@  discard block
 block discarded – undo
432 432
 	 *
433 433
 	 * @return string
434 434
 	 */
435
-	public function get_dismiss_link( $notice_args ) {
435
+	public function get_dismiss_link($notice_args) {
436 436
 		$notice_args = wp_parse_args(
437 437
 			$notice_args,
438 438
 			array(
439
-				'title'                 => __( 'Click here', 'give' ),
439
+				'title'                 => __('Click here', 'give'),
440 440
 				'dismissible_type'      => '',
441 441
 				'dismiss_interval'      => '',
442 442
 				'dismiss_interval_time' => null,
@@ -463,31 +463,31 @@  discard block
 block discarded – undo
463 463
 	 *
464 464
 	 * @return bool|null
465 465
 	 */
466
-	public function is_notice_dismissed( $notice ) {
467
-		$notice_key          = $this->get_notice_key( $notice['id'], $notice['dismiss_interval'] );
466
+	public function is_notice_dismissed($notice) {
467
+		$notice_key          = $this->get_notice_key($notice['id'], $notice['dismiss_interval']);
468 468
 		$is_notice_dismissed = false;
469 469
 
470
-		if ( 'user' === $notice['dismissible_type'] ) {
470
+		if ('user' === $notice['dismissible_type']) {
471 471
 			$current_user = wp_get_current_user();
472
-			$notice_key   = Give()->notices->get_notice_key( $notice['id'], $notice['dismiss_interval'], $current_user->ID );
472
+			$notice_key   = Give()->notices->get_notice_key($notice['id'], $notice['dismiss_interval'], $current_user->ID);
473 473
 		}
474 474
 
475
-		$notice_data = Give_Cache::get( $notice_key, true );
475
+		$notice_data = Give_Cache::get($notice_key, true);
476 476
 
477 477
 		// Find notice dismiss link status if notice has extra dismissible links.
478
-		if ( ( empty( $notice_data ) || is_wp_error( $notice_data ) ) && ! empty( $notice['extra_links'] ) ) {
478
+		if ((empty($notice_data) || is_wp_error($notice_data)) && ! empty($notice['extra_links'])) {
479 479
 
480
-			foreach ( $notice['extra_links'] as $extra_link ) {
481
-				$new_notice_data = wp_parse_args( $extra_link, $notice );
482
-				unset( $new_notice_data['extra_links'] );
480
+			foreach ($notice['extra_links'] as $extra_link) {
481
+				$new_notice_data = wp_parse_args($extra_link, $notice);
482
+				unset($new_notice_data['extra_links']);
483 483
 
484
-				if ( $is_notice_dismissed = $this->is_notice_dismissed( $new_notice_data ) ) {
484
+				if ($is_notice_dismissed = $this->is_notice_dismissed($new_notice_data)) {
485 485
 					return $is_notice_dismissed;
486 486
 				}
487 487
 			}
488 488
 		}
489 489
 
490
-		$is_notice_dismissed = ! empty( $notice_data ) && ! is_wp_error( $notice_data );
490
+		$is_notice_dismissed = ! empty($notice_data) && ! is_wp_error($notice_data);
491 491
 
492 492
 		return $is_notice_dismissed;
493 493
 	}
@@ -501,9 +501,9 @@  discard block
 block discarded – undo
501 501
 	 *
502 502
 	 * @param array $errors
503 503
 	 */
504
-	public static function print_frontend_errors( $errors ) {
504
+	public static function print_frontend_errors($errors) {
505 505
 		// Bailout.
506
-		if ( ! $errors ) {
506
+		if ( ! $errors) {
507 507
 			return;
508 508
 		}
509 509
 
@@ -518,37 +518,37 @@  discard block
 block discarded – undo
518 518
 		);
519 519
 
520 520
 		// Note: we will remove give_errors class in future.
521
-		$classes = apply_filters( 'give_error_class', array( 'give_notices', 'give_errors' ) );
521
+		$classes = apply_filters('give_error_class', array('give_notices', 'give_errors'));
522 522
 
523
-		echo sprintf( '<div class="%s">', implode( ' ', $classes ) );
523
+		echo sprintf('<div class="%s">', implode(' ', $classes));
524 524
 
525 525
 		// Loop error codes and display errors.
526
-		foreach ( $errors as $error_id => $error ) {
526
+		foreach ($errors as $error_id => $error) {
527 527
 			// Backward compatibility v<1.8.11
528
-			if ( is_string( $error ) ) {
528
+			if (is_string($error)) {
529 529
 				$error = array(
530 530
 					'message'     => $error,
531 531
 					'notice_args' => array(),
532 532
 				);
533 533
 			}
534 534
 
535
-			$notice_args = wp_parse_args( $error['notice_args'], $default_notice_args );
535
+			$notice_args = wp_parse_args($error['notice_args'], $default_notice_args);
536 536
 
537 537
 			/**
538 538
 			 * Filter to modify Frontend Errors args before errors is display.
539 539
 			 *
540 540
 			 * @since 1.8.14
541 541
 			 */
542
-			$notice_args = apply_filters( 'give_frontend_errors_args', $notice_args );
542
+			$notice_args = apply_filters('give_frontend_errors_args', $notice_args);
543 543
 
544 544
 			echo sprintf(
545 545
 				'<div class="give_error give_notice" id="give_error_%1$s" data-dismissible="%2$s" data-dismiss-interval="%3$d">
546 546
 						<p><strong>%4$s</strong>: %5$s</p>
547 547
 					</div>',
548 548
 				$error_id,
549
-				give_clean( $notice_args['dismissible'] ),
550
-				absint( $notice_args['dismiss_interval'] ),
551
-				esc_html__( 'Error', 'give' ),
549
+				give_clean($notice_args['dismissible']),
550
+				absint($notice_args['dismiss_interval']),
551
+				esc_html__('Error', 'give'),
552 552
 				$error['message']
553 553
 			);
554 554
 		}
@@ -570,8 +570,8 @@  discard block
 block discarded – undo
570 570
 	 *
571 571
 	 * @return  string
572 572
 	 */
573
-	public static function print_frontend_notice( $message, $echo = true, $notice_type = 'warning', $notice_args = array() ) {
574
-		if ( empty( $message ) ) {
573
+	public static function print_frontend_notice($message, $echo = true, $notice_type = 'warning', $notice_args = array()) {
574
+		if (empty($message)) {
575 575
 			return '';
576 576
 		}
577 577
 
@@ -585,14 +585,14 @@  discard block
 block discarded – undo
585 585
 			'dismiss_interval' => 5000,
586 586
 		);
587 587
 
588
-		$notice_args = wp_parse_args( $notice_args, $default_notice_args );
588
+		$notice_args = wp_parse_args($notice_args, $default_notice_args);
589 589
 
590 590
 		/**
591 591
 		 * Filter to modify Frontend notice args before notices is display.
592 592
 		 *
593 593
 		 * @since 1.8.14
594 594
 		 */
595
-		$notice_args = apply_filters( 'give_frontend_notice_args', $notice_args );
595
+		$notice_args = apply_filters('give_frontend_notice_args', $notice_args);
596 596
 
597 597
 		// Note: we will remove give_errors class in future.
598 598
 		$error = sprintf(
@@ -602,12 +602,12 @@  discard block
 block discarded – undo
602 602
 				</p>
603 603
 			</div>',
604 604
 			$notice_type,
605
-			give_clean( $notice_args['dismissible'] ),
606
-			absint( $notice_args['dismiss_interval'] ),
605
+			give_clean($notice_args['dismissible']),
606
+			absint($notice_args['dismiss_interval']),
607 607
 			$message
608 608
 		);
609 609
 
610
-		if ( ! $echo ) {
610
+		if ( ! $echo) {
611 611
 			return $error;
612 612
 		}
613 613
 
Please login to merge, or discard this patch.
includes/import-functions.php 2 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -666,6 +666,7 @@
 block discarded – undo
666 666
  * Check if Import donation is duplicate
667 667
  *
668 668
  * @since 1.8.13
669
+ * @param Give_Donate_Form $form
669 670
  */
670 671
 function give_check_import_donation_duplicate( $payment_data, $data, $form, $donor_data ) {
671 672
 	$return = false;
Please login to merge, or discard this patch.
Spacing   +218 added lines, -218 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
  * @since 1.8.13
21 21
  */
22 22
 function give_import_donation_report() {
23
-	return get_option( 'give_import_donation_report', array() );
23
+	return get_option('give_import_donation_report', array());
24 24
 }
25 25
 
26 26
 
@@ -29,8 +29,8 @@  discard block
 block discarded – undo
29 29
  *
30 30
  * @since 1.8.13
31 31
  */
32
-function give_import_donation_report_update( $value = array() ) {
33
-	update_option( 'give_import_donation_report', $value );
32
+function give_import_donation_report_update($value = array()) {
33
+	update_option('give_import_donation_report', $value);
34 34
 }
35 35
 
36 36
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
  * @since 1.8.13
41 41
  */
42 42
 function give_import_donation_report_reset() {
43
-	update_option( 'give_import_donation_report', array() );
43
+	update_option('give_import_donation_report', array());
44 44
 }
45 45
 
46 46
 /**
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
  *
53 53
  * @return array|bool|Give_Donate_Form|int|null|WP_Post
54 54
  */
55
-function give_import_get_form_data_from_csv( $data, $import_setting = array() ) {
55
+function give_import_get_form_data_from_csv($data, $import_setting = array()) {
56 56
 	$new_form = false;
57 57
 
58 58
 	// Get the import report
@@ -61,58 +61,58 @@  discard block
 block discarded – undo
61 61
 	$form = false;
62 62
 	$meta = array();
63 63
 
64
-	if ( ! empty( $data['form_id'] ) ) {
65
-		$form = new Give_Donate_Form( $data['form_id'] );
64
+	if ( ! empty($data['form_id'])) {
65
+		$form = new Give_Donate_Form($data['form_id']);
66 66
 		// Add support to older php version.
67 67
 		$form_id = $form->get_ID();
68
-		if ( empty( $form_id ) ) {
69
-			$report['duplicate_form'] = ( ! empty( $report['duplicate_form'] ) ? ( absint( $report['duplicate_form'] ) + 1 ) : 1 );
68
+		if (empty($form_id)) {
69
+			$report['duplicate_form'] = ( ! empty($report['duplicate_form']) ? (absint($report['duplicate_form']) + 1) : 1);
70 70
 			$form                     = false;
71 71
 		}
72 72
 	}
73 73
 
74
-	if ( false === $form && ! empty( $data['form_title'] ) ) {
75
-		$form = get_page_by_title( $data['form_title'], OBJECT, 'give_forms' );
74
+	if (false === $form && ! empty($data['form_title'])) {
75
+		$form = get_page_by_title($data['form_title'], OBJECT, 'give_forms');
76 76
 
77
-		if ( ! empty( $form->ID ) ) {
77
+		if ( ! empty($form->ID)) {
78 78
 
79
-			$report['duplicate_form'] = ( ! empty( $report['duplicate_form'] ) ? ( absint( $report['duplicate_form'] ) + 1 ) : 1 );
79
+			$report['duplicate_form'] = ( ! empty($report['duplicate_form']) ? (absint($report['duplicate_form']) + 1) : 1);
80 80
 
81
-			$form = new Give_Donate_Form( $form->ID );
81
+			$form = new Give_Donate_Form($form->ID);
82 82
 		} else {
83 83
 			$form                  = new Give_Donate_Form();
84 84
 			$args                  = array(
85 85
 				'post_title'  => $data['form_title'],
86 86
 				'post_status' => 'publish',
87 87
 			);
88
-			$form                  = $form->create( $args );
89
-			$report['create_form'] = ( ! empty( $report['create_form'] ) ? ( absint( $report['create_form'] ) + 1 ) : 1 );
88
+			$form                  = $form->create($args);
89
+			$report['create_form'] = ( ! empty($report['create_form']) ? (absint($report['create_form']) + 1) : 1);
90 90
 			$new_form              = true;
91 91
 
92 92
 		}
93 93
 
94
-		$form = get_page_by_title( $data['form_title'], OBJECT, 'give_forms' );
95
-		$form = new Give_Donate_Form( $form->ID );
94
+		$form = get_page_by_title($data['form_title'], OBJECT, 'give_forms');
95
+		$form = new Give_Donate_Form($form->ID);
96 96
 	}
97 97
 
98
-	if ( ! empty( $form ) && $form->get_ID() ) {
99
-		if ( ! empty( $data['form_level'] ) && 'custom' != (string) strtolower( $data['form_level'] ) ) {
98
+	if ( ! empty($form) && $form->get_ID()) {
99
+		if ( ! empty($data['form_level']) && 'custom' != (string) strtolower($data['form_level'])) {
100 100
 			$prices     = (array) $form->get_prices();
101 101
 			$price_text = array();
102
-			foreach ( $prices as $key => $price ) {
103
-				if ( isset( $price['_give_id']['level_id'] ) ) {
104
-					$price_text[ $price['_give_id']['level_id'] ] = ( ! empty( $price['_give_text'] ) ? $price['_give_text'] : '' );
102
+			foreach ($prices as $key => $price) {
103
+				if (isset($price['_give_id']['level_id'])) {
104
+					$price_text[$price['_give_id']['level_id']] = ( ! empty($price['_give_text']) ? $price['_give_text'] : '');
105 105
 				}
106 106
 			}
107 107
 
108
-			if ( ! in_array( $data['form_level'], $price_text ) ) {
108
+			if ( ! in_array($data['form_level'], $price_text)) {
109 109
 
110 110
 				// For generating unquiet level id.
111 111
 				$count     = 1;
112
-				$new_level = count( $prices ) + $count;
113
-				while ( array_key_exists( $new_level, $price_text ) ) {
114
-					$count ++;
115
-					$new_level = count( $prices ) + $count;
112
+				$new_level = count($prices) + $count;
113
+				while (array_key_exists($new_level, $price_text)) {
114
+					$count++;
115
+					$new_level = count($prices) + $count;
116 116
 				}
117 117
 
118 118
 				$multi_level_donations = array(
@@ -120,57 +120,57 @@  discard block
 block discarded – undo
120 120
 						'_give_id'     => array(
121 121
 							'level_id' => $new_level,
122 122
 						),
123
-						'_give_amount' => give_sanitize_amount_for_db( $data['amount'] ),
123
+						'_give_amount' => give_sanitize_amount_for_db($data['amount']),
124 124
 						'_give_text'   => $data['form_level'],
125 125
 					),
126 126
 				);
127 127
 
128
-				$price_text[ $new_level ] = $data['form_level'];
128
+				$price_text[$new_level] = $data['form_level'];
129 129
 
130
-				if ( ! empty( $prices ) && is_array( $prices ) && ! empty( $prices[0] ) ) {
131
-					$prices = wp_parse_args( $multi_level_donations, $prices );
130
+				if ( ! empty($prices) && is_array($prices) && ! empty($prices[0])) {
131
+					$prices = wp_parse_args($multi_level_donations, $prices);
132 132
 
133 133
 					// Sort $prices by amount in ascending order.
134
-					$prices = wp_list_sort( $prices, '_give_amount', 'ASC' );
134
+					$prices = wp_list_sort($prices, '_give_amount', 'ASC');
135 135
 				} else {
136 136
 					$prices = $multi_level_donations;
137 137
 				}
138 138
 
139 139
 				// Unset _give_default key from $prices.
140
-				foreach ( $prices as $key => $price ) {
141
-					if ( isset( $prices[ $key ]['_give_default'] ) ) {
142
-						unset( $prices[ $key ]['_give_default'] );
140
+				foreach ($prices as $key => $price) {
141
+					if (isset($prices[$key]['_give_default'])) {
142
+						unset($prices[$key]['_give_default']);
143 143
 					}
144 144
 				}
145 145
 
146 146
 				// Set the first $price of the $prices as defalut.
147 147
 				$prices[0]['_give_default'] = 'default';
148 148
 			}
149
-			$form->price_id = array_search( $data['form_level'], $price_text );
149
+			$form->price_id = array_search($data['form_level'], $price_text);
150 150
 
151
-			$donation_levels_amounts = wp_list_pluck( $prices, '_give_amount' );
152
-			$min_amount              = min( $donation_levels_amounts );
153
-			$max_amount              = max( $donation_levels_amounts );
151
+			$donation_levels_amounts = wp_list_pluck($prices, '_give_amount');
152
+			$min_amount              = min($donation_levels_amounts);
153
+			$max_amount              = max($donation_levels_amounts);
154 154
 
155 155
 			$meta = array(
156 156
 				'_give_levels_minimum_amount' => $min_amount,
157 157
 				'_give_levels_maximum_amount' => $max_amount,
158 158
 				'_give_price_option'          => 'multi',
159
-				'_give_donation_levels'       => array_values( $prices ),
159
+				'_give_donation_levels'       => array_values($prices),
160 160
 			);
161 161
 		} else {
162 162
 			$form->price_id = 'custom';
163 163
 		}
164 164
 
165 165
 		$defaults = array(
166
-			'_give_set_price'    => give_sanitize_amount_for_db( $data['amount'] ),
166
+			'_give_set_price'    => give_sanitize_amount_for_db($data['amount']),
167 167
 			'_give_price_option' => 'set',
168 168
 		);
169 169
 
170 170
 		// If new form is created.
171
-		if ( ! empty( $new_form ) ) {
171
+		if ( ! empty($new_form)) {
172 172
 			$new_form = array(
173
-				'_give_custom_amount_text' => ( ! empty( $data['form_custom_amount_text'] ) ? $data['form_custom_amount_text'] : 'Custom' ),
173
+				'_give_custom_amount_text' => ( ! empty($data['form_custom_amount_text']) ? $data['form_custom_amount_text'] : 'Custom'),
174 174
 				'_give_logged_in_only'     => 'enabled',
175 175
 				'_give_custom_amount'      => 'enabled',
176 176
 				'_give_payment_import'     => true,
@@ -181,18 +181,18 @@  discard block
 block discarded – undo
181 181
 				'_give_default_gateway'    => 'global',
182 182
 				'_give_show_register_form' => 'both',
183 183
 			);
184
-			$defaults = wp_parse_args( $defaults, $new_form );
184
+			$defaults = wp_parse_args($defaults, $new_form);
185 185
 		}
186 186
 
187
-		$meta = wp_parse_args( $meta, $defaults );
187
+		$meta = wp_parse_args($meta, $defaults);
188 188
 
189
-		foreach ( $meta as $key => $value ) {
190
-			give_update_meta( $form->get_ID(), $key, $value );
189
+		foreach ($meta as $key => $value) {
190
+			give_update_meta($form->get_ID(), $key, $value);
191 191
 		}
192 192
 	}
193 193
 
194 194
 	// update the report
195
-	give_import_donation_report_update( $report );
195
+	give_import_donation_report_update($report);
196 196
 
197 197
 	return $form;
198 198
 }
@@ -206,30 +206,30 @@  discard block
 block discarded – undo
206 206
  *
207 207
  * @return bool|false|WP_User
208 208
  */
209
-function give_import_get_user_from_csv( $data, $import_setting = array() ) {
209
+function give_import_get_user_from_csv($data, $import_setting = array()) {
210 210
 	$report      = give_import_donation_report();
211 211
 	$donor_data  = false;
212 212
 	$customer_id = false;
213 213
 
214 214
 	// check if donor id is not empty
215
-	if ( ! empty( $data['donor_id'] ) ) {
216
-		$donor_data = new Give_Donor( (int) $data['donor_id'] );
217
-		if ( ! empty( $donor_data->id ) ) {
218
-			$report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 );
215
+	if ( ! empty($data['donor_id'])) {
216
+		$donor_data = new Give_Donor((int) $data['donor_id']);
217
+		if ( ! empty($donor_data->id)) {
218
+			$report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1);
219 219
 		}
220 220
 	}
221 221
 
222
-	if ( empty( $donor_data->id ) && ! empty( $data['user_id'] ) ) {
222
+	if (empty($donor_data->id) && ! empty($data['user_id'])) {
223 223
 		$user_id    = (int) $data['user_id'];
224
-		$donor_data = new Give_Donor( $user_id, true );
224
+		$donor_data = new Give_Donor($user_id, true);
225 225
 
226 226
 
227
-		if ( empty( $donor_data->id ) ) {
228
-			$donor_data = get_user_by( 'id', $user_id );
229
-			if ( ! empty( $donor_data->ID ) ) {
230
-				$first_name = ( ! empty( $data['first_name'] ) ? $data['first_name'] : $donor_data->user_nicename );
231
-				$last_name  = ( ! empty( $data['last_name'] ) ? $data['last_name'] : ( ( $lastname = get_user_meta( $donor_data->ID, 'last_name', true ) ) ? $lastname : '' ) );
232
-				$name       = $first_name . ' ' . $last_name;
227
+		if (empty($donor_data->id)) {
228
+			$donor_data = get_user_by('id', $user_id);
229
+			if ( ! empty($donor_data->ID)) {
230
+				$first_name = ( ! empty($data['first_name']) ? $data['first_name'] : $donor_data->user_nicename);
231
+				$last_name  = ( ! empty($data['last_name']) ? $data['last_name'] : (($lastname = get_user_meta($donor_data->ID, 'last_name', true)) ? $lastname : ''));
232
+				$name       = $first_name.' '.$last_name;
233 233
 				$user_email = $donor_data->user_email;
234 234
 				$donor_args = array(
235 235
 					'name'    => $name,
@@ -238,44 +238,44 @@  discard block
 block discarded – undo
238 238
 				);
239 239
 
240 240
 				$donor_data = new Give_Donor();
241
-				$donor_data->create( $donor_args );
241
+				$donor_data->create($donor_args);
242 242
 
243 243
 				// Adding notes that donor is being imported from CSV.
244 244
 				$current_user = wp_get_current_user();
245
-				$donor_data->add_note( esc_html( wp_sprintf( __( 'This donor was imported by %s', 'give' ), $current_user->user_email ) ) );
245
+				$donor_data->add_note(esc_html(wp_sprintf(__('This donor was imported by %s', 'give'), $current_user->user_email)));
246 246
 
247 247
 				// Add is used to ensure duplicate emails are not added
248
-				if ( $user_email != $data['email'] && ! empty( $data['email'] ) ) {
249
-					$donor_data->add_meta( 'additional_email', $data['email'] );
248
+				if ($user_email != $data['email'] && ! empty($data['email'])) {
249
+					$donor_data->add_meta('additional_email', $data['email']);
250 250
 				}
251 251
 
252
-				$report['create_donor'] = ( ! empty( $report['create_donor'] ) ? ( absint( $report['create_donor'] ) + 1 ) : 1 );
252
+				$report['create_donor'] = ( ! empty($report['create_donor']) ? (absint($report['create_donor']) + 1) : 1);
253 253
 			} else {
254 254
 			}
255 255
 		} else {
256 256
 			// Add is used to ensure duplicate emails are not added
257
-			if ( $donor_data->email != $data['email'] ) {
258
-				$donor_data->add_meta( 'additional_email', ( ! empty( $data['email'] ) ? $data['email'] : $donor_data->email ) );
257
+			if ($donor_data->email != $data['email']) {
258
+				$donor_data->add_meta('additional_email', ( ! empty($data['email']) ? $data['email'] : $donor_data->email));
259 259
 			}
260
-			$report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 );
260
+			$report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1);
261 261
 		}
262 262
 	}
263 263
 
264
-	if ( empty( $donor_data->id ) && ! empty( $data['email'] ) ) {
264
+	if (empty($donor_data->id) && ! empty($data['email'])) {
265 265
 
266
-		$donor_data = new Give_Donor( $data['email'] );
267
-		if ( empty( $donor_data->id ) ) {
268
-			$donor_data = get_user_by( 'email', $data['email'] );
266
+		$donor_data = new Give_Donor($data['email']);
267
+		if (empty($donor_data->id)) {
268
+			$donor_data = get_user_by('email', $data['email']);
269 269
 
270
-			if ( empty( $donor_data->ID ) && ! empty( $data['first_name'] ) && ! empty( $data['last_name'] ) && isset( $import_setting['create_user'] ) && 1 === absint( $import_setting['create_user'] ) ) {
271
-				$give_role  = (array) give_get_option( 'donor_default_user_role', get_option( 'default_role', ( ( $give_donor = wp_roles()->is_role( 'give_donor' ) ) && ! empty( $give_donor ) ? 'give_donor' : 'subscriber' ) ) );
270
+			if (empty($donor_data->ID) && ! empty($data['first_name']) && ! empty($data['last_name']) && isset($import_setting['create_user']) && 1 === absint($import_setting['create_user'])) {
271
+				$give_role  = (array) give_get_option('donor_default_user_role', get_option('default_role', (($give_donor = wp_roles()->is_role('give_donor')) && ! empty($give_donor) ? 'give_donor' : 'subscriber')));
272 272
 				$donor_args = array(
273 273
 					'user_login'      => $data['email'],
274 274
 					'user_email'      => $data['email'],
275
-					'user_registered' => date( 'Y-m-d H:i:s' ),
275
+					'user_registered' => date('Y-m-d H:i:s'),
276 276
 					'user_first'      => $data['first_name'],
277 277
 					'user_last'       => $data['last_name'],
278
-					'user_pass'       => wp_generate_password( 8, true ),
278
+					'user_pass'       => wp_generate_password(8, true),
279 279
 					'role'            => $give_role,
280 280
 				);
281 281
 
@@ -284,56 +284,56 @@  discard block
 block discarded – undo
284 284
 				 *
285 285
 				 * @since 1.8.13
286 286
 				 */
287
-				$donor_args = (array) apply_filters( 'give_import_insert_user_args', $donor_args, $data, $import_setting );
287
+				$donor_args = (array) apply_filters('give_import_insert_user_args', $donor_args, $data, $import_setting);
288 288
 
289 289
 				// This action was added to remove the login when using the give register function.
290
-				add_filter( 'give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11 );
291
-				$customer_id = give_register_and_login_new_user( $donor_args );
292
-				remove_filter( 'give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11 );
290
+				add_filter('give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11);
291
+				$customer_id = give_register_and_login_new_user($donor_args);
292
+				remove_filter('give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11);
293 293
 
294
-				update_user_meta( $customer_id, '_give_payment_import', true );
295
-				$donor_data = new Give_Donor( $customer_id, true );
294
+				update_user_meta($customer_id, '_give_payment_import', true);
295
+				$donor_data = new Give_Donor($customer_id, true);
296 296
 			} else {
297
-				$customer_id = ( ! empty( $donor_data->ID ) ? $donor_data->ID : false );
297
+				$customer_id = ( ! empty($donor_data->ID) ? $donor_data->ID : false);
298 298
 			}
299 299
 
300
-			if ( ! empty( $customer_id ) || ( isset( $import_setting['create_user'] ) && 0 === absint( $import_setting['create_user'] ) ) ) {
301
-				$donor_data = new Give_Donor( $customer_id, true );
300
+			if ( ! empty($customer_id) || (isset($import_setting['create_user']) && 0 === absint($import_setting['create_user']))) {
301
+				$donor_data = new Give_Donor($customer_id, true);
302 302
 
303
-				if ( empty( $donor_data->id ) ) {
303
+				if (empty($donor_data->id)) {
304 304
 
305
-					if ( ! empty( $data['form_id'] ) ) {
306
-						$form = new Give_Donate_Form( $data['form_id'] );
305
+					if ( ! empty($data['form_id'])) {
306
+						$form = new Give_Donate_Form($data['form_id']);
307 307
 					}
308 308
 
309
-					$payment_title = ( isset( $data['form_title'] ) ? $data['form_title'] : ( isset( $form ) ? $form->get_name() : esc_html__( 'New Form', 'give' ) ) );
309
+					$payment_title = (isset($data['form_title']) ? $data['form_title'] : (isset($form) ? $form->get_name() : esc_html__('New Form', 'give')));
310 310
 					$donor_args    = array(
311
-						'name'  => ! is_email( $payment_title ) ? $data['first_name'] . ' ' . $data['last_name'] : '',
311
+						'name'  => ! is_email($payment_title) ? $data['first_name'].' '.$data['last_name'] : '',
312 312
 						'email' => $data['email'],
313 313
 					);
314 314
 
315
-					if ( ! empty( $customer_id ) ) {
315
+					if ( ! empty($customer_id)) {
316 316
 						$donor_args['user_id'] = $customer_id;
317 317
 					}
318 318
 
319
-					$donor_data->create( $donor_args );
319
+					$donor_data->create($donor_args);
320 320
 
321 321
 					// Adding notes that donor is being imported from CSV.
322 322
 					$current_user = wp_get_current_user();
323
-					$donor_data->add_note( esc_html( wp_sprintf( __( 'This donor was imported by %s', 'give' ), $current_user->user_email ) ) );
323
+					$donor_data->add_note(esc_html(wp_sprintf(__('This donor was imported by %s', 'give'), $current_user->user_email)));
324 324
 
325
-					$report['create_donor'] = ( ! empty( $report['create_donor'] ) ? ( absint( $report['create_donor'] ) + 1 ) : 1 );
325
+					$report['create_donor'] = ( ! empty($report['create_donor']) ? (absint($report['create_donor']) + 1) : 1);
326 326
 				} else {
327
-					$report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 );
327
+					$report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1);
328 328
 				}
329 329
 			}
330 330
 		} else {
331
-			$report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 );
331
+			$report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1);
332 332
 		}
333 333
 	}
334 334
 
335 335
 	// update the report
336
-	give_import_donation_report_update( $report );
336
+	give_import_donation_report_update($report);
337 337
 
338 338
 	return $donor_data;
339 339
 }
@@ -351,9 +351,9 @@  discard block
 block discarded – undo
351 351
 	 *
352 352
 	 * @return array
353 353
 	 */
354
-	return (array) apply_filters( 'give_import_default_options', array(
355
-		'' => __( 'Do not import', 'give' ),
356
-	) );
354
+	return (array) apply_filters('give_import_default_options', array(
355
+		'' => __('Do not import', 'give'),
356
+	));
357 357
 }
358 358
 
359 359
 /**
@@ -369,25 +369,25 @@  discard block
 block discarded – undo
369 369
 	 *
370 370
 	 * @return array
371 371
 	 */
372
-	return (array) apply_filters( 'give_import_donations_options', array(
373
-		'id'          => __( 'Donation ID', 'give' ),
374
-		'amount'      => __( 'Donation Amount', 'give' ),
375
-		'post_date'   => __( 'Donation Date', 'give' ),
376
-		'first_name'  => __( 'Donor First Name', 'give' ),
377
-		'last_name'   => __( 'Donor Last Name', 'give' ),
378
-		'line1'       => __( 'Address 1', 'give' ),
379
-		'line2'       => __( 'Address 2', 'give' ),
380
-		'city'        => __( 'City', 'give' ),
381
-		'state'       => __( 'State', 'give' ),
382
-		'country'     => __( 'Country', 'give' ),
383
-		'zip'         => __( 'Zip', 'give' ),
384
-		'email'       => __( 'Donor Email', 'give' ),
385
-		'post_status' => __( 'Donation Status', 'give' ),
386
-		'gateway'     => __( 'Payment Method', 'give' ),
387
-		'notes'       => __( 'Notes', 'give' ),
388
-		'mode'        => __( 'Test Mode', 'give' ),
389
-		'post_meta'   => __( 'Import as Meta', 'give' ),
390
-	) );
372
+	return (array) apply_filters('give_import_donations_options', array(
373
+		'id'          => __('Donation ID', 'give'),
374
+		'amount'      => __('Donation Amount', 'give'),
375
+		'post_date'   => __('Donation Date', 'give'),
376
+		'first_name'  => __('Donor First Name', 'give'),
377
+		'last_name'   => __('Donor Last Name', 'give'),
378
+		'line1'       => __('Address 1', 'give'),
379
+		'line2'       => __('Address 2', 'give'),
380
+		'city'        => __('City', 'give'),
381
+		'state'       => __('State', 'give'),
382
+		'country'     => __('Country', 'give'),
383
+		'zip'         => __('Zip', 'give'),
384
+		'email'       => __('Donor Email', 'give'),
385
+		'post_status' => __('Donation Status', 'give'),
386
+		'gateway'     => __('Payment Method', 'give'),
387
+		'notes'       => __('Notes', 'give'),
388
+		'mode'        => __('Test Mode', 'give'),
389
+		'post_meta'   => __('Import as Meta', 'give'),
390
+	));
391 391
 }
392 392
 
393 393
 /**
@@ -403,10 +403,10 @@  discard block
 block discarded – undo
403 403
 	 *
404 404
 	 * @return array
405 405
 	 */
406
-	return (array) apply_filters( 'give_import_donor_options', array(
407
-		'donor_id' => __( 'Donor ID', 'give' ),
408
-		'user_id'  => __( 'User ID', 'give' ),
409
-	) );
406
+	return (array) apply_filters('give_import_donor_options', array(
407
+		'donor_id' => __('Donor ID', 'give'),
408
+		'user_id'  => __('User ID', 'give'),
409
+	));
410 410
 }
411 411
 
412 412
 /**
@@ -422,12 +422,12 @@  discard block
 block discarded – undo
422 422
 	 *
423 423
 	 * @return array
424 424
 	 */
425
-	return (array) apply_filters( 'give_import_donation_form_options', array(
426
-		'form_title'              => __( 'Donation Form', 'give' ),
427
-		'form_id'                 => __( 'Donation Form ID', 'give' ),
428
-		'form_level'              => __( 'Donation Level', 'give' ),
429
-		'form_custom_amount_text' => __( 'Custom Amount Text', 'give' ),
430
-	) );
425
+	return (array) apply_filters('give_import_donation_form_options', array(
426
+		'form_title'              => __('Donation Form', 'give'),
427
+		'form_id'                 => __('Donation Form ID', 'give'),
428
+		'form_level'              => __('Donation Level', 'give'),
429
+		'form_custom_amount_text' => __('Custom Amount Text', 'give'),
430
+	));
431 431
 }
432 432
 
433 433
 /**
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
  *
441 441
  * @return array
442 442
  */
443
-function give_get_donation_data_from_csv( $file_id, $start, $end, $delimiter = 'csv' ) {
443
+function give_get_donation_data_from_csv($file_id, $start, $end, $delimiter = 'csv') {
444 444
 	/**
445 445
 	 * Filter to modify delimiter of Import.
446 446
 	 *
@@ -449,19 +449,19 @@  discard block
 block discarded – undo
449 449
 	 *
450 450
 	 * Return string $delimiter.
451 451
 	 */
452
-	$delimiter = (string) apply_filters( 'give_import_delimiter_set', $delimiter );
452
+	$delimiter = (string) apply_filters('give_import_delimiter_set', $delimiter);
453 453
 
454 454
 	$raw_data = array();
455
-	$file_dir = get_attached_file( $file_id );
455
+	$file_dir = get_attached_file($file_id);
456 456
 	$count    = 0;
457
-	if ( false !== ( $handle = fopen( $file_dir, 'r' ) ) ) {
458
-		while ( false !== ( $row = fgetcsv( $handle, 0, $delimiter ) ) ) {
459
-			if ( $count >= $start && $count <= $end ) {
457
+	if (false !== ($handle = fopen($file_dir, 'r'))) {
458
+		while (false !== ($row = fgetcsv($handle, 0, $delimiter))) {
459
+			if ($count >= $start && $count <= $end) {
460 460
 				$raw_data[] = $row;
461 461
 			}
462
-			$count ++;
462
+			$count++;
463 463
 		}
464
-		fclose( $handle );
464
+		fclose($handle);
465 465
 	}
466 466
 
467 467
 	return $raw_data;
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
  *
478 478
  * @return bool
479 479
  */
480
-function give_log_user_in_on_register_callback( $value ) {
480
+function give_log_user_in_on_register_callback($value) {
481 481
 	return false;
482 482
 }
483 483
 
@@ -493,22 +493,22 @@  discard block
 block discarded – undo
493 493
  *
494 494
  * @return bool
495 495
  */
496
-function give_save_import_donation_to_db( $raw_key, $row_data, $main_key = array(), $import_setting = array() ) {
497
-	$data                          = array_combine( $raw_key, $row_data );
496
+function give_save_import_donation_to_db($raw_key, $row_data, $main_key = array(), $import_setting = array()) {
497
+	$data                          = array_combine($raw_key, $row_data);
498 498
 	$price_id                      = false;
499 499
 	$customer_id                   = 0;
500
-	$import_setting['create_user'] = ( isset( $import_setting['create_user'] ) ? $import_setting['create_user'] : 1 );
500
+	$import_setting['create_user'] = (isset($import_setting['create_user']) ? $import_setting['create_user'] : 1);
501 501
 
502
-	$data = (array) apply_filters( 'give_save_import_donation_to_db', $data );
502
+	$data = (array) apply_filters('give_save_import_donation_to_db', $data);
503 503
 
504
-	$data['amount'] = give_maybe_sanitize_amount( $data['amount'] );
504
+	$data['amount'] = give_maybe_sanitize_amount($data['amount']);
505 505
 
506 506
 	// Here come the login function.
507
-	$donor_data = give_import_get_user_from_csv( $data, $import_setting );
508
-	if ( ! empty( $donor_data->id ) ) {
509
-		if ( ! empty( $donor_data->user_id ) ) {
507
+	$donor_data = give_import_get_user_from_csv($data, $import_setting);
508
+	if ( ! empty($donor_data->id)) {
509
+		if ( ! empty($donor_data->user_id)) {
510 510
 			$customer_id = $donor_data->user_id;
511
-		} elseif ( ! empty( $data['user_id'] ) ) {
511
+		} elseif ( ! empty($data['user_id'])) {
512 512
 			$customer_id = $data['user_id'];
513 513
 		}
514 514
 	} else {
@@ -516,95 +516,95 @@  discard block
 block discarded – undo
516 516
 	}
517 517
 
518 518
 	// get form data or register a form data.
519
-	$form = give_import_get_form_data_from_csv( $data, $import_setting );
520
-	if ( false == $form ) {
519
+	$form = give_import_get_form_data_from_csv($data, $import_setting);
520
+	if (false == $form) {
521 521
 		return false;
522 522
 	} else {
523
-		$price_id = ( ! empty( $form->price_id ) ) ? $form->price_id : false;
523
+		$price_id = ( ! empty($form->price_id)) ? $form->price_id : false;
524 524
 	}
525 525
 
526 526
 
527 527
 	$address = array(
528
-		'line1'   => ( ! empty( $data['line1'] ) ? give_clean( $data['line1'] ) : '' ),
529
-		'line2'   => ( ! empty( $data['line1'] ) ? give_clean( $data['line2'] ) : '' ),
530
-		'city'    => ( ! empty( $data['line1'] ) ? give_clean( $data['city'] ) : '' ),
531
-		'zip'     => ( ! empty( $data['zip'] ) ? give_clean( $data['zip'] ) : '' ),
532
-		'state'   => ( ! empty( $data['state'] ) ? give_clean( $data['state'] ) : '' ),
533
-		'country' => ( ! empty( $data['country'] ) ? ( ( $country_code = array_search( $data['country'], give_get_country_list() ) ) ? $country_code : $data['country'] ) : '' ),
528
+		'line1'   => ( ! empty($data['line1']) ? give_clean($data['line1']) : ''),
529
+		'line2'   => ( ! empty($data['line1']) ? give_clean($data['line2']) : ''),
530
+		'city'    => ( ! empty($data['line1']) ? give_clean($data['city']) : ''),
531
+		'zip'     => ( ! empty($data['zip']) ? give_clean($data['zip']) : ''),
532
+		'state'   => ( ! empty($data['state']) ? give_clean($data['state']) : ''),
533
+		'country' => ( ! empty($data['country']) ? (($country_code = array_search($data['country'], give_get_country_list())) ? $country_code : $data['country']) : ''),
534 534
 	);
535 535
 
536 536
 	//Create payment_data array
537 537
 	$payment_data = array(
538 538
 		'donor_id'        => $donor_data->id,
539 539
 		'price'           => $data['amount'],
540
-		'status'          => ( ! empty( $data['post_status'] ) ? $data['post_status'] : 'publish' ),
540
+		'status'          => ( ! empty($data['post_status']) ? $data['post_status'] : 'publish'),
541 541
 		'currency'        => give_get_currency(),
542 542
 		'user_info'       => array(
543 543
 			'id'         => $customer_id,
544
-			'email'      => ( ! empty( $data['email'] ) ? $data['email'] : ( isset( $donor_data->email ) ? $donor_data->email : false ) ),
545
-			'first_name' => ( ! empty( $data['first_name'] ) ? $data['first_name'] : ( ! empty( $customer_id ) && ( $first_name = get_user_meta( $customer_id, 'first_name', true ) ) ? $first_name : $donor_data->name ) ),
546
-			'last_name'  => ( ! empty( $data['last_name'] ) ? $data['last_name'] : ( ! empty( $customer_id ) && ( $last_name = get_user_meta( $customer_id, 'last_name', true ) ) ? $last_name : $donor_data->name ) ),
544
+			'email'      => ( ! empty($data['email']) ? $data['email'] : (isset($donor_data->email) ? $donor_data->email : false)),
545
+			'first_name' => ( ! empty($data['first_name']) ? $data['first_name'] : ( ! empty($customer_id) && ($first_name = get_user_meta($customer_id, 'first_name', true)) ? $first_name : $donor_data->name)),
546
+			'last_name'  => ( ! empty($data['last_name']) ? $data['last_name'] : ( ! empty($customer_id) && ($last_name = get_user_meta($customer_id, 'last_name', true)) ? $last_name : $donor_data->name)),
547 547
 			'address'    => $address,
548 548
 		),
549
-		'gateway'         => ( ! empty( $data['gateway'] ) && 'offline' != strtolower( $data['gateway'] ) ? strtolower( $data['gateway'] ) : 'manual' ),
550
-		'give_form_title' => ( ! empty( $data['form_title'] ) ? $data['form_title'] : $form->get_name() ),
549
+		'gateway'         => ( ! empty($data['gateway']) && 'offline' != strtolower($data['gateway']) ? strtolower($data['gateway']) : 'manual'),
550
+		'give_form_title' => ( ! empty($data['form_title']) ? $data['form_title'] : $form->get_name()),
551 551
 		'give_form_id'    => (string) $form->get_ID(),
552 552
 		'give_price_id'   => $price_id,
553
-		'purchase_key'    => strtolower( md5( uniqid() ) ),
553
+		'purchase_key'    => strtolower(md5(uniqid())),
554 554
 		'user_email'      => $data['email'],
555
-		'post_date'       => ( ! empty( $data['post_date'] ) ? mysql2date( 'Y-m-d H:i:s', $data['post_date'] ) : current_time( 'mysql' ) ),
556
-		'mode'            => ( ! empty( $data['mode'] ) ? ( 'true' == (string) $data['mode'] || 'TRUE' == (string) $data['mode'] ? 'test' : 'live' ) : ( isset( $import_setting['mode'] ) ? ( true == (bool) $import_setting['mode'] ? 'test' : 'live' ) : ( give_is_test_mode() ? 'test' : 'live' ) ) ),
555
+		'post_date'       => ( ! empty($data['post_date']) ? mysql2date('Y-m-d H:i:s', $data['post_date']) : current_time('mysql')),
556
+		'mode'            => ( ! empty($data['mode']) ? ('true' == (string) $data['mode'] || 'TRUE' == (string) $data['mode'] ? 'test' : 'live') : (isset($import_setting['mode']) ? (true == (bool) $import_setting['mode'] ? 'test' : 'live') : (give_is_test_mode() ? 'test' : 'live'))),
557 557
 	);
558 558
 
559
-	$payment_data = apply_filters( 'give_import_before_import_payment', $payment_data, $data, $donor_data, $form );
559
+	$payment_data = apply_filters('give_import_before_import_payment', $payment_data, $data, $donor_data, $form);
560 560
 
561 561
 	// Get the report
562 562
 	$report = give_import_donation_report();
563 563
 
564 564
 	// Check for duplicate code.
565
-	if ( true === give_check_import_donation_duplicate( $payment_data, $data, $form, $donor_data ) ) {
566
-		$report['duplicate_donation'] = ( ! empty( $report['duplicate_donation'] ) ? ( absint( $report['duplicate_donation'] ) + 1 ) : 1 );
565
+	if (true === give_check_import_donation_duplicate($payment_data, $data, $form, $donor_data)) {
566
+		$report['duplicate_donation'] = ( ! empty($report['duplicate_donation']) ? (absint($report['duplicate_donation']) + 1) : 1);
567 567
 	} else {
568
-		add_action( 'give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1, 1 );
569
-		add_filter( 'give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11, 2 );
570
-		add_filter( 'give_update_donor_information', 'give_donation_import_update_donor_information', 11, 3 );
571
-		add_action( 'give_insert_payment', 'give_import_donation_insert_payment', 11, 2 );
572
-		$payment = give_insert_payment( $payment_data );
573
-		remove_action( 'give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1 );
574
-		remove_filter( 'give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11 );
575
-		remove_filter( 'give_update_donor_information', 'give_donation_import_update_donor_information', 11 );
576
-		remove_action( 'give_insert_payment', 'give_import_donation_insert_payment', 11 );
568
+		add_action('give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1, 1);
569
+		add_filter('give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11, 2);
570
+		add_filter('give_update_donor_information', 'give_donation_import_update_donor_information', 11, 3);
571
+		add_action('give_insert_payment', 'give_import_donation_insert_payment', 11, 2);
572
+		$payment = give_insert_payment($payment_data);
573
+		remove_action('give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1);
574
+		remove_filter('give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11);
575
+		remove_filter('give_update_donor_information', 'give_donation_import_update_donor_information', 11);
576
+		remove_action('give_insert_payment', 'give_import_donation_insert_payment', 11);
577 577
 
578
-		if ( $payment ) {
578
+		if ($payment) {
579 579
 
580
-			$report['create_donation'] = ( ! empty( $report['create_donation'] ) ? ( absint( $report['create_donation'] ) + 1 ) : 1 );
580
+			$report['create_donation'] = ( ! empty($report['create_donation']) ? (absint($report['create_donation']) + 1) : 1);
581 581
 
582
-			update_post_meta( $payment, '_give_payment_import', true );
582
+			update_post_meta($payment, '_give_payment_import', true);
583 583
 
584
-			if ( ! empty( $import_setting['csv'] ) ) {
585
-				update_post_meta( $payment, '_give_payment_import_id', $import_setting['csv'] );
584
+			if ( ! empty($import_setting['csv'])) {
585
+				update_post_meta($payment, '_give_payment_import_id', $import_setting['csv']);
586 586
 			}
587 587
 
588 588
 			// Insert Notes.
589
-			if ( ! empty( $data['notes'] ) ) {
590
-				give_insert_payment_note( $payment, $data['notes'] );
589
+			if ( ! empty($data['notes'])) {
590
+				give_insert_payment_note($payment, $data['notes']);
591 591
 			}
592 592
 
593
-			$meta_exists = array_keys( $raw_key, 'post_meta' );
594
-			if ( ! empty( $main_key ) && ! empty( $meta_exists ) ) {
595
-				foreach ( $meta_exists as $meta_exist ) {
596
-					if ( ! empty( $main_key[ $meta_exist ] ) && ! empty( $row_data[ $meta_exist ] ) ) {
597
-						update_post_meta( $payment, $main_key[ $meta_exist ], $row_data[ $meta_exist ] );
593
+			$meta_exists = array_keys($raw_key, 'post_meta');
594
+			if ( ! empty($main_key) && ! empty($meta_exists)) {
595
+				foreach ($meta_exists as $meta_exist) {
596
+					if ( ! empty($main_key[$meta_exist]) && ! empty($row_data[$meta_exist])) {
597
+						update_post_meta($payment, $main_key[$meta_exist], $row_data[$meta_exist]);
598 598
 					}
599 599
 				}
600 600
 			}
601 601
 		} else {
602
-			$report['failed_donation'] = ( ! empty( $report['failed_donation'] ) ? ( absint( $report['failed_donation'] ) + 1 ) : 1 );
602
+			$report['failed_donation'] = ( ! empty($report['failed_donation']) ? (absint($report['failed_donation']) + 1) : 1);
603 603
 		}
604 604
 	}
605 605
 
606 606
 	// update the report
607
-	give_import_donation_report_update( $report );
607
+	give_import_donation_report_update($report);
608 608
 
609 609
 	return true;
610 610
 }
@@ -620,12 +620,12 @@  discard block
 block discarded – undo
620 620
  *
621 621
  * @return Give_Donor
622 622
  */
623
-function give_donation_import_update_donor_information( $donor, $payment_id, $payment_data ) {
623
+function give_donation_import_update_donor_information($donor, $payment_id, $payment_data) {
624 624
 	$old_donor = $donor;
625
-	if ( ! empty( $payment_data['donor_id'] ) ) {
626
-		$donor_id = absint( $payment_data['donor_id'] );
627
-		$donor    = new Give_Donor( $donor_id );
628
-		if ( ! empty( $donor->id ) ) {
625
+	if ( ! empty($payment_data['donor_id'])) {
626
+		$donor_id = absint($payment_data['donor_id']);
627
+		$donor    = new Give_Donor($donor_id);
628
+		if ( ! empty($donor->id)) {
629 629
 			return $donor;
630 630
 		}
631 631
 	}
@@ -638,12 +638,12 @@  discard block
 block discarded – undo
638 638
  *
639 639
  * @since 1.8.13
640 640
  */
641
-function give_import_donation_insert_payment( $payment_id, $payment_data ) {
641
+function give_import_donation_insert_payment($payment_id, $payment_data) {
642 642
 	// Update Give Customers purchase_count
643
-	if ( ! empty( $payment_data['status'] ) && ( 'complete' === (string) $payment_data['status'] || 'publish' === (string) $payment_data['status'] ) ) {
644
-		$donor_id = (int) get_post_meta( $payment_id, '_give_payment_customer_id', true );
645
-		if ( ! empty( $donor_id ) ) {
646
-			$donor = new Give_Donor( $donor_id );
643
+	if ( ! empty($payment_data['status']) && ('complete' === (string) $payment_data['status'] || 'publish' === (string) $payment_data['status'])) {
644
+		$donor_id = (int) get_post_meta($payment_id, '_give_payment_customer_id', true);
645
+		if ( ! empty($donor_id)) {
646
+			$donor = new Give_Donor($donor_id);
647 647
 			$donor->increase_purchase_count();
648 648
 		}
649 649
 	}
@@ -654,8 +654,8 @@  discard block
 block discarded – undo
654 654
  *
655 655
  * @since 1.8.13
656 656
  */
657
-function give_donation_import_give_insert_payment_args( $args, $payment_data ) {
658
-	if ( ! empty( $payment_data['user_info']['id'] ) ) {
657
+function give_donation_import_give_insert_payment_args($args, $payment_data) {
658
+	if ( ! empty($payment_data['user_info']['id'])) {
659 659
 		$args['post_author'] = (int) $payment_data['user_info']['id'];
660 660
 	}
661 661
 
@@ -667,11 +667,11 @@  discard block
 block discarded – undo
667 667
  *
668 668
  * @since 1.8.13
669 669
  */
670
-function give_check_import_donation_duplicate( $payment_data, $data, $form, $donor_data ) {
670
+function give_check_import_donation_duplicate($payment_data, $data, $form, $donor_data) {
671 671
 	$return = false;
672
-	if ( ! empty( $data['post_date'] ) ) {
673
-		$post_date = mysql2date( 'Y-m-d-H-i-s', $data['post_date'] );
674
-		$post_date = explode( '-', $post_date );
672
+	if ( ! empty($data['post_date'])) {
673
+		$post_date = mysql2date('Y-m-d-H-i-s', $data['post_date']);
674
+		$post_date = explode('-', $post_date);
675 675
 		$args      = array(
676 676
 			'post_type'              => 'give_payment',
677 677
 			'cache_results'          => false,
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
 			'meta_query'             => array(
693 693
 				array(
694 694
 					'key'     => '_give_payment_total',
695
-					'value'   => preg_replace( '/[\$,]/', '', $payment_data['price'] ),
695
+					'value'   => preg_replace('/[\$,]/', '', $payment_data['price']),
696 696
 					'compare' => 'LIKE',
697 697
 				),
698 698
 				array(
@@ -709,9 +709,9 @@  discard block
 block discarded – undo
709 709
 			),
710 710
 		);
711 711
 
712
-		$payments  = new Give_Payments_Query( $args );
712
+		$payments  = new Give_Payments_Query($args);
713 713
 		$donations = $payments->get_payments();
714
-		if ( ! empty( $donations ) ) {
714
+		if ( ! empty($donations)) {
715 715
 			return true;
716 716
 		}
717 717
 	}
@@ -728,9 +728,9 @@  discard block
 block discarded – undo
728 728
  *
729 729
  * @return void
730 730
  */
731
-function give_donation_import_insert_default_payment_note( $payment_id ) {
731
+function give_donation_import_insert_default_payment_note($payment_id) {
732 732
 	$current_user = wp_get_current_user();
733
-	give_insert_payment_note( $payment_id, esc_html( wp_sprintf( __( 'This donation was imported by %s', 'give' ), $current_user->user_email ) ) );
733
+	give_insert_payment_note($payment_id, esc_html(wp_sprintf(__('This donation was imported by %s', 'give'), $current_user->user_email)));
734 734
 }
735 735
 
736 736
 /**
@@ -742,14 +742,14 @@  discard block
 block discarded – undo
742 742
  *
743 743
  * @return string URL
744 744
  */
745
-function give_import_page_url( $parameter = array() ) {
745
+function give_import_page_url($parameter = array()) {
746 746
 	$defalut_query_arg = array(
747 747
 		'post_type'     => 'give_forms',
748 748
 		'page'          => 'give-tools',
749 749
 		'tab'           => 'import',
750 750
 		'importer-type' => 'import_donations',
751 751
 	);
752
-	$import_query_arg  = wp_parse_args( $parameter, $defalut_query_arg );
752
+	$import_query_arg = wp_parse_args($parameter, $defalut_query_arg);
753 753
 
754
-	return add_query_arg( $import_query_arg, admin_url( 'edit.php' ) );
754
+	return add_query_arg($import_query_arg, admin_url('edit.php'));
755 755
 }
756 756
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/settings/class-settings-advanced.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -9,11 +9,11 @@  discard block
 block discarded – undo
9 9
  * @since       1.8
10 10
  */
11 11
 
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit; // Exit if accessed directly
14 14
 }
15 15
 
16
-if ( ! class_exists( 'Give_Settings_Advanced' ) ) :
16
+if ( ! class_exists('Give_Settings_Advanced')) :
17 17
 
18 18
 	/**
19 19
 	 * Give_Settings_Advanced.
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 		 */
28 28
 		public function __construct() {
29 29
 			$this->id    = 'advanced';
30
-			$this->label = __( 'Advanced', 'give' );
30
+			$this->label = __('Advanced', 'give');
31 31
 
32 32
 			$this->default_tab = 'advanced-options';
33 33
 
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 
46 46
 			$current_section = give_get_current_setting_section();
47 47
 
48
-			switch ( $current_section ) {
48
+			switch ($current_section) {
49 49
 				case 'advanced-options':
50 50
 					$settings = array(
51 51
 						array(
@@ -53,19 +53,19 @@  discard block
 block discarded – undo
53 53
 							'type' => 'title',
54 54
 						),
55 55
 						array(
56
-							'name'    => __( 'Remove Data on Uninstall', 'give' ),
57
-							'desc'    => __( 'When the plugin is deleted, completely remove all Give data. This includes all Give settings, forms, form meta, donor, donor data, donations. Everything.', 'give' ),
56
+							'name'    => __('Remove Data on Uninstall', 'give'),
57
+							'desc'    => __('When the plugin is deleted, completely remove all Give data. This includes all Give settings, forms, form meta, donor, donor data, donations. Everything.', 'give'),
58 58
 							'id'      => 'uninstall_on_delete',
59 59
 							'type'    => 'radio_inline',
60 60
 							'default' => 'disabled',
61 61
 							'options' => array(
62
-								'enabled'  => __( 'Yes, Remove all data', 'give' ),
63
-								'disabled' => __( 'No, keep my Give settings and donation data', 'give' ),
62
+								'enabled'  => __('Yes, Remove all data', 'give'),
63
+								'disabled' => __('No, keep my Give settings and donation data', 'give'),
64 64
 							),
65 65
 						),
66 66
 						array(
67
-							'name'    => __( 'Default User Role', 'give' ),
68
-							'desc'    => __( 'Assign default user roles for donors when donors opt to register as a WP User.', 'give' ),
67
+							'name'    => __('Default User Role', 'give'),
68
+							'desc'    => __('Assign default user roles for donors when donors opt to register as a WP User.', 'give'),
69 69
 							'id'      => 'donor_default_user_role',
70 70
 							'type'    => 'select',
71 71
 							'default' => 'give_donor',
@@ -73,44 +73,44 @@  discard block
 block discarded – undo
73 73
 						),
74 74
 						array(
75 75
 							/* translators: %s: the_content */
76
-							'name'    => sprintf( __( '%s filter', 'give' ), '<code>the_content</code>' ),
76
+							'name'    => sprintf(__('%s filter', 'give'), '<code>the_content</code>'),
77 77
 							/* translators: 1: https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content 2: the_content */
78
-							'desc'    => sprintf( __( 'If you are seeing extra social buttons, related posts, or other unwanted elements appearing within your forms then you can disable WordPress\' content filter. <a href="%1$s" target="_blank">Learn more</a> about %2$s filter.', 'give' ), esc_url( 'https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content' ), '<code>the_content</code>' ),
78
+							'desc'    => sprintf(__('If you are seeing extra social buttons, related posts, or other unwanted elements appearing within your forms then you can disable WordPress\' content filter. <a href="%1$s" target="_blank">Learn more</a> about %2$s filter.', 'give'), esc_url('https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content'), '<code>the_content</code>'),
79 79
 							'id'      => 'the_content_filter',
80 80
 							'default' => 'enabled',
81 81
 							'type'    => 'radio_inline',
82 82
 							'options' => array(
83
-								'enabled'  => __( 'Enabled', 'give' ),
84
-								'disabled' => __( 'Disabled', 'give' ),
83
+								'enabled'  => __('Enabled', 'give'),
84
+								'disabled' => __('Disabled', 'give'),
85 85
 							),
86 86
 						),
87 87
 						array(
88
-							'name'    => __( 'Script Loading Location', 'give' ),
89
-							'desc'    => __( 'This allows you to load your Give scripts either in the <code>&lt;head&gt;</code> or footer of your website.', 'give' ),
88
+							'name'    => __('Script Loading Location', 'give'),
89
+							'desc'    => __('This allows you to load your Give scripts either in the <code>&lt;head&gt;</code> or footer of your website.', 'give'),
90 90
 							'id'      => 'scripts_footer',
91 91
 							'type'    => 'radio_inline',
92 92
 							'default' => 'disabled',
93 93
 							'options' => array(
94
-								'enabled'  => __( 'Footer', 'give' ),
95
-								'disabled' => __( 'Head', 'give' ),
94
+								'enabled'  => __('Footer', 'give'),
95
+								'disabled' => __('Head', 'give'),
96 96
 							),
97 97
 						),
98 98
 						array(
99
-							'name'    => __( 'Akismet SPAM Protection', 'give' ),
100
-							'desc'    => __( 'Add a layer of SPAM protection to your donation submissions with Akismet. When enabled, donation submissions will be first sent to Akismet\'s API if you have the plugin activated and configured.', 'give' ),
99
+							'name'    => __('Akismet SPAM Protection', 'give'),
100
+							'desc'    => __('Add a layer of SPAM protection to your donation submissions with Akismet. When enabled, donation submissions will be first sent to Akismet\'s API if you have the plugin activated and configured.', 'give'),
101 101
 							'id'      => 'akismet_spam_protection',
102 102
 							'type'    => 'radio_inline',
103
-							'default' => ( give_check_akismet_key() ) ? 'enabled' : 'disabled',
103
+							'default' => (give_check_akismet_key()) ? 'enabled' : 'disabled',
104 104
 							'options' => array(
105
-								'enabled'  => __( 'Enabled', 'give' ),
106
-								'disabled' => __( 'Disabled', 'give' ),
105
+								'enabled'  => __('Enabled', 'give'),
106
+								'disabled' => __('Disabled', 'give'),
107 107
 							),
108 108
 						),
109 109
 						array(
110
-							'name'  => __( 'Advanced Settings Docs Link', 'give' ),
110
+							'name'  => __('Advanced Settings Docs Link', 'give'),
111 111
 							'id'    => 'advanced_settings_docs_link',
112
-							'url'   => esc_url( 'http://docs.givewp.com/settings-advanced' ),
113
-							'title' => __( 'Advanced Settings', 'give' ),
112
+							'url'   => esc_url('http://docs.givewp.com/settings-advanced'),
113
+							'title' => __('Advanced Settings', 'give'),
114 114
 							'type'  => 'give_docs_link',
115 115
 						),
116 116
 						array(
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 			 * Filter the advanced settings.
127 127
 			 * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8
128 128
 			 */
129
-			$settings = apply_filters( 'give_settings_advanced', $settings );
129
+			$settings = apply_filters('give_settings_advanced', $settings);
130 130
 
131 131
 			/**
132 132
 			 * Filter the settings.
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 			 *
136 136
 			 * @param  array $settings
137 137
 			 */
138
-			$settings = apply_filters( 'give_get_settings_' . $this->id, $settings );
138
+			$settings = apply_filters('give_get_settings_'.$this->id, $settings);
139 139
 
140 140
 			// Output.
141 141
 			return $settings;
@@ -149,10 +149,10 @@  discard block
 block discarded – undo
149 149
 		 */
150 150
 		public function get_sections() {
151 151
 			$sections = array(
152
-				'advanced-options' => __( 'Advanced Options', 'give' ),
152
+				'advanced-options' => __('Advanced Options', 'give'),
153 153
 			);
154 154
 
155
-			return apply_filters( 'give_get_sections_' . $this->id, $sections );
155
+			return apply_filters('give_get_sections_'.$this->id, $sections);
156 156
 		}
157 157
 	}
158 158
 
Please login to merge, or discard this patch.
includes/admin/tools/export/pdf-reports.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@
 block discarded – undo
59 59
 	$font_style   = '';
60 60
 
61 61
 	if ( file_exists( GIVE_PLUGIN_DIR . '/includes/libraries/tcpdf/fonts/CODE2000.TTF' ) &&
62
-	     in_array( give_get_currency(), array( 'RIAL', 'RUB' ) ) ) {
62
+		 in_array( give_get_currency(), array( 'RIAL', 'RUB' ) ) ) {
63 63
 		TCPDF_FONTS::addTTFfont( GIVE_PLUGIN_DIR . '/includes/libraries/tcpdf/fonts/CODE2000.TTF', '' );
64 64
 		$custom_font = 'CODE2000';
65 65
 		$font_style  = 'B';
Please login to merge, or discard this patch.
Spacing   +159 added lines, -159 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly..
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -25,130 +25,130 @@  discard block
 block discarded – undo
25 25
  *
26 26
  * @uses   give_pdf
27 27
  */
28
-function give_generate_pdf( $data ) {
28
+function give_generate_pdf($data) {
29 29
 
30
-	if ( ! current_user_can( 'view_give_reports' ) ) {
31
-		wp_die( __( 'You do not have permission to generate PDF sales reports.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
30
+	if ( ! current_user_can('view_give_reports')) {
31
+		wp_die(__('You do not have permission to generate PDF sales reports.', 'give'), __('Error', 'give'), array('response' => 403));
32 32
 	}
33 33
 
34
-	if ( ! wp_verify_nonce( $_GET['_wpnonce'], 'give_generate_pdf' ) ) {
35
-		wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
34
+	if ( ! wp_verify_nonce($_GET['_wpnonce'], 'give_generate_pdf')) {
35
+		wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'), array('response' => 403));
36 36
 	}
37 37
 
38
-	if ( ! file_exists( GIVE_PLUGIN_DIR . '/includes/libraries/give-pdf.php' ) ) {
39
-		wp_die( __( 'Dependency missing.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
38
+	if ( ! file_exists(GIVE_PLUGIN_DIR.'/includes/libraries/give-pdf.php')) {
39
+		wp_die(__('Dependency missing.', 'give'), __('Error', 'give'), array('response' => 403));
40 40
 	}
41 41
 
42
-	require_once GIVE_PLUGIN_DIR . '/includes/libraries/give-pdf.php';
42
+	require_once GIVE_PLUGIN_DIR.'/includes/libraries/give-pdf.php';
43 43
 
44 44
 	$daterange = utf8_decode(
45 45
 		sprintf(
46 46
 		/* translators: 1: start date 2: end date */
47
-			__( '%1$s to %2$s', 'give' ),
48
-			date_i18n( give_date_format(), mktime( 0, 0, 0, 1, 1, date( 'Y' ) ) ),
49
-			date_i18n( give_date_format() )
47
+			__('%1$s to %2$s', 'give'),
48
+			date_i18n(give_date_format(), mktime(0, 0, 0, 1, 1, date('Y'))),
49
+			date_i18n(give_date_format())
50 50
 		)
51 51
 	);
52 52
 
53
-	$categories_enabled = give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) );
54
-	$tags_enabled       = give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) );
53
+	$categories_enabled = give_is_setting_enabled(give_get_option('categories', 'disabled'));
54
+	$tags_enabled       = give_is_setting_enabled(give_get_option('tags', 'disabled'));
55 55
 
56
-	$pdf          = new Give_PDF( 'L', 'mm', 'A', true, 'UTF-8', false );
57
-	$default_font = apply_filters( 'give_pdf_default_font', 'Helvetica' );
56
+	$pdf          = new Give_PDF('L', 'mm', 'A', true, 'UTF-8', false);
57
+	$default_font = apply_filters('give_pdf_default_font', 'Helvetica');
58 58
 	$custom_font  = 'dejavusans';
59 59
 	$font_style   = '';
60 60
 
61
-	if ( file_exists( GIVE_PLUGIN_DIR . '/includes/libraries/tcpdf/fonts/CODE2000.TTF' ) &&
62
-	     in_array( give_get_currency(), array( 'RIAL', 'RUB' ) ) ) {
63
-		TCPDF_FONTS::addTTFfont( GIVE_PLUGIN_DIR . '/includes/libraries/tcpdf/fonts/CODE2000.TTF', '' );
61
+	if (file_exists(GIVE_PLUGIN_DIR.'/includes/libraries/tcpdf/fonts/CODE2000.TTF') &&
62
+	     in_array(give_get_currency(), array('RIAL', 'RUB'))) {
63
+		TCPDF_FONTS::addTTFfont(GIVE_PLUGIN_DIR.'/includes/libraries/tcpdf/fonts/CODE2000.TTF', '');
64 64
 		$custom_font = 'CODE2000';
65 65
 		$font_style  = 'B';
66 66
 	}
67 67
 
68
-	$pdf->AddPage( 'L', 'A4' );
69
-	$pdf->setImageScale( 1.5 );
70
-	$pdf->SetTitle( utf8_decode( __( 'Donation report for the current year for all forms', 'give' ) ) );
71
-	$pdf->SetAuthor( utf8_decode( __( 'Give - Democratizing Generosity', 'give' ) ) );
72
-	$pdf->SetCreator( utf8_decode( __( 'Give - Democratizing Generosity', 'give' ) ) );
68
+	$pdf->AddPage('L', 'A4');
69
+	$pdf->setImageScale(1.5);
70
+	$pdf->SetTitle(utf8_decode(__('Donation report for the current year for all forms', 'give')));
71
+	$pdf->SetAuthor(utf8_decode(__('Give - Democratizing Generosity', 'give')));
72
+	$pdf->SetCreator(utf8_decode(__('Give - Democratizing Generosity', 'give')));
73 73
 
74
-	$pdf->Image( apply_filters( 'give_pdf_export_logo', GIVE_PLUGIN_URL . 'assets/images/give-logo-small.png' ), 247, 8 );
74
+	$pdf->Image(apply_filters('give_pdf_export_logo', GIVE_PLUGIN_URL.'assets/images/give-logo-small.png'), 247, 8);
75 75
 
76
-	$pdf->SetMargins( 8, 8, 8 );
77
-	$pdf->SetX( 8 );
76
+	$pdf->SetMargins(8, 8, 8);
77
+	$pdf->SetX(8);
78 78
 
79
-	$pdf->SetFont( $default_font, '', 16 );
80
-	$pdf->SetTextColor( 50, 50, 50 );
81
-	$pdf->Cell( 0, 3, utf8_decode( __( 'Donation report for the current year for all forms', 'give' ) ), 0, 2, 'L', false );
79
+	$pdf->SetFont($default_font, '', 16);
80
+	$pdf->SetTextColor(50, 50, 50);
81
+	$pdf->Cell(0, 3, utf8_decode(__('Donation report for the current year for all forms', 'give')), 0, 2, 'L', false);
82 82
 
83
-	$pdf->SetFont( $default_font, '', 13 );
84
-	$pdf->SetTextColor( 150, 150, 150 );
85
-	$pdf->Ln( 1 );
86
-	$pdf->Cell( 0, 6, utf8_decode( __( 'Date Range: ', 'give' ) ) . $daterange, 0, 2, 'L', false );
83
+	$pdf->SetFont($default_font, '', 13);
84
+	$pdf->SetTextColor(150, 150, 150);
85
+	$pdf->Ln(1);
86
+	$pdf->Cell(0, 6, utf8_decode(__('Date Range: ', 'give')).$daterange, 0, 2, 'L', false);
87 87
 	$pdf->Ln();
88
-	$pdf->SetTextColor( 50, 50, 50 );
89
-	$pdf->SetFont( $default_font, '', 14 );
90
-	$pdf->Cell( 0, 10, utf8_decode( __( 'Table View', 'give' ) ), 0, 2, 'L', false );
91
-	$pdf->SetFont( $default_font, '', 12 );
88
+	$pdf->SetTextColor(50, 50, 50);
89
+	$pdf->SetFont($default_font, '', 14);
90
+	$pdf->Cell(0, 10, utf8_decode(__('Table View', 'give')), 0, 2, 'L', false);
91
+	$pdf->SetFont($default_font, '', 12);
92 92
 
93
-	$pdf->SetFillColor( 238, 238, 238 );
94
-	$pdf->SetTextColor( 0, 0, 0, 100 ); // Set Black color.
95
-	$pdf->Cell( 50, 6, utf8_decode( __( 'Form Name', 'give' ) ), 1, 0, 'L', true );
96
-	$pdf->Cell( 50, 6, utf8_decode( __( 'Price', 'give' ) ), 1, 0, 'L', true );
93
+	$pdf->SetFillColor(238, 238, 238);
94
+	$pdf->SetTextColor(0, 0, 0, 100); // Set Black color.
95
+	$pdf->Cell(50, 6, utf8_decode(__('Form Name', 'give')), 1, 0, 'L', true);
96
+	$pdf->Cell(50, 6, utf8_decode(__('Price', 'give')), 1, 0, 'L', true);
97 97
 
98 98
 	// Display Categories Heading only, if user has opted for it.
99
-	if ( $categories_enabled ) {
100
-		$pdf->Cell( 45, 6, utf8_decode( __( 'Categories', 'give' ) ), 1, 0, 'L', true );
99
+	if ($categories_enabled) {
100
+		$pdf->Cell(45, 6, utf8_decode(__('Categories', 'give')), 1, 0, 'L', true);
101 101
 	}
102 102
 
103 103
 	// Display Tags Heading only, if user has opted for it.
104
-	if ( $tags_enabled ) {
105
-		$pdf->Cell( 45, 6, utf8_decode( __( 'Tags', 'give' ) ), 1, 0, 'L', true );
104
+	if ($tags_enabled) {
105
+		$pdf->Cell(45, 6, utf8_decode(__('Tags', 'give')), 1, 0, 'L', true);
106 106
 	}
107 107
 
108
-	$pdf->Cell( 45, 6, utf8_decode( __( 'Number of Donations', 'give' ) ), 1, 0, 'L', true );
109
-	$pdf->Cell( 45, 6, utf8_decode( __( 'Income to Date', 'give' ) ), 1, 1, 'L', true );
108
+	$pdf->Cell(45, 6, utf8_decode(__('Number of Donations', 'give')), 1, 0, 'L', true);
109
+	$pdf->Cell(45, 6, utf8_decode(__('Income to Date', 'give')), 1, 1, 'L', true);
110 110
 
111 111
 	// Set Custom Font to support various currencies.
112
-	$pdf->SetFont( apply_filters( 'give_pdf_custom_font', $custom_font ), $font_style, 12 );
112
+	$pdf->SetFont(apply_filters('give_pdf_custom_font', $custom_font), $font_style, 12);
113 113
 
114
-	$year       = date( 'Y' );
115
-	$give_forms = get_posts( array(
114
+	$year       = date('Y');
115
+	$give_forms = get_posts(array(
116 116
 		'post_type'      => 'give_forms',
117 117
 		'year'           => $year,
118
-		'posts_per_page' => - 1,
118
+		'posts_per_page' => -1,
119 119
 		'supply_filter'  => false,
120
-	) );
120
+	));
121 121
 
122
-	if ( $give_forms ) {
123
-		$pdf->SetWidths( array( 50, 50, 45, 45, 45, 45 ) );
122
+	if ($give_forms) {
123
+		$pdf->SetWidths(array(50, 50, 45, 45, 45, 45));
124 124
 
125
-		foreach ( $give_forms as $form ):
126
-			$pdf->SetFillColor( 255, 255, 255 );
125
+		foreach ($give_forms as $form):
126
+			$pdf->SetFillColor(255, 255, 255);
127 127
 
128 128
 			$title = $form->post_title;
129 129
 
130
-			if ( give_has_variable_prices( $form->ID ) ) {
131
-				$price = html_entity_decode( give_price_range( $form->ID, false ) );
130
+			if (give_has_variable_prices($form->ID)) {
131
+				$price = html_entity_decode(give_price_range($form->ID, false));
132 132
 			} else {
133
-				$price = give_currency_filter( give_get_form_price( $form->ID ), '', true );
133
+				$price = give_currency_filter(give_get_form_price($form->ID), '', true);
134 134
 			}
135 135
 
136 136
 			// Display Categories Data only, if user has opted for it.
137 137
 			$categories = array();
138
-			if ( $categories_enabled ) {
139
-				$categories = get_the_term_list( $form->ID, 'give_forms_category', '', ', ', '' );
140
-				$categories = ! is_wp_error( $categories ) ? strip_tags( $categories ) : '';
138
+			if ($categories_enabled) {
139
+				$categories = get_the_term_list($form->ID, 'give_forms_category', '', ', ', '');
140
+				$categories = ! is_wp_error($categories) ? strip_tags($categories) : '';
141 141
 			}
142 142
 
143 143
 			// Display Tags Data only, if user has opted for it.
144 144
 			$tags = array();
145
-			if ( $tags_enabled ) {
146
-				$tags = get_the_term_list( $form->ID, 'give_forms_tag', '', ', ', '' );
147
-				$tags = ! is_wp_error( $tags ) ? strip_tags( $tags ) : '';
145
+			if ($tags_enabled) {
146
+				$tags = get_the_term_list($form->ID, 'give_forms_tag', '', ', ', '');
147
+				$tags = ! is_wp_error($tags) ? strip_tags($tags) : '';
148 148
 			}
149 149
 
150
-			$sales    = give_get_form_sales_stats( $form->ID );
151
-			$earnings = give_currency_filter( give_format_amount( give_get_form_earnings_stats( $form->ID ), array( 'sanitize' => false, ) ), '', true );
150
+			$sales    = give_get_form_sales_stats($form->ID);
151
+			$earnings = give_currency_filter(give_format_amount(give_get_form_earnings_stats($form->ID), array('sanitize' => false,)), '', true);
152 152
 
153 153
 			// This will help filter data before appending it to PDF Receipt.
154 154
 			$prepare_pdf_data   = array();
@@ -156,53 +156,53 @@  discard block
 block discarded – undo
156 156
 			$prepare_pdf_data[] = $price;
157 157
 
158 158
 			// Append Categories Data only, if user has opted for it.
159
-			if ( $categories_enabled ) {
159
+			if ($categories_enabled) {
160 160
 				$prepare_pdf_data[] = $categories;
161 161
 			}
162 162
 
163 163
 			// Append Tags Data only, if user has opted for it.
164
-			if ( $tags_enabled ) {
164
+			if ($tags_enabled) {
165 165
 				$prepare_pdf_data[] = $tags;
166 166
 			}
167 167
 
168 168
 			$prepare_pdf_data[] = $sales;
169 169
 			$prepare_pdf_data[] = $earnings;
170 170
 
171
-			$pdf->Row( $prepare_pdf_data );
171
+			$pdf->Row($prepare_pdf_data);
172 172
 
173 173
 		endforeach;
174 174
 	} else {
175 175
 
176 176
 		// Fix: Minor Styling Alignment Issue for PDF.
177
-		if ( $categories_enabled && $tags_enabled ) {
177
+		if ($categories_enabled && $tags_enabled) {
178 178
 			$no_found_width = 280;
179
-		} elseif ( $categories_enabled || $tags_enabled ) {
179
+		} elseif ($categories_enabled || $tags_enabled) {
180 180
 			$no_found_width = 235;
181 181
 		} else {
182 182
 			$no_found_width = 190;
183 183
 		}
184
-		$title = utf8_decode( __( 'No forms found.', 'give' ) );
185
-		$pdf->MultiCell( $no_found_width, 5, $title, 1, 'C', false, 1, '', '', true, 0, false, true, 0, 'T', false );
184
+		$title = utf8_decode(__('No forms found.', 'give'));
185
+		$pdf->MultiCell($no_found_width, 5, $title, 1, 'C', false, 1, '', '', true, 0, false, true, 0, 'T', false);
186 186
 	}// End if().
187 187
 	$pdf->Ln();
188
-	$pdf->SetTextColor( 50, 50, 50 );
189
-	$pdf->SetFont( $default_font, '', 14 );
188
+	$pdf->SetTextColor(50, 50, 50);
189
+	$pdf->SetFont($default_font, '', 14);
190 190
 
191 191
 	// Output Graph on a new page.
192
-	$pdf->AddPage( 'L', 'A4' );
193
-	$pdf->Cell( 0, 10, utf8_decode( __( 'Graph View', 'give' ) ), 0, 2, 'L', false );
194
-	$pdf->SetFont( $default_font, '', 12 );
192
+	$pdf->AddPage('L', 'A4');
193
+	$pdf->Cell(0, 10, utf8_decode(__('Graph View', 'give')), 0, 2, 'L', false);
194
+	$pdf->SetFont($default_font, '', 12);
195 195
 
196
-	$image = html_entity_decode( urldecode( give_draw_chart_image() ) );
197
-	$image = str_replace( ' ', '%20', $image );
196
+	$image = html_entity_decode(urldecode(give_draw_chart_image()));
197
+	$image = str_replace(' ', '%20', $image);
198 198
 
199
-	$pdf->SetX( 25 );
200
-	$pdf->Image( $image . '&file=.png' );
201
-	$pdf->Ln( 7 );
202
-	$pdf->Output( apply_filters( 'give_sales_earnings_pdf_export_filename', 'give-report-' . date_i18n( 'Y-m-d' ) ) . '.pdf', 'D' );
199
+	$pdf->SetX(25);
200
+	$pdf->Image($image.'&file=.png');
201
+	$pdf->Ln(7);
202
+	$pdf->Output(apply_filters('give_sales_earnings_pdf_export_filename', 'give-report-'.date_i18n('Y-m-d')).'.pdf', 'D');
203 203
 }
204 204
 
205
-add_action( 'give_generate_pdf', 'give_generate_pdf' );
205
+add_action('give_generate_pdf', 'give_generate_pdf');
206 206
 
207 207
 /**
208 208
  * Draws Chart for PDF Report.
@@ -219,38 +219,38 @@  discard block
 block discarded – undo
219 219
  * @return string $chart->getUrl() URL for the Google Chart
220 220
  */
221 221
 function give_draw_chart_image() {
222
-	require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/GoogleChart.php';
223
-	require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/markers/GoogleChartShapeMarker.php';
224
-	require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/markers/GoogleChartTextMarker.php';
222
+	require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/GoogleChart.php';
223
+	require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/markers/GoogleChartShapeMarker.php';
224
+	require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/markers/GoogleChartTextMarker.php';
225 225
 
226
-	$chart = new GoogleChart( 'lc', 900, 330 );
226
+	$chart = new GoogleChart('lc', 900, 330);
227 227
 
228 228
 	$i        = 1;
229 229
 	$earnings = "";
230 230
 	$sales    = "";
231 231
 
232
-	while ( $i <= 12 ) :
233
-		$earnings .= give_get_earnings_by_date( null, $i, date( 'Y' ) ) . ",";
234
-		$sales    .= give_get_sales_by_date( null, $i, date( 'Y' ) ) . ",";
235
-		$i ++;
232
+	while ($i <= 12) :
233
+		$earnings .= give_get_earnings_by_date(null, $i, date('Y')).",";
234
+		$sales    .= give_get_sales_by_date(null, $i, date('Y')).",";
235
+		$i++;
236 236
 	endwhile;
237 237
 
238
-	$earnings_array = explode( ",", $earnings );
239
-	$sales_array    = explode( ",", $sales );
238
+	$earnings_array = explode(",", $earnings);
239
+	$sales_array    = explode(",", $sales);
240 240
 
241 241
 	$i = 0;
242
-	while ( $i <= 11 ) {
243
-		if ( empty( $sales_array[ $i ] ) ) {
244
-			$sales_array[ $i ] = 0;
242
+	while ($i <= 11) {
243
+		if (empty($sales_array[$i])) {
244
+			$sales_array[$i] = 0;
245 245
 		}
246
-		$i ++;
246
+		$i++;
247 247
 	}
248 248
 
249 249
 	$min_earnings   = 0;
250
-	$max_earnings   = max( $earnings_array );
251
-	$earnings_scale = round( $max_earnings, - 1 );
250
+	$max_earnings   = max($earnings_array);
251
+	$earnings_scale = round($max_earnings, - 1);
252 252
 
253
-	$data = new GoogleChartData( array(
253
+	$data = new GoogleChartData(array(
254 254
 		$earnings_array[0],
255 255
 		$earnings_array[1],
256 256
 		$earnings_array[2],
@@ -263,25 +263,25 @@  discard block
 block discarded – undo
263 263
 		$earnings_array[9],
264 264
 		$earnings_array[10],
265 265
 		$earnings_array[11],
266
-	) );
266
+	));
267 267
 
268
-	$data->setLegend( __( 'Income', 'give' ) );
269
-	$data->setColor( '1b58a3' );
270
-	$chart->addData( $data );
268
+	$data->setLegend(__('Income', 'give'));
269
+	$data->setColor('1b58a3');
270
+	$chart->addData($data);
271 271
 
272
-	$shape_marker = new GoogleChartShapeMarker( GoogleChartShapeMarker::CIRCLE );
273
-	$shape_marker->setColor( '000000' );
274
-	$shape_marker->setSize( 7 );
275
-	$shape_marker->setBorder( 2 );
276
-	$shape_marker->setData( $data );
277
-	$chart->addMarker( $shape_marker );
272
+	$shape_marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE);
273
+	$shape_marker->setColor('000000');
274
+	$shape_marker->setSize(7);
275
+	$shape_marker->setBorder(2);
276
+	$shape_marker->setData($data);
277
+	$chart->addMarker($shape_marker);
278 278
 
279
-	$value_marker = new GoogleChartTextMarker( GoogleChartTextMarker::VALUE );
280
-	$value_marker->setColor( '000000' );
281
-	$value_marker->setData( $data );
282
-	$chart->addMarker( $value_marker );
279
+	$value_marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE);
280
+	$value_marker->setColor('000000');
281
+	$value_marker->setData($data);
282
+	$chart->addMarker($value_marker);
283 283
 
284
-	$data = new GoogleChartData( array(
284
+	$data = new GoogleChartData(array(
285 285
 		$sales_array[0],
286 286
 		$sales_array[1],
287 287
 		$sales_array[2],
@@ -294,46 +294,46 @@  discard block
 block discarded – undo
294 294
 		$sales_array[9],
295 295
 		$sales_array[10],
296 296
 		$sales_array[11],
297
-	) );
298
-	$data->setLegend( __( 'Donations', 'give' ) );
299
-	$data->setColor( 'ff6c1c' );
300
-	$chart->addData( $data );
301
-
302
-	$chart->setTitle( __( 'Donations by Month for all Give Forms', 'give' ), '336699', 18 );
303
-
304
-	$chart->setScale( 0, $max_earnings );
305
-
306
-	$y_axis = new GoogleChartAxis( 'y' );
307
-	$y_axis->setDrawTickMarks( true )->setLabels( array( 0, $max_earnings ) );
308
-	$chart->addAxis( $y_axis );
309
-
310
-	$x_axis = new GoogleChartAxis( 'x' );
311
-	$x_axis->setTickMarks( 5 );
312
-	$x_axis->setLabels( array(
313
-		__( 'Jan', 'give' ),
314
-		__( 'Feb', 'give' ),
315
-		__( 'Mar', 'give' ),
316
-		__( 'Apr', 'give' ),
317
-		__( 'May', 'give' ),
318
-		__( 'June', 'give' ),
319
-		__( 'July', 'give' ),
320
-		__( 'Aug', 'give' ),
321
-		__( 'Sept', 'give' ),
322
-		__( 'Oct', 'give' ),
323
-		__( 'Nov', 'give' ),
324
-		__( 'Dec', 'give' ),
325
-	) );
326
-	$chart->addAxis( $x_axis );
327
-
328
-	$shape_marker = new GoogleChartShapeMarker( GoogleChartShapeMarker::CIRCLE );
329
-	$shape_marker->setSize( 6 );
330
-	$shape_marker->setBorder( 2 );
331
-	$shape_marker->setData( $data );
332
-	$chart->addMarker( $shape_marker );
333
-
334
-	$value_marker = new GoogleChartTextMarker( GoogleChartTextMarker::VALUE );
335
-	$value_marker->setData( $data );
336
-	$chart->addMarker( $value_marker );
297
+	));
298
+	$data->setLegend(__('Donations', 'give'));
299
+	$data->setColor('ff6c1c');
300
+	$chart->addData($data);
301
+
302
+	$chart->setTitle(__('Donations by Month for all Give Forms', 'give'), '336699', 18);
303
+
304
+	$chart->setScale(0, $max_earnings);
305
+
306
+	$y_axis = new GoogleChartAxis('y');
307
+	$y_axis->setDrawTickMarks(true)->setLabels(array(0, $max_earnings));
308
+	$chart->addAxis($y_axis);
309
+
310
+	$x_axis = new GoogleChartAxis('x');
311
+	$x_axis->setTickMarks(5);
312
+	$x_axis->setLabels(array(
313
+		__('Jan', 'give'),
314
+		__('Feb', 'give'),
315
+		__('Mar', 'give'),
316
+		__('Apr', 'give'),
317
+		__('May', 'give'),
318
+		__('June', 'give'),
319
+		__('July', 'give'),
320
+		__('Aug', 'give'),
321
+		__('Sept', 'give'),
322
+		__('Oct', 'give'),
323
+		__('Nov', 'give'),
324
+		__('Dec', 'give'),
325
+	));
326
+	$chart->addAxis($x_axis);
327
+
328
+	$shape_marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE);
329
+	$shape_marker->setSize(6);
330
+	$shape_marker->setBorder(2);
331
+	$shape_marker->setData($data);
332
+	$chart->addMarker($shape_marker);
333
+
334
+	$value_marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE);
335
+	$value_marker->setData($data);
336
+	$chart->addMarker($value_marker);
337 337
 
338 338
 	return $chart->getUrl();
339 339
 }
Please login to merge, or discard this patch.