Test Failed
Push — master ( 2f4c9e...518013 )
by Devin
06:05
created
includes/admin/payments/actions.php 1 patch
Spacing   +145 added lines, -145 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,48 +25,48 @@  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( __( 'You do not have permission to edit payments.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
30
+	if ( ! current_user_can('edit_give_payments', $data['give_payment_id'])) {
31
+		wp_die(__('You do not have permission to edit payments.', 'give'), __('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
 	$status = $data['give-payment-status'];
43
-	$date   = sanitize_text_field( $data['give-payment-date'] );
44
-	$hour   = sanitize_text_field( $data['give-payment-time-hour'] );
43
+	$date   = sanitize_text_field($data['give-payment-date']);
44
+	$hour   = sanitize_text_field($data['give-payment-time-hour']);
45 45
 
46 46
 	// Restrict to our high and low.
47
-	if ( $hour > 23 ) {
47
+	if ($hour > 23) {
48 48
 		$hour = 23;
49
-	} elseif ( $hour < 0 ) {
49
+	} elseif ($hour < 0) {
50 50
 		$hour = 00;
51 51
 	}
52 52
 
53
-	$minute = sanitize_text_field( $data['give-payment-time-min'] );
53
+	$minute = sanitize_text_field($data['give-payment-time-min']);
54 54
 
55 55
 	// Restrict to our high and low.
56
-	if ( $minute > 59 ) {
56
+	if ($minute > 59) {
57 57
 		$minute = 59;
58
-	} elseif ( $minute < 0 ) {
58
+	} elseif ($minute < 0) {
59 59
 		$minute = 00;
60 60
 	}
61 61
 
62
-	$address = give_clean( $data['give-payment-address'][0] );
62
+	$address = give_clean($data['give-payment-address'][0]);
63 63
 
64 64
 	$curr_total = $payment->total;
65
-	$new_total  = give_maybe_sanitize_amount( ( ! empty( $data['give-payment-total'] ) ? $data['give-payment-total'] : 0 ) );
66
-	$date       = date( 'Y-m-d', strtotime( $date ) ) . ' ' . $hour . ':' . $minute . ':00';
65
+	$new_total  = give_maybe_sanitize_amount(( ! empty($data['give-payment-total']) ? $data['give-payment-total'] : 0));
66
+	$date       = date('Y-m-d', strtotime($date)).' '.$hour.':'.$minute.':00';
67 67
 
68
-	$curr_donor_id = sanitize_text_field( $data['give-current-donor'] );
69
-	$new_donor_id  = sanitize_text_field( $data['donor-id'] );
68
+	$curr_donor_id = sanitize_text_field($data['give-current-donor']);
69
+	$new_donor_id  = sanitize_text_field($data['donor-id']);
70 70
 
71 71
 	/**
72 72
 	 * Fires before updating edited donation.
@@ -76,74 +76,74 @@  discard block
 block discarded – undo
76 76
 	 *
77 77
 	 * @param int $payment_id The ID of the payment.
78 78
 	 */
79
-	do_action( 'give_update_edited_donation', $payment_id );
79
+	do_action('give_update_edited_donation', $payment_id);
80 80
 
81 81
 	$payment->date = $date;
82
-	$payment->anonymous = isset( $data['give_anonymous_donation'] ) ? absint( $data['give_anonymous_donation'] ) : 0;
82
+	$payment->anonymous = isset($data['give_anonymous_donation']) ? absint($data['give_anonymous_donation']) : 0;
83 83
 
84 84
 
85
-	$updated       = $payment->save();
85
+	$updated = $payment->save();
86 86
 
87
-	if ( 0 === $updated ) {
88
-		wp_die( __( 'Error Updating Donation.', 'give' ), __( 'Error', 'give' ), array( 'response' => 400 ) );
87
+	if (0 === $updated) {
88
+		wp_die(__('Error Updating Donation.', 'give'), __('Error', 'give'), array('response' => 400));
89 89
 	}
90 90
 
91 91
 	$donor_changed = false;
92 92
 
93
-	if ( isset( $data['give-new-donor'] ) && $data['give-new-donor'] == '1' ) {
93
+	if (isset($data['give-new-donor']) && $data['give-new-donor'] == '1') {
94 94
 
95
-		$email      = ! empty( $data['give-new-donor-email'] ) ? sanitize_text_field( $data['give-new-donor-email'] ) : '';
96
-		$first_name = ! empty( $data['give-new-donor-first-name'] ) ? sanitize_text_field( $data['give-new-donor-first-name'] ) : '';
97
-		$last_name  = ! empty( $data['give-new-donor-last-name'] ) ? sanitize_text_field( $data['give-new-donor-last-name'] ) : '';
98
-		$names      = strip_tags( wp_unslash( trim( "{$first_name} {$last_name}" ) ) );
95
+		$email      = ! empty($data['give-new-donor-email']) ? sanitize_text_field($data['give-new-donor-email']) : '';
96
+		$first_name = ! empty($data['give-new-donor-first-name']) ? sanitize_text_field($data['give-new-donor-first-name']) : '';
97
+		$last_name  = ! empty($data['give-new-donor-last-name']) ? sanitize_text_field($data['give-new-donor-last-name']) : '';
98
+		$names      = strip_tags(wp_unslash(trim("{$first_name} {$last_name}")));
99 99
 
100
-		if ( empty( $email ) || empty( $first_name ) ) {
101
-			wp_die( __( 'New Donor requires first name and email address.', 'give' ), __( 'Error', 'give' ), array( 'response' => 400 ) );
100
+		if (empty($email) || empty($first_name)) {
101
+			wp_die(__('New Donor requires first name and email address.', 'give'), __('Error', 'give'), array('response' => 400));
102 102
 		}
103 103
 
104
-		$donor = new Give_Donor( $email );
105
-		if ( empty( $donor->id ) ) {
106
-			$donor_data = array( 'name' => $names, 'email' => $email );
107
-			$user_id       = email_exists( $email );
108
-			if ( false !== $user_id ) {
104
+		$donor = new Give_Donor($email);
105
+		if (empty($donor->id)) {
106
+			$donor_data = array('name' => $names, 'email' => $email);
107
+			$user_id = email_exists($email);
108
+			if (false !== $user_id) {
109 109
 				$donor_data['user_id'] = $user_id;
110 110
 			}
111 111
 
112
-			if ( ! $donor->create( $donor_data ) ) {
112
+			if ( ! $donor->create($donor_data)) {
113 113
 				// Failed to create the new donor, assume the previous donor.
114 114
 				$donor_changed = false;
115
-				$donor         = new Give_Donor( $curr_donor_id );
116
-				give_set_error( 'give-payment-new-donor-fail', __( 'Error creating new donor.', 'give' ) );
115
+				$donor         = new Give_Donor($curr_donor_id);
116
+				give_set_error('give-payment-new-donor-fail', __('Error creating new donor.', 'give'));
117 117
 			}
118 118
 		}
119 119
 
120 120
 		// Create and Update Donor First Name and Last Name in Meta Fields.
121
-		$donor->update_meta( '_give_donor_first_name', $first_name );
122
-		$donor->update_meta( '_give_donor_last_name', $last_name );
121
+		$donor->update_meta('_give_donor_first_name', $first_name);
122
+		$donor->update_meta('_give_donor_last_name', $last_name);
123 123
 
124 124
 		$new_donor_id = $donor->id;
125 125
 
126
-		$previous_donor = new Give_Donor( $curr_donor_id );
126
+		$previous_donor = new Give_Donor($curr_donor_id);
127 127
 
128 128
 		$donor_changed = true;
129 129
 
130
-	} elseif ( $curr_donor_id !== $new_donor_id ) {
130
+	} elseif ($curr_donor_id !== $new_donor_id) {
131 131
 
132
-		$donor = new Give_Donor( $new_donor_id );
132
+		$donor = new Give_Donor($new_donor_id);
133 133
 		$email    = $donor->email;
134 134
 		$names    = $donor->name;
135 135
 
136
-		$previous_donor = new Give_Donor( $curr_donor_id );
136
+		$previous_donor = new Give_Donor($curr_donor_id);
137 137
 
138 138
 		$donor_changed = true;
139 139
 
140 140
 	} else {
141
-		$donor = new Give_Donor( $curr_donor_id );
141
+		$donor = new Give_Donor($curr_donor_id);
142 142
 		$email    = $donor->email;
143 143
 		$names    = $donor->name;
144 144
 	}
145 145
 
146
-	if ( $donor_changed ) {
146
+	if ($donor_changed) {
147 147
 
148 148
 		// Setup first and last name from input values.
149 149
 		$first_name = $donor->get_first_name();
@@ -153,26 +153,26 @@  discard block
 block discarded – undo
153 153
 		$payment->last_name  = $last_name;
154 154
 
155 155
 		// Remove the stats and payment from the previous donor and attach it to the new donor.
156
-		$previous_donor->remove_payment( $payment_id, false );
157
-		$donor->attach_payment( $payment_id, false );
156
+		$previous_donor->remove_payment($payment_id, false);
157
+		$donor->attach_payment($payment_id, false);
158 158
 
159
-		if ( 'publish' == $status ) {
159
+		if ('publish' == $status) {
160 160
 
161 161
 			// Reduce previous user donation count and amount.
162 162
 			$previous_donor->decrease_donation_count();
163
-			$previous_donor->decrease_value( $curr_total );
163
+			$previous_donor->decrease_value($curr_total);
164 164
 
165 165
 			// If donation was completed adjust stats of new donors.
166 166
 			$donor->increase_purchase_count();
167
-			$donor->increase_value( $new_total );
167
+			$donor->increase_value($new_total);
168 168
 		}
169 169
 
170 170
 		$payment->customer_id = $donor->id;
171 171
 	} else {
172 172
 
173
-		if ( 'publish' === $status ) {
173
+		if ('publish' === $status) {
174 174
 			// Update user donation stat.
175
-			$donor->update_donation_value( $curr_total, $new_total );
175
+			$donor->update_donation_value($curr_total, $new_total);
176 176
 		}
177 177
 	}
178 178
 
@@ -183,10 +183,10 @@  discard block
 block discarded – undo
183 183
 	$payment->total      = $new_total;
184 184
 
185 185
 	// Check for payment notes.
186
-	if ( ! empty( $data['give-payment-note'] ) ) {
186
+	if ( ! empty($data['give-payment-note'])) {
187 187
 
188
-		$note = wp_kses( $data['give-payment-note'], array() );
189
-		give_insert_payment_note( $payment_id, $note );
188
+		$note = wp_kses($data['give-payment-note'], array());
189
+		give_insert_payment_note($payment_id, $note);
190 190
 
191 191
 	}
192 192
 
@@ -194,77 +194,77 @@  discard block
 block discarded – undo
194 194
 	$payment->status = $status;
195 195
 
196 196
 	// Adjust total store earnings if the payment total has been changed.
197
-	if ( $new_total !== $curr_total && 'publish' == $status ) {
197
+	if ($new_total !== $curr_total && 'publish' == $status) {
198 198
 
199
-		if ( $new_total > $curr_total ) {
199
+		if ($new_total > $curr_total) {
200 200
 			// Increase if our new total is higher.
201 201
 			$difference = $new_total - $curr_total;
202
-			give_increase_total_earnings( $difference );
202
+			give_increase_total_earnings($difference);
203 203
 
204 204
 			// Increase form earnings.
205
-			give_increase_earnings( $payment->form_id, $difference, $payment->ID );
206
-		} elseif ( $curr_total > $new_total ) {
205
+			give_increase_earnings($payment->form_id, $difference, $payment->ID);
206
+		} elseif ($curr_total > $new_total) {
207 207
 			// Decrease if our new total is lower.
208 208
 			$difference = $curr_total - $new_total;
209
-			give_decrease_total_earnings( $difference );
209
+			give_decrease_total_earnings($difference);
210 210
 
211 211
 			// Decrease form earnings.
212
-			give_decrease_form_earnings( $payment->form_id, $difference, $payment->ID );
212
+			give_decrease_form_earnings($payment->form_id, $difference, $payment->ID);
213 213
 		}
214 214
 	}
215 215
 
216 216
 	$payment->save();
217 217
 
218 218
 	// Get new give form ID.
219
-	$new_form_id     = absint( $data['give-payment-form-select'] );
220
-	$current_form_id = absint( $payment->get_meta( '_give_payment_form_id' ) );
219
+	$new_form_id     = absint($data['give-payment-form-select']);
220
+	$current_form_id = absint($payment->get_meta('_give_payment_form_id'));
221 221
 
222 222
 	// We are adding payment transfer code in last to remove any conflict with above functionality.
223 223
 	// For example: above code will automatically handle form stat (increase/decrease) when payment status changes.
224 224
 	// Check if user want to transfer current payment to new give form id.
225
-	if ( $new_form_id && $new_form_id != $current_form_id ) {
225
+	if ($new_form_id && $new_form_id != $current_form_id) {
226 226
 
227 227
 		// Get new give form title.
228
-		$new_form_title = get_the_title( $new_form_id );
228
+		$new_form_title = get_the_title($new_form_id);
229 229
 
230 230
 		// Update payment give form meta data.
231
-		$payment->update_meta( '_give_payment_form_id', $new_form_id );
232
-		$payment->update_meta( '_give_payment_form_title', $new_form_title );
231
+		$payment->update_meta('_give_payment_form_id', $new_form_id);
232
+		$payment->update_meta('_give_payment_form_title', $new_form_title);
233 233
 
234 234
 		// Update price id payment metadata.
235
-		if ( ! give_has_variable_prices( $new_form_id ) ) {
236
-			$payment->update_meta( '_give_payment_price_id', '' );
235
+		if ( ! give_has_variable_prices($new_form_id)) {
236
+			$payment->update_meta('_give_payment_price_id', '');
237 237
 		}
238 238
 
239 239
 		// If donation was completed, adjust stats of forms.
240
-		if ( 'publish' == $status ) {
240
+		if ('publish' == $status) {
241 241
 
242 242
 			// Decrease sale of old give form. For other payment status.
243
-			$current_form = new Give_Donate_Form( $current_form_id );
243
+			$current_form = new Give_Donate_Form($current_form_id);
244 244
 			$current_form->decrease_sales();
245
-			$current_form->decrease_earnings( $curr_total, $payment->ID );
245
+			$current_form->decrease_earnings($curr_total, $payment->ID);
246 246
 
247 247
 			// Increase sale of new give form.
248
-			$new_form = new Give_Donate_Form( $new_form_id );
248
+			$new_form = new Give_Donate_Form($new_form_id);
249 249
 			$new_form->increase_sales();
250
-			$new_form->increase_earnings( $new_total, $payment->ID );
250
+			$new_form->increase_earnings($new_total, $payment->ID);
251 251
 		}
252 252
 
253 253
 		// Re setup payment to update new meta value in object.
254
-		$payment->update_payment_setup( $payment->ID );
254
+		$payment->update_payment_setup($payment->ID);
255 255
 
256 256
 		// Update form id in payment logs.
257
-		Give()->async_process->data( array(
258
-			'data' => array( $new_form_id, $payment_id ),
257
+		Give()->async_process->data(array(
258
+			'data' => array($new_form_id, $payment_id),
259 259
 			'hook' => 'give_update_log_form_id',
260
-		) )->dispatch();
260
+		))->dispatch();
261 261
 	}
262 262
 
263 263
 	// Update price id if current form is variable form.
264 264
 	/* @var Give_Donate_Form $form */
265
-	$form = new Give_Donate_Form( $payment->form_id );
265
+	$form = new Give_Donate_Form($payment->form_id);
266 266
 
267
-	if ( isset( $data['give-variable-price'] ) && $form->has_variable_prices() ) {
267
+	if (isset($data['give-variable-price']) && $form->has_variable_prices()) {
268 268
 
269 269
 		// Get payment meta data.
270 270
 		$payment_meta = $payment->get_meta();
@@ -273,9 +273,9 @@  discard block
 block discarded – undo
273 273
 		$price_id = '';
274 274
 
275 275
 		// Get price info
276
-		if( 0 <= $data['give-variable-price'] ) {
277
-			foreach ( $form->prices as $variable_price ) {
278
-				if( $new_total === give_maybe_sanitize_amount( $variable_price['_give_amount'] ) ) {
276
+		if (0 <= $data['give-variable-price']) {
277
+			foreach ($form->prices as $variable_price) {
278
+				if ($new_total === give_maybe_sanitize_amount($variable_price['_give_amount'])) {
279 279
 					$price_info = $variable_price;
280 280
 					break;
281 281
 				}
@@ -283,15 +283,15 @@  discard block
 block discarded – undo
283 283
 		}
284 284
 
285 285
 		// Set price id.
286
-		if( ! empty( $price_info ) ) {
286
+		if ( ! empty($price_info)) {
287 287
 			$price_id = $data['give-variable-price'];
288 288
 
289
-			if( $data['give-variable-price'] !== $price_info['_give_id']['level_id'] ) {
289
+			if ($data['give-variable-price'] !== $price_info['_give_id']['level_id']) {
290 290
 				// Set price id to amount match.
291 291
 				$price_id = $price_info['_give_id']['level_id'];
292 292
 			}
293 293
 
294
-		} elseif( $form->is_custom_price_mode() ){
294
+		} elseif ($form->is_custom_price_mode()) {
295 295
 			$price_id = 'custom';
296 296
 		}
297 297
 
@@ -299,34 +299,34 @@  discard block
 block discarded – undo
299 299
 		$payment_meta['price_id'] = $price_id;
300 300
 
301 301
 		// Update payment give form meta data.
302
-		$payment->update_meta( '_give_payment_price_id', $price_id );
303
-		$payment->update_meta( '_give_payment_meta', $payment_meta );
302
+		$payment->update_meta('_give_payment_price_id', $price_id);
303
+		$payment->update_meta('_give_payment_meta', $payment_meta);
304 304
 
305 305
 		// Re setup payment to update new meta value in object.
306
-		$payment->update_payment_setup( $payment->ID );
306
+		$payment->update_payment_setup($payment->ID);
307 307
 	}
308 308
 
309
-	$comment_id            = isset( $data['give_comment_id'] ) ? absint( $data['give_comment_id'] ) : 0;
310
-	$is_anonymous_donation = give_is_anonymous_donation_field_enabled( $payment->form_id );
309
+	$comment_id            = isset($data['give_comment_id']) ? absint($data['give_comment_id']) : 0;
310
+	$is_anonymous_donation = give_is_anonymous_donation_field_enabled($payment->form_id);
311 311
 
312
-	if ( $is_anonymous_donation ) {
313
-		give_update_meta( $payment->ID, '_give_anonymous_donation', $payment->anonymous );
314
-		Give()->donor_meta->update_meta( $payment->donor_id, '_give_anonymous_donor', $payment->anonymous );
312
+	if ($is_anonymous_donation) {
313
+		give_update_meta($payment->ID, '_give_anonymous_donation', $payment->anonymous);
314
+		Give()->donor_meta->update_meta($payment->donor_id, '_give_anonymous_donor', $payment->anonymous);
315 315
 
316 316
 		// Update comment meta if admin is not updating comment.
317
-		if( $comment_id ) {
318
-			update_comment_meta( $comment_id, '_give_anonymous_donation', $payment->anonymous );
317
+		if ($comment_id) {
318
+			update_comment_meta($comment_id, '_give_anonymous_donation', $payment->anonymous);
319 319
 		}
320 320
 	}
321 321
 
322 322
 	// Update comment.
323
-	if ( give_is_donor_comment_field_enabled( $payment->form_id ) ) {
323
+	if (give_is_donor_comment_field_enabled($payment->form_id)) {
324 324
 		// We are access comment directly from $_POST because comment formatting remove because of give_clean in give_post_actions.
325
-		$data['give_comment'] = trim( $_POST['give_comment'] );
325
+		$data['give_comment'] = trim($_POST['give_comment']);
326 326
 
327
-		if ( empty( $data['give_comment'] ) ) {
327
+		if (empty($data['give_comment'])) {
328 328
 			// Delete comment if empty
329
-			Give_Comment::delete( $comment_id, $payment_id, 'payment' );
329
+			Give_Comment::delete($comment_id, $payment_id, 'payment');
330 330
 
331 331
 		} else {
332 332
 
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 				'comment_author_email' => $payment->email
338 338
 			);
339 339
 
340
-			if ( $comment_id ) {
340
+			if ($comment_id) {
341 341
 				$comment_args['comment_ID'] = $comment_id;
342 342
 			}
343 343
 
@@ -348,16 +348,16 @@  discard block
 block discarded – undo
348 348
 				$comment_args
349 349
 			);
350 350
 
351
-			if ( $is_update_comment_meta ) {
352
-				update_comment_meta( $comment_id, '_give_anonymous_donation', $is_anonymous_donation );
351
+			if ($is_update_comment_meta) {
352
+				update_comment_meta($comment_id, '_give_anonymous_donation', $is_anonymous_donation);
353 353
 			}
354 354
 		}
355 355
 
356
-		$donor_has_comment = empty( $data['give_comment'] )
357
-			? ( $latest_comment = give_get_donor_latest_comment( $payment->donor_id ) && empty( $latest_comment ) ? '0' : '1' )
356
+		$donor_has_comment = empty($data['give_comment'])
357
+			? ($latest_comment = give_get_donor_latest_comment($payment->donor_id) && empty($latest_comment) ? '0' : '1')
358 358
 			: '1';
359 359
 
360
-		Give()->donor_meta->update_meta( $payment->donor_id, '_give_has_comment', $donor_has_comment );
360
+		Give()->donor_meta->update_meta($payment->donor_id, '_give_has_comment', $donor_has_comment);
361 361
 	}
362 362
 
363 363
 	/**
@@ -368,13 +368,13 @@  discard block
 block discarded – undo
368 368
 	 *
369 369
 	 * @param int $payment_id The ID of the payment.
370 370
 	 */
371
-	do_action( 'give_updated_edited_donation', $payment_id );
371
+	do_action('give_updated_edited_donation', $payment_id);
372 372
 
373
-	wp_safe_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&give-messages[]=payment-updated&id=' . $payment_id ) );
373
+	wp_safe_redirect(admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&give-messages[]=payment-updated&id='.$payment_id));
374 374
 	exit;
375 375
 }
376 376
 
377
-add_action( 'give_update_payment_details', 'give_update_payment_details' );
377
+add_action('give_update_payment_details', 'give_update_payment_details');
378 378
 
379 379
 /**
380 380
  * Trigger a Donation Deletion.
@@ -385,48 +385,48 @@  discard block
 block discarded – undo
385 385
  *
386 386
  * @return void
387 387
  */
388
-function give_trigger_donation_delete( $data ) {
389
-	if ( wp_verify_nonce( $data['_wpnonce'], 'give_donation_nonce' ) ) {
388
+function give_trigger_donation_delete($data) {
389
+	if (wp_verify_nonce($data['_wpnonce'], 'give_donation_nonce')) {
390 390
 
391
-		$payment_id = absint( $data['purchase_id'] );
391
+		$payment_id = absint($data['purchase_id']);
392 392
 
393
-		if ( ! current_user_can( 'edit_give_payments', $payment_id ) ) {
394
-			wp_die( __( 'You do not have permission to edit payments.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
393
+		if ( ! current_user_can('edit_give_payments', $payment_id)) {
394
+			wp_die(__('You do not have permission to edit payments.', 'give'), __('Error', 'give'), array('response' => 403));
395 395
 		}
396 396
 
397
-		give_delete_donation( $payment_id );
398
-		wp_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&give-messages[]=donation-deleted' ) );
397
+		give_delete_donation($payment_id);
398
+		wp_redirect(admin_url('edit.php?post_type=give_forms&page=give-payment-history&give-messages[]=donation-deleted'));
399 399
 		give_die();
400 400
 	}
401 401
 }
402 402
 
403
-add_action( 'give_delete_payment', 'give_trigger_donation_delete' );
403
+add_action('give_delete_payment', 'give_trigger_donation_delete');
404 404
 
405 405
 /**
406 406
  * AJAX Store Donation Note
407 407
  */
408 408
 function give_ajax_store_payment_note() {
409 409
 
410
-	$payment_id = absint( $_POST['payment_id'] );
411
-	$note       = wp_kses( $_POST['note'], array() );
410
+	$payment_id = absint($_POST['payment_id']);
411
+	$note       = wp_kses($_POST['note'], array());
412 412
 
413
-	if ( ! current_user_can( 'edit_give_payments', $payment_id ) ) {
414
-		wp_die( __( 'You do not have permission to edit payments.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
413
+	if ( ! current_user_can('edit_give_payments', $payment_id)) {
414
+		wp_die(__('You do not have permission to edit payments.', 'give'), __('Error', 'give'), array('response' => 403));
415 415
 	}
416 416
 
417
-	if ( empty( $payment_id ) ) {
418
-		die( '-1' );
417
+	if (empty($payment_id)) {
418
+		die('-1');
419 419
 	}
420 420
 
421
-	if ( empty( $note ) ) {
422
-		die( '-1' );
421
+	if (empty($note)) {
422
+		die('-1');
423 423
 	}
424 424
 
425
-	$note_id = give_insert_payment_note( $payment_id, $note );
426
-	die( give_get_payment_note_html( $note_id ) );
425
+	$note_id = give_insert_payment_note($payment_id, $note);
426
+	die(give_get_payment_note_html($note_id));
427 427
 }
428 428
 
429
-add_action( 'wp_ajax_give_insert_payment_note', 'give_ajax_store_payment_note' );
429
+add_action('wp_ajax_give_insert_payment_note', 'give_ajax_store_payment_note');
430 430
 
431 431
 /**
432 432
  * Triggers a donation note deletion without ajax
@@ -437,24 +437,24 @@  discard block
 block discarded – undo
437 437
  *
438 438
  * @return void
439 439
  */
440
-function give_trigger_payment_note_deletion( $data ) {
440
+function give_trigger_payment_note_deletion($data) {
441 441
 
442
-	if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_delete_payment_note_' . $data['note_id'] ) ) {
442
+	if ( ! wp_verify_nonce($data['_wpnonce'], 'give_delete_payment_note_'.$data['note_id'])) {
443 443
 		return;
444 444
 	}
445 445
 
446
-	if ( ! current_user_can( 'edit_give_payments', $data['payment_id'] ) ) {
447
-		wp_die( __( 'You do not have permission to edit payments.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
446
+	if ( ! current_user_can('edit_give_payments', $data['payment_id'])) {
447
+		wp_die(__('You do not have permission to edit payments.', 'give'), __('Error', 'give'), array('response' => 403));
448 448
 	}
449 449
 
450
-	$edit_order_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&give-messages[]=donation-note-deleted&id=' . absint( $data['payment_id'] ) );
450
+	$edit_order_url = admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&give-messages[]=donation-note-deleted&id='.absint($data['payment_id']));
451 451
 
452
-	give_delete_payment_note( $data['note_id'], $data['payment_id'] );
452
+	give_delete_payment_note($data['note_id'], $data['payment_id']);
453 453
 
454
-	wp_redirect( $edit_order_url );
454
+	wp_redirect($edit_order_url);
455 455
 }
456 456
 
457
-add_action( 'give_delete_payment_note', 'give_trigger_payment_note_deletion' );
457
+add_action('give_delete_payment_note', 'give_trigger_payment_note_deletion');
458 458
 
459 459
 /**
460 460
  * Delete a payment note deletion with ajax
@@ -465,16 +465,16 @@  discard block
 block discarded – undo
465 465
  */
466 466
 function give_ajax_delete_payment_note() {
467 467
 
468
-	if ( ! current_user_can( 'edit_give_payments', $_POST['payment_id'] ) ) {
469
-		wp_die( __( 'You do not have permission to edit payments.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
468
+	if ( ! current_user_can('edit_give_payments', $_POST['payment_id'])) {
469
+		wp_die(__('You do not have permission to edit payments.', 'give'), __('Error', 'give'), array('response' => 403));
470 470
 	}
471 471
 
472
-	if ( give_delete_payment_note( $_POST['note_id'], $_POST['payment_id'] ) ) {
473
-		die( '1' );
472
+	if (give_delete_payment_note($_POST['note_id'], $_POST['payment_id'])) {
473
+		die('1');
474 474
 	} else {
475
-		die( '-1' );
475
+		die('-1');
476 476
 	}
477 477
 
478 478
 }
479 479
 
480
-add_action( 'wp_ajax_give_delete_payment_note', 'give_ajax_delete_payment_note' );
480
+add_action('wp_ajax_give_delete_payment_note', 'give_ajax_delete_payment_note');
Please login to merge, or discard this patch.
includes/admin/plugins.php 1 patch
Spacing   +116 added lines, -117 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -23,19 +23,19 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * @return array An array of updated action links.
25 25
  */
26
-function give_plugin_action_links( $actions ) {
26
+function give_plugin_action_links($actions) {
27 27
 	$new_actions = array(
28 28
 		'settings' => sprintf(
29 29
 			'<a href="%1$s">%2$s</a>',
30
-			admin_url( 'edit.php?post_type=give_forms&page=give-settings' ),
31
-			__( 'Settings', 'give' )
30
+			admin_url('edit.php?post_type=give_forms&page=give-settings'),
31
+			__('Settings', 'give')
32 32
 		),
33 33
 	);
34 34
 
35
-	return array_merge( $new_actions, $actions );
35
+	return array_merge($new_actions, $actions);
36 36
 }
37 37
 
38
-add_filter( 'plugin_action_links_' . GIVE_PLUGIN_BASENAME, 'give_plugin_action_links' );
38
+add_filter('plugin_action_links_'.GIVE_PLUGIN_BASENAME, 'give_plugin_action_links');
39 39
 
40 40
 
41 41
 /**
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
  *
49 49
  * @return array
50 50
  */
51
-function give_plugin_row_meta( $plugin_meta, $plugin_file ) {
52
-	if ( GIVE_PLUGIN_BASENAME !== $plugin_file ) {
51
+function give_plugin_row_meta($plugin_meta, $plugin_file) {
52
+	if (GIVE_PLUGIN_BASENAME !== $plugin_file) {
53 53
 		return $plugin_meta;
54 54
 	}
55 55
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 					), 'https://givewp.com/documentation/'
66 66
 				)
67 67
 			),
68
-			__( 'Documentation', 'give' )
68
+			__('Documentation', 'give')
69 69
 		),
70 70
 		sprintf(
71 71
 			'<a href="%1$s" target="_blank">%2$s</a>',
@@ -78,14 +78,14 @@  discard block
 block discarded – undo
78 78
 					), 'https://givewp.com/addons/'
79 79
 				)
80 80
 			),
81
-			__( 'Add-ons', 'give' )
81
+			__('Add-ons', 'give')
82 82
 		),
83 83
 	);
84 84
 
85
-	return array_merge( $plugin_meta, $new_meta_links );
85
+	return array_merge($plugin_meta, $new_meta_links);
86 86
 }
87 87
 
88
-add_filter( 'plugin_row_meta', 'give_plugin_row_meta', 10, 2 );
88
+add_filter('plugin_row_meta', 'give_plugin_row_meta', 10, 2);
89 89
 
90 90
 
91 91
 /**
@@ -103,19 +103,18 @@  discard block
 block discarded – undo
103 103
 	$title = '';
104 104
 	global $submenu, $plugin_page;
105 105
 
106
-	foreach ( array_keys( $submenu ) as $parent ) {
107
-		if ( 'edit.php?post_type=give_forms' !== $parent ) {
106
+	foreach (array_keys($submenu) as $parent) {
107
+		if ('edit.php?post_type=give_forms' !== $parent) {
108 108
 			continue;
109 109
 		}
110 110
 
111
-		foreach ( $submenu[ $parent ] as $submenu_array ) {
112
-			if ( $plugin_page !== $submenu_array[2] ) {
111
+		foreach ($submenu[$parent] as $submenu_array) {
112
+			if ($plugin_page !== $submenu_array[2]) {
113 113
 				continue;
114 114
 			}
115 115
 
116
-			$title = isset( $submenu_array[0] ) ?
117
-				$submenu_array[0] :
118
-				$submenu_array[3];
116
+			$title = isset($submenu_array[0]) ?
117
+				$submenu_array[0] : $submenu_array[3];
119 118
 		}
120 119
 	}
121 120
 
@@ -129,11 +128,11 @@  discard block
 block discarded – undo
129 128
  */
130 129
 function give_recently_activated_addons() {
131 130
 	// Check if action is set.
132
-	if ( isset( $_REQUEST['action'] ) ) {
133
-		$plugin_action = ( '-1' !== $_REQUEST['action'] ) ? $_REQUEST['action'] : ( isset( $_REQUEST['action2'] ) ? $_REQUEST['action2'] : '' );
131
+	if (isset($_REQUEST['action'])) {
132
+		$plugin_action = ('-1' !== $_REQUEST['action']) ? $_REQUEST['action'] : (isset($_REQUEST['action2']) ? $_REQUEST['action2'] : '');
134 133
 		$plugins       = array();
135 134
 
136
-		switch ( $plugin_action ) {
135
+		switch ($plugin_action) {
137 136
 			case 'activate': // Single add-on activation.
138 137
 				$plugins[] = $_REQUEST['plugin'];
139 138
 				break;
@@ -143,27 +142,27 @@  discard block
 block discarded – undo
143 142
 		}
144 143
 
145 144
 
146
-		if ( ! empty( $plugins ) ) {
145
+		if ( ! empty($plugins)) {
147 146
 
148 147
 			$give_addons = give_get_recently_activated_addons();
149 148
 
150
-			foreach ( $plugins as $plugin ) {
149
+			foreach ($plugins as $plugin) {
151 150
 				// Get plugins which has 'Give-' as prefix.
152
-				if ( stripos( $plugin, 'Give-' ) !== false ) {
151
+				if (stripos($plugin, 'Give-') !== false) {
153 152
 					$give_addons[] = $plugin;
154 153
 				}
155 154
 			}
156 155
 
157
-			if ( ! empty( $give_addons ) ) {
156
+			if ( ! empty($give_addons)) {
158 157
 				// Update the Give's activated add-ons.
159
-				update_option( 'give_recently_activated_addons', $give_addons, false );
158
+				update_option('give_recently_activated_addons', $give_addons, false);
160 159
 			}
161 160
 		}
162 161
 	}
163 162
 }
164 163
 
165 164
 // Add add-on plugins to wp option table.
166
-add_action( 'activated_plugin', 'give_recently_activated_addons', 10 );
165
+add_action('activated_plugin', 'give_recently_activated_addons', 10);
167 166
 
168 167
 /**
169 168
  * Create new menu in plugin section that include all the add-on
@@ -174,19 +173,19 @@  discard block
 block discarded – undo
174 173
  *
175 174
  * @return mixed
176 175
  */
177
-function give_filter_addons_do_filter_addons( $plugin_menu ) {
176
+function give_filter_addons_do_filter_addons($plugin_menu) {
178 177
 	global $plugins;
179 178
 
180
-	foreach ( $plugins['all'] as $plugin_slug => $plugin_data ) {
179
+	foreach ($plugins['all'] as $plugin_slug => $plugin_data) {
181 180
 
182
-		if ( false !== strpos( $plugin_data['Name'], 'Give' ) && false !== strpos( $plugin_data['AuthorName'], 'WordImpress' ) ) {
183
-			$plugins['give'][ $plugin_slug ]           = $plugins['all'][ $plugin_slug ];
184
-			$plugins['give'][ $plugin_slug ]['plugin'] = $plugin_slug;
181
+		if (false !== strpos($plugin_data['Name'], 'Give') && false !== strpos($plugin_data['AuthorName'], 'WordImpress')) {
182
+			$plugins['give'][$plugin_slug]           = $plugins['all'][$plugin_slug];
183
+			$plugins['give'][$plugin_slug]['plugin'] = $plugin_slug;
185 184
 			// replicate the next step.
186
-			if ( current_user_can( 'update_plugins' ) ) {
187
-				$current = get_site_transient( 'update_plugins' );
188
-				if ( isset( $current->response[ $plugin_slug ] ) ) {
189
-					$plugins['give'][ $plugin_slug ]['update'] = true;
185
+			if (current_user_can('update_plugins')) {
186
+				$current = get_site_transient('update_plugins');
187
+				if (isset($current->response[$plugin_slug])) {
188
+					$plugins['give'][$plugin_slug]['update'] = true;
190 189
 				}
191 190
 			}
192 191
 		}
@@ -196,8 +195,8 @@  discard block
 block discarded – undo
196 195
 
197 196
 }
198 197
 
199
-add_filter( 'show_advanced_plugins', 'give_filter_addons_do_filter_addons' );
200
-add_filter( 'show_network_active_plugins', 'give_filter_addons_do_filter_addons' );
198
+add_filter('show_advanced_plugins', 'give_filter_addons_do_filter_addons');
199
+add_filter('show_network_active_plugins', 'give_filter_addons_do_filter_addons');
201 200
 
202 201
 /**
203 202
  * Keep activating the same add-on when admin activate or deactivate from Give Menu
@@ -207,18 +206,18 @@  discard block
 block discarded – undo
207 206
  * @param $action
208 207
  * @param $result
209 208
  */
210
-function give_prepare_filter_addons_referer( $action, $result ) {
211
-	if ( ! function_exists( 'get_current_screen' ) ) {
209
+function give_prepare_filter_addons_referer($action, $result) {
210
+	if ( ! function_exists('get_current_screen')) {
212 211
 		return;
213 212
 	}
214 213
 	$screen = get_current_screen();
215
-	if ( is_object( $screen ) && $screen->base === 'plugins' && ! empty( $_REQUEST['plugin_status'] ) && $_REQUEST['plugin_status'] === 'give' ) {
214
+	if (is_object($screen) && $screen->base === 'plugins' && ! empty($_REQUEST['plugin_status']) && $_REQUEST['plugin_status'] === 'give') {
216 215
 		global $status;
217 216
 		$status = 'give';
218 217
 	}
219 218
 }
220 219
 
221
-add_action( 'check_admin_referer', 'give_prepare_filter_addons_referer', 10, 2 );
220
+add_action('check_admin_referer', 'give_prepare_filter_addons_referer', 10, 2);
222 221
 
223 222
 /**
224 223
  * Make the Give Menu as an default menu and update the Menu Name
@@ -229,30 +228,30 @@  discard block
 block discarded – undo
229 228
  *
230 229
  * @return mixed
231 230
  */
232
-function give_filter_addons_filter_addons( $views ) {
231
+function give_filter_addons_filter_addons($views) {
233 232
 
234 233
 	global $status, $plugins;
235 234
 
236
-	if ( ! empty( $plugins['give'] ) ) {
235
+	if ( ! empty($plugins['give'])) {
237 236
 		$class = '';
238 237
 
239
-		if ( 'give' === $status ) {
238
+		if ('give' === $status) {
240 239
 			$class = 'current';
241 240
 		}
242 241
 
243 242
 		$views['give'] = sprintf(
244 243
 			'<a class="%s" href="plugins.php?plugin_status=give"> %s <span class="count">(%s) </span></a>',
245 244
 			$class,
246
-			__( 'Give', 'give' ),
247
-			count( $plugins['give'] )
245
+			__('Give', 'give'),
246
+			count($plugins['give'])
248 247
 		);
249 248
 	}
250 249
 
251 250
 	return $views;
252 251
 }
253 252
 
254
-add_filter( 'views_plugins', 'give_filter_addons_filter_addons' );
255
-add_filter( 'views_plugins-network', 'give_filter_addons_filter_addons' );
253
+add_filter('views_plugins', 'give_filter_addons_filter_addons');
254
+add_filter('views_plugins-network', 'give_filter_addons_filter_addons');
256 255
 
257 256
 /**
258 257
  * Set the Give as the Main menu when admin click on the Give Menu in Plugin section.
@@ -263,17 +262,17 @@  discard block
 block discarded – undo
263 262
  *
264 263
  * @return mixed
265 264
  */
266
-function give_prepare_filter_addons( $plugins ) {
265
+function give_prepare_filter_addons($plugins) {
267 266
 	global $status;
268 267
 
269
-	if ( isset( $_REQUEST['plugin_status'] ) && 'give' === $_REQUEST['plugin_status'] ) {
268
+	if (isset($_REQUEST['plugin_status']) && 'give' === $_REQUEST['plugin_status']) {
270 269
 		$status = 'give';
271 270
 	}
272 271
 
273 272
 	return $plugins;
274 273
 }
275 274
 
276
-add_filter( 'all_plugins', 'give_prepare_filter_addons' );
275
+add_filter('all_plugins', 'give_prepare_filter_addons');
277 276
 
278 277
 
279 278
 /**
@@ -284,26 +283,26 @@  discard block
 block discarded – undo
284 283
  *
285 284
  * @since 2.1
286 285
  */
287
-function give_in_plugin_update_message( $data, $response ) {
286
+function give_in_plugin_update_message($data, $response) {
288 287
 	$new_version           = $data['new_version'];
289
-	$current_version_parts = explode( '.', GIVE_VERSION );
290
-	$new_version_parts     = explode( '.', $new_version );
288
+	$current_version_parts = explode('.', GIVE_VERSION);
289
+	$new_version_parts     = explode('.', $new_version);
291 290
 
292 291
 	// If it is a minor upgrade then return.
293
-	if ( version_compare( $current_version_parts[0] . '.' . $current_version_parts[1], $new_version_parts[0] . '.' . $new_version_parts[1], '=' ) ) {
292
+	if (version_compare($current_version_parts[0].'.'.$current_version_parts[1], $new_version_parts[0].'.'.$new_version_parts[1], '=')) {
294 293
 
295 294
 		return;
296 295
 	}
297 296
 
298 297
 	// Get the upgrade notice from the trunk.
299
-	$upgrade_notice = give_get_plugin_upgrade_notice( $new_version );
298
+	$upgrade_notice = give_get_plugin_upgrade_notice($new_version);
300 299
 
301 300
 	// Display upgrade notice.
302
-	echo apply_filters( 'give_in_plugin_update_message', $upgrade_notice ? '</p>' . wp_kses_post( $upgrade_notice ) . '<p class="dummy">' : '' );
301
+	echo apply_filters('give_in_plugin_update_message', $upgrade_notice ? '</p>'.wp_kses_post($upgrade_notice).'<p class="dummy">' : '');
303 302
 }
304 303
 
305 304
 // Display upgrade notice.
306
-add_action( 'in_plugin_update_message-' . GIVE_PLUGIN_BASENAME, 'give_in_plugin_update_message', 10, 2 );
305
+add_action('in_plugin_update_message-'.GIVE_PLUGIN_BASENAME, 'give_in_plugin_update_message', 10, 2);
307 306
 
308 307
 
309 308
 /**
@@ -317,18 +316,18 @@  discard block
 block discarded – undo
317 316
  *
318 317
  * @return string
319 318
  */
320
-function give_get_plugin_upgrade_notice( $new_version ) {
319
+function give_get_plugin_upgrade_notice($new_version) {
321 320
 
322 321
 	// Cache the upgrade notice.
323 322
 	$transient_name = "give_upgrade_notice_{$new_version}";
324
-	$upgrade_notice = get_transient( $transient_name );
323
+	$upgrade_notice = get_transient($transient_name);
325 324
 
326
-	if ( false === $upgrade_notice ) {
327
-		$response = wp_safe_remote_get( 'https://plugins.svn.wordpress.org/give/trunk/readme.txt' );
325
+	if (false === $upgrade_notice) {
326
+		$response = wp_safe_remote_get('https://plugins.svn.wordpress.org/give/trunk/readme.txt');
328 327
 
329
-		if ( ! is_wp_error( $response ) && ! empty( $response['body'] ) ) {
330
-			$upgrade_notice = give_parse_plugin_update_notice( $response['body'], $new_version );
331
-			set_transient( $transient_name, $upgrade_notice, DAY_IN_SECONDS );
328
+		if ( ! is_wp_error($response) && ! empty($response['body'])) {
329
+			$upgrade_notice = give_parse_plugin_update_notice($response['body'], $new_version);
330
+			set_transient($transient_name, $upgrade_notice, DAY_IN_SECONDS);
332 331
 		}
333 332
 	}
334 333
 
@@ -348,46 +347,46 @@  discard block
 block discarded – undo
348 347
  *
349 348
  * @return string
350 349
  */
351
-function give_parse_plugin_update_notice( $content, $new_version ) {
352
-	$version_parts     = explode( '.', $new_version );
350
+function give_parse_plugin_update_notice($content, $new_version) {
351
+	$version_parts     = explode('.', $new_version);
353 352
 	$check_for_notices = array(
354
-		$version_parts[0] . '.0',
355
-		$version_parts[0] . '.0.0',
356
-		$version_parts[0] . '.' . $version_parts[1] . '.' . '0',
353
+		$version_parts[0].'.0',
354
+		$version_parts[0].'.0.0',
355
+		$version_parts[0].'.'.$version_parts[1].'.'.'0',
357 356
 	);
358 357
 
359 358
 	// Regex to extract Upgrade notice from the readme.txt file.
360
-	$notice_regexp = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( $new_version ) . '\s*=|$)~Uis';
359
+	$notice_regexp = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*'.preg_quote($new_version).'\s*=|$)~Uis';
361 360
 
362 361
 	$upgrade_notice = '';
363 362
 
364
-	foreach ( $check_for_notices as $check_version ) {
365
-		if ( version_compare( GIVE_VERSION, $check_version, '>' ) ) {
363
+	foreach ($check_for_notices as $check_version) {
364
+		if (version_compare(GIVE_VERSION, $check_version, '>')) {
366 365
 			continue;
367 366
 		}
368 367
 
369 368
 		$matches = null;
370 369
 
371
-		if ( preg_match( $notice_regexp, $content, $matches ) ) {
372
-			$notices = (array) preg_split( '~[\r\n]+~', trim( $matches[2] ) );
370
+		if (preg_match($notice_regexp, $content, $matches)) {
371
+			$notices = (array) preg_split('~[\r\n]+~', trim($matches[2]));
373 372
 
374
-			if ( version_compare( trim( $matches[1] ), $check_version, '=' ) ) {
373
+			if (version_compare(trim($matches[1]), $check_version, '=')) {
375 374
 				$upgrade_notice .= '<p class="give-plugin-upgrade-notice">';
376 375
 
377
-				foreach ( $notices as $index => $line ) {
378
-					$upgrade_notice .= preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line );
376
+				foreach ($notices as $index => $line) {
377
+					$upgrade_notice .= preg_replace('~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line);
379 378
 				}
380 379
 
381 380
 				$upgrade_notice .= '</p>';
382 381
 			}
383 382
 
384
-			if ( ! empty( $upgrade_notice ) ) {
383
+			if ( ! empty($upgrade_notice)) {
385 384
 				break;
386 385
 			}
387 386
 		}
388 387
 	}
389 388
 
390
-	return wp_kses_post( $upgrade_notice );
389
+	return wp_kses_post($upgrade_notice);
391 390
 }
392 391
 
393 392
 
@@ -424,7 +423,7 @@  discard block
 block discarded – undo
424 423
 	<?php
425 424
 }
426 425
 
427
-add_action( 'admin_head', 'give_plugin_notice_css' );
426
+add_action('admin_head', 'give_plugin_notice_css');
428 427
 
429 428
 /**
430 429
  * Get list of add-on last activated.
@@ -434,7 +433,7 @@  discard block
 block discarded – undo
434 433
  * @return mixed|array list of recently activated add-on
435 434
  */
436 435
 function give_get_recently_activated_addons() {
437
-	return get_option( 'give_recently_activated_addons', array() );
436
+	return get_option('give_recently_activated_addons', array());
438 437
 }
439 438
 
440 439
 /**
@@ -452,34 +451,34 @@  discard block
 block discarded – undo
452 451
 	?>
453 452
 
454 453
 	<h2 id="deactivation-survey-title">
455
-		<img src="<?php echo esc_url( GIVE_PLUGIN_URL ) ?>/assets/dist/images/give-icon-full-circle.svg">
456
-		<span><?php esc_html_e( 'Give Deactivation', 'give' ); ?></span>
454
+		<img src="<?php echo esc_url(GIVE_PLUGIN_URL) ?>/assets/dist/images/give-icon-full-circle.svg">
455
+		<span><?php esc_html_e('Give Deactivation', 'give'); ?></span>
457 456
 	</h2>
458 457
 	<form class="deactivation-survey-form" method="POST">
459
-		<p><?php esc_html_e( 'If you have a moment, please let us know why you are deactivating Give. All submissions are anonymous and we only use this feedback to improve this plugin.', 'give' ); ?></p>
458
+		<p><?php esc_html_e('If you have a moment, please let us know why you are deactivating Give. All submissions are anonymous and we only use this feedback to improve this plugin.', 'give'); ?></p>
460 459
 
461 460
 		<div>
462 461
 			<label class="give-field-description">
463 462
 				<input type="radio" name="give-survey-radios" value="1">
464
-				<?php esc_html_e( "I'm only deactivating temporarily", 'give' ); ?>
463
+				<?php esc_html_e("I'm only deactivating temporarily", 'give'); ?>
465 464
 			</label>
466 465
 		</div>
467 466
 
468 467
 		<div>
469 468
 			<label class="give-field-description">
470 469
 				<input type="radio" name="give-survey-radios" value="2">
471
-				<?php esc_html_e( 'I no longer need the plugin', 'give' ); ?>
470
+				<?php esc_html_e('I no longer need the plugin', 'give'); ?>
472 471
 			</label>
473 472
 		</div>
474 473
 
475 474
 		<div>
476 475
 			<label class="give-field-description">
477 476
 				<input type="radio" name="give-survey-radios" value="3" data-has-field="true">
478
-				<?php esc_html_e( 'I found a better plugin', 'give' ); ?>
477
+				<?php esc_html_e('I found a better plugin', 'give'); ?>
479 478
 			</label>
480 479
 
481 480
 			<div class="give-survey-extra-field">
482
-				<p><?php esc_html_e( 'What is the name of the plugin?', 'give' ); ?></p>
481
+				<p><?php esc_html_e('What is the name of the plugin?', 'give'); ?></p>
483 482
 				<input type="text" name="user-reason" class="widefat">
484 483
 			</div>
485 484
 		</div>
@@ -487,23 +486,23 @@  discard block
 block discarded – undo
487 486
 		<div>
488 487
 			<label class="give-field-description">
489 488
 				<input type="radio" name="give-survey-radios" value="4">
490
-				<?php esc_html_e( 'I only needed the plugin for a short period', 'give' ); ?>
489
+				<?php esc_html_e('I only needed the plugin for a short period', 'give'); ?>
491 490
 			</label>
492 491
 		</div>
493 492
 
494 493
 		<div>
495 494
 			<label class="give-field-description">
496 495
 				<input type="radio" name="give-survey-radios" value="5" data-has-field="true">
497
-				<?php esc_html_e( 'The plugin broke my site', 'give' ); ?>
496
+				<?php esc_html_e('The plugin broke my site', 'give'); ?>
498 497
 			</label>
499 498
 
500 499
 			<div class="give-survey-extra-field">
501 500
 				<p><?php
502 501
 					printf(
503 502
 						'%1$s %2$s %3$s',
504
-						__( "We're sorry to hear that, check", 'give' ),
503
+						__("We're sorry to hear that, check", 'give'),
505 504
 						'<a href="https://wordpress.org/support/plugin/give">Give Support</a>.',
506
-						__( 'Can you describe the issue?', 'give' )
505
+						__('Can you describe the issue?', 'give')
507 506
 					);
508 507
 					?>
509 508
 				</p>
@@ -514,16 +513,16 @@  discard block
 block discarded – undo
514 513
 		<div>
515 514
 			<label class="give-field-description">
516 515
 				<input type="radio" name="give-survey-radios" value="6" data-has-field="true">
517
-				<?php esc_html_e( 'The plugin suddenly stopped working', 'give' ); ?>
516
+				<?php esc_html_e('The plugin suddenly stopped working', 'give'); ?>
518 517
 			</label>
519 518
 
520 519
 			<div class="give-survey-extra-field">
521 520
 				<p><?php
522 521
 					printf(
523 522
 						'%1$s %2$s %3$s',
524
-						__( "We're sorry to hear that, check", 'give' ),
523
+						__("We're sorry to hear that, check", 'give'),
525 524
 						'<a href="https://wordpress.org/support/plugin/give">Give Support</a>.',
526
-						__( 'Can you describe the issue?', 'give' )
525
+						__('Can you describe the issue?', 'give')
527 526
 					);
528 527
 					?>
529 528
 				</p>
@@ -534,11 +533,11 @@  discard block
 block discarded – undo
534 533
 		<div>
535 534
 			<label class="give-field-description">
536 535
 				<input type="radio" name="give-survey-radios" value="7" data-has-field="true">
537
-				<?php esc_html_e( 'Other', 'give' ); ?>
536
+				<?php esc_html_e('Other', 'give'); ?>
538 537
 			</label>
539 538
 
540 539
 			<div class="give-survey-extra-field">
541
-				<p><?php esc_html_e( "Please describe why you're deactivating Give", 'give' ); ?></p>
540
+				<p><?php esc_html_e("Please describe why you're deactivating Give", 'give'); ?></p>
542 541
 				<textarea disabled name="user-reason" class="widefat" rows="6"></textarea disabled>
543 542
 			</div>
544 543
 		</div>
@@ -547,10 +546,10 @@  discard block
 block discarded – undo
547 546
 			<p>
548 547
 				<label>
549 548
 					<input type="checkbox" name="confirm_reset_store" value="1">
550
-					<?php esc_html_e( 'Would you like to delete all Give data?', 'give' ); ?>
549
+					<?php esc_html_e('Would you like to delete all Give data?', 'give'); ?>
551 550
 				</label>
552 551
 				<section class="give-field-description">
553
-					<?php esc_html_e( 'By default the custom roles, Give options, and database entries are not deleted when you deactivate Give. If you are deleting Give completely from your website and want those items removed as well check this option. Note: This will permanently delete all Give data from your database.', 'give' ); ?>
552
+					<?php esc_html_e('By default the custom roles, Give options, and database entries are not deleted when you deactivate Give. If you are deleting Give completely from your website and want those items removed as well check this option. Note: This will permanently delete all Give data from your database.', 'give'); ?>
554 553
 				</section>
555 554
 			</p>
556 555
 		</div>
@@ -559,9 +558,9 @@  discard block
 block discarded – undo
559 558
 		$current_user_email = $current_user->user_email;
560 559
 		?>
561 560
 		<input type="hidden" name="current-user-email" value="<?php echo $current_user_email; ?>">
562
-		<input type="hidden" name="current-site-url" value="<?php echo esc_url( get_bloginfo( 'url' ) ); ?>">
561
+		<input type="hidden" name="current-site-url" value="<?php echo esc_url(get_bloginfo('url')); ?>">
563 562
 		<input type="hidden" name="give-export-class" value="Give_Tools_Reset_Stats">
564
-		<?php wp_nonce_field( 'give_ajax_export', 'give_ajax_export' ); ?>
563
+		<?php wp_nonce_field('give_ajax_export', 'give_ajax_export'); ?>
565 564
 	</form>
566 565
 
567 566
 	<?php
@@ -574,10 +573,10 @@  discard block
 block discarded – undo
574 573
 
575 574
 	$results['html'] = $output;
576 575
 
577
-	wp_send_json( $results );
576
+	wp_send_json($results);
578 577
 }
579 578
 
580
-add_action( 'wp_ajax_give_deactivation_popup', 'give_deactivation_popup' );
579
+add_action('wp_ajax_give_deactivation_popup', 'give_deactivation_popup');
581 580
 
582 581
 /**
583 582
  * Ajax callback after the deactivation survey form has been submitted.
@@ -587,27 +586,27 @@  discard block
 block discarded – undo
587 586
  */
588 587
 function give_deactivation_form_submit() {
589 588
 
590
-	if ( ! check_ajax_referer( 'deactivation_survey_nonce', 'nonce', false ) ) {
589
+	if ( ! check_ajax_referer('deactivation_survey_nonce', 'nonce', false)) {
591 590
 		wp_send_json_error();
592 591
 		wp_die();
593 592
 	}
594 593
 
595
-	$form_data = give_clean( wp_parse_args( $_POST['form-data'] ) );
594
+	$form_data = give_clean(wp_parse_args($_POST['form-data']));
596 595
 
597 596
 	// Get the selected radio value.
598
-	$radio_value = isset( $form_data['give-survey-radios'] ) ? $form_data['give-survey-radios'] : 0;
597
+	$radio_value = isset($form_data['give-survey-radios']) ? $form_data['give-survey-radios'] : 0;
599 598
 
600 599
 	// Get the reason if any radio button has an optional text field.
601
-	$user_reason = isset( $form_data['user-reason'] ) ? $form_data['user-reason'] : '';
600
+	$user_reason = isset($form_data['user-reason']) ? $form_data['user-reason'] : '';
602 601
 
603 602
 	// Get the email of the user who deactivated the plugin.
604
-	$user_email = isset( $form_data['current-user-email'] ) ? $form_data['current-user-email'] : '';
603
+	$user_email = isset($form_data['current-user-email']) ? $form_data['current-user-email'] : '';
605 604
 
606 605
 	// Get the URL of the website on which Give plugin is being deactivated.
607
-	$site_url = isset( $form_data['current-site-url'] ) ? $form_data['current-site-url'] : '';
606
+	$site_url = isset($form_data['current-site-url']) ? $form_data['current-site-url'] : '';
608 607
 
609 608
 	// Get the value of the checkbox for deleting Give's data.
610
-	$delete_data = isset( $form_data['confirm_reset_store'] ) ? $form_data['confirm_reset_store'] : '';
609
+	$delete_data = isset($form_data['confirm_reset_store']) ? $form_data['confirm_reset_store'] : '';
611 610
 
612 611
 	/**
613 612
 	 * Make a POST request to the endpoint to send the survey data.
@@ -625,10 +624,10 @@  discard block
 block discarded – undo
625 624
 	);
626 625
 
627 626
 	// Check if the data is sent and stored correctly.
628
-	$response = wp_remote_retrieve_body( $response );
627
+	$response = wp_remote_retrieve_body($response);
629 628
 
630
-	if ( 'true' === $response ) {
631
-		if ( '1' === $delete_data ) {
629
+	if ('true' === $response) {
630
+		if ('1' === $delete_data) {
632 631
 			wp_send_json_success(
633 632
 				array(
634 633
 					'delete_data' => true,
@@ -648,4 +647,4 @@  discard block
 block discarded – undo
648 647
 	wp_die();
649 648
 }
650 649
 
651
-add_action( 'wp_ajax_deactivation_form_submit', 'give_deactivation_form_submit' );
650
+add_action('wp_ajax_deactivation_form_submit', 'give_deactivation_form_submit');
Please login to merge, or discard this patch.
includes/admin/donors/donors.php 2 patches
Spacing   +253 added lines, -253 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  *
26 26
  * @return string
27 27
  */
28
-function __give_get_format_address( $address, $address_args = array() ) {
28
+function __give_get_format_address($address, $address_args = array()) {
29 29
 	$address_html = '';
30 30
 	$address_args = wp_parse_args(
31 31
 		$address_args,
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	$address_id = $address_args['type'];
41 41
 
42 42
 	// Bailout.
43
-	if ( empty( $address ) || ! is_array( $address ) ) {
43
+	if (empty($address) || ! is_array($address)) {
44 44
 		return $address_html;
45 45
 	}
46 46
 
@@ -49,19 +49,19 @@  discard block
 block discarded – undo
49 49
 	$address_html .= sprintf(
50 50
 		'<span data-address-type="line1">%1$s</span>%2$s',
51 51
 		$address['line1'],
52
-		( ! empty( $address['line2'] ) ? '<br>' : '' )
52
+		( ! empty($address['line2']) ? '<br>' : '')
53 53
 	);
54 54
 	$address_html .= sprintf(
55 55
 		'<span data-address-type="line2">%1$s</span>%2$s',
56 56
 		$address['line2'],
57
-		( ! empty( $address['city'] ) ? '<br>' : '' )
57
+		( ! empty($address['city']) ? '<br>' : '')
58 58
 	);
59 59
 	$address_html .= sprintf(
60 60
 		'<span data-address-type="city">%1$s</span><span data-address-type="state">%2$s</span><span data-address-type="zip">%3$s</span>%4$s',
61 61
 		$address['city'],
62
-		( ! empty( $address['state'] ) ? ", {$address['state']}" : '' ),
63
-		( ! empty( $address['zip'] ) ? " {$address['zip']}" : '' ),
64
-		( ! empty( $address['country'] ) ? '<br>' : '' )
62
+		( ! empty($address['state']) ? ", {$address['state']}" : ''),
63
+		( ! empty($address['zip']) ? " {$address['zip']}" : ''),
64
+		( ! empty($address['country']) ? '<br>' : '')
65 65
 	);
66 66
 	$address_html .= sprintf(
67 67
 		'<span data-address-type="country">%s</span><br>',
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
 	// Address action.
72 72
 	$address_html .= sprintf(
73 73
 		'<br><a href="#" class="js-edit">%1$s</a> | <a href="#" class="js-remove">%2$s</a>',
74
-		__( 'Edit', 'give' ),
75
-		__( 'Remove', 'give' )
74
+		__('Edit', 'give'),
75
+		__('Remove', 'give')
76 76
 	);
77 77
 
78 78
 	/**
@@ -80,14 +80,14 @@  discard block
 block discarded – undo
80 80
 	 *
81 81
 	 * @since 2.0
82 82
 	 */
83
-	$address_label = apply_filters( "give_donor_{$address_args['type']}_address_label", ucfirst( $address_args['type'] ), $address_args );
83
+	$address_label = apply_filters("give_donor_{$address_args['type']}_address_label", ucfirst($address_args['type']), $address_args);
84 84
 
85 85
 	// Set unique id and index for multi type address.
86
-	if ( isset( $address_args['index'] ) ) {
86
+	if (isset($address_args['index'])) {
87 87
 		$address_label = "{$address_label} #{$address_args['index']}";
88 88
 	}
89 89
 
90
-	if ( isset( $address_args['id'] ) ) {
90
+	if (isset($address_args['id'])) {
91 91
 		$address_id = "{$address_id}_{$address_args['id']}";
92 92
 	}
93 93
 
@@ -112,9 +112,9 @@  discard block
 block discarded – undo
112 112
  */
113 113
 function give_donors_page() {
114 114
 	$default_views  = give_donor_views();
115
-	$requested_view = isset( $_GET['view'] ) ? sanitize_text_field( $_GET['view'] ) : 'donors';
116
-	if ( array_key_exists( $requested_view, $default_views ) && function_exists( $default_views[ $requested_view ] ) ) {
117
-		give_render_donor_view( $requested_view, $default_views );
115
+	$requested_view = isset($_GET['view']) ? sanitize_text_field($_GET['view']) : 'donors';
116
+	if (array_key_exists($requested_view, $default_views) && function_exists($default_views[$requested_view])) {
117
+		give_render_donor_view($requested_view, $default_views);
118 118
 	} else {
119 119
 		give_donors_list();
120 120
 	}
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 
131 131
 	$views = array();
132 132
 
133
-	return apply_filters( 'give_donor_views', $views );
133
+	return apply_filters('give_donor_views', $views);
134 134
 
135 135
 }
136 136
 
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 
145 145
 	$tabs = array();
146 146
 
147
-	return apply_filters( 'give_donor_tabs', $tabs );
147
+	return apply_filters('give_donor_tabs', $tabs);
148 148
 
149 149
 }
150 150
 
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
  */
157 157
 function give_donors_list() {
158 158
 
159
-	include GIVE_PLUGIN_DIR . 'includes/admin/donors/class-donor-table.php';
159
+	include GIVE_PLUGIN_DIR.'includes/admin/donors/class-donor-table.php';
160 160
 
161 161
 	$donors_table = new Give_Donor_List_Table();
162 162
 	$donors_table->prepare_items();
@@ -169,13 +169,13 @@  discard block
 block discarded – undo
169 169
 		 *
170 170
 		 * @since 1.0
171 171
 		 */
172
-		do_action( 'give_donors_table_top' );
172
+		do_action('give_donors_table_top');
173 173
 		?>
174 174
 
175 175
 		<hr class="wp-header-end">
176 176
 		<form id="give-donors-search-filter" method="get"
177
-		      action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors' ); ?>">
178
-			<?php $donors_table->search_box( __( 'Search Donors', 'give' ), 'give-donors' ); ?>
177
+		      action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors'); ?>">
178
+			<?php $donors_table->search_box(__('Search Donors', 'give'), 'give-donors'); ?>
179 179
 			<input type="hidden" name="post_type" value="give_forms"/>
180 180
 			<input type="hidden" name="page" value="give-donors"/>
181 181
 			<input type="hidden" name="view" value="donors"/>
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 		 *
193 193
 		 * @since 1.0
194 194
 		 */
195
-		do_action( 'give_donors_table_bottom' );
195
+		do_action('give_donors_table_bottom');
196 196
 		?>
197 197
 	</div>
198 198
 	<?php
@@ -208,33 +208,33 @@  discard block
 block discarded – undo
208 208
  *
209 209
  * @return void
210 210
  */
211
-function give_render_donor_view( $view, $callbacks ) {
211
+function give_render_donor_view($view, $callbacks) {
212 212
 
213 213
 	$render = true;
214 214
 
215
-	$donor_view_role = apply_filters( 'give_view_donors_role', 'view_give_reports' );
215
+	$donor_view_role = apply_filters('give_view_donors_role', 'view_give_reports');
216 216
 
217
-	if ( ! current_user_can( $donor_view_role ) ) {
218
-		give_set_error( 'give-no-access', __( 'You are not permitted to view this data.', 'give' ) );
217
+	if ( ! current_user_can($donor_view_role)) {
218
+		give_set_error('give-no-access', __('You are not permitted to view this data.', 'give'));
219 219
 		$render = false;
220 220
 	}
221 221
 
222
-	if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
223
-		give_set_error( 'give-invalid_donor', __( 'Invalid Donor ID.', 'give' ) );
222
+	if ( ! isset($_GET['id']) || ! is_numeric($_GET['id'])) {
223
+		give_set_error('give-invalid_donor', __('Invalid Donor ID.', 'give'));
224 224
 		$render = false;
225 225
 	}
226 226
 
227 227
 	$donor_id          = (int) $_GET['id'];
228
-	$reconnect_user_id = ! empty( $_GET['user_id'] ) ? (int) $_GET['user_id'] : '';
229
-	$donor             = new Give_Donor( $donor_id );
228
+	$reconnect_user_id = ! empty($_GET['user_id']) ? (int) $_GET['user_id'] : '';
229
+	$donor             = new Give_Donor($donor_id);
230 230
 
231 231
 	// Reconnect User with Donor profile.
232
-	if ( $reconnect_user_id ) {
233
-		give_connect_user_donor_profile( $donor, array( 'user_id' => $reconnect_user_id ), array() );
232
+	if ($reconnect_user_id) {
233
+		give_connect_user_donor_profile($donor, array('user_id' => $reconnect_user_id), array());
234 234
 	}
235 235
 
236
-	if ( empty( $donor->id ) ) {
237
-		give_set_error( 'give-invalid_donor', __( 'Invalid Donor ID.', 'give' ) );
236
+	if (empty($donor->id)) {
237
+		give_set_error('give-invalid_donor', __('Invalid Donor ID.', 'give'));
238 238
 		$render = false;
239 239
 	}
240 240
 
@@ -243,9 +243,9 @@  discard block
 block discarded – undo
243 243
 
244 244
 	<div class='wrap'>
245 245
 
246
-		<?php if ( give_get_errors() ) : ?>
246
+		<?php if (give_get_errors()) : ?>
247 247
 			<div class="error settings-error">
248
-				<?php Give()->notices->render_frontend_notices( 0 ); ?>
248
+				<?php Give()->notices->render_frontend_notices(0); ?>
249 249
 			</div>
250 250
 		<?php endif; ?>
251 251
 
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 			<?php
254 254
 			printf(
255 255
 			/* translators: %s: donor first name */
256
-				__( 'Edit Donor: %s %s', 'give' ),
256
+				__('Edit Donor: %s %s', 'give'),
257 257
 				$donor->get_first_name(),
258 258
 				$donor->get_last_name()
259 259
 			);
@@ -262,26 +262,26 @@  discard block
 block discarded – undo
262 262
 
263 263
 		<hr class="wp-header-end">
264 264
 
265
-		<?php if ( $donor && $render ) : ?>
265
+		<?php if ($donor && $render) : ?>
266 266
 
267 267
 			<h2 class="nav-tab-wrapper">
268 268
 				<?php
269
-				foreach ( $donor_tabs as $key => $tab ) :
269
+				foreach ($donor_tabs as $key => $tab) :
270 270
 					$active = $key === $view ? true : false;
271 271
 					$class  = $active ? 'nav-tab nav-tab-active' : 'nav-tab';
272 272
 					printf(
273
-						'<a href="%1$s" class="%2$s"><span class="dashicons %3$s"></span>%4$s</a>' . "\n",
274
-						esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=' . $key . '&id=' . $donor->id ) ),
275
-						esc_attr( $class ),
276
-						sanitize_html_class( $tab['dashicon'] ),
277
-						esc_html( $tab['title'] )
273
+						'<a href="%1$s" class="%2$s"><span class="dashicons %3$s"></span>%4$s</a>'."\n",
274
+						esc_url(admin_url('edit.php?post_type=give_forms&page=give-donors&view='.$key.'&id='.$donor->id)),
275
+						esc_attr($class),
276
+						sanitize_html_class($tab['dashicon']),
277
+						esc_html($tab['title'])
278 278
 					);
279 279
 				endforeach;
280 280
 				?>
281 281
 			</h2>
282 282
 
283 283
 			<div id="give-donor-card-wrapper">
284
-				<?php $callbacks[ $view ]( $donor ) ?>
284
+				<?php $callbacks[$view]($donor) ?>
285 285
 			</div>
286 286
 
287 287
 		<?php endif; ?>
@@ -301,9 +301,9 @@  discard block
 block discarded – undo
301 301
  *
302 302
  * @return void
303 303
  */
304
-function give_donor_view( $donor ) {
304
+function give_donor_view($donor) {
305 305
 
306
-	$donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' );
306
+	$donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments');
307 307
 
308 308
 	/**
309 309
 	 * Fires in donor profile screen, above the donor card.
@@ -312,11 +312,11 @@  discard block
 block discarded – undo
312 312
 	 *
313 313
 	 * @param object $donor The donor object being displayed.
314 314
 	 */
315
-	do_action( 'give_donor_card_top', $donor );
315
+	do_action('give_donor_card_top', $donor);
316 316
 
317 317
 	// Set Read only to the fields which needs to be locked.
318 318
 	$read_only = '';
319
-	if ( $donor->user_id ) {
319
+	if ($donor->user_id) {
320 320
 		$read_only = 'readonly="readonly"';
321 321
 	}
322 322
 
@@ -324,28 +324,28 @@  discard block
 block discarded – undo
324 324
 	$title_prefixes = give_get_name_title_prefixes();
325 325
 
326 326
 	// Prepend title prefix to name if it is set.
327
-	$title_prefix = Give()->donor_meta->get_meta( $donor->id, '_give_donor_title_prefix', true );
328
-	$donor->name  = give_get_donor_name_with_title_prefixes( $title_prefix, $donor->name );
327
+	$title_prefix = Give()->donor_meta->get_meta($donor->id, '_give_donor_title_prefix', true);
328
+	$donor->name  = give_get_donor_name_with_title_prefixes($title_prefix, $donor->name);
329 329
 	?>
330 330
 	<div id="donor-summary" class="info-wrapper donor-section postbox">
331 331
 		<form id="edit-donor-info" method="post"
332
-		      action="<?php echo esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) ); ?>">
332
+		      action="<?php echo esc_url(admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id)); ?>">
333 333
 			<div class="donor-info">
334 334
 				<div class="donor-bio-header clearfix">
335 335
 					<div class="avatar-wrap left" id="donor-avatar">
336
-						<?php echo get_avatar( $donor->email ); ?>
336
+						<?php echo get_avatar($donor->email); ?>
337 337
 					</div>
338 338
 					<div id="donor-name-wrap" class="left">
339 339
 						<span class="donor-name info-item edit-item">
340 340
 							<select name="donor_info[title]">
341
-								<option disabled value="0"><?php esc_html_e( 'Title', 'give' ); ?></option>
341
+								<option disabled value="0"><?php esc_html_e('Title', 'give'); ?></option>
342 342
 								<?php
343
-								if ( is_array( $title_prefixes ) && count( $title_prefixes ) > 0 ) {
344
-									foreach ( $title_prefixes as $title ) {
343
+								if (is_array($title_prefixes) && count($title_prefixes) > 0) {
344
+									foreach ($title_prefixes as $title) {
345 345
 										echo sprintf(
346 346
 											'<option %1$s value="%2$s">%2$s</option>',
347
-											selected( $title_prefix, $title, false ),
348
-											esc_html( $title )
347
+											selected($title_prefix, $title, false),
348
+											esc_html($title)
349 349
 										);
350 350
 									}
351 351
 								}
@@ -353,34 +353,34 @@  discard block
 block discarded – undo
353 353
 							</select>
354 354
 							<input <?php echo $read_only; ?> size="15" data-key="first_name"
355 355
 							                                 name="donor_info[first_name]" type="text"
356
-							                                 value="<?php echo esc_html( $donor->get_first_name() ); ?>"
357
-							                                 placeholder="<?php esc_html_e( 'First Name', 'give' ); ?>"/>
358
-							<?php if ( $donor->user_id ) : ?>
356
+							                                 value="<?php echo esc_html($donor->get_first_name()); ?>"
357
+							                                 placeholder="<?php esc_html_e('First Name', 'give'); ?>"/>
358
+							<?php if ($donor->user_id) : ?>
359 359
 								<a href="#" class="give-lock-block">
360 360
 									<i class="give-icon give-icon-locked"></i>
361 361
 								</a>
362 362
 							<?php endif; ?>
363 363
 							<input <?php echo $read_only; ?> size="15" data-key="last_name"
364 364
 							                                 name="donor_info[last_name]" type="text"
365
-							                                 value="<?php echo esc_html( $donor->get_last_name() ); ?>"
366
-							                                 placeholder="<?php esc_html_e( 'Last Name', 'give' ); ?>"/>
367
-							<?php if ( $donor->user_id ) : ?>
365
+							                                 value="<?php echo esc_html($donor->get_last_name()); ?>"
366
+							                                 placeholder="<?php esc_html_e('Last Name', 'give'); ?>"/>
367
+							<?php if ($donor->user_id) : ?>
368 368
 								<a href="#" class="give-lock-block">
369 369
 									<i class="give-icon give-icon-locked"></i>
370 370
 								</a>
371 371
 							<?php endif; ?>
372 372
 						</span>
373 373
 						<span class="donor-name info-item editable">
374
-							<span data-key="name"><?php echo esc_html( $donor->name ); ?></span>
374
+							<span data-key="name"><?php echo esc_html($donor->name); ?></span>
375 375
 						</span>
376 376
 					</div>
377 377
 					<p class="donor-since info-item">
378
-						<?php esc_html_e( 'Donor since', 'give' ); ?>
379
-						<?php echo date_i18n( give_date_format(), strtotime( $donor->date_created ) ) ?>
378
+						<?php esc_html_e('Donor since', 'give'); ?>
379
+						<?php echo date_i18n(give_date_format(), strtotime($donor->date_created)) ?>
380 380
 					</p>
381
-					<?php if ( current_user_can( $donor_edit_role ) ) : ?>
381
+					<?php if (current_user_can($donor_edit_role)) : ?>
382 382
 						<a href="#" id="edit-donor" class="button info-item editable donor-edit-link">
383
-							<?php esc_html_e( 'Edit Donor', 'give' ); ?>
383
+							<?php esc_html_e('Edit Donor', 'give'); ?>
384 384
 						</a>
385 385
 					<?php endif; ?>
386 386
 				</div>
@@ -391,12 +391,12 @@  discard block
 block discarded – undo
391 391
 					<table class="widefat striped">
392 392
 						<tbody>
393 393
 						<tr>
394
-							<th scope="col"><label for="tablecell"><?php esc_html_e( 'Donor ID:', 'give' ); ?></label>
394
+							<th scope="col"><label for="tablecell"><?php esc_html_e('Donor ID:', 'give'); ?></label>
395 395
 							</th>
396
-							<td><?php echo intval( $donor->id ); ?></td>
396
+							<td><?php echo intval($donor->id); ?></td>
397 397
 						</tr>
398 398
 						<tr>
399
-							<th scope="col"><label for="tablecell"><?php esc_html_e( 'User ID:', 'give' ); ?></label>
399
+							<th scope="col"><label for="tablecell"><?php esc_html_e('User ID:', 'give'); ?></label>
400 400
 							</th>
401 401
 							<td>
402 402
 									<span class="donor-user-id info-item edit-item">
@@ -414,24 +414,24 @@  discard block
 block discarded – undo
414 414
 											'data'  => $data_atts,
415 415
 										);
416 416
 
417
-										if ( ! empty( $user_id ) ) {
418
-											$userdata              = get_userdata( $user_id );
417
+										if ( ! empty($user_id)) {
418
+											$userdata              = get_userdata($user_id);
419 419
 											$user_args['selected'] = $user_id;
420 420
 										}
421 421
 
422
-										echo Give()->html->ajax_user_search( $user_args );
422
+										echo Give()->html->ajax_user_search($user_args);
423 423
 										?>
424 424
 									</span>
425 425
 
426 426
 								<span class="donor-user-id info-item editable">
427
-										<?php if ( ! empty( $userdata ) ) : ?>
427
+										<?php if ( ! empty($userdata)) : ?>
428 428
 											<span
429
-												data-key="user_id">#<?php echo $donor->user_id . ' - ' . $userdata->display_name; ?></span>
429
+												data-key="user_id">#<?php echo $donor->user_id.' - '.$userdata->display_name; ?></span>
430 430
 										<?php else : ?>
431 431
 											<span
432
-												data-key="user_id"><?php esc_html_e( 'Unregistered', 'give' ); ?></span>
432
+												data-key="user_id"><?php esc_html_e('Unregistered', 'give'); ?></span>
433 433
 										<?php endif; ?>
434
-									<?php if ( current_user_can( $donor_edit_role ) && intval( $donor->user_id ) > 0 ) :
434
+									<?php if (current_user_can($donor_edit_role) && intval($donor->user_id) > 0) :
435 435
 
436 436
 										echo sprintf(
437 437
 											'- <span class="disconnect-user">
@@ -440,11 +440,11 @@  discard block
 block discarded – undo
440 440
 											<span class="view-user-profile">
441 441
 												<a id="view-user-profile" href="%3$s" aria-label="%4$s">%5$s</a>
442 442
 											</span>',
443
-											esc_html__( 'Disconnects the current user ID from this donor record.', 'give' ),
444
-											esc_html__( 'Disconnect User', 'give' ),
445
-											esc_url( 'user-edit.php?user_id=' . $donor->user_id ),
446
-											esc_html__( 'View User Profile of current user ID.', 'give' ),
447
-											esc_html__( 'View User Profile', 'give' )
443
+											esc_html__('Disconnects the current user ID from this donor record.', 'give'),
444
+											esc_html__('Disconnect User', 'give'),
445
+											esc_url('user-edit.php?user_id='.$donor->user_id),
446
+											esc_html__('View User Profile of current user ID.', 'give'),
447
+											esc_html__('View User Profile', 'give')
448 448
 										);
449 449
 
450 450
 									endif; ?>
@@ -453,11 +453,11 @@  discard block
 block discarded – undo
453 453
 						</tr>
454 454
 
455 455
 						<?php
456
-						$donor_company = $donor->get_meta( '_give_donor_company', true );
456
+						$donor_company = $donor->get_meta('_give_donor_company', true);
457 457
 						?>
458 458
 						<tr class="alternate">
459 459
 							<th scope="col">
460
-								<label for="tablecell"><?php esc_html_e( 'Company Name:', 'give' ); ?></label>
460
+								<label for="tablecell"><?php esc_html_e('Company Name:', 'give'); ?></label>
461 461
 							</th>
462 462
 							<td>
463 463
 								<span class="donor-user-id info-item edit-item">
@@ -470,10 +470,10 @@  discard block
 block discarded – undo
470 470
 							</td>
471 471
 						</tr>
472 472
 
473
-						<?php $anonymous_donor = absint( $donor->get_meta( '_give_anonymous_donor', true ) ); ?>
473
+						<?php $anonymous_donor = absint($donor->get_meta('_give_anonymous_donor', true)); ?>
474 474
 						<tr class="alternate">
475 475
 							<th scope="col">
476
-								<label for="tablecell"><?php _e( 'Anonymous Donor:', 'give' ); ?></label>
476
+								<label for="tablecell"><?php _e('Anonymous Donor:', 'give'); ?></label>
477 477
 							</th>
478 478
 							<td>
479 479
 								<span class="donor-anonymous-donor info-item edit-item">
@@ -484,8 +484,8 @@  discard block
 block discarded – undo
484 484
 													name="give_anonymous_donor"
485 485
 													value="1"
486 486
 													type="radio"
487
-													<?php checked( 1, $anonymous_donor ) ?>
488
-												><?php _e( 'Yes', 'give' ); ?>
487
+													<?php checked(1, $anonymous_donor) ?>
488
+												><?php _e('Yes', 'give'); ?>
489 489
 											</label>
490 490
 										</li>
491 491
 										<li>
@@ -494,14 +494,14 @@  discard block
 block discarded – undo
494 494
 													name="give_anonymous_donor"
495 495
 													value="0"
496 496
 													type="radio"
497
-													<?php checked( 0, $anonymous_donor ) ?>
498
-												><?php _e( 'No', 'give' ); ?>
497
+													<?php checked(0, $anonymous_donor) ?>
498
+												><?php _e('No', 'give'); ?>
499 499
 											</label>
500 500
 										</li>
501 501
 									</ul>
502 502
 								</span>
503 503
 								<span class="donor-anonymous-donor info-item editable">
504
-									<?php echo( $anonymous_donor ? __( 'Yes', 'give' ) : __( 'No', 'give' ) ); ?>
504
+									<?php echo($anonymous_donor ? __('Yes', 'give') : __('No', 'give')); ?>
505 505
 								</span>
506 506
 							</td>
507 507
 						</tr>
@@ -513,12 +513,12 @@  discard block
 block discarded – undo
513 513
 			</div>
514 514
 
515 515
 			<span id="donor-edit-actions" class="edit-item">
516
-				<input type="hidden" data-key="id" name="donor_info[id]" value="<?php echo intval( $donor->id ); ?>"/>
517
-				<?php wp_nonce_field( 'edit-donor', '_wpnonce', false, true ); ?>
516
+				<input type="hidden" data-key="id" name="donor_info[id]" value="<?php echo intval($donor->id); ?>"/>
517
+				<?php wp_nonce_field('edit-donor', '_wpnonce', false, true); ?>
518 518
 				<input type="hidden" name="give_action" value="edit-donor"/>
519 519
 				<input type="submit" id="give-edit-donor-save" class="button-secondary"
520
-				       value="<?php esc_html_e( 'Update Donor', 'give' ); ?>"/>
521
-				<a id="give-edit-donor-cancel" href="" class="delete"><?php esc_html_e( 'Cancel', 'give' ); ?></a>
520
+				       value="<?php esc_html_e('Update Donor', 'give'); ?>"/>
521
+				<a id="give-edit-donor-cancel" href="" class="delete"><?php esc_html_e('Cancel', 'give'); ?></a>
522 522
 			</span>
523 523
 
524 524
 		</form>
@@ -533,24 +533,24 @@  discard block
 block discarded – undo
533 533
 	 *
534 534
 	 * @param Give_Donor $donor The donor object being displayed.
535 535
 	 */
536
-	do_action( 'give_donor_before_stats', $donor );
536
+	do_action('give_donor_before_stats', $donor);
537 537
 	?>
538 538
 
539 539
 	<div id="donor-stats-wrapper" class="donor-section postbox clear">
540 540
 		<ul>
541 541
 			<li>
542
-				<a href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&donor=' . absint( $donor->id ) ); ?>">
542
+				<a href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history&donor='.absint($donor->id)); ?>">
543 543
 					<span class="dashicons dashicons-heart"></span>
544 544
 					<?php
545 545
 					// Completed Donations.
546
-					$completed_donations_text = sprintf( _n( '%d Completed Donation', '%d Completed Donations', $donor->purchase_count, 'give' ), $donor->purchase_count );
547
-					echo apply_filters( 'give_donor_completed_donations', $completed_donations_text, $donor );
546
+					$completed_donations_text = sprintf(_n('%d Completed Donation', '%d Completed Donations', $donor->purchase_count, 'give'), $donor->purchase_count);
547
+					echo apply_filters('give_donor_completed_donations', $completed_donations_text, $donor);
548 548
 					?>
549 549
 				</a>
550 550
 			</li>
551 551
 			<li>
552 552
 				<span class="dashicons dashicons-chart-area"></span>
553
-				<?php echo give_currency_filter( give_format_amount( $donor->get_total_donation_amount(), array( 'sanitize' => false ) ) ); ?> <?php _e( 'Lifetime Donations', 'give' ); ?>
553
+				<?php echo give_currency_filter(give_format_amount($donor->get_total_donation_amount(), array('sanitize' => false))); ?> <?php _e('Lifetime Donations', 'give'); ?>
554 554
 			</li>
555 555
 			<?php
556 556
 			/**
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
 			 *
563 563
 			 * @param object $donor The donor object being displayed.
564 564
 			 */
565
-			do_action( 'give_donor_stats_list', $donor );
565
+			do_action('give_donor_stats_list', $donor);
566 566
 			?>
567 567
 		</ul>
568 568
 	</div>
@@ -575,11 +575,11 @@  discard block
 block discarded – undo
575 575
 	 *
576 576
 	 * @param Give_Donor $donor The donor object being displayed.
577 577
 	 */
578
-	do_action( 'give_donor_before_address', $donor );
578
+	do_action('give_donor_before_address', $donor);
579 579
 	?>
580 580
 
581 581
 	<div id="donor-address-wrapper" class="donor-section clear">
582
-		<h3><?php _e( 'Addresses', 'give' ); ?></h3>
582
+		<h3><?php _e('Addresses', 'give'); ?></h3>
583 583
 
584 584
 		<div class="postbox">
585 585
 			<div class="give-spinner-wrapper">
@@ -589,16 +589,16 @@  discard block
 block discarded – undo
589 589
 				<div class="all-address">
590 590
 					<div class="give-grid-row">
591 591
 						<?php
592
-						if ( ! empty( $donor->address ) ) :
592
+						if ( ! empty($donor->address)) :
593 593
 							// Default address always will be at zero array index.
594 594
 							$is_set_as_default = null;
595 595
 
596
-							foreach ( $donor->address as $address_type => $addresses ) {
596
+							foreach ($donor->address as $address_type => $addresses) {
597 597
 
598
-								switch ( true ) {
599
-									case is_array( end( $addresses ) ):
598
+								switch (true) {
599
+									case is_array(end($addresses)):
600 600
 										$index = 1;
601
-										foreach ( $addresses as $id => $address ) {
601
+										foreach ($addresses as $id => $address) {
602 602
 											echo __give_get_format_address(
603 603
 												$address,
604 604
 												array(
@@ -608,11 +608,11 @@  discard block
 block discarded – undo
608 608
 												)
609 609
 											);
610 610
 
611
-											$index ++;
611
+											$index++;
612 612
 										}
613 613
 										break;
614 614
 
615
-									case is_string( end( $addresses ) ):
615
+									case is_string(end($addresses)):
616 616
 										echo __give_get_format_address(
617 617
 											$addresses,
618 618
 											array(
@@ -625,13 +625,13 @@  discard block
 block discarded – undo
625 625
 						endif;
626 626
 						?>
627 627
 					</div>
628
-					<span class="give-no-address-message<?php if ( ! empty( $donor->address ) ) {
628
+					<span class="give-no-address-message<?php if ( ! empty($donor->address)) {
629 629
 						echo ' give-hidden';
630 630
 					} ?>">
631
-						<?php _e( 'This donor does not have any addresses saved.', 'give' ); ?>
631
+						<?php _e('This donor does not have any addresses saved.', 'give'); ?>
632 632
 					</span>
633 633
 					<button class="button add-new-address">
634
-						<?php _e( 'Add Address', 'give' ); ?>
634
+						<?php _e('Add Address', 'give'); ?>
635 635
 					</button>
636 636
 				</div>
637 637
 
@@ -641,26 +641,26 @@  discard block
 block discarded – undo
641 641
 							<tbody>
642 642
 							<tr>
643 643
 								<th class="col">
644
-									<label class="country"><?php esc_html_e( 'Country:', 'give' ); ?></label>
644
+									<label class="country"><?php esc_html_e('Country:', 'give'); ?></label>
645 645
 								</th>
646 646
 								<td>
647 647
 									<?php
648
-									echo Give()->html->select( array(
648
+									echo Give()->html->select(array(
649 649
 										'options'          => give_get_country_list(),
650 650
 										'name'             => 'country',
651
-										'selected'         => give_get_option( 'base_country' ),
651
+										'selected'         => give_get_option('base_country'),
652 652
 										'show_option_all'  => false,
653 653
 										'show_option_none' => false,
654 654
 										'chosen'           => true,
655
-										'placeholder'      => esc_attr__( 'Select a country', 'give' ),
656
-										'data'             => array( 'search-type' => 'no_ajax' ),
657
-									) );
655
+										'placeholder'      => esc_attr__('Select a country', 'give'),
656
+										'data'             => array('search-type' => 'no_ajax'),
657
+									));
658 658
 									?>
659 659
 								</td>
660 660
 							</tr>
661 661
 							<tr>
662 662
 								<th class="col">
663
-									<label for="line1"><?php esc_html_e( 'Address 1:', 'give' ); ?></label>
663
+									<label for="line1"><?php esc_html_e('Address 1:', 'give'); ?></label>
664 664
 								</th>
665 665
 								<td>
666 666
 									<input id="line1" name="line1" type="text" class="medium-text"/>
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
 							</tr>
669 669
 							<tr>
670 670
 								<th class="col">
671
-									<label for="line2"><?php esc_html_e( 'Address 2:', 'give' ); ?></label>
671
+									<label for="line2"><?php esc_html_e('Address 2:', 'give'); ?></label>
672 672
 								</th>
673 673
 								<td>
674 674
 									<input id="line2" type="text" name="line2" value="" class="medium-text"/>
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
 							</tr>
678 678
 							<tr>
679 679
 								<th class="col">
680
-									<label for="city"><?php esc_html_e( 'City:', 'give' ); ?></label>
680
+									<label for="city"><?php esc_html_e('City:', 'give'); ?></label>
681 681
 								</th>
682 682
 								<td>
683 683
 									<input id="city" type="text" name="city" value="" class="medium-text"/>
@@ -685,42 +685,42 @@  discard block
 block discarded – undo
685 685
 							</tr>
686 686
 							<?php
687 687
 							$no_states_country = give_no_states_country_list();
688
-							$base_country      = give_get_option( 'base_country' );
689
-							if ( ! array_key_exists( $base_country, $no_states_country ) ) {
688
+							$base_country      = give_get_option('base_country');
689
+							if ( ! array_key_exists($base_country, $no_states_country)) {
690 690
 								?>
691 691
 								<tr class="give-field-wrap">
692 692
 									<th class="col">
693 693
 										<label
694
-											for="state"><?php esc_html_e( 'State / Province / County:', 'give' ); ?></label>
694
+											for="state"><?php esc_html_e('State / Province / County:', 'give'); ?></label>
695 695
 									</th>
696 696
 									<td>
697 697
 										<?php
698
-										$states     = give_get_states( $base_country );
698
+										$states     = give_get_states($base_country);
699 699
 										$state_args = array(
700 700
 											'name'  => 'state',
701 701
 											'class' => 'regular-text',
702 702
 										);
703 703
 
704
-										if ( empty( $states ) ) {
704
+										if (empty($states)) {
705 705
 
706 706
 											// Show Text field, if empty states.
707
-											$state_args = wp_parse_args( $state_args, array(
708
-												'value' => give_get_option( 'base_state' ),
709
-											) );
710
-											echo Give()->html->text( $state_args );
707
+											$state_args = wp_parse_args($state_args, array(
708
+												'value' => give_get_option('base_state'),
709
+											));
710
+											echo Give()->html->text($state_args);
711 711
 										} else {
712 712
 
713 713
 											// Show Chosen DropDown, if states are not empty.
714
-											$state_args = wp_parse_args( $state_args, array(
714
+											$state_args = wp_parse_args($state_args, array(
715 715
 												'options'          => $states,
716
-												'selected'         => give_get_option( 'base_state' ),
716
+												'selected'         => give_get_option('base_state'),
717 717
 												'show_option_all'  => false,
718 718
 												'show_option_none' => false,
719 719
 												'chosen'           => true,
720
-												'placeholder'      => __( 'Select a state', 'give' ),
721
-												'data'             => array( 'search-type' => 'no_ajax' ),
722
-											) );
723
-											echo Give()->html->select( $state_args );
720
+												'placeholder'      => __('Select a state', 'give'),
721
+												'data'             => array('search-type' => 'no_ajax'),
722
+											));
723
+											echo Give()->html->select($state_args);
724 724
 										}
725 725
 										?>
726 726
 									</td>
@@ -730,7 +730,7 @@  discard block
 block discarded – undo
730 730
 							?>
731 731
 							<tr>
732 732
 								<th class="col">
733
-									<label for="zip"><?php esc_html_e( 'Zip / Postal Code:', 'give' ); ?></label>
733
+									<label for="zip"><?php esc_html_e('Zip / Postal Code:', 'give'); ?></label>
734 734
 								</th>
735 735
 								<td>
736 736
 									<input id="zip" type="text" name="zip" value="" class="medium-text"/>
@@ -738,12 +738,12 @@  discard block
 block discarded – undo
738 738
 							</tr>
739 739
 							<tr>
740 740
 								<td colspan="2">
741
-									<?php wp_nonce_field( 'give-manage-donor-addresses', '_wpnonce', false ); ?>
741
+									<?php wp_nonce_field('give-manage-donor-addresses', '_wpnonce', false); ?>
742 742
 									<input type="hidden" name="address-action" value="add">
743 743
 									<input type="hidden" name="address-id" value="">
744 744
 									<input type="submit" class="button button-primary js-save"
745
-									       value="<?php _e( 'Save', 'give' ); ?>">&nbsp;&nbsp;<button
746
-										class="button js-cancel"><?php _e( 'Cancel', 'give' ); ?></button>
745
+									       value="<?php _e('Save', 'give'); ?>">&nbsp;&nbsp;<button
746
+										class="button js-cancel"><?php _e('Cancel', 'give'); ?></button>
747 747
 								</td>
748 748
 							</tr>
749 749
 							</tbody>
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
 	 *
763 763
 	 * @param Give_Donor $donor The donor object being displayed.
764 764
 	 */
765
-	do_action( 'give_donor_before_tables_wrapper', $donor );
765
+	do_action('give_donor_before_tables_wrapper', $donor);
766 766
 	?>
767 767
 
768 768
 	<div id="donor-tables-wrapper" class="donor-section">
@@ -775,46 +775,46 @@  discard block
 block discarded – undo
775 775
 		 *
776 776
 		 * @param object $donor The donor object being displayed.
777 777
 		 */
778
-		do_action( 'give_donor_before_tables', $donor );
778
+		do_action('give_donor_before_tables', $donor);
779 779
 		?>
780 780
 
781
-		<h3><?php _e( 'Donor Emails', 'give' ); ?></h3>
781
+		<h3><?php _e('Donor Emails', 'give'); ?></h3>
782 782
 
783 783
 		<table class="wp-list-table widefat striped emails">
784 784
 			<thead>
785 785
 			<tr>
786
-				<th><?php _e( 'Email', 'give' ); ?></th>
787
-				<th><?php _e( 'Actions', 'give' ); ?></th>
786
+				<th><?php _e('Email', 'give'); ?></th>
787
+				<th><?php _e('Actions', 'give'); ?></th>
788 788
 			</tr>
789 789
 			</thead>
790 790
 
791 791
 			<tbody>
792
-			<?php if ( ! empty( $donor->emails ) ) { ?>
792
+			<?php if ( ! empty($donor->emails)) { ?>
793 793
 
794
-				<?php foreach ( $donor->emails as $key => $email ) : ?>
794
+				<?php foreach ($donor->emails as $key => $email) : ?>
795 795
 					<tr data-key="<?php echo $key; ?>">
796 796
 						<td>
797 797
 							<?php echo $email; ?>
798
-							<?php if ( 'primary' === $key ) : ?>
798
+							<?php if ('primary' === $key) : ?>
799 799
 								<span class="dashicons dashicons-star-filled primary-email-icon"></span>
800 800
 							<?php endif; ?>
801 801
 						</td>
802 802
 						<td>
803
-							<?php if ( 'primary' !== $key ) : ?>
803
+							<?php if ('primary' !== $key) : ?>
804 804
 								<?php
805
-								$base_url    = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id );
806
-								$promote_url = wp_nonce_url( add_query_arg( array(
807
-									'email'       => rawurlencode( $email ),
805
+								$base_url    = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id);
806
+								$promote_url = wp_nonce_url(add_query_arg(array(
807
+									'email'       => rawurlencode($email),
808 808
 									'give_action' => 'set_donor_primary_email',
809
-								), $base_url ), 'give-set-donor-primary-email' );
810
-								$remove_url  = wp_nonce_url( add_query_arg( array(
811
-									'email'       => rawurlencode( $email ),
809
+								), $base_url), 'give-set-donor-primary-email');
810
+								$remove_url = wp_nonce_url(add_query_arg(array(
811
+									'email'       => rawurlencode($email),
812 812
 									'give_action' => 'remove_donor_email',
813
-								), $base_url ), 'give-remove-donor-email' );
813
+								), $base_url), 'give-remove-donor-email');
814 814
 								?>
815
-								<a href="<?php echo $promote_url; ?>"><?php _e( 'Make Primary', 'give' ); ?></a>
815
+								<a href="<?php echo $promote_url; ?>"><?php _e('Make Primary', 'give'); ?></a>
816 816
 								&nbsp;|&nbsp;
817
-								<a href="<?php echo $remove_url; ?>" class="delete"><?php _e( 'Remove', 'give' ); ?></a>
817
+								<a href="<?php echo $remove_url; ?>" class="delete"><?php _e('Remove', 'give'); ?></a>
818 818
 							<?php endif; ?>
819 819
 						</td>
820 820
 					</tr>
@@ -824,14 +824,14 @@  discard block
 block discarded – undo
824 824
 					<td colspan="2" class="add-donor-email-td">
825 825
 						<div class="add-donor-email-wrapper">
826 826
 							<input type="hidden" name="donor-id" value="<?php echo $donor->id; ?>"/>
827
-							<?php wp_nonce_field( 'give_add_donor_email', 'add_email_nonce', false, true ); ?>
827
+							<?php wp_nonce_field('give_add_donor_email', 'add_email_nonce', false, true); ?>
828 828
 							<input type="email" name="additional-email" value=""
829
-							       placeholder="<?php _e( 'Email Address', 'give' ); ?>"/>&nbsp;
829
+							       placeholder="<?php _e('Email Address', 'give'); ?>"/>&nbsp;
830 830
 							<input type="checkbox" name="make-additional-primary" value="1"
831 831
 							       id="make-additional-primary"/>&nbsp;<label
832
-								for="make-additional-primary"><?php _e( 'Make Primary', 'give' ); ?></label>
832
+								for="make-additional-primary"><?php _e('Make Primary', 'give'); ?></label>
833 833
 							<button class="button-secondary give-add-donor-email"
834
-							        id="add-donor-email"><?php _e( 'Add Email', 'give' ); ?></button>
834
+							        id="add-donor-email"><?php _e('Add Email', 'give'); ?></button>
835 835
 							<span class="spinner"></span>
836 836
 						</div>
837 837
 						<div class="notice-wrap"></div>
@@ -839,54 +839,54 @@  discard block
 block discarded – undo
839 839
 				</tr>
840 840
 			<?php } else { ?>
841 841
 				<tr>
842
-					<td colspan="2"><?php _e( 'No Emails Found', 'give' ); ?></td>
842
+					<td colspan="2"><?php _e('No Emails Found', 'give'); ?></td>
843 843
 				</tr>
844 844
 			<?php }// End if().
845 845
 			?>
846 846
 			</tbody>
847 847
 		</table>
848 848
 
849
-		<h3><?php _e( 'Recent Donations', 'give' ); ?></h3>
849
+		<h3><?php _e('Recent Donations', 'give'); ?></h3>
850 850
 		<?php
851
-		$payment_ids = explode( ',', $donor->payment_ids );
852
-		$payments    = give_get_payments( array(
851
+		$payment_ids = explode(',', $donor->payment_ids);
852
+		$payments    = give_get_payments(array(
853 853
 			'post__in' => $payment_ids,
854
-		) );
855
-		$payments    = array_slice( $payments, 0, 10 );
854
+		));
855
+		$payments    = array_slice($payments, 0, 10);
856 856
 		?>
857 857
 		<table class="wp-list-table widefat striped payments">
858 858
 			<thead>
859 859
 			<tr>
860
-				<th scope="col"><?php _e( 'ID', 'give' ); ?></th>
861
-				<th scope="col"><?php _e( 'Amount', 'give' ); ?></th>
862
-				<th scope="col"><?php _e( 'Date', 'give' ); ?></th>
863
-				<th scope="col"><?php _e( 'Status', 'give' ); ?></th>
864
-				<th scope="col"><?php _e( 'Actions', 'give' ); ?></th>
860
+				<th scope="col"><?php _e('ID', 'give'); ?></th>
861
+				<th scope="col"><?php _e('Amount', 'give'); ?></th>
862
+				<th scope="col"><?php _e('Date', 'give'); ?></th>
863
+				<th scope="col"><?php _e('Status', 'give'); ?></th>
864
+				<th scope="col"><?php _e('Actions', 'give'); ?></th>
865 865
 			</tr>
866 866
 			</thead>
867 867
 			<tbody>
868
-			<?php if ( ! empty( $payments ) ) { ?>
869
-				<?php foreach ( $payments as $payment ) : ?>
868
+			<?php if ( ! empty($payments)) { ?>
869
+				<?php foreach ($payments as $payment) : ?>
870 870
 					<tr>
871
-						<td><?php echo Give()->seq_donation_number->get_serial_code( $payment->ID ); ?></td>
872
-						<td><?php echo give_donation_amount( $payment->ID, array(
871
+						<td><?php echo Give()->seq_donation_number->get_serial_code($payment->ID); ?></td>
872
+						<td><?php echo give_donation_amount($payment->ID, array(
873 873
 								'currency' => true,
874 874
 								'amount'   => true,
875 875
 								'type'     => 'donor'
876
-							) ); ?></td>
877
-						<td><?php echo date_i18n( give_date_format(), strtotime( $payment->post_date ) ); ?></td>
878
-						<td><?php echo give_get_payment_status( $payment, true ); ?></td>
876
+							)); ?></td>
877
+						<td><?php echo date_i18n(give_date_format(), strtotime($payment->post_date)); ?></td>
878
+						<td><?php echo give_get_payment_status($payment, true); ?></td>
879 879
 						<td>
880 880
 							<?php
881 881
 							printf(
882 882
 								'<a href="%1$s" aria-label="%2$s">%3$s</a>',
883
-								admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $payment->ID ),
883
+								admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id='.$payment->ID),
884 884
 								sprintf(
885 885
 								/* translators: %s: Donation ID */
886
-									esc_attr__( 'View Donation %s.', 'give' ),
886
+									esc_attr__('View Donation %s.', 'give'),
887 887
 									$payment->ID
888 888
 								),
889
-								__( 'View Donation', 'give' )
889
+								__('View Donation', 'give')
890 890
 							);
891 891
 							?>
892 892
 
@@ -901,47 +901,47 @@  discard block
 block discarded – undo
901 901
 							 * @param object $donor The donor object being displayed.
902 902
 							 * @param object $payment The payment object being displayed.
903 903
 							 */
904
-							do_action( 'give_donor_recent_purchases_actions', $donor, $payment );
904
+							do_action('give_donor_recent_purchases_actions', $donor, $payment);
905 905
 							?>
906 906
 						</td>
907 907
 					</tr>
908 908
 				<?php endforeach; ?>
909 909
 			<?php } else { ?>
910 910
 				<tr>
911
-					<td colspan="5"><?php _e( 'No donations found.', 'give' ); ?></td>
911
+					<td colspan="5"><?php _e('No donations found.', 'give'); ?></td>
912 912
 				</tr>
913 913
 			<?php }// End if().
914 914
 			?>
915 915
 			</tbody>
916 916
 		</table>
917 917
 
918
-		<h3><?php _e( 'Completed Forms', 'give' ); ?></h3>
918
+		<h3><?php _e('Completed Forms', 'give'); ?></h3>
919 919
 		<?php
920
-		$donations = give_get_users_completed_donations( $donor->email );
920
+		$donations = give_get_users_completed_donations($donor->email);
921 921
 		?>
922 922
 		<table class="wp-list-table widefat striped donations">
923 923
 			<thead>
924 924
 			<tr>
925
-				<th scope="col"><?php _e( 'Form', 'give' ); ?></th>
926
-				<th scope="col" width="120px"><?php _e( 'Actions', 'give' ); ?></th>
925
+				<th scope="col"><?php _e('Form', 'give'); ?></th>
926
+				<th scope="col" width="120px"><?php _e('Actions', 'give'); ?></th>
927 927
 			</tr>
928 928
 			</thead>
929 929
 			<tbody>
930
-			<?php if ( ! empty( $donations ) ) { ?>
931
-				<?php foreach ( $donations as $donation ) : ?>
930
+			<?php if ( ! empty($donations)) { ?>
931
+				<?php foreach ($donations as $donation) : ?>
932 932
 					<tr>
933 933
 						<td><?php echo $donation->post_title; ?></td>
934 934
 						<td>
935 935
 							<?php
936 936
 							printf(
937 937
 								'<a href="%1$s" aria-label="%2$s">%3$s</a>',
938
-								esc_url( admin_url( 'post.php?action=edit&post=' . $donation->ID ) ),
938
+								esc_url(admin_url('post.php?action=edit&post='.$donation->ID)),
939 939
 								sprintf(
940 940
 								/* translators: %s: form name */
941
-									esc_attr__( 'View Form %s.', 'give' ),
941
+									esc_attr__('View Form %s.', 'give'),
942 942
 									$donation->post_title
943 943
 								),
944
-								__( 'View Form', 'give' )
944
+								__('View Form', 'give')
945 945
 							);
946 946
 							?>
947 947
 						</td>
@@ -949,62 +949,62 @@  discard block
 block discarded – undo
949 949
 				<?php endforeach; ?>
950 950
 			<?php } else { ?>
951 951
 				<tr>
952
-					<td colspan="2"><?php _e( 'No completed donations found.', 'give' ); ?></td>
952
+					<td colspan="2"><?php _e('No completed donations found.', 'give'); ?></td>
953 953
 				</tr>
954 954
 			<?php } ?>
955 955
 			</tbody>
956 956
 		</table>
957 957
 
958
-		<h3><?php _e( 'Comments', 'give' ); ?></h3>
958
+		<h3><?php _e('Comments', 'give'); ?></h3>
959 959
 		<?php
960 960
 		// @todo load comment by ajax to improve performance.
961
-		$donations = give_get_users_donations( $donor->email );
961
+		$donations = give_get_users_donations($donor->email);
962 962
 		?>
963 963
 		<table class="wp-list-table widefat striped comments">
964 964
 			<thead>
965 965
 			<tr>
966
-				<th scope="col"><?php _e( 'Donation', 'give' ); ?></th>
967
-				<th scope="col"><?php _e( 'Anonymous', 'give' ); ?></th>
968
-				<th scope="col" colspan="3"><?php _e( 'Comment', 'give' ); ?></th>
966
+				<th scope="col"><?php _e('Donation', 'give'); ?></th>
967
+				<th scope="col"><?php _e('Anonymous', 'give'); ?></th>
968
+				<th scope="col" colspan="3"><?php _e('Comment', 'give'); ?></th>
969 969
 			</tr>
970 970
 			</thead>
971 971
 			<tbody>
972
-			<?php if ( ! empty( $donations ) ) : ?>
973
-				<?php foreach ( $donations as $donation ) : ?>
972
+			<?php if ( ! empty($donations)) : ?>
973
+				<?php foreach ($donations as $donation) : ?>
974 974
 					<?php
975
-					$comment = give_get_donor_donation_comment( $donation->ID, give_get_payment_donor_id( $donation->ID ) );
975
+					$comment = give_get_donor_donation_comment($donation->ID, give_get_payment_donor_id($donation->ID));
976 976
 
977
-					if ( ! $comment instanceof WP_Comment ) {
977
+					if ( ! $comment instanceof WP_Comment) {
978 978
 						continue;
979 979
 					}
980 980
 					?>
981 981
 					<tr>
982 982
 						<td>
983 983
 							<?php
984
-							$donation_number = Give()->seq_donation_number->get_serial_code( $donation );
984
+							$donation_number = Give()->seq_donation_number->get_serial_code($donation);
985 985
 							echo $donation_number;
986 986
 							?>
987 987
 						</td>
988 988
 						<td>
989 989
 							<?php
990
-							echo absint( give_get_payment_meta( $donation->ID, '_give_anonymous_donation' ) )
991
-								? __( 'Yes', 'give' )
992
-								: __( 'No', 'give' );
990
+							echo absint(give_get_payment_meta($donation->ID, '_give_anonymous_donation'))
991
+								? __('Yes', 'give')
992
+								: __('No', 'give');
993 993
 							?>
994 994
 						</td>
995 995
 						<td>
996 996
 							<?php
997
-							echo apply_filters( 'the_content', $comment->comment_content );
997
+							echo apply_filters('the_content', $comment->comment_content);
998 998
 
999 999
 							echo sprintf(
1000 1000
 								'<a href="%1$s" aria-label="%2$s" target="_blank">%3$s</a>',
1001
-								admin_url( "edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id={$donation->ID}#give-payment-donor-comment" ),
1001
+								admin_url("edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id={$donation->ID}#give-payment-donor-comment"),
1002 1002
 								sprintf(
1003 1003
 								/* translators: %s: Comment ID */
1004
-									esc_attr__( 'Edit Comment %s.', 'give' ),
1004
+									esc_attr__('Edit Comment %s.', 'give'),
1005 1005
 									$comment->comment_ID
1006 1006
 								),
1007
-								__( 'Edit Comment', 'give' )
1007
+								__('Edit Comment', 'give')
1008 1008
 							);
1009 1009
 							?>
1010 1010
 						</td>
@@ -1012,7 +1012,7 @@  discard block
 block discarded – undo
1012 1012
 				<?php endforeach; ?>
1013 1013
 			<?php else: ?>
1014 1014
 				<tr>
1015
-					<td colspan="5"><?php _e( 'No comment found.', 'give' ); ?></td>
1015
+					<td colspan="5"><?php _e('No comment found.', 'give'); ?></td>
1016 1016
 				</tr>
1017 1017
 			<?php endif ?>
1018 1018
 			</tbody>
@@ -1026,7 +1026,7 @@  discard block
 block discarded – undo
1026 1026
 		 *
1027 1027
 		 * @param object $donor The donor object being displayed.
1028 1028
 		 */
1029
-		do_action( 'give_donor_after_tables', $donor );
1029
+		do_action('give_donor_after_tables', $donor);
1030 1030
 		?>
1031 1031
 
1032 1032
 	</div>
@@ -1039,7 +1039,7 @@  discard block
 block discarded – undo
1039 1039
 	 *
1040 1040
 	 * @param object $donor The donor object being displayed.
1041 1041
 	 */
1042
-	do_action( 'give_donor_card_bottom', $donor );
1042
+	do_action('give_donor_card_bottom', $donor);
1043 1043
 
1044 1044
 }
1045 1045
 
@@ -1052,31 +1052,31 @@  discard block
 block discarded – undo
1052 1052
  *
1053 1053
  * @return void
1054 1054
  */
1055
-function give_donor_notes_view( $donor ) {
1055
+function give_donor_notes_view($donor) {
1056 1056
 
1057
-	$paged       = isset( $_GET['paged'] ) && is_numeric( $_GET['paged'] ) ? $_GET['paged'] : 1;
1058
-	$paged       = absint( $paged );
1057
+	$paged       = isset($_GET['paged']) && is_numeric($_GET['paged']) ? $_GET['paged'] : 1;
1058
+	$paged       = absint($paged);
1059 1059
 	$note_count  = $donor->get_notes_count();
1060
-	$per_page    = apply_filters( 'give_donor_notes_per_page', 20 );
1061
-	$total_pages = ceil( $note_count / $per_page );
1062
-	$donor_notes = $donor->get_notes( $per_page, $paged );
1060
+	$per_page    = apply_filters('give_donor_notes_per_page', 20);
1061
+	$total_pages = ceil($note_count / $per_page);
1062
+	$donor_notes = $donor->get_notes($per_page, $paged);
1063 1063
 	?>
1064 1064
 
1065 1065
 	<div id="donor-notes-wrapper">
1066 1066
 		<div class="donor-notes-header">
1067
-			<?php echo get_avatar( $donor->email, 30 ); ?> <span><?php echo $donor->name; ?></span>
1067
+			<?php echo get_avatar($donor->email, 30); ?> <span><?php echo $donor->name; ?></span>
1068 1068
 		</div>
1069
-		<h3><?php _e( 'Notes', 'give' ); ?></h3>
1069
+		<h3><?php _e('Notes', 'give'); ?></h3>
1070 1070
 
1071
-		<?php if ( 1 == $paged ) : ?>
1071
+		<?php if (1 == $paged) : ?>
1072 1072
 			<div style="display: block; margin-bottom: 55px;">
1073 1073
 				<form id="give-add-donor-note" method="post"
1074
-				      action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=notes&id=' . $donor->id ); ?>">
1074
+				      action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=notes&id='.$donor->id); ?>">
1075 1075
 					<textarea id="donor-note" name="donor_note" class="donor-note-input" rows="10"></textarea>
1076 1076
 					<br/>
1077 1077
 					<input type="hidden" id="donor-id" name="customer_id" value="<?php echo $donor->id; ?>"/>
1078 1078
 					<input type="hidden" name="give_action" value="add-donor-note"/>
1079
-					<?php wp_nonce_field( 'add-donor-note', 'add_donor_note_nonce', true, true ); ?>
1079
+					<?php wp_nonce_field('add-donor-note', 'add_donor_note_nonce', true, true); ?>
1080 1080
 					<input id="add-donor-note" class="right button-primary" type="submit" value="Add Note"/>
1081 1081
 				</form>
1082 1082
 			</div>
@@ -1091,26 +1091,26 @@  discard block
 block discarded – undo
1091 1091
 			'show_all' => true,
1092 1092
 		);
1093 1093
 
1094
-		echo paginate_links( $pagination_args );
1094
+		echo paginate_links($pagination_args);
1095 1095
 		?>
1096 1096
 
1097 1097
 		<div id="give-donor-notes" class="postbox">
1098
-			<?php if ( count( $donor_notes ) > 0 ) { ?>
1099
-				<?php foreach ( $donor_notes as $key => $note ) : ?>
1098
+			<?php if (count($donor_notes) > 0) { ?>
1099
+				<?php foreach ($donor_notes as $key => $note) : ?>
1100 1100
 					<div class="donor-note-wrapper dashboard-comment-wrap comment-item">
1101 1101
 					<span class="note-content-wrap">
1102
-						<?php echo stripslashes( $note ); ?>
1102
+						<?php echo stripslashes($note); ?>
1103 1103
 					</span>
1104 1104
 					</div>
1105 1105
 				<?php endforeach; ?>
1106 1106
 			<?php } else { ?>
1107 1107
 				<div class="give-no-donor-notes">
1108
-					<?php _e( 'No donor notes found.', 'give' ); ?>
1108
+					<?php _e('No donor notes found.', 'give'); ?>
1109 1109
 				</div>
1110 1110
 			<?php } ?>
1111 1111
 		</div>
1112 1112
 
1113
-		<?php echo paginate_links( $pagination_args ); ?>
1113
+		<?php echo paginate_links($pagination_args); ?>
1114 1114
 
1115 1115
 	</div>
1116 1116
 
@@ -1126,9 +1126,9 @@  discard block
 block discarded – undo
1126 1126
  *
1127 1127
  * @return void
1128 1128
  */
1129
-function give_donor_delete_view( $donor ) {
1129
+function give_donor_delete_view($donor) {
1130 1130
 
1131
-	$donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' );
1131
+	$donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments');
1132 1132
 
1133 1133
 	/**
1134 1134
 	 * Fires in donor delete screen, above the content.
@@ -1137,16 +1137,16 @@  discard block
 block discarded – undo
1137 1137
 	 *
1138 1138
 	 * @param object $donor The donor object being displayed.
1139 1139
 	 */
1140
-	do_action( 'give_donor_delete_top', $donor );
1140
+	do_action('give_donor_delete_top', $donor);
1141 1141
 	?>
1142 1142
 
1143 1143
 	<div class="info-wrapper donor-section">
1144 1144
 
1145 1145
 		<form id="delete-donor" method="post"
1146
-		      action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $donor->id ); ?>">
1146
+		      action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$donor->id); ?>">
1147 1147
 
1148 1148
 			<div class="donor-notes-header">
1149
-				<?php echo get_avatar( $donor->email, 30 ); ?> <span><?php echo $donor->name; ?></span>
1149
+				<?php echo get_avatar($donor->email, 30); ?> <span><?php echo $donor->name; ?></span>
1150 1150
 			</div>
1151 1151
 
1152 1152
 
@@ -1154,22 +1154,22 @@  discard block
 block discarded – undo
1154 1154
 
1155 1155
 				<span class="delete-donor-options">
1156 1156
 					<p>
1157
-						<?php echo Give()->html->checkbox( array(
1157
+						<?php echo Give()->html->checkbox(array(
1158 1158
 							'name' => 'give-donor-delete-confirm',
1159
-						) ); ?>
1159
+						)); ?>
1160 1160
 						<label
1161
-							for="give-donor-delete-confirm"><?php _e( 'Are you sure you want to delete this donor?', 'give' ); ?></label>
1161
+							for="give-donor-delete-confirm"><?php _e('Are you sure you want to delete this donor?', 'give'); ?></label>
1162 1162
 					</p>
1163 1163
 
1164 1164
 					<p>
1165
-						<?php echo Give()->html->checkbox( array(
1165
+						<?php echo Give()->html->checkbox(array(
1166 1166
 							'name'    => 'give-donor-delete-records',
1167 1167
 							'options' => array(
1168 1168
 								'disabled' => true,
1169 1169
 							),
1170
-						) ); ?>
1170
+						)); ?>
1171 1171
 						<label
1172
-							for="give-donor-delete-records"><?php _e( 'Delete all associated donations and records?', 'give' ); ?></label>
1172
+							for="give-donor-delete-records"><?php _e('Delete all associated donations and records?', 'give'); ?></label>
1173 1173
 					</p>
1174 1174
 
1175 1175
 					<?php
@@ -1182,19 +1182,19 @@  discard block
 block discarded – undo
1182 1182
 					 *
1183 1183
 					 * @param object $donor The donor object being displayed.
1184 1184
 					 */
1185
-					do_action( 'give_donor_delete_inputs', $donor );
1185
+					do_action('give_donor_delete_inputs', $donor);
1186 1186
 					?>
1187 1187
 				</span>
1188 1188
 
1189 1189
 				<span id="donor-edit-actions">
1190 1190
 					<input type="hidden" name="donor_id" value="<?php echo $donor->id; ?>"/>
1191
-					<?php wp_nonce_field( 'give-delete-donor', '_wpnonce', false, true ); ?>
1191
+					<?php wp_nonce_field('give-delete-donor', '_wpnonce', false, true); ?>
1192 1192
 					<input type="hidden" name="give_action" value="delete_donor"/>
1193 1193
 					<input type="submit" disabled="disabled" id="give-delete-donor" class="button-primary"
1194
-					       value="<?php _e( 'Delete Donor', 'give' ); ?>"/>
1194
+					       value="<?php _e('Delete Donor', 'give'); ?>"/>
1195 1195
 					<a id="give-delete-donor-cancel"
1196
-					   href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ); ?>"
1197
-					   class="delete"><?php _e( 'Cancel', 'give' ); ?></a>
1196
+					   href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id); ?>"
1197
+					   class="delete"><?php _e('Cancel', 'give'); ?></a>
1198 1198
 				</span>
1199 1199
 
1200 1200
 			</div>
@@ -1210,5 +1210,5 @@  discard block
 block discarded – undo
1210 1210
 	 *
1211 1211
 	 * @param object $donor The donor object being displayed.
1212 1212
 	 */
1213
-	do_action( 'give_donor_delete_bottom', $donor );
1213
+	do_action('give_donor_delete_bottom', $donor);
1214 1214
 }
Please login to merge, or discard this patch.
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -427,9 +427,12 @@  discard block
 block discarded – undo
427 427
 										<?php if ( ! empty( $userdata ) ) : ?>
428 428
 											<span
429 429
 												data-key="user_id">#<?php echo $donor->user_id . ' - ' . $userdata->display_name; ?></span>
430
-										<?php else : ?>
430
+										<?php else {
431
+	: ?>
431 432
 											<span
432
-												data-key="user_id"><?php esc_html_e( 'Unregistered', 'give' ); ?></span>
433
+												data-key="user_id"><?php esc_html_e( 'Unregistered', 'give' );
434
+}
435
+?></span>
433 436
 										<?php endif; ?>
434 437
 									<?php if ( current_user_can( $donor_edit_role ) && intval( $donor->user_id ) > 0 ) :
435 438
 
@@ -1010,9 +1013,12 @@  discard block
 block discarded – undo
1010 1013
 						</td>
1011 1014
 					</tr>
1012 1015
 				<?php endforeach; ?>
1013
-			<?php else: ?>
1016
+			<?php else {
1017
+	: ?>
1014 1018
 				<tr>
1015
-					<td colspan="5"><?php _e( 'No comment found.', 'give' ); ?></td>
1019
+					<td colspan="5"><?php _e( 'No comment found.', 'give' );
1020
+}
1021
+?></td>
1016 1022
 				</tr>
1017 1023
 			<?php endif ?>
1018 1024
 			</tbody>
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-reset-stats.php 1 patch
Spacing   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly.
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
 	/**
50 50
 	 * Constructor.
51 51
 	 */
52
-	public function __construct( $_step = 1 ) {
53
-		parent::__construct( $_step );
52
+	public function __construct($_step = 1) {
53
+		parent::__construct($_step);
54 54
 
55 55
 		$this->is_writable = true;
56 56
 	}
@@ -67,16 +67,16 @@  discard block
 block discarded – undo
67 67
 	public function get_data() {
68 68
 		global $wpdb;
69 69
 
70
-		$items = $this->get_stored_data( 'give_temp_reset_ids' );
70
+		$items = $this->get_stored_data('give_temp_reset_ids');
71 71
 
72
-		if ( ! is_array( $items ) ) {
72
+		if ( ! is_array($items)) {
73 73
 			return false;
74 74
 		}
75 75
 
76
-		$offset     = ( $this->step - 1 ) * $this->per_step;
77
-		$step_items = array_slice( $items, $offset, $this->per_step );
76
+		$offset     = ($this->step - 1) * $this->per_step;
77
+		$step_items = array_slice($items, $offset, $this->per_step);
78 78
 
79
-		if ( $step_items ) {
79
+		if ($step_items) {
80 80
 
81 81
 			$step_ids = array(
82 82
 				'customers' => array(),
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
 				'other'     => array(),
85 85
 			);
86 86
 
87
-			foreach ( $step_items as $item ) {
87
+			foreach ($step_items as $item) {
88 88
 
89
-				switch ( $item['type'] ) {
89
+				switch ($item['type']) {
90 90
 					case 'customer':
91 91
 						$step_ids['customers'][] = $item['id'];
92 92
 						break;
@@ -94,24 +94,24 @@  discard block
 block discarded – undo
94 94
 						$step_ids['give_forms'][] = $item['id'];
95 95
 						break;
96 96
 					default:
97
-						$item_type                = apply_filters( 'give_reset_item_type', 'other', $item );
98
-						$step_ids[ $item_type ][] = $item['id'];
97
+						$item_type                = apply_filters('give_reset_item_type', 'other', $item);
98
+						$step_ids[$item_type][] = $item['id'];
99 99
 						break;
100 100
 				}
101 101
 			}
102 102
 
103 103
 			$sql = array();
104
-			$meta_table = __give_v20_bc_table_details('form' );
104
+			$meta_table = __give_v20_bc_table_details('form');
105 105
 
106
-			foreach ( $step_ids as $type => $ids ) {
106
+			foreach ($step_ids as $type => $ids) {
107 107
 
108
-				if ( empty( $ids ) ) {
108
+				if (empty($ids)) {
109 109
 					continue;
110 110
 				}
111 111
 
112
-				$ids = implode( ',', $ids );
112
+				$ids = implode(',', $ids);
113 113
 
114
-				switch ( $type ) {
114
+				switch ($type) {
115 115
 					case 'customers':
116 116
 						$sql[]           = "DELETE FROM $wpdb->donors WHERE id IN ($ids)";
117 117
 						$table_name      = $wpdb->donors;
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 								OR $wpdb->term_taxonomy.taxonomy = %s
140 140
 							)
141 141
 							",
142
-							array( 'give_forms_category', 'give_forms_tag' )
142
+							array('give_forms_category', 'give_forms_tag')
143 143
 						);
144 144
 						$sql[] = $wpdb->prepare(
145 145
 							"
@@ -147,21 +147,21 @@  discard block
 block discarded – undo
147 147
 							WHERE $wpdb->term_taxonomy.taxonomy = %s
148 148
 							OR $wpdb->term_taxonomy.taxonomy = %s
149 149
 							",
150
-							array( 'give_forms_category', 'give_forms_tag' )
150
+							array('give_forms_category', 'give_forms_tag')
151 151
 						);
152 152
 						break;
153 153
 				}
154 154
 
155
-				if ( ! in_array( $type, array( 'customers', 'forms', 'other' ) ) ) {
155
+				if ( ! in_array($type, array('customers', 'forms', 'other'))) {
156 156
 					// Allows other types of custom post types to filter on their own post_type
157 157
 					// and add items to the query list, for the IDs found in their post type.
158
-					$sql = apply_filters( "give_reset_add_queries_{$type}", $sql, $ids );
158
+					$sql = apply_filters("give_reset_add_queries_{$type}", $sql, $ids);
159 159
 				}
160 160
 			}
161 161
 
162
-			if ( ! empty( $sql ) ) {
163
-				foreach ( $sql as $query ) {
164
-					$wpdb->query( $query );
162
+			if ( ! empty($sql)) {
163
+				foreach ($sql as $query) {
164
+					$wpdb->query($query);
165 165
 				}
166 166
 			}
167 167
 
@@ -181,16 +181,16 @@  discard block
 block discarded – undo
181 181
 	 */
182 182
 	public function get_percentage_complete() {
183 183
 
184
-		$items = $this->get_stored_data( 'give_temp_reset_ids' );
185
-		$total = count( $items );
184
+		$items = $this->get_stored_data('give_temp_reset_ids');
185
+		$total = count($items);
186 186
 
187 187
 		$percentage = 100;
188 188
 
189
-		if ( $total > 0 ) {
190
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
189
+		if ($total > 0) {
190
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
191 191
 		}
192 192
 
193
-		if ( $percentage > 100 ) {
193
+		if ($percentage > 100) {
194 194
 			$percentage = 100;
195 195
 		}
196 196
 
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 	 *
205 205
 	 * @param array $request The Form Data passed into the batch processing.
206 206
 	 */
207
-	public function set_properties( $request ) {
207
+	public function set_properties($request) {
208 208
 	}
209 209
 
210 210
 	/**
@@ -215,26 +215,26 @@  discard block
 block discarded – undo
215 215
 	 */
216 216
 	public function process_step() {
217 217
 
218
-		if ( ! $this->can_export() ) {
219
-			wp_die( esc_html__( 'You do not have permission to reset data.', 'give' ), esc_html__( 'Error', 'give' ), array(
218
+		if ( ! $this->can_export()) {
219
+			wp_die(esc_html__('You do not have permission to reset data.', 'give'), esc_html__('Error', 'give'), array(
220 220
 				'response' => 403,
221
-			) );
221
+			));
222 222
 		}
223 223
 
224 224
 		$had_data = $this->get_data();
225 225
 
226
-		if ( $had_data ) {
226
+		if ($had_data) {
227 227
 			$this->done = false;
228 228
 
229 229
 			return true;
230 230
 		} else {
231
-			update_option( 'give_earnings_total', 0, false );
232
-			Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) );
231
+			update_option('give_earnings_total', 0, false);
232
+			Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats'));
233 233
 
234
-			$this->delete_data( 'give_temp_reset_ids' );
234
+			$this->delete_data('give_temp_reset_ids');
235 235
 
236 236
 			$this->done    = true;
237
-			$this->message = esc_html__( 'Donation forms, income, donations counts, and logs successfully reset.', 'give' );
237
+			$this->message = esc_html__('Donation forms, income, donations counts, and logs successfully reset.', 'give');
238 238
 
239 239
 			return false;
240 240
 		}
@@ -267,26 +267,26 @@  discard block
 block discarded – undo
267 267
 	 */
268 268
 	public function pre_fetch() {
269 269
 
270
-		if ( $this->step == 1 ) {
271
-			$this->delete_data( 'give_temp_reset_ids' );
270
+		if ($this->step == 1) {
271
+			$this->delete_data('give_temp_reset_ids');
272 272
 		}
273 273
 
274
-		$items = get_option( 'give_temp_reset_ids', false );
274
+		$items = get_option('give_temp_reset_ids', false);
275 275
 
276
-		if ( false === $items ) {
276
+		if (false === $items) {
277 277
 			$items = array();
278 278
 
279
-			$give_types_for_reset = array( 'give_forms', 'give_payment' );
280
-			$give_types_for_reset = apply_filters( 'give_reset_store_post_types', $give_types_for_reset );
279
+			$give_types_for_reset = array('give_forms', 'give_payment');
280
+			$give_types_for_reset = apply_filters('give_reset_store_post_types', $give_types_for_reset);
281 281
 
282
-			$args = apply_filters( 'give_tools_reset_stats_total_args', array(
282
+			$args = apply_filters('give_tools_reset_stats_total_args', array(
283 283
 				'post_type'      => $give_types_for_reset,
284 284
 				'post_status'    => 'any',
285
-				'posts_per_page' => - 1,
286
-			) );
285
+				'posts_per_page' => -1,
286
+			));
287 287
 
288
-			$posts = get_posts( $args );
289
-			foreach ( $posts as $post ) {
288
+			$posts = get_posts($args);
289
+			foreach ($posts as $post) {
290 290
 				$items[] = array(
291 291
 					'id'   => (int) $post->ID,
292 292
 					'type' => $post->post_type,
@@ -294,10 +294,10 @@  discard block
 block discarded – undo
294 294
 			}
295 295
 
296 296
 			$donor_args = array(
297
-				'number' => - 1,
297
+				'number' => -1,
298 298
 			);
299
-			$donors     = Give()->donors->get_donors( $donor_args );
300
-			foreach ( $donors as $donor ) {
299
+			$donors     = Give()->donors->get_donors($donor_args);
300
+			foreach ($donors as $donor) {
301 301
 				$items[] = array(
302 302
 					'id'   => (int) $donor->id,
303 303
 					'type' => 'customer',
@@ -306,9 +306,9 @@  discard block
 block discarded – undo
306 306
 
307 307
 			// Allow filtering of items to remove with an unassociative array for each item
308 308
 			// The array contains the unique ID of the item, and a 'type' for you to use in the execution of the get_data method
309
-			$items = apply_filters( 'give_reset_items', $items );
309
+			$items = apply_filters('give_reset_items', $items);
310 310
 
311
-			$this->store_data( 'give_temp_reset_ids', $items );
311
+			$this->store_data('give_temp_reset_ids', $items);
312 312
 		}// End if().
313 313
 
314 314
 	}
@@ -322,17 +322,17 @@  discard block
 block discarded – undo
322 322
 	 *
323 323
 	 * @return mixed       Returns the data from the database.
324 324
 	 */
325
-	private function get_stored_data( $key ) {
325
+	private function get_stored_data($key) {
326 326
 		global $wpdb;
327
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s", $key ) );
327
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = %s", $key));
328 328
 
329
-		if ( empty( $value ) ) {
329
+		if (empty($value)) {
330 330
 			return false;
331 331
 		}
332 332
 
333
-		$maybe_json = json_decode( $value );
334
-		if ( ! is_null( $maybe_json ) ) {
335
-			$value = json_decode( $value, true );
333
+		$maybe_json = json_decode($value);
334
+		if ( ! is_null($maybe_json)) {
335
+			$value = json_decode($value, true);
336 336
 		}
337 337
 
338 338
 		return (array) $value;
@@ -348,10 +348,10 @@  discard block
 block discarded – undo
348 348
 	 *
349 349
 	 * @return void
350 350
 	 */
351
-	private function store_data( $key, $value ) {
351
+	private function store_data($key, $value) {
352 352
 		global $wpdb;
353 353
 
354
-		$value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value );
354
+		$value = is_array($value) ? wp_json_encode($value) : esc_attr($value);
355 355
 
356 356
 		$data = array(
357 357
 			'option_name'  => $key,
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 			'%s',
366 366
 		);
367 367
 
368
-		$wpdb->replace( $wpdb->options, $data, $formats );
368
+		$wpdb->replace($wpdb->options, $data, $formats);
369 369
 	}
370 370
 
371 371
 	/**
@@ -377,11 +377,11 @@  discard block
 block discarded – undo
377 377
 	 *
378 378
 	 * @return void
379 379
 	 */
380
-	private function delete_data( $key ) {
380
+	private function delete_data($key) {
381 381
 		global $wpdb;
382
-		$wpdb->delete( $wpdb->options, array(
382
+		$wpdb->delete($wpdb->options, array(
383 383
 			'option_name' => $key,
384
-		) );
384
+		));
385 385
 	}
386 386
 
387 387
 }
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-recount-income.php 1 patch
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly.
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 	/**
47 47
 	 * Constructor.
48 48
 	 */
49
-	public function __construct( $_step = 1 ) {
50
-		parent::__construct( $_step );
49
+	public function __construct($_step = 1) {
50
+		parent::__construct($_step);
51 51
 
52 52
 		$this->is_writable = true;
53 53
 	}
@@ -61,33 +61,33 @@  discard block
 block discarded – undo
61 61
 	 */
62 62
 	public function get_data() {
63 63
 
64
-		if ( $this->step == 1 ) {
65
-			$this->delete_data( 'give_temp_recount_earnings' );
64
+		if ($this->step == 1) {
65
+			$this->delete_data('give_temp_recount_earnings');
66 66
 		}
67 67
 
68
-		$total = get_option( 'give_temp_recount_earnings', false );
68
+		$total = get_option('give_temp_recount_earnings', false);
69 69
 
70
-		if ( false === $total ) {
70
+		if (false === $total) {
71 71
 			$total = (float) 0;
72
-			$this->store_data( 'give_temp_recount_earnings', $total );
72
+			$this->store_data('give_temp_recount_earnings', $total);
73 73
 		}
74 74
 
75
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
75
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
76 76
 
77
-		$args = apply_filters( 'give_recount_earnings_args', array(
77
+		$args = apply_filters('give_recount_earnings_args', array(
78 78
 			'number' => $this->per_step,
79 79
 			'page'   => $this->step,
80 80
 			'status' => $accepted_statuses,
81 81
 			'fields' => 'ids'
82
-		) );
82
+		));
83 83
 
84
-		$payments = give_get_payments( $args );
84
+		$payments = give_get_payments($args);
85 85
 
86
-		if ( ! empty( $payments ) ) {
86
+		if ( ! empty($payments)) {
87 87
 
88
-			foreach ( $payments as $payment ) {
88
+			foreach ($payments as $payment) {
89 89
 				// Get the payment amount.
90
-				$payment_amount = give_get_meta( $payment->ID, '_give_payment_total', true );
90
+				$payment_amount = give_get_meta($payment->ID, '_give_payment_total', true);
91 91
 
92 92
 				/**
93 93
 				 * Filter the payment amount.
@@ -96,28 +96,28 @@  discard block
 block discarded – undo
96 96
 				 */
97 97
 				$donation_amount = apply_filters(
98 98
 					'give_donation_amount',
99
-					give_format_amount( $payment_amount, array( 'donation_id' => $payment->ID ) ),
99
+					give_format_amount($payment_amount, array('donation_id' => $payment->ID)),
100 100
 					$payment->total,
101 101
 					$payment->ID,
102
-					array( 'type' => 'stats', 'currency' => false, 'amount' => false )
102
+					array('type' => 'stats', 'currency' => false, 'amount' => false)
103 103
 				);
104 104
 
105
-				$total += (float) give_maybe_sanitize_amount( $donation_amount );
105
+				$total += (float) give_maybe_sanitize_amount($donation_amount);
106 106
 			}
107 107
 
108
-			if ( $total < 0 ) {
108
+			if ($total < 0) {
109 109
 				$totals = 0;
110 110
 			}
111 111
 
112
-			$total = round( $total, give_get_price_decimals() );
112
+			$total = round($total, give_get_price_decimals());
113 113
 
114
-			$this->store_data( 'give_temp_recount_earnings', $total );
114
+			$this->store_data('give_temp_recount_earnings', $total);
115 115
 
116 116
 			return true;
117 117
 
118 118
 		}
119 119
 
120
-		update_option( 'give_earnings_total', $total, false );
120
+		update_option('give_earnings_total', $total, false);
121 121
 
122 122
 		return false;
123 123
 
@@ -131,25 +131,25 @@  discard block
 block discarded – undo
131 131
 	 */
132 132
 	public function get_percentage_complete() {
133 133
 
134
-		$total = $this->get_stored_data( 'give_recount_earnings_total' );
134
+		$total = $this->get_stored_data('give_recount_earnings_total');
135 135
 
136
-		if ( false === $total ) {
137
-			$args = apply_filters( 'give_recount_earnings_total_args', array() );
136
+		if (false === $total) {
137
+			$args = apply_filters('give_recount_earnings_total_args', array());
138 138
 
139
-			$counts = give_count_payments( $args );
140
-			$total  = absint( $counts->publish );
141
-			$total  = apply_filters( 'give_recount_store_earnings_total', $total );
139
+			$counts = give_count_payments($args);
140
+			$total  = absint($counts->publish);
141
+			$total  = apply_filters('give_recount_store_earnings_total', $total);
142 142
 
143
-			$this->store_data( 'give_recount_earnings_total', $total );
143
+			$this->store_data('give_recount_earnings_total', $total);
144 144
 		}
145 145
 
146 146
 		$percentage = 100;
147 147
 
148
-		if ( $total > 0 ) {
149
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
148
+		if ($total > 0) {
149
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
150 150
 		}
151 151
 
152
-		if ( $percentage > 100 ) {
152
+		if ($percentage > 100) {
153 153
 			$percentage = 100;
154 154
 		}
155 155
 
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 	 *
164 164
 	 * @param array $request The Form Data passed into the batch processing
165 165
 	 */
166
-	public function set_properties( $request ) {
166
+	public function set_properties($request) {
167 167
 	}
168 168
 
169 169
 	/**
@@ -174,21 +174,21 @@  discard block
 block discarded – undo
174 174
 	 */
175 175
 	public function process_step() {
176 176
 
177
-		if ( ! $this->can_export() ) {
178
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
177
+		if ( ! $this->can_export()) {
178
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
179 179
 		}
180 180
 
181 181
 		$had_data = $this->get_data();
182 182
 
183
-		if ( $had_data ) {
183
+		if ($had_data) {
184 184
 			$this->done = false;
185 185
 
186 186
 			return true;
187 187
 		} else {
188
-			$this->delete_data( 'give_recount_earnings_total' );
189
-			$this->delete_data( 'give_temp_recount_earnings' );
188
+			$this->delete_data('give_recount_earnings_total');
189
+			$this->delete_data('give_temp_recount_earnings');
190 190
 			$this->done    = true;
191
-			$this->message = esc_html__( 'Income stats have been successfully recounted.', 'give' );
191
+			$this->message = esc_html__('Income stats have been successfully recounted.', 'give');
192 192
 
193 193
 			return false;
194 194
 		}
@@ -225,17 +225,17 @@  discard block
 block discarded – undo
225 225
 	 *
226 226
 	 * @return mixed       Returns the data from the database
227 227
 	 */
228
-	private function get_stored_data( $key ) {
228
+	private function get_stored_data($key) {
229 229
 		global $wpdb;
230
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
230
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
231 231
 
232
-		if ( empty( $value ) ) {
232
+		if (empty($value)) {
233 233
 			return false;
234 234
 		}
235 235
 
236
-		$maybe_json = json_decode( $value );
237
-		if ( ! is_null( $maybe_json ) ) {
238
-			$value = json_decode( $value, true );
236
+		$maybe_json = json_decode($value);
237
+		if ( ! is_null($maybe_json)) {
238
+			$value = json_decode($value, true);
239 239
 		}
240 240
 
241 241
 		return $value;
@@ -251,10 +251,10 @@  discard block
 block discarded – undo
251 251
 	 *
252 252
 	 * @return void
253 253
 	 */
254
-	private function store_data( $key, $value ) {
254
+	private function store_data($key, $value) {
255 255
 		global $wpdb;
256 256
 
257
-		$value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value );
257
+		$value = is_array($value) ? wp_json_encode($value) : esc_attr($value);
258 258
 
259 259
 		$data = array(
260 260
 			'option_name'  => $key,
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 			'%s',
269 269
 		);
270 270
 
271
-		$wpdb->replace( $wpdb->options, $data, $formats );
271
+		$wpdb->replace($wpdb->options, $data, $formats);
272 272
 	}
273 273
 
274 274
 	/**
@@ -280,9 +280,9 @@  discard block
 block discarded – undo
280 280
 	 *
281 281
 	 * @return void
282 282
 	 */
283
-	private function delete_data( $key ) {
283
+	private function delete_data($key) {
284 284
 		global $wpdb;
285
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
285
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
286 286
 	}
287 287
 
288 288
 }
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-delete-test-transactions.php 1 patch
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly.
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 	/**
47 47
 	 * Constructor.
48 48
 	 */
49
-	public function __construct( $_step = 1 ) {
50
-		parent::__construct( $_step );
49
+	public function __construct($_step = 1) {
50
+		parent::__construct($_step);
51 51
 
52 52
 		$this->is_writable = true;
53 53
 	}
@@ -62,20 +62,20 @@  discard block
 block discarded – undo
62 62
 	 * @return array|bool $data The data for the CSV file
63 63
 	 */
64 64
 	public function get_data() {
65
-		$items = $this->get_stored_data( 'give_temp_delete_test_ids' );
65
+		$items = $this->get_stored_data('give_temp_delete_test_ids');
66 66
 
67
-		if ( ! is_array( $items ) ) {
67
+		if ( ! is_array($items)) {
68 68
 			return false;
69 69
 		}
70 70
 
71
-		$offset     = ( $this->step - 1 ) * $this->per_step;
72
-		$step_items = array_slice( $items, $offset, $this->per_step );
73
-		$meta_table = __give_v20_bc_table_details( 'payment' );
71
+		$offset     = ($this->step - 1) * $this->per_step;
72
+		$step_items = array_slice($items, $offset, $this->per_step);
73
+		$meta_table = __give_v20_bc_table_details('payment');
74 74
 
75
-		if ( $step_items ) {
76
-			foreach ( $step_items as $item ) {
75
+		if ($step_items) {
76
+			foreach ($step_items as $item) {
77 77
 				// Delete the main payment.
78
-				give_delete_donation( absint( $item['id'] ) );
78
+				give_delete_donation(absint($item['id']));
79 79
 			}
80 80
 			return true;
81 81
 		}
@@ -91,16 +91,16 @@  discard block
 block discarded – undo
91 91
 	 */
92 92
 	public function get_percentage_complete() {
93 93
 
94
-		$items = $this->get_stored_data( 'give_temp_delete_test_ids', false );
95
-		$total = count( $items );
94
+		$items = $this->get_stored_data('give_temp_delete_test_ids', false);
95
+		$total = count($items);
96 96
 
97 97
 		$percentage = 100;
98 98
 
99
-		if ( $total > 0 ) {
100
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
99
+		if ($total > 0) {
100
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
101 101
 		}
102 102
 
103
-		if ( $percentage > 100 ) {
103
+		if ($percentage > 100) {
104 104
 			$percentage = 100;
105 105
 		}
106 106
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	 *
115 115
 	 * @param array $request The Form Data passed into the batch processing
116 116
 	 */
117
-	public function set_properties( $request ) {
117
+	public function set_properties($request) {
118 118
 	}
119 119
 
120 120
 	/**
@@ -125,24 +125,24 @@  discard block
 block discarded – undo
125 125
 	 */
126 126
 	public function process_step() {
127 127
 
128
-		if ( ! $this->can_export() ) {
129
-			wp_die( __( 'You do not have permission to delete test transactions.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
128
+		if ( ! $this->can_export()) {
129
+			wp_die(__('You do not have permission to delete test transactions.', 'give'), __('Error', 'give'), array('response' => 403));
130 130
 		}
131 131
 
132 132
 		$had_data = $this->get_data();
133 133
 
134
-		if ( $had_data ) {
134
+		if ($had_data) {
135 135
 			$this->done = false;
136 136
 
137 137
 			return true;
138 138
 		} else {
139
-			update_option( 'give_earnings_total', give_get_total_earnings( true ), false );
140
-			Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) );
139
+			update_option('give_earnings_total', give_get_total_earnings(true), false);
140
+			Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats'));
141 141
 
142
-			$this->delete_data( 'give_temp_delete_test_ids' );
142
+			$this->delete_data('give_temp_delete_test_ids');
143 143
 
144 144
 			$this->done    = true;
145
-			$this->message = __( 'Test transactions successfully deleted.', 'give' );
145
+			$this->message = __('Test transactions successfully deleted.', 'give');
146 146
 
147 147
 			return false;
148 148
 		}
@@ -175,27 +175,27 @@  discard block
 block discarded – undo
175 175
 	 */
176 176
 	public function pre_fetch() {
177 177
 
178
-		if ( $this->step == 1 ) {
179
-			$this->delete_data( 'give_temp_delete_test_ids' );
178
+		if ($this->step == 1) {
179
+			$this->delete_data('give_temp_delete_test_ids');
180 180
 		}
181 181
 
182
-		$items = get_option( 'give_temp_delete_test_ids', false );
182
+		$items = get_option('give_temp_delete_test_ids', false);
183 183
 
184
-		if ( false === $items ) {
184
+		if (false === $items) {
185 185
 			$items = array();
186 186
 
187
-			$args = apply_filters( 'give_tools_reset_stats_total_args', array(
187
+			$args = apply_filters('give_tools_reset_stats_total_args', array(
188 188
 				'post_status' => 'any',
189
-				'number'      => - 1,
189
+				'number'      => -1,
190 190
 				'meta_key'    => '_give_payment_mode',
191 191
 				'meta_value'  => 'test'
192
-			) );
192
+			));
193 193
 
194
-			$posts    = new Give_Payments_Query( $args );
194
+			$posts    = new Give_Payments_Query($args);
195 195
 			$payments = $posts->get_payments();
196 196
 
197 197
 			/* @var Give_Payment $payment */
198
-			foreach ( $payments as $payment ) {
198
+			foreach ($payments as $payment) {
199 199
 				$items[] = array(
200 200
 					'id'   => (int) $payment->ID,
201 201
 					'type' => 'give_payment',
@@ -204,9 +204,9 @@  discard block
 block discarded – undo
204 204
 
205 205
 			// Allow filtering of items to remove with an unassociative array for each item.
206 206
 			// The array contains the unique ID of the item, and a 'type' for you to use in the execution of the get_data method.
207
-			$items = apply_filters( 'give_delete_test_items', $items );
207
+			$items = apply_filters('give_delete_test_items', $items);
208 208
 
209
-			$this->store_data( 'give_temp_delete_test_ids', $items );
209
+			$this->store_data('give_temp_delete_test_ids', $items);
210 210
 		}
211 211
 
212 212
 	}
@@ -220,17 +220,17 @@  discard block
 block discarded – undo
220 220
 	 *
221 221
 	 * @return mixed       Returns the data from the database
222 222
 	 */
223
-	private function get_stored_data( $key ) {
223
+	private function get_stored_data($key) {
224 224
 		global $wpdb;
225
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
225
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
226 226
 
227
-		if ( empty( $value ) ) {
227
+		if (empty($value)) {
228 228
 			return false;
229 229
 		}
230 230
 
231
-		$maybe_json = json_decode( $value );
232
-		if ( ! is_null( $maybe_json ) ) {
233
-			$value = json_decode( $value, true );
231
+		$maybe_json = json_decode($value);
232
+		if ( ! is_null($maybe_json)) {
233
+			$value = json_decode($value, true);
234 234
 		}
235 235
 
236 236
 		return $value;
@@ -246,10 +246,10 @@  discard block
 block discarded – undo
246 246
 	 *
247 247
 	 * @return void
248 248
 	 */
249
-	private function store_data( $key, $value ) {
249
+	private function store_data($key, $value) {
250 250
 		global $wpdb;
251 251
 
252
-		$value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value );
252
+		$value = is_array($value) ? wp_json_encode($value) : esc_attr($value);
253 253
 
254 254
 		$data = array(
255 255
 			'option_name'  => $key,
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 			'%s',
264 264
 		);
265 265
 
266
-		$wpdb->replace( $wpdb->options, $data, $formats );
266
+		$wpdb->replace($wpdb->options, $data, $formats);
267 267
 	}
268 268
 
269 269
 	/**
@@ -275,9 +275,9 @@  discard block
 block discarded – undo
275 275
 	 *
276 276
 	 * @return void
277 277
 	 */
278
-	private function delete_data( $key ) {
278
+	private function delete_data($key) {
279 279
 		global $wpdb;
280
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
280
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
281 281
 	}
282 282
 
283 283
 }
Please login to merge, or discard this patch.
includes/admin/tools/import/class-give-import-core-settings.php 1 patch
Spacing   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -11,11 +11,11 @@  discard block
 block discarded – undo
11 11
  * @since       1.8.17
12 12
  */
13 13
 
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit; // Exit if accessed directly
16 16
 }
17 17
 
18
-if ( ! class_exists( 'Give_Import_Core_Settings' ) ) {
18
+if ( ! class_exists('Give_Import_Core_Settings')) {
19 19
 
20 20
 	/**
21 21
 	 * Give_Import_Core_Settings.
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 		 * @return static
78 78
 		 */
79 79
 		public static function get_instance() {
80
-			if ( null === static::$instance ) {
80
+			if (null === static::$instance) {
81 81
 				self::$instance = new static();
82 82
 			}
83 83
 
@@ -104,26 +104,26 @@  discard block
 block discarded – undo
104 104
 		 * @return void
105 105
 		 */
106 106
 		private function setup_hooks() {
107
-			if ( ! $this->is_donations_import_page() ) {
107
+			if ( ! $this->is_donations_import_page()) {
108 108
 				return;
109 109
 			}
110 110
 
111 111
 			// Do not render main import tools page.
112
-			remove_action( 'give_admin_field_tools_import', array( 'Give_Settings_Import', 'render_import_field', ) );
112
+			remove_action('give_admin_field_tools_import', array('Give_Settings_Import', 'render_import_field',));
113 113
 
114 114
 			// Render donation import page
115
-			add_action( 'give_admin_field_tools_import', array( $this, 'render_page' ) );
115
+			add_action('give_admin_field_tools_import', array($this, 'render_page'));
116 116
 
117 117
 			// Print the HTML.
118
-			add_action( 'give_tools_import_core_settings_form_start', array( $this, 'html' ), 10 );
118
+			add_action('give_tools_import_core_settings_form_start', array($this, 'html'), 10);
119 119
 
120 120
 			// Run when form submit.
121
-			add_action( 'give-tools_save_import', array( $this, 'save' ) );
121
+			add_action('give-tools_save_import', array($this, 'save'));
122 122
 
123
-			add_action( 'give-tools_update_notices', array( $this, 'update_notices' ), 11, 1 );
123
+			add_action('give-tools_update_notices', array($this, 'update_notices'), 11, 1);
124 124
 
125 125
 			// Used to add submit button.
126
-			add_action( 'give_tools_import_core_settings_form_end', array( $this, 'submit' ), 10 );
126
+			add_action('give_tools_import_core_settings_form_end', array($this, 'submit'), 10);
127 127
 		}
128 128
 
129 129
 		/**
@@ -135,9 +135,9 @@  discard block
 block discarded – undo
135 135
 		 *
136 136
 		 * @return mixed
137 137
 		 */
138
-		public function update_notices( $messages ) {
139
-			if ( ! empty( $_GET['tab'] ) && 'import' === give_clean( $_GET['tab'] ) ) {
140
-				unset( $messages['give-setting-updated'] );
138
+		public function update_notices($messages) {
139
+			if ( ! empty($_GET['tab']) && 'import' === give_clean($_GET['tab'])) {
140
+				unset($messages['give-setting-updated']);
141 141
 			}
142 142
 
143 143
 			return $messages;
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 		 * @since 1.8.17
150 150
 		 */
151 151
 		public function submit() {
152
-			wp_nonce_field( 'give-save-settings', '_give-save-settings' );
152
+			wp_nonce_field('give-save-settings', '_give-save-settings');
153 153
 			?>
154 154
 			<input type="hidden" class="import-step" id="import-step" name="step" value="<?php echo $this->get_step(); ?>"/>
155 155
 			<input type="hidden" class="importer-type" value="<?php echo $this->importer_type; ?>"/>
@@ -169,11 +169,11 @@  discard block
 block discarded – undo
169 169
 			?>
170 170
 			<section>
171 171
 				<table
172
-					class="widefat export-options-table give-table <?php echo "step-{$step}"; ?> <?php echo( 1 === $step && ! empty( $this->is_json_valid ) ? 'give-hidden' : '' ); ?> "
172
+					class="widefat export-options-table give-table <?php echo "step-{$step}"; ?> <?php echo(1 === $step && ! empty($this->is_json_valid) ? 'give-hidden' : ''); ?> "
173 173
 					id="<?php echo "step-{$step}"; ?>">
174 174
 					<tbody>
175 175
 					<?php
176
-					switch ( $step ) {
176
+					switch ($step) {
177 177
 						case 1:
178 178
 							$this->render_upload_html();
179 179
 							break;
@@ -200,14 +200,14 @@  discard block
 block discarded – undo
200 200
 		public function import_success() {
201 201
 			// Imported successfully
202 202
 
203
-			$success = (bool) ( isset( $_GET['success'] ) ? give_clean( $_GET['success'] ) : false );
204
-			$undo = (bool) ( isset( $_GET['undo'] ) ? give_clean( $_GET['undo'] ) : false );
203
+			$success = (bool) (isset($_GET['success']) ? give_clean($_GET['success']) : false);
204
+			$undo = (bool) (isset($_GET['undo']) ? give_clean($_GET['undo']) : false);
205 205
 			$query_arg_setting = array(
206 206
 				'post_type' => 'give_forms',
207 207
 				'page'      => 'give-settings',
208 208
 			);
209 209
 
210
-			if ( $undo ) {
210
+			if ($undo) {
211 211
 				$success = false;
212 212
 			}
213 213
 
@@ -220,30 +220,30 @@  discard block
 block discarded – undo
220 220
 				'undo'      => 'true',
221 221
 			);
222 222
 
223
-			$title = __( 'Settings Importing Completed!', 'give' );
224
-			if ( $success ) {
223
+			$title = __('Settings Importing Completed!', 'give');
224
+			if ($success) {
225 225
 				$query_arg_success['undo'] = '1';
226 226
 				$query_arg_success['step'] = '3';
227 227
 				$query_arg_success['success'] = '1';
228
-				$text = __( 'Undo Importing', 'give' );
228
+				$text = __('Undo Importing', 'give');
229 229
 			} else {
230
-				if ( $undo ) {
231
-					$host_give_options = get_option( 'give_settings_old', array() );
232
-					update_option( 'give_settings', $host_give_options, false );
233
-					$title = __( 'Undo of Setting Imported Completed!', 'give' );
230
+				if ($undo) {
231
+					$host_give_options = get_option('give_settings_old', array());
232
+					update_option('give_settings', $host_give_options, false);
233
+					$title = __('Undo of Setting Imported Completed!', 'give');
234 234
 				} else {
235
-					$title = __( 'Failed to import', 'give' );
235
+					$title = __('Failed to import', 'give');
236 236
 				}
237 237
 
238
-				$text = __( 'Importing Again', 'give' );
238
+				$text = __('Importing Again', 'give');
239 239
 			}
240 240
 			?>
241 241
 			<tr valign="top" class="give-import-dropdown">
242 242
 				<th colspan="2">
243 243
 					<h2><?php echo $title; ?></h2>
244 244
 					<p>
245
-						<a class="button button-large button-secondary" href="<?php echo add_query_arg( $query_arg_success, admin_url( 'edit.php' ) ); ?>"><?php echo $text; ?></a>
246
-						<a class="button button-large button-secondary" href="<?php echo add_query_arg( $query_arg_setting, admin_url( 'edit.php' ) ); ?>"><?php echo __( 'View Settings', 'give' ); ?></a>
245
+						<a class="button button-large button-secondary" href="<?php echo add_query_arg($query_arg_success, admin_url('edit.php')); ?>"><?php echo $text; ?></a>
246
+						<a class="button button-large button-secondary" href="<?php echo add_query_arg($query_arg_setting, admin_url('edit.php')); ?>"><?php echo __('View Settings', 'give'); ?></a>
247 247
 					</p>
248 248
 				</th>
249 249
 			</tr>
@@ -256,14 +256,14 @@  discard block
 block discarded – undo
256 256
 		 * @since 1.8.17
257 257
 		 */
258 258
 		public function start_import() {
259
-			$type      = ( ! empty( $_GET['type'] ) ? give_clean( $_GET['type'] ) : 'replace' );
260
-			$file_name = ( ! empty( $_GET['file_name'] ) ? give_clean( $_GET['file_name'] ) : '' );
259
+			$type      = ( ! empty($_GET['type']) ? give_clean($_GET['type']) : 'replace');
260
+			$file_name = ( ! empty($_GET['file_name']) ? give_clean($_GET['file_name']) : '');
261 261
 
262 262
 			?>
263 263
 			<tr valign="top" class="give-import-dropdown">
264 264
 				<th colspan="2">
265
-					<h2 id="give-import-title"><?php esc_html_e( 'Importing', 'give' ) ?></h2>
266
-					<p class="give-field-description"><?php esc_html_e( 'Your settings are now being imported...', 'give' ) ?></p>
265
+					<h2 id="give-import-title"><?php esc_html_e('Importing', 'give') ?></h2>
266
+					<p class="give-field-description"><?php esc_html_e('Your settings are now being imported...', 'give') ?></p>
267 267
 				</th>
268 268
 			</tr>
269 269
 
@@ -290,14 +290,14 @@  discard block
 block discarded – undo
290 290
 			$step = $this->get_step();
291 291
 			?>
292 292
 			<ol class="give-progress-steps">
293
-				<li class="<?php echo( 1 === $step ? 'active' : '' ); ?>">
294
-					<?php esc_html_e( 'Upload JSON file', 'give' ); ?>
293
+				<li class="<?php echo(1 === $step ? 'active' : ''); ?>">
294
+					<?php esc_html_e('Upload JSON file', 'give'); ?>
295 295
 				</li>
296
-				<li class="<?php echo( 2 === $step ? 'active' : '' ); ?>">
297
-					<?php esc_html_e( 'Import', 'give' ); ?>
296
+				<li class="<?php echo(2 === $step ? 'active' : ''); ?>">
297
+					<?php esc_html_e('Import', 'give'); ?>
298 298
 				</li>
299
-				<li class="<?php echo( 3 === $step ? 'active' : '' ); ?>">
300
-					<?php esc_html_e( 'Done!', 'give' ); ?>
299
+				<li class="<?php echo(3 === $step ? 'active' : ''); ?>">
300
+					<?php esc_html_e('Done!', 'give'); ?>
301 301
 				</li>
302 302
 			</ol>
303 303
 			<?php
@@ -311,14 +311,14 @@  discard block
 block discarded – undo
311 311
 		 * @return int $step on which step doest the import is on.
312 312
 		 */
313 313
 		public function get_step() {
314
-			$step    = (int) ( isset( $_REQUEST['step'] ) ? give_clean( $_REQUEST['step'] ) : 0 );
314
+			$step    = (int) (isset($_REQUEST['step']) ? give_clean($_REQUEST['step']) : 0);
315 315
 			$on_step = 1;
316 316
 
317
-			if ( empty( $step ) || 1 === $step ) {
317
+			if (empty($step) || 1 === $step) {
318 318
 				$on_step = 1;
319
-			} elseif ( 2 === $step ) {
319
+			} elseif (2 === $step) {
320 320
 				$on_step = 2;
321
-			} elseif ( 3 === $step ) {
321
+			} elseif (3 === $step) {
322 322
 				$on_step = 3;
323 323
 			}
324 324
 
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 		 * @since 1.8.17
332 332
 		 */
333 333
 		public function render_page() {
334
-			include_once GIVE_PLUGIN_DIR . 'includes/admin/tools/views/html-admin-page-import-core-settings.php';
334
+			include_once GIVE_PLUGIN_DIR.'includes/admin/tools/views/html-admin-page-import-core-settings.php';
335 335
 		}
336 336
 
337 337
 		/**
@@ -343,28 +343,28 @@  discard block
 block discarded – undo
343 343
 		 * @return void
344 344
 		 */
345 345
 		public function render_upload_html() {
346
-			$json = ( isset( $_POST['json'] ) ? give_clean( $_POST['json'] ) : '' );
347
-			$type = ( isset( $_POST['type'] ) ? give_clean( $_POST['type'] ) : 'merge' );
346
+			$json = (isset($_POST['json']) ? give_clean($_POST['json']) : '');
347
+			$type = (isset($_POST['type']) ? give_clean($_POST['type']) : 'merge');
348 348
 			$step = $this->get_step();
349 349
 
350 350
 			?>
351 351
 			<tr valign="top">
352 352
 				<th colspan="2">
353
-					<h2 id="give-import-title"><?php esc_html_e( 'Import Core Settings from a JSON file', 'give' ) ?></h2>
354
-					<p class="give-field-description"><?php esc_html_e( 'This tool allows you to import Give settings from another Give installation. Settings imported contain data from Give core as well as any of our Premium Add-ons.', 'give' ) ?></p>
353
+					<h2 id="give-import-title"><?php esc_html_e('Import Core Settings from a JSON file', 'give') ?></h2>
354
+					<p class="give-field-description"><?php esc_html_e('This tool allows you to import Give settings from another Give installation. Settings imported contain data from Give core as well as any of our Premium Add-ons.', 'give') ?></p>
355 355
 				</th>
356 356
 			</tr>
357 357
 
358 358
 			<tr valign="top">
359 359
 				<th scope="row" class="titledesc">
360
-					<label for="json"><?php esc_html_e( 'Choose a JSON file:', 'give' ) ?></label>
360
+					<label for="json"><?php esc_html_e('Choose a JSON file:', 'give') ?></label>
361 361
 				</th>
362 362
 				<td class="give-forminp">
363 363
 					<div class="give-field-wrap">
364 364
 						<label for="json">
365 365
 							<input type="file" name="json" class="give-upload-json-file" value="<?php echo $json; ?>"
366 366
 							       accept=".json">
367
-							<p class="give-field-description"><?php esc_html_e( 'The file type must be JSON.', 'give' )?></p>
367
+							<p class="give-field-description"><?php esc_html_e('The file type must be JSON.', 'give')?></p>
368 368
 						</label>
369 369
 					</div>
370 370
 				</td>
@@ -373,21 +373,21 @@  discard block
 block discarded – undo
373 373
 			$settings = array(
374 374
 				array(
375 375
 					'id'          => 'type',
376
-					'name'        => __( 'Merge Type:', 'give' ),
377
-					'description' => __( 'Select "Merge" to retain existing settings, or "Replace" to overwrite with the settings from the JSON file', 'give' ),
376
+					'name'        => __('Merge Type:', 'give'),
377
+					'description' => __('Select "Merge" to retain existing settings, or "Replace" to overwrite with the settings from the JSON file', 'give'),
378 378
 					'default'     => $type,
379 379
 					'type'        => 'radio_inline',
380 380
 					'options'     => array(
381
-						'merge'   => __( 'Merge', 'give' ),
382
-						'replace' => __( 'Replace', 'give' ),
381
+						'merge'   => __('Merge', 'give'),
382
+						'replace' => __('Replace', 'give'),
383 383
 					),
384 384
 				),
385 385
 			);
386 386
 
387
-			$settings = apply_filters( 'give_import_core_setting_html', $settings );
387
+			$settings = apply_filters('give_import_core_setting_html', $settings);
388 388
 
389
-			if ( empty( $this->is_json_valid ) ) {
390
-				Give_Admin_Settings::output_fields( $settings, 'give_settings' );
389
+			if (empty($this->is_json_valid)) {
390
+				Give_Admin_Settings::output_fields($settings, 'give_settings');
391 391
 				?>
392 392
 				<tr valign="top">
393 393
 					<th></th>
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 						<input type="submit"
396 396
 						       class="button button-primary button-large button-secondary <?php echo "step-{$step}"; ?>"
397 397
 						       id="recount-stats-submit"
398
-						       value="<?php esc_attr_e( 'Submit', 'give' ); ?>"/>
398
+						       value="<?php esc_attr_e('Submit', 'give'); ?>"/>
399 399
 					</th>
400 400
 				</tr>
401 401
 				<?php
@@ -417,20 +417,20 @@  discard block
 block discarded – undo
417 417
 			$step = $this->get_step();
418 418
 
419 419
 			// Validation for first step.
420
-			if ( 1 === $step ) {
421
-				$type          = ( ! empty( $_REQUEST['type'] ) ? give_clean( $_REQUEST['type'] ) : 'replace' );
420
+			if (1 === $step) {
421
+				$type          = ( ! empty($_REQUEST['type']) ? give_clean($_REQUEST['type']) : 'replace');
422 422
 				$core_settings = self::upload_widget_settings_file();
423
-				if ( ! empty( $core_settings['error'] ) ) {
424
-					Give_Admin_Settings::add_error( 'give-import-csv', __( 'Please upload a valid JSON settings file.', 'give' ) );
423
+				if ( ! empty($core_settings['error'])) {
424
+					Give_Admin_Settings::add_error('give-import-csv', __('Please upload a valid JSON settings file.', 'give'));
425 425
 				} else {
426
-					$file_path = explode( '/', $core_settings['file'] );
427
-					$count     = ( count( $file_path ) - 1 );
428
-					$url       = give_import_page_url( (array) apply_filters( 'give_import_core_settings_importing_url', array(
426
+					$file_path = explode('/', $core_settings['file']);
427
+					$count     = (count($file_path) - 1);
428
+					$url       = give_import_page_url((array) apply_filters('give_import_core_settings_importing_url', array(
429 429
 						'step'          => '2',
430 430
 						'importer-type' => $this->importer_type,
431 431
 						'type'          => $type,
432
-						'file_name'     => $file_path[ $count ],
433
-					) ) );
432
+						'file_name'     => $file_path[$count],
433
+					)));
434 434
 
435 435
 
436 436
 					$this->is_json_valid = $url;
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 		 * @return bool
446 446
 		 */
447 447
 		private function is_donations_import_page() {
448
-			return 'import' === give_get_current_setting_tab() && isset( $_GET['importer-type'] ) && $this->importer_type === give_clean( $_GET['importer-type'] );
448
+			return 'import' === give_get_current_setting_tab() && isset($_GET['importer-type']) && $this->importer_type === give_clean($_GET['importer-type']);
449 449
 		}
450 450
 
451 451
 		/**
@@ -454,14 +454,14 @@  discard block
 block discarded – undo
454 454
 		 */
455 455
 		public static function upload_widget_settings_file() {
456 456
 			$upload = false;
457
-			if ( isset( $_FILES['json'] ) ) {
458
-				add_filter( 'upload_mimes', array( __CLASS__, 'json_upload_mimes' ) );
457
+			if (isset($_FILES['json'])) {
458
+				add_filter('upload_mimes', array(__CLASS__, 'json_upload_mimes'));
459 459
 
460
-				$upload = wp_handle_upload( $_FILES['json'], array( 'test_form' => false ) );
460
+				$upload = wp_handle_upload($_FILES['json'], array('test_form' => false));
461 461
 
462
-				remove_filter( 'upload_mimes', array( __CLASS__, 'json_upload_mimes' ) );
462
+				remove_filter('upload_mimes', array(__CLASS__, 'json_upload_mimes'));
463 463
 			} else {
464
-				Give_Admin_Settings::add_error( 'give-import-csv', __( 'Please upload or provide a valid JSON file.', 'give' ) );
464
+				Give_Admin_Settings::add_error('give-import-csv', __('Please upload or provide a valid JSON file.', 'give'));
465 465
 			}
466 466
 
467 467
 			return $upload;
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
 		 *
473 473
 		 * @param array $existing_mimes
474 474
 		 */
475
-		public static function json_upload_mimes( $existing_mimes = array() ) {
475
+		public static function json_upload_mimes($existing_mimes = array()) {
476 476
 			$existing_mimes['json'] = 'application/json';
477 477
 
478 478
 			return $existing_mimes;
Please login to merge, or discard this patch.
includes/admin/tools/export/give-export-donations-exporter.php 1 patch
Spacing   +159 added lines, -159 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly.
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -85,28 +85,28 @@  discard block
 block discarded – undo
85 85
 	 *
86 86
 	 * @param array $request The Form Data passed into the batch processing.
87 87
 	 */
88
-	public function set_properties( $request ) {
88
+	public function set_properties($request) {
89 89
 
90 90
 		// Set data from form submission
91
-		if ( isset( $_POST['form'] ) ) {
92
-			$this->data = give_clean( wp_parse_args( $_POST['form'] ) );
91
+		if (isset($_POST['form'])) {
92
+			$this->data = give_clean(wp_parse_args($_POST['form']));
93 93
 		}
94 94
 
95 95
 		$this->form       = $this->data['forms'];
96
-		$this->categories = ! empty( $request['give_forms_categories'] ) ? (array) $request['give_forms_categories'] : array();
97
-		$this->tags       = ! empty( $request['give_forms_tags'] ) ? (array) $request['give_forms_tags'] : array();
98
-		$this->form_id    = $this->get_form_ids( $request );
99
-		$this->price_id   = isset( $request['give_price_option'] ) && ( 'all' !== $request['give_price_option'] && '' !== $request['give_price_option'] ) ? absint( $request['give_price_option'] ) : null;
100
-		$this->start      = isset( $request['start'] ) ? sanitize_text_field( $request['start'] ) : '';
101
-		$this->end        = isset( $request['end'] ) ? sanitize_text_field( $request['end'] ) : '';
102
-		$this->status     = isset( $request['status'] ) ? sanitize_text_field( $request['status'] ) : 'complete';
96
+		$this->categories = ! empty($request['give_forms_categories']) ? (array) $request['give_forms_categories'] : array();
97
+		$this->tags       = ! empty($request['give_forms_tags']) ? (array) $request['give_forms_tags'] : array();
98
+		$this->form_id    = $this->get_form_ids($request);
99
+		$this->price_id   = isset($request['give_price_option']) && ('all' !== $request['give_price_option'] && '' !== $request['give_price_option']) ? absint($request['give_price_option']) : null;
100
+		$this->start      = isset($request['start']) ? sanitize_text_field($request['start']) : '';
101
+		$this->end        = isset($request['end']) ? sanitize_text_field($request['end']) : '';
102
+		$this->status     = isset($request['status']) ? sanitize_text_field($request['status']) : 'complete';
103 103
 
104 104
 		/**
105 105
 		 * Hook to use after setting properties.
106 106
 		 *
107 107
 		 * @since 2.1.3
108 108
 		 */
109
-		do_action( 'give_export_donations_form_data', $this->data );
109
+		do_action('give_export_donations_form_data', $this->data);
110 110
 	}
111 111
 
112 112
 	/**
@@ -118,13 +118,13 @@  discard block
 block discarded – undo
118 118
 	 *
119 119
 	 * @return array|boolean|null $form get all the donation id that need to be exported
120 120
 	 */
121
-	public function get_form_ids( $request = array() ) {
122
-		$form = ! empty( $request['forms'] ) && 0 !== $request['forms'] ? absint( $request['forms'] ) : null;
121
+	public function get_form_ids($request = array()) {
122
+		$form = ! empty($request['forms']) && 0 !== $request['forms'] ? absint($request['forms']) : null;
123 123
 
124
-		$form_ids = ! empty( $request['form_ids'] ) ? sanitize_text_field( $request['form_ids'] ) : null;
124
+		$form_ids = ! empty($request['form_ids']) ? sanitize_text_field($request['form_ids']) : null;
125 125
 
126
-		if ( empty( $form ) && ! empty( $form_ids ) && ( ! empty( $this->categories ) || ! empty( $this->tags ) ) ) {
127
-			$form = explode( ',', $form_ids );
126
+		if (empty($form) && ! empty($form_ids) && ( ! empty($this->categories) || ! empty($this->tags))) {
127
+			$form = explode(',', $form_ids);
128 128
 		}
129 129
 
130 130
 		return $form;
@@ -141,14 +141,14 @@  discard block
 block discarded – undo
141 141
 	 */
142 142
 	public function csv_cols() {
143 143
 
144
-		$columns = isset( $this->data['give_give_donations_export_option'] ) ? $this->data['give_give_donations_export_option'] : array();
144
+		$columns = isset($this->data['give_give_donations_export_option']) ? $this->data['give_give_donations_export_option'] : array();
145 145
 
146 146
 		// We need columns.
147
-		if ( empty( $columns ) ) {
147
+		if (empty($columns)) {
148 148
 			return false;
149 149
 		}
150 150
 
151
-		$this->cols = $this->get_cols( $columns );
151
+		$this->cols = $this->get_cols($columns);
152 152
 
153 153
 		return $this->cols;
154 154
 	}
@@ -163,88 +163,88 @@  discard block
 block discarded – undo
163 163
 	 *
164 164
 	 * @return array
165 165
 	 */
166
-	private function get_cols( $columns ) {
166
+	private function get_cols($columns) {
167 167
 
168 168
 		$cols = array();
169 169
 
170
-		foreach ( $columns as $key => $value ) {
170
+		foreach ($columns as $key => $value) {
171 171
 
172
-			switch ( $key ) {
172
+			switch ($key) {
173 173
 				case 'donation_id':
174
-					$cols['donation_id'] = __( 'Donation ID', 'give' );
174
+					$cols['donation_id'] = __('Donation ID', 'give');
175 175
 					break;
176 176
 				case 'seq_id':
177
-					$cols['seq_id'] = __( 'Donation Number', 'give' );
177
+					$cols['seq_id'] = __('Donation Number', 'give');
178 178
 					break;
179 179
 				case 'title_prefix':
180
-					$cols['title_prefix'] = __( 'Title Prefix', 'give' );
180
+					$cols['title_prefix'] = __('Title Prefix', 'give');
181 181
 					break;
182 182
 				case 'first_name':
183
-					$cols['first_name'] = __( 'First Name', 'give' );
183
+					$cols['first_name'] = __('First Name', 'give');
184 184
 					break;
185 185
 				case 'last_name':
186
-					$cols['last_name'] = __( 'Last Name', 'give' );
186
+					$cols['last_name'] = __('Last Name', 'give');
187 187
 					break;
188 188
 				case 'email':
189
-					$cols['email'] = __( 'Email Address', 'give' );
189
+					$cols['email'] = __('Email Address', 'give');
190 190
 					break;
191 191
 				case 'company':
192
-					$cols['company'] = __( 'Company Name', 'give' );
192
+					$cols['company'] = __('Company Name', 'give');
193 193
 					break;
194 194
 				case 'address':
195
-					$cols['address_line1']   = __( 'Address 1', 'give' );
196
-					$cols['address_line2']   = __( 'Address 2', 'give' );
197
-					$cols['address_city']    = __( 'City', 'give' );
198
-					$cols['address_state']   = __( 'State', 'give' );
199
-					$cols['address_zip']     = __( 'Zip', 'give' );
200
-					$cols['address_country'] = __( 'Country', 'give' );
195
+					$cols['address_line1']   = __('Address 1', 'give');
196
+					$cols['address_line2']   = __('Address 2', 'give');
197
+					$cols['address_city']    = __('City', 'give');
198
+					$cols['address_state']   = __('State', 'give');
199
+					$cols['address_zip']     = __('Zip', 'give');
200
+					$cols['address_country'] = __('Country', 'give');
201 201
 					break;
202 202
 				case 'donation_total':
203
-					$cols['donation_total'] = __( 'Donation Total', 'give' );
203
+					$cols['donation_total'] = __('Donation Total', 'give');
204 204
 					break;
205 205
 				case 'currency_code':
206
-					$cols['currency_code'] = __( 'Currency Code', 'give' );
206
+					$cols['currency_code'] = __('Currency Code', 'give');
207 207
 					break;
208 208
 				case 'currency_symbol':
209
-					$cols['currency_symbol'] = __( 'Currency Symbol', 'give' );
209
+					$cols['currency_symbol'] = __('Currency Symbol', 'give');
210 210
 					break;
211 211
 				case 'donation_status':
212
-					$cols['donation_status'] = __( 'Donation Status', 'give' );
212
+					$cols['donation_status'] = __('Donation Status', 'give');
213 213
 					break;
214 214
 				case 'payment_gateway':
215
-					$cols['payment_gateway'] = __( 'Payment Gateway', 'give' );
215
+					$cols['payment_gateway'] = __('Payment Gateway', 'give');
216 216
 				case 'payment_mode':
217
-					$cols['payment_mode'] = __( 'Payment Mode', 'give' );
217
+					$cols['payment_mode'] = __('Payment Mode', 'give');
218 218
 					break;
219 219
 				case 'form_id':
220
-					$cols['form_id'] = __( 'Form ID', 'give' );
220
+					$cols['form_id'] = __('Form ID', 'give');
221 221
 					break;
222 222
 				case 'form_title':
223
-					$cols['form_title'] = __( 'Form Title', 'give' );
223
+					$cols['form_title'] = __('Form Title', 'give');
224 224
 					break;
225 225
 				case 'form_level_id':
226
-					$cols['form_level_id'] = __( 'Level ID', 'give' );
226
+					$cols['form_level_id'] = __('Level ID', 'give');
227 227
 					break;
228 228
 				case 'form_level_title':
229
-					$cols['form_level_title'] = __( 'Level Title', 'give' );
229
+					$cols['form_level_title'] = __('Level Title', 'give');
230 230
 					break;
231 231
 				case 'donation_date':
232
-					$cols['donation_date'] = __( 'Donation Date', 'give' );
232
+					$cols['donation_date'] = __('Donation Date', 'give');
233 233
 					break;
234 234
 				case 'donation_time':
235
-					$cols['donation_time'] = __( 'Donation Time', 'give' );
235
+					$cols['donation_time'] = __('Donation Time', 'give');
236 236
 					break;
237 237
 				case 'userid':
238
-					$cols['userid'] = __( 'User ID', 'give' );
238
+					$cols['userid'] = __('User ID', 'give');
239 239
 					break;
240 240
 				case 'donorid':
241
-					$cols['donorid'] = __( 'Donor ID', 'give' );
241
+					$cols['donorid'] = __('Donor ID', 'give');
242 242
 					break;
243 243
 				case 'donor_ip':
244
-					$cols['donor_ip'] = __( 'Donor IP Address', 'give' );
244
+					$cols['donor_ip'] = __('Donor IP Address', 'give');
245 245
 					break;
246 246
 				default:
247
-					$cols[ $key ] = $key;
247
+					$cols[$key] = $key;
248 248
 
249 249
 			}
250 250
 		}
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 		 * @param array $cols columns name for CSV
258 258
 		 * @param array $columns columns select by admin to export
259 259
 		 */
260
-		return (array) apply_filters( 'give_export_donation_get_columns_name', $cols, $columns );
260
+		return (array) apply_filters('give_export_donation_get_columns_name', $cols, $columns);
261 261
 	}
262 262
 
263 263
 	/**
@@ -269,24 +269,24 @@  discard block
 block discarded – undo
269 269
 	 *
270 270
 	 * @return array $args donation argument
271 271
 	 */
272
-	public function get_donation_argument( $args = array() ) {
272
+	public function get_donation_argument($args = array()) {
273 273
 		$defaults = array(
274 274
 			'number' => 30,
275 275
 			'page'   => $this->step,
276 276
 			'status' => $this->status,
277 277
 		);
278 278
 		// Date query.
279
-		if ( ! empty( $this->start ) || ! empty( $this->end ) ) {
280
-			if ( ! empty( $this->start ) ) {
281
-				$defaults['date_query'][0]['after'] = date( 'Y-n-d 00:00:00', strtotime( $this->start ) );
279
+		if ( ! empty($this->start) || ! empty($this->end)) {
280
+			if ( ! empty($this->start)) {
281
+				$defaults['date_query'][0]['after'] = date('Y-n-d 00:00:00', strtotime($this->start));
282 282
 			}
283
-			if ( ! empty( $this->end ) ) {
284
-				$defaults['date_query'][0]['before'] = date( 'Y-n-d 00:00:00', strtotime( $this->end ) );
283
+			if ( ! empty($this->end)) {
284
+				$defaults['date_query'][0]['before'] = date('Y-n-d 00:00:00', strtotime($this->end));
285 285
 			}
286 286
 		}
287 287
 
288
-		if ( ! empty( $this->form_id ) ) {
289
-			$defaults['give_forms'] = is_array( $this->form_id ) ? $this->form_id : array( $this->form_id );
288
+		if ( ! empty($this->form_id)) {
289
+			$defaults['give_forms'] = is_array($this->form_id) ? $this->form_id : array($this->form_id);
290 290
 		}
291 291
 
292 292
 		/**
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 		 *
296 296
 		 * @since 2.1.3
297 297
 		 */
298
-		return apply_filters( 'give_export_donations_donation_query_args', wp_parse_args( $args, $defaults ) );
298
+		return apply_filters('give_export_donations_donation_query_args', wp_parse_args($args, $defaults));
299 299
 	}
300 300
 
301 301
 	/**
@@ -314,130 +314,130 @@  discard block
 block discarded – undo
314 314
 		$data = array();
315 315
 		$i    = 0;
316 316
 		// Payment query.
317
-		$payments = give_get_payments( $this->get_donation_argument() );
317
+		$payments = give_get_payments($this->get_donation_argument());
318 318
 
319
-		if ( $payments ) {
319
+		if ($payments) {
320 320
 
321
-			foreach ( $payments as $payment ) {
321
+			foreach ($payments as $payment) {
322 322
 
323 323
 				$columns      = $this->csv_cols();
324
-				$payment      = new Give_Payment( $payment->ID );
324
+				$payment      = new Give_Payment($payment->ID);
325 325
 				$payment_meta = $payment->payment_meta;
326 326
 				$address      = $payment->address;
327 327
 
328 328
 				// Set columns.
329
-				if ( ! empty( $columns['donation_id'] ) ) {
330
-					$data[ $i ]['donation_id'] = $payment->ID;
329
+				if ( ! empty($columns['donation_id'])) {
330
+					$data[$i]['donation_id'] = $payment->ID;
331 331
 				}
332 332
 
333
-				if ( ! empty( $columns['seq_id'] ) ) {
334
-					$data[ $i ]['seq_id'] = Give()->seq_donation_number->get_serial_code( $payment->ID );
333
+				if ( ! empty($columns['seq_id'])) {
334
+					$data[$i]['seq_id'] = Give()->seq_donation_number->get_serial_code($payment->ID);
335 335
 				}
336 336
 
337
-				if ( ! empty( $columns['title_prefix'] ) ) {
338
-					$data[ $i ]['title_prefix'] = ! empty( $payment->title_prefix ) ? $payment->title_prefix : '';
337
+				if ( ! empty($columns['title_prefix'])) {
338
+					$data[$i]['title_prefix'] = ! empty($payment->title_prefix) ? $payment->title_prefix : '';
339 339
 				}
340 340
 
341
-				if ( ! empty( $columns['first_name'] ) ) {
342
-					$data[ $i ]['first_name'] = isset( $payment->first_name ) ? $payment->first_name : '';
341
+				if ( ! empty($columns['first_name'])) {
342
+					$data[$i]['first_name'] = isset($payment->first_name) ? $payment->first_name : '';
343 343
 				}
344 344
 
345
-				if ( ! empty( $columns['last_name'] ) ) {
346
-					$data[ $i ]['last_name'] = isset( $payment->last_name ) ? $payment->last_name : '';
345
+				if ( ! empty($columns['last_name'])) {
346
+					$data[$i]['last_name'] = isset($payment->last_name) ? $payment->last_name : '';
347 347
 				}
348 348
 
349
-				if ( ! empty( $columns['email'] ) ) {
350
-					$data[ $i ]['email'] = $payment->email;
349
+				if ( ! empty($columns['email'])) {
350
+					$data[$i]['email'] = $payment->email;
351 351
 				}
352 352
 
353
-				if ( ! empty( $columns['company'] ) ) {
354
-					$data[ $i ]['company'] = empty( $payment_meta['_give_donation_company'] ) ? '' : str_replace( "\'", "'", $payment_meta['_give_donation_company'] );
353
+				if ( ! empty($columns['company'])) {
354
+					$data[$i]['company'] = empty($payment_meta['_give_donation_company']) ? '' : str_replace("\'", "'", $payment_meta['_give_donation_company']);
355 355
 				}
356 356
 
357
-				if ( ! empty( $columns['address_line1'] ) ) {
358
-					$data[ $i ]['address_line1']   = isset( $address['line1'] ) ? $address['line1'] : '';
359
-					$data[ $i ]['address_line2']   = isset( $address['line2'] ) ? $address['line2'] : '';
360
-					$data[ $i ]['address_city']    = isset( $address['city'] ) ? $address['city'] : '';
361
-					$data[ $i ]['address_state']   = isset( $address['state'] ) ? $address['state'] : '';
362
-					$data[ $i ]['address_zip']     = isset( $address['zip'] ) ? $address['zip'] : '';
363
-					$data[ $i ]['address_country'] = isset( $address['country'] ) ? $address['country'] : '';
357
+				if ( ! empty($columns['address_line1'])) {
358
+					$data[$i]['address_line1']   = isset($address['line1']) ? $address['line1'] : '';
359
+					$data[$i]['address_line2']   = isset($address['line2']) ? $address['line2'] : '';
360
+					$data[$i]['address_city']    = isset($address['city']) ? $address['city'] : '';
361
+					$data[$i]['address_state']   = isset($address['state']) ? $address['state'] : '';
362
+					$data[$i]['address_zip']     = isset($address['zip']) ? $address['zip'] : '';
363
+					$data[$i]['address_country'] = isset($address['country']) ? $address['country'] : '';
364 364
 				}
365 365
 
366
-				if ( ! empty( $columns['donation_total'] ) ) {
367
-					$data[ $i ]['donation_total'] = give_format_amount( give_donation_amount( $payment->ID ) );
366
+				if ( ! empty($columns['donation_total'])) {
367
+					$data[$i]['donation_total'] = give_format_amount(give_donation_amount($payment->ID));
368 368
 				}
369 369
 
370
-				if ( ! empty( $columns['currency_code'] ) ) {
371
-					$data[ $i ]['currency_code'] = empty( $payment_meta['_give_payment_currency'] ) ? give_get_currency() : $payment_meta['_give_payment_currency'];
370
+				if ( ! empty($columns['currency_code'])) {
371
+					$data[$i]['currency_code'] = empty($payment_meta['_give_payment_currency']) ? give_get_currency() : $payment_meta['_give_payment_currency'];
372 372
 				}
373 373
 
374
-				if ( ! empty( $columns['currency_symbol'] ) ) {
375
-					$currency_code                 = $data[ $i ]['currency_code'];
376
-					$data[ $i ]['currency_symbol'] = give_currency_symbol( $currency_code, true );
374
+				if ( ! empty($columns['currency_symbol'])) {
375
+					$currency_code                 = $data[$i]['currency_code'];
376
+					$data[$i]['currency_symbol'] = give_currency_symbol($currency_code, true);
377 377
 				}
378 378
 
379
-				if ( ! empty( $columns['donation_status'] ) ) {
380
-					$data[ $i ]['donation_status'] = give_get_payment_status( $payment, true );
379
+				if ( ! empty($columns['donation_status'])) {
380
+					$data[$i]['donation_status'] = give_get_payment_status($payment, true);
381 381
 				}
382 382
 
383
-				if ( ! empty( $columns['payment_gateway'] ) ) {
384
-					$data[ $i ]['payment_gateway'] = $payment->gateway;
383
+				if ( ! empty($columns['payment_gateway'])) {
384
+					$data[$i]['payment_gateway'] = $payment->gateway;
385 385
 				}
386 386
 
387
-				if ( ! empty( $columns['payment_mode'] ) ) {
388
-					$data[ $i ]['payment_mode'] = $payment->mode;
387
+				if ( ! empty($columns['payment_mode'])) {
388
+					$data[$i]['payment_mode'] = $payment->mode;
389 389
 				}
390 390
 
391
-				if ( ! empty( $columns['form_id'] ) ) {
392
-					$data[ $i ]['form_id'] = $payment->form_id;
391
+				if ( ! empty($columns['form_id'])) {
392
+					$data[$i]['form_id'] = $payment->form_id;
393 393
 				}
394 394
 
395
-				if ( ! empty( $columns['form_title'] ) ) {
396
-					$data[ $i ]['form_title'] = get_the_title( $payment->form_id );
395
+				if ( ! empty($columns['form_title'])) {
396
+					$data[$i]['form_title'] = get_the_title($payment->form_id);
397 397
 				}
398 398
 
399
-				if ( ! empty( $columns['form_level_id'] ) ) {
400
-					$data[ $i ]['form_level_id'] = $payment->price_id;
399
+				if ( ! empty($columns['form_level_id'])) {
400
+					$data[$i]['form_level_id'] = $payment->price_id;
401 401
 				}
402 402
 
403
-				if ( ! empty( $columns['form_level_title'] ) ) {
404
-					$var_prices = give_has_variable_prices( $payment->form_id );
405
-					if ( empty( $var_prices ) ) {
406
-						$data[ $i ]['form_level_title'] = '';
403
+				if ( ! empty($columns['form_level_title'])) {
404
+					$var_prices = give_has_variable_prices($payment->form_id);
405
+					if (empty($var_prices)) {
406
+						$data[$i]['form_level_title'] = '';
407 407
 					} else {
408
-						if ( 'custom' === $payment->price_id ) {
409
-							$custom_amount_text = give_get_meta( $payment->form_id, '_give_custom_amount_text', true );
408
+						if ('custom' === $payment->price_id) {
409
+							$custom_amount_text = give_get_meta($payment->form_id, '_give_custom_amount_text', true);
410 410
 
411
-							if ( empty( $custom_amount_text ) ) {
412
-								$custom_amount_text = esc_html__( 'Custom', 'give' );
411
+							if (empty($custom_amount_text)) {
412
+								$custom_amount_text = esc_html__('Custom', 'give');
413 413
 							}
414
-							$data[ $i ]['form_level_title'] = $custom_amount_text;
414
+							$data[$i]['form_level_title'] = $custom_amount_text;
415 415
 						} else {
416
-							$data[ $i ]['form_level_title'] = give_get_price_option_name( $payment->form_id, $payment->price_id );
416
+							$data[$i]['form_level_title'] = give_get_price_option_name($payment->form_id, $payment->price_id);
417 417
 						}
418 418
 					}
419 419
 				}
420 420
 
421
-				if ( ! empty( $columns['donation_date'] ) ) {
422
-					$payment_date                = strtotime( $payment->date );
423
-					$data[ $i ]['donation_date'] = date( give_date_format(), $payment_date );
421
+				if ( ! empty($columns['donation_date'])) {
422
+					$payment_date                = strtotime($payment->date);
423
+					$data[$i]['donation_date'] = date(give_date_format(), $payment_date);
424 424
 				}
425 425
 
426
-				if ( ! empty( $columns['donation_time'] ) ) {
427
-					$payment_date                = strtotime( $payment->date );
428
-					$data[ $i ]['donation_time'] = date_i18n( 'H', $payment_date ) . ':' . date( 'i', $payment_date );
426
+				if ( ! empty($columns['donation_time'])) {
427
+					$payment_date                = strtotime($payment->date);
428
+					$data[$i]['donation_time'] = date_i18n('H', $payment_date).':'.date('i', $payment_date);
429 429
 				}
430 430
 
431
-				if ( ! empty( $columns['userid'] ) ) {
432
-					$data[ $i ]['userid'] = $payment->user_id;
431
+				if ( ! empty($columns['userid'])) {
432
+					$data[$i]['userid'] = $payment->user_id;
433 433
 				}
434 434
 
435
-				if ( ! empty( $columns['donorid'] ) ) {
436
-					$data[ $i ]['donorid'] = $payment->customer_id;
435
+				if ( ! empty($columns['donorid'])) {
436
+					$data[$i]['donorid'] = $payment->customer_id;
437 437
 				}
438 438
 
439
-				if ( ! empty( $columns['donor_ip'] ) ) {
440
-					$data[ $i ]['donor_ip'] = give_get_payment_user_ip( $payment->ID );
439
+				if ( ! empty($columns['donor_ip'])) {
440
+					$data[$i]['donor_ip'] = give_get_payment_user_ip($payment->ID);
441 441
 				}
442 442
 
443 443
 				// Add custom field data.
@@ -469,15 +469,15 @@  discard block
 block discarded – undo
469 469
 				);
470 470
 
471 471
 				// Removing above keys...
472
-				foreach ( $remove_keys as $key ) {
473
-					unset( $columns[ $key ] );
472
+				foreach ($remove_keys as $key) {
473
+					unset($columns[$key]);
474 474
 				}
475 475
 
476 476
 				// Now loop through remaining meta fields.
477
-				foreach ( $columns as $col ) {
478
-					$field_data         = get_post_meta( $payment->ID, $col, true );
479
-					$data[ $i ][ $col ] = $field_data;
480
-					unset( $columns[ $col ] );
477
+				foreach ($columns as $col) {
478
+					$field_data         = get_post_meta($payment->ID, $col, true);
479
+					$data[$i][$col] = $field_data;
480
+					unset($columns[$col]);
481 481
 				}
482 482
 
483 483
 				/**
@@ -492,27 +492,27 @@  discard block
 block discarded – undo
492 492
 				 *
493 493
 				 * @return array Donation data
494 494
 				 */
495
-				$data[ $i ] = apply_filters( 'give_export_donation_data', $data[ $i ], $payment, $columns, $this );
495
+				$data[$i] = apply_filters('give_export_donation_data', $data[$i], $payment, $columns, $this);
496 496
 
497 497
 				$new_data = array();
498
-				$old_data = $data[ $i ];
498
+				$old_data = $data[$i];
499 499
 
500 500
 				// sorting the columns bas on row
501
-				foreach ( $this->csv_cols() as $key => $value ) {
502
-					if ( array_key_exists( $key, $old_data ) ) {
503
-						$new_data[ $key ] = $old_data[ $key ];
501
+				foreach ($this->csv_cols() as $key => $value) {
502
+					if (array_key_exists($key, $old_data)) {
503
+						$new_data[$key] = $old_data[$key];
504 504
 					}
505 505
 				}
506 506
 
507
-				$data[ $i ] = $new_data;
507
+				$data[$i] = $new_data;
508 508
 
509 509
 				// Increment iterator.
510
-				$i ++;
510
+				$i++;
511 511
 
512 512
 			}
513 513
 
514
-			$data = apply_filters( 'give_export_get_data', $data );
515
-			$data = apply_filters( "give_export_get_data_{$this->export_type}", $data );
514
+			$data = apply_filters('give_export_get_data', $data);
515
+			$data = apply_filters("give_export_get_data_{$this->export_type}", $data);
516 516
 
517 517
 			return $data;
518 518
 
@@ -530,17 +530,17 @@  discard block
 block discarded – undo
530 530
 	 * @return int
531 531
 	 */
532 532
 	public function get_percentage_complete() {
533
-		$args = $this->get_donation_argument( array( 'number' => - 1 ) );
534
-		if ( isset( $args['page'] ) ) {
535
-			unset( $args['page'] );
533
+		$args = $this->get_donation_argument(array('number' => -1));
534
+		if (isset($args['page'])) {
535
+			unset($args['page']);
536 536
 		}
537
-		$query      = give_get_payments( $args );
538
-		$total      = count( $query );
537
+		$query      = give_get_payments($args);
538
+		$total      = count($query);
539 539
 		$percentage = 100;
540
-		if ( $total > 0 ) {
541
-			$percentage = ( ( 30 * $this->step ) / $total ) * 100;
540
+		if ($total > 0) {
541
+			$percentage = ((30 * $this->step) / $total) * 100;
542 542
 		}
543
-		if ( $percentage > 100 ) {
543
+		if ($percentage > 100) {
544 544
 			$percentage = 100;
545 545
 		}
546 546
 
@@ -562,23 +562,23 @@  discard block
 block discarded – undo
562 562
 		$data     = $this->get_data();
563 563
 		$cols     = $this->get_csv_cols();
564 564
 
565
-		if ( $data ) {
565
+		if ($data) {
566 566
 
567 567
 			// Output each row
568
-			foreach ( $data as $row ) {
568
+			foreach ($data as $row) {
569 569
 				$i = 1;
570
-				foreach ( $row as $col_id => $column ) {
570
+				foreach ($row as $col_id => $column) {
571 571
 					// Make sure the column is valid
572
-					if ( array_key_exists( $col_id, $cols ) ) {
573
-						$row_data .= '"' . preg_replace( '/"/', "'", $column ) . '"';
574
-						$row_data .= $i == count( $cols ) ? '' : ',';
575
-						$i ++;
572
+					if (array_key_exists($col_id, $cols)) {
573
+						$row_data .= '"'.preg_replace('/"/', "'", $column).'"';
574
+						$row_data .= $i == count($cols) ? '' : ',';
575
+						$i++;
576 576
 					}
577 577
 				}
578 578
 				$row_data .= "\r\n";
579 579
 			}
580 580
 
581
-			$this->stash_step_data( $row_data );
581
+			$this->stash_step_data($row_data);
582 582
 
583 583
 			return $row_data;
584 584
 		}
Please login to merge, or discard this patch.
includes/admin/tools/export/pdf-reports.php 1 patch
Spacing   +158 added lines, -158 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,136 +25,136 @@  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 61
 	if (
62
-		file_exists( GIVE_PLUGIN_DIR . '/includes/libraries/tcpdf/fonts/CODE2000.TTF' ) &&
62
+		file_exists(GIVE_PLUGIN_DIR.'/includes/libraries/tcpdf/fonts/CODE2000.TTF') &&
63 63
 
64 64
 		// RIAL exist for backward compatibility.
65
-		in_array( give_get_currency(), array( 'RIAL', 'RUB', 'IRR' ) )
65
+		in_array(give_get_currency(), array('RIAL', 'RUB', 'IRR'))
66 66
 	) {
67
-		TCPDF_FONTS::addTTFfont( GIVE_PLUGIN_DIR . '/includes/libraries/tcpdf/fonts/CODE2000.TTF', '' );
67
+		TCPDF_FONTS::addTTFfont(GIVE_PLUGIN_DIR.'/includes/libraries/tcpdf/fonts/CODE2000.TTF', '');
68 68
 		$custom_font = 'CODE2000';
69 69
 		$font_style  = 'B';
70 70
 	}
71 71
 
72
-	$pdf->AddPage( 'L', 'A4' );
73
-	$pdf->setImageScale( 1.5 );
74
-	$pdf->SetTitle( utf8_decode( __( 'Donation report for the current year for all forms', 'give' ) ) );
75
-	$pdf->SetAuthor( utf8_decode( __( 'Give - Democratizing Generosity', 'give' ) ) );
76
-	$pdf->SetCreator( utf8_decode( __( 'Give - Democratizing Generosity', 'give' ) ) );
72
+	$pdf->AddPage('L', 'A4');
73
+	$pdf->setImageScale(1.5);
74
+	$pdf->SetTitle(utf8_decode(__('Donation report for the current year for all forms', 'give')));
75
+	$pdf->SetAuthor(utf8_decode(__('Give - Democratizing Generosity', 'give')));
76
+	$pdf->SetCreator(utf8_decode(__('Give - Democratizing Generosity', 'give')));
77 77
 
78 78
 	// Image URL should have absolute path. @see https://tcpdf.org/examples/example_009/.
79
-	$pdf->Image( apply_filters( 'give_pdf_export_logo', GIVE_PLUGIN_DIR . 'assets/dist/images/give-logo-small.png' ), 247, 8 );
79
+	$pdf->Image(apply_filters('give_pdf_export_logo', GIVE_PLUGIN_DIR.'assets/dist/images/give-logo-small.png'), 247, 8);
80 80
 
81
-	$pdf->SetMargins( 8, 8, 8 );
82
-	$pdf->SetX( 8 );
81
+	$pdf->SetMargins(8, 8, 8);
82
+	$pdf->SetX(8);
83 83
 
84
-	$pdf->SetFont( $default_font, '', 16 );
85
-	$pdf->SetTextColor( 50, 50, 50 );
86
-	$pdf->Cell( 0, 3, utf8_decode( __( 'Donation report for the current year for all forms', 'give' ) ), 0, 2, 'L', false );
84
+	$pdf->SetFont($default_font, '', 16);
85
+	$pdf->SetTextColor(50, 50, 50);
86
+	$pdf->Cell(0, 3, utf8_decode(__('Donation report for the current year for all forms', 'give')), 0, 2, 'L', false);
87 87
 
88
-	$pdf->SetFont( $default_font, '', 13 );
89
-	$pdf->SetTextColor( 150, 150, 150 );
90
-	$pdf->Ln( 1 );
91
-	$pdf->Cell( 0, 6, utf8_decode( __( 'Date Range: ', 'give' ) ) . $daterange, 0, 2, 'L', false );
88
+	$pdf->SetFont($default_font, '', 13);
89
+	$pdf->SetTextColor(150, 150, 150);
90
+	$pdf->Ln(1);
91
+	$pdf->Cell(0, 6, utf8_decode(__('Date Range: ', 'give')).$daterange, 0, 2, 'L', false);
92 92
 	$pdf->Ln();
93
-	$pdf->SetTextColor( 50, 50, 50 );
94
-	$pdf->SetFont( $default_font, '', 14 );
95
-	$pdf->Cell( 0, 10, utf8_decode( __( 'Table View', 'give' ) ), 0, 2, 'L', false );
96
-	$pdf->SetFont( $default_font, '', 12 );
93
+	$pdf->SetTextColor(50, 50, 50);
94
+	$pdf->SetFont($default_font, '', 14);
95
+	$pdf->Cell(0, 10, utf8_decode(__('Table View', 'give')), 0, 2, 'L', false);
96
+	$pdf->SetFont($default_font, '', 12);
97 97
 
98
-	$pdf->SetFillColor( 238, 238, 238 );
99
-	$pdf->SetTextColor( 0, 0, 0, 100 ); // Set Black color.
100
-	$pdf->Cell( 50, 6, utf8_decode( __( 'Form Name', 'give' ) ), 1, 0, 'L', true );
101
-	$pdf->Cell( 50, 6, utf8_decode( __( 'Price', 'give' ) ), 1, 0, 'L', true );
98
+	$pdf->SetFillColor(238, 238, 238);
99
+	$pdf->SetTextColor(0, 0, 0, 100); // Set Black color.
100
+	$pdf->Cell(50, 6, utf8_decode(__('Form Name', 'give')), 1, 0, 'L', true);
101
+	$pdf->Cell(50, 6, utf8_decode(__('Price', 'give')), 1, 0, 'L', true);
102 102
 
103 103
 	// Display Categories Heading only, if user has opted for it.
104
-	if ( $categories_enabled ) {
105
-		$pdf->Cell( 45, 6, utf8_decode( __( 'Categories', 'give' ) ), 1, 0, 'L', true );
104
+	if ($categories_enabled) {
105
+		$pdf->Cell(45, 6, utf8_decode(__('Categories', 'give')), 1, 0, 'L', true);
106 106
 	}
107 107
 
108 108
 	// Display Tags Heading only, if user has opted for it.
109
-	if ( $tags_enabled ) {
110
-		$pdf->Cell( 45, 6, utf8_decode( __( 'Tags', 'give' ) ), 1, 0, 'L', true );
109
+	if ($tags_enabled) {
110
+		$pdf->Cell(45, 6, utf8_decode(__('Tags', 'give')), 1, 0, 'L', true);
111 111
 	}
112 112
 
113
-	$pdf->Cell( 45, 6, utf8_decode( __( 'Number of Donations', 'give' ) ), 1, 0, 'L', true );
114
-	$pdf->Cell( 45, 6, utf8_decode( __( 'Income to Date', 'give' ) ), 1, 1, 'L', true );
113
+	$pdf->Cell(45, 6, utf8_decode(__('Number of Donations', 'give')), 1, 0, 'L', true);
114
+	$pdf->Cell(45, 6, utf8_decode(__('Income to Date', 'give')), 1, 1, 'L', true);
115 115
 
116 116
 	// Set Custom Font to support various currencies.
117
-	$pdf->SetFont( apply_filters( 'give_pdf_custom_font', $custom_font ), $font_style, 12 );
117
+	$pdf->SetFont(apply_filters('give_pdf_custom_font', $custom_font), $font_style, 12);
118 118
 
119 119
 	// Object for getting stats.
120 120
 	$donation_stats = new Give_Payment_Stats();
121 121
 
122
-	$give_forms = get_posts( array(
122
+	$give_forms = get_posts(array(
123 123
 		'post_type'        => 'give_forms',
124
-		'posts_per_page'   => - 1,
124
+		'posts_per_page'   => -1,
125 125
 		'suppress_filters' => false,
126
-	) );
126
+	));
127 127
 
128
-	if ( $give_forms ) {
129
-		$pdf->SetWidths( array( 50, 50, 45, 45, 45, 45 ) );
128
+	if ($give_forms) {
129
+		$pdf->SetWidths(array(50, 50, 45, 45, 45, 45));
130 130
 
131
-		foreach ( $give_forms as $form ):
132
-			$pdf->SetFillColor( 255, 255, 255 );
131
+		foreach ($give_forms as $form):
132
+			$pdf->SetFillColor(255, 255, 255);
133 133
 
134 134
 			$title = $form->post_title;
135 135
 
136
-			if ( give_has_variable_prices( $form->ID ) ) {
137
-				$price = html_entity_decode( give_price_range( $form->ID, false ), ENT_COMPAT, 'UTF-8' );
136
+			if (give_has_variable_prices($form->ID)) {
137
+				$price = html_entity_decode(give_price_range($form->ID, false), ENT_COMPAT, 'UTF-8');
138 138
 			} else {
139
-				$price = give_currency_filter( give_get_form_price( $form->ID ), array( 'decode_currency' => true ) );
139
+				$price = give_currency_filter(give_get_form_price($form->ID), array('decode_currency' => true));
140 140
 			}
141 141
 
142 142
 			// Display Categories Data only, if user has opted for it.
143 143
 			$categories = array();
144
-			if ( $categories_enabled ) {
145
-				$categories = get_the_term_list( $form->ID, 'give_forms_category', '', ', ', '' );
146
-				$categories = ! is_wp_error( $categories ) ? strip_tags( $categories ) : '';
144
+			if ($categories_enabled) {
145
+				$categories = get_the_term_list($form->ID, 'give_forms_category', '', ', ', '');
146
+				$categories = ! is_wp_error($categories) ? strip_tags($categories) : '';
147 147
 			}
148 148
 
149 149
 			// Display Tags Data only, if user has opted for it.
150 150
 			$tags = array();
151
-			if ( $tags_enabled ) {
152
-				$tags = get_the_term_list( $form->ID, 'give_forms_tag', '', ', ', '' );
153
-				$tags = ! is_wp_error( $tags ) ? strip_tags( $tags ) : '';
151
+			if ($tags_enabled) {
152
+				$tags = get_the_term_list($form->ID, 'give_forms_tag', '', ', ', '');
153
+				$tags = ! is_wp_error($tags) ? strip_tags($tags) : '';
154 154
 			}
155 155
 
156
-			$sales    = $donation_stats->get_sales( $form->ID, 'this_year' );
157
-			$earnings = give_currency_filter( give_format_amount( $donation_stats->get_earnings( $form->ID, 'this_year' ), array( 'sanitize' => false, ) ), array( 'decode_currency' => true ) );
156
+			$sales    = $donation_stats->get_sales($form->ID, 'this_year');
157
+			$earnings = give_currency_filter(give_format_amount($donation_stats->get_earnings($form->ID, 'this_year'), array('sanitize' => false,)), array('decode_currency' => true));
158 158
 
159 159
 			// This will help filter data before appending it to PDF Receipt.
160 160
 			$prepare_pdf_data   = array();
@@ -162,54 +162,54 @@  discard block
 block discarded – undo
162 162
 			$prepare_pdf_data[] = $price;
163 163
 
164 164
 			// Append Categories Data only, if user has opted for it.
165
-			if ( $categories_enabled ) {
165
+			if ($categories_enabled) {
166 166
 				$prepare_pdf_data[] = $categories;
167 167
 			}
168 168
 
169 169
 			// Append Tags Data only, if user has opted for it.
170
-			if ( $tags_enabled ) {
170
+			if ($tags_enabled) {
171 171
 				$prepare_pdf_data[] = $tags;
172 172
 			}
173 173
 
174 174
 			$prepare_pdf_data[] = $sales;
175 175
 			$prepare_pdf_data[] = $earnings;
176 176
 
177
-			$pdf->Row( $prepare_pdf_data );
177
+			$pdf->Row($prepare_pdf_data);
178 178
 
179 179
 		endforeach;
180 180
 	} else {
181 181
 
182 182
 		// Fix: Minor Styling Alignment Issue for PDF.
183
-		if ( $categories_enabled && $tags_enabled ) {
183
+		if ($categories_enabled && $tags_enabled) {
184 184
 			$no_found_width = 280;
185
-		} elseif ( $categories_enabled || $tags_enabled ) {
185
+		} elseif ($categories_enabled || $tags_enabled) {
186 186
 			$no_found_width = 235;
187 187
 		} else {
188 188
 			$no_found_width = 190;
189 189
 		}
190
-		$title = utf8_decode( __( 'No forms found.', 'give' ) );
191
-		$pdf->MultiCell( $no_found_width, 5, $title, 1, 'C', false, 1, '', '', true, 0, false, true, 0, 'T', false );
190
+		$title = utf8_decode(__('No forms found.', 'give'));
191
+		$pdf->MultiCell($no_found_width, 5, $title, 1, 'C', false, 1, '', '', true, 0, false, true, 0, 'T', false);
192 192
 	}// End if().
193 193
 	$pdf->Ln();
194
-	$pdf->SetTextColor( 50, 50, 50 );
195
-	$pdf->SetFont( $default_font, '', 14 );
194
+	$pdf->SetTextColor(50, 50, 50);
195
+	$pdf->SetFont($default_font, '', 14);
196 196
 
197 197
 	// Output Graph on a new page.
198
-	$pdf->AddPage( 'L', 'A4' );
199
-	$pdf->Cell( 0, 10, utf8_decode( __( 'Graph View', 'give' ) ), 0, 2, 'L', false );
200
-	$pdf->SetFont( $default_font, '', 12 );
198
+	$pdf->AddPage('L', 'A4');
199
+	$pdf->Cell(0, 10, utf8_decode(__('Graph View', 'give')), 0, 2, 'L', false);
200
+	$pdf->SetFont($default_font, '', 12);
201 201
 
202
-	$image = html_entity_decode( urldecode( give_draw_chart_image() ) );
203
-	$image = str_replace( ' ', '%20', $image );
202
+	$image = html_entity_decode(urldecode(give_draw_chart_image()));
203
+	$image = str_replace(' ', '%20', $image);
204 204
 
205
-	$pdf->SetX( 25 );
206
-	$pdf->Image( $image . '&file=.png' );
207
-	$pdf->Ln( 7 );
208
-	$pdf->Output( apply_filters( 'give_sales_earnings_pdf_export_filename', 'give-report-' . date_i18n( 'Y-m-d' ) ) . '.pdf', 'D' );
205
+	$pdf->SetX(25);
206
+	$pdf->Image($image.'&file=.png');
207
+	$pdf->Ln(7);
208
+	$pdf->Output(apply_filters('give_sales_earnings_pdf_export_filename', 'give-report-'.date_i18n('Y-m-d')).'.pdf', 'D');
209 209
 	exit();
210 210
 }
211 211
 
212
-add_action( 'give_generate_pdf', 'give_generate_pdf' );
212
+add_action('give_generate_pdf', 'give_generate_pdf');
213 213
 
214 214
 /**
215 215
  * Draws Chart for PDF Report.
@@ -226,38 +226,38 @@  discard block
 block discarded – undo
226 226
  * @return string $chart->getUrl() URL for the Google Chart
227 227
  */
228 228
 function give_draw_chart_image() {
229
-	require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/GoogleChart.php';
230
-	require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/markers/GoogleChartShapeMarker.php';
231
-	require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/markers/GoogleChartTextMarker.php';
229
+	require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/GoogleChart.php';
230
+	require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/markers/GoogleChartShapeMarker.php';
231
+	require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/markers/GoogleChartTextMarker.php';
232 232
 
233
-	$chart = new GoogleChart( 'lc', 900, 330 );
233
+	$chart = new GoogleChart('lc', 900, 330);
234 234
 
235 235
 	$i        = 1;
236 236
 	$earnings = "";
237 237
 	$sales    = "";
238 238
 
239
-	while ( $i <= 12 ) :
240
-		$earnings .= give_get_earnings_by_date( null, $i, date( 'Y' ) ) . ",";
241
-		$sales    .= give_get_sales_by_date( null, $i, date( 'Y' ) ) . ",";
242
-		$i ++;
239
+	while ($i <= 12) :
240
+		$earnings .= give_get_earnings_by_date(null, $i, date('Y')).",";
241
+		$sales    .= give_get_sales_by_date(null, $i, date('Y')).",";
242
+		$i++;
243 243
 	endwhile;
244 244
 
245
-	$earnings_array = explode( ",", $earnings );
246
-	$sales_array    = explode( ",", $sales );
245
+	$earnings_array = explode(",", $earnings);
246
+	$sales_array    = explode(",", $sales);
247 247
 
248 248
 	$i = 0;
249
-	while ( $i <= 11 ) {
250
-		if ( empty( $sales_array[ $i ] ) ) {
251
-			$sales_array[ $i ] = 0;
249
+	while ($i <= 11) {
250
+		if (empty($sales_array[$i])) {
251
+			$sales_array[$i] = 0;
252 252
 		}
253
-		$i ++;
253
+		$i++;
254 254
 	}
255 255
 
256 256
 	$min_earnings   = 0;
257
-	$max_earnings   = max( $earnings_array );
258
-	$earnings_scale = round( $max_earnings, - 1 );
257
+	$max_earnings   = max($earnings_array);
258
+	$earnings_scale = round($max_earnings, - 1);
259 259
 
260
-	$data = new GoogleChartData( array(
260
+	$data = new GoogleChartData(array(
261 261
 		$earnings_array[0],
262 262
 		$earnings_array[1],
263 263
 		$earnings_array[2],
@@ -270,25 +270,25 @@  discard block
 block discarded – undo
270 270
 		$earnings_array[9],
271 271
 		$earnings_array[10],
272 272
 		$earnings_array[11],
273
-	) );
273
+	));
274 274
 
275
-	$data->setLegend( __( 'Income', 'give' ) );
276
-	$data->setColor( '1b58a3' );
277
-	$chart->addData( $data );
275
+	$data->setLegend(__('Income', 'give'));
276
+	$data->setColor('1b58a3');
277
+	$chart->addData($data);
278 278
 
279
-	$shape_marker = new GoogleChartShapeMarker( GoogleChartShapeMarker::CIRCLE );
280
-	$shape_marker->setColor( '000000' );
281
-	$shape_marker->setSize( 7 );
282
-	$shape_marker->setBorder( 2 );
283
-	$shape_marker->setData( $data );
284
-	$chart->addMarker( $shape_marker );
279
+	$shape_marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE);
280
+	$shape_marker->setColor('000000');
281
+	$shape_marker->setSize(7);
282
+	$shape_marker->setBorder(2);
283
+	$shape_marker->setData($data);
284
+	$chart->addMarker($shape_marker);
285 285
 
286
-	$value_marker = new GoogleChartTextMarker( GoogleChartTextMarker::VALUE );
287
-	$value_marker->setColor( '000000' );
288
-	$value_marker->setData( $data );
289
-	$chart->addMarker( $value_marker );
286
+	$value_marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE);
287
+	$value_marker->setColor('000000');
288
+	$value_marker->setData($data);
289
+	$chart->addMarker($value_marker);
290 290
 
291
-	$data = new GoogleChartData( array(
291
+	$data = new GoogleChartData(array(
292 292
 		$sales_array[0],
293 293
 		$sales_array[1],
294 294
 		$sales_array[2],
@@ -301,46 +301,46 @@  discard block
 block discarded – undo
301 301
 		$sales_array[9],
302 302
 		$sales_array[10],
303 303
 		$sales_array[11],
304
-	) );
305
-	$data->setLegend( __( 'Donations', 'give' ) );
306
-	$data->setColor( 'ff6c1c' );
307
-	$chart->addData( $data );
308
-
309
-	$chart->setTitle( __( 'Donations by Month for all Give Forms', 'give' ), '336699', 18 );
310
-
311
-	$chart->setScale( 0, $max_earnings );
312
-
313
-	$y_axis = new GoogleChartAxis( 'y' );
314
-	$y_axis->setDrawTickMarks( true )->setLabels( array( 0, $max_earnings ) );
315
-	$chart->addAxis( $y_axis );
316
-
317
-	$x_axis = new GoogleChartAxis( 'x' );
318
-	$x_axis->setTickMarks( 5 );
319
-	$x_axis->setLabels( array(
320
-		__( 'Jan', 'give' ),
321
-		__( 'Feb', 'give' ),
322
-		__( 'Mar', 'give' ),
323
-		__( 'Apr', 'give' ),
324
-		__( 'May', 'give' ),
325
-		__( 'June', 'give' ),
326
-		__( 'July', 'give' ),
327
-		__( 'Aug', 'give' ),
328
-		__( 'Sept', 'give' ),
329
-		__( 'Oct', 'give' ),
330
-		__( 'Nov', 'give' ),
331
-		__( 'Dec', 'give' ),
332
-	) );
333
-	$chart->addAxis( $x_axis );
334
-
335
-	$shape_marker = new GoogleChartShapeMarker( GoogleChartShapeMarker::CIRCLE );
336
-	$shape_marker->setSize( 6 );
337
-	$shape_marker->setBorder( 2 );
338
-	$shape_marker->setData( $data );
339
-	$chart->addMarker( $shape_marker );
340
-
341
-	$value_marker = new GoogleChartTextMarker( GoogleChartTextMarker::VALUE );
342
-	$value_marker->setData( $data );
343
-	$chart->addMarker( $value_marker );
304
+	));
305
+	$data->setLegend(__('Donations', 'give'));
306
+	$data->setColor('ff6c1c');
307
+	$chart->addData($data);
308
+
309
+	$chart->setTitle(__('Donations by Month for all Give Forms', 'give'), '336699', 18);
310
+
311
+	$chart->setScale(0, $max_earnings);
312
+
313
+	$y_axis = new GoogleChartAxis('y');
314
+	$y_axis->setDrawTickMarks(true)->setLabels(array(0, $max_earnings));
315
+	$chart->addAxis($y_axis);
316
+
317
+	$x_axis = new GoogleChartAxis('x');
318
+	$x_axis->setTickMarks(5);
319
+	$x_axis->setLabels(array(
320
+		__('Jan', 'give'),
321
+		__('Feb', 'give'),
322
+		__('Mar', 'give'),
323
+		__('Apr', 'give'),
324
+		__('May', 'give'),
325
+		__('June', 'give'),
326
+		__('July', 'give'),
327
+		__('Aug', 'give'),
328
+		__('Sept', 'give'),
329
+		__('Oct', 'give'),
330
+		__('Nov', 'give'),
331
+		__('Dec', 'give'),
332
+	));
333
+	$chart->addAxis($x_axis);
334
+
335
+	$shape_marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE);
336
+	$shape_marker->setSize(6);
337
+	$shape_marker->setBorder(2);
338
+	$shape_marker->setData($data);
339
+	$chart->addMarker($shape_marker);
340
+
341
+	$value_marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE);
342
+	$value_marker->setData($data);
343
+	$chart->addMarker($value_marker);
344 344
 
345 345
 	return $chart->getUrl();
346 346
 }
Please login to merge, or discard this patch.